(V <- pi*(56.4/2)^2*(144.4)/1000)
[1] 360.7574
\[ \begin{Bmatrix} \mathrm{rate \, of \, change} \\ \mathrm{of \, heat } \end{Bmatrix} = \begin{Bmatrix} \mathrm{rate \, heat \, produced} \\ \mathrm{by\, heating \, element} \end{Bmatrix} - \begin{Bmatrix} \mathrm{rate \, heat \, lost} \\ \mathrm{to \, surroundings} \end{Bmatrix} \]
\[ Q = cm \frac{dU}{dt} \]
\[ Q = cm \frac{dU}{dt} \]
\[ \begin{Bmatrix} \mathrm{rate \, of \, change} \\ \mathrm{of \, heat } \end{Bmatrix} = \begin{Bmatrix} \mathrm{rate \, heat \, produced} \\ \mathrm{by\, heating \, element} \end{Bmatrix} - \begin{Bmatrix} \mathrm{rate \, heat \, lost} \\ \mathrm{to \, surroundings} \end{Bmatrix} \]
\[ \begin{Bmatrix} \mathrm{rate \, heat \, produced} \\ \mathrm{by\, heating \, element} \end{Bmatrix} = q \]
\[ \begin{Bmatrix} \mathrm{rate \, of \, change} \\ \mathrm{of \, heat } \end{Bmatrix} = \begin{Bmatrix} \mathrm{rate \, heat \, produced} \\ \mathrm{by\, heating \, element} \end{Bmatrix} - \begin{Bmatrix} \mathrm{rate \, heat \, lost} \\ \mathrm{to \, surroundings} \end{Bmatrix} \]
\[ \begin{align*} \begin{Bmatrix} \mathrm{rate \, heat \, lost} \\ \mathrm{to \, surroundings} \end{Bmatrix} & = hS \begin{Bmatrix} \mathrm{temperature} \\ \mathrm{difference} \end{Bmatrix} \\ \\ & = hS\left[ U(t) - u_s \right] \end{align*} \]
\[ cm \frac{dU}{dt} = q - hS\left[ U(t) - u_s \right] \]
\[ \begin{Bmatrix} \mathrm{rate \, of \, change} \\ \mathrm{of \, heat } \end{Bmatrix} = \begin{Bmatrix} \mathrm{rate \, heat \, produced} \\ \mathrm{by\, heating \, element} \end{Bmatrix} - \begin{Bmatrix} \mathrm{rate \, heat \, lost} \\ \mathrm{to \, surroundings} \end{Bmatrix} \]
\[ \begin{Bmatrix} \mathrm{change \, in} \\ \mathrm{heat \, energy } \\ \mathrm{of \, tank } \end{Bmatrix} = \begin{Bmatrix} \mathrm{amount \, heat } \\ \mathrm{produced \, by } \\ \mathrm{heating \, element} \end{Bmatrix} - \begin{Bmatrix} \mathrm{amount\, heat} \\ \mathrm{lost \, to } \\ \mathrm{surroundings} \end{Bmatrix} \]
\[ \begin{Bmatrix} \mathrm{change \, in} \\ \mathrm{heat \, energy } \end{Bmatrix} = \begin{Bmatrix} \mathrm{amount \, heat } \\ \mathrm{produced \, by } \\ \mathrm{heating \, element} \end{Bmatrix} - \begin{Bmatrix} \mathrm{amount\, heat} \\ \mathrm{lost \, to } \\ \mathrm{surroundings} \end{Bmatrix} \]
\[ \begin{Bmatrix} \mathrm{change \, in} \\ \mathrm{heat \, energy } \end{Bmatrix} = \begin{Bmatrix} \mathrm{amount \, heat } \\ \mathrm{produced \, by } \\ \mathrm{heating \, element} \end{Bmatrix} - \begin{Bmatrix} \mathrm{amount\, heat} \\ \mathrm{lost \, to } \\ \mathrm{surroundings} \end{Bmatrix} \]
\[ \begin{align*} mc \left[ U(t + \Delta t) - U(t) \right] &= q \Delta t - hS \left[ U(t^*) - u_s \right]\Delta t \\ mc \lim_{\Delta t \rightarrow 0} \frac{U(t + \Delta t) - U(t)}{\Delta t}\Delta t &= q - hS \lim_{\Delta t \rightarrow 0} \left[ U(t^*) - u_s \right] \\ cm \frac{dU}{dt} &= q - hS\left[ U(t) - u_s \right] \end{align*} \]
\[ cm \frac{dU}{dt} = q - hS\left[ U(t) - u_s \right] \]
\[ \frac{dU}{dt} = \frac{q}{cm} - \frac{hS}{cm}\left[U - u_s \right] \]
\[ \frac{dU}{dt} = \frac{q}{cm} - \frac{hS}{cm}\left(U - u_s \right) \]
\[ \begin{aligned} \left[\frac{q}{cm}\right] & = \frac{ \frac{J}{sec} } { \left(\frac{J}{kg ~C}\right)kg } = \frac{C}{sec} \\ \left[\frac{hS}{cm}\left(U - u_s \right)\right] & = \frac{ \left(~\frac{J}{m^2 sec~ C}\right)\left(m^2~\right)\left(~C~\right) } { \left(\frac{J}{kg ~C~}\right)~kg~ } = \frac{C}{sec} \end{aligned} \]
Ch93Ex1(10)
Ch93Ex1 <- function(T) {
#Ch9.3: Perform Rk4 for water heater
#T is time length in hours for [0, T]
N <- 3600*10 #N is number of time nodes
h <- 3600*T/N #Time step size in seconds
#System Parameters
t0 <- 0
u0 <- 15
us <- 15
q <- 3600
c <- 4200
m <- 250
h2 <- 12 #h is used above for step size
S <- 3.06
#Slope function from ODE
f <- function(U) {q/(c*m) - (h2*S)/(c*m)*(U - us)}
#Initialize vectors for time t and temperature U.
t <- rep(0, N)
U <- rep(0, N)
t[1] <- t0
U[1] <- u0
#Runge-Kutta Loop (Generate temperature vector U)
for(i in 1:N) {
a1 <- h*f(U[i]); #f = slope of U
b1 <- h*f(U[i]+0.5*a1); #Half-step predictor
c1 <- h*f(U[i]+0.5*b1); #Half-step predictor
d1 <- h*f(U[i]+c1); #Full-step predictor
U[i+1]<-U[i]+(1/6)*(a1+2*b1+2*c1+d1);#Next U value
t[i+1] <- t[i] + h #Next t value, need for plot}