Skip to content

Commit

Permalink
Fixed an error in the left hand terms conduction terms
Browse files Browse the repository at this point in the history
While revising the equations for one dimensional heat transfer (see mtiller#53), I recognized that
there was an error in the equations in these models.  One term included the effects of
length while the other didn't.
  • Loading branch information
mtiller committed Apr 11, 2014
1 parent f7823e0 commit a87d4af
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ model Rod_ArrayComprehensions
initial equation
T = linspace(200,300,n);
equation
rho*V*C*der(T[1]) = -h*(T[1]-Tamb)-k*A/(L/n)*(T[1]-T[2]);
rho*V*C*der(T[2:n-1]) = {-k*(L/n)*(T[i]-T[i-1])-k*A/(L/n)*(T[i]-T[i+1]) for i in 2:(n-1)};
rho*V*C*der(T[end]) = -h*(T[end]-Tamb)-k*A/(L/n)*(T[end]-T[end-1]);
rho*V*C*der(T[1]) = -h*(T[1]-Tamb)-k*A*(T[1]-T[2])/(L/n);
rho*V*C*der(T[2:n-1]) = {-k*A*(T[i]-T[i-1])/(L/n)-k*A*(T[i]-T[i+1])/(L/n) for i in 2:(n-1)};
rho*V*C*der(T[end]) = -h*(T[end]-Tamb)-k*A*(T[end]-T[end-1])/(L/n);
end Rod_ArrayComprehensions;
6 changes: 3 additions & 3 deletions ModelicaByExample/ArrayEquations/HeatTransfer/Rod_ForLoop.mo
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ model Rod_ForLoop "Modeling heat conduction in a rod using a for loop"
initial equation
T = linspace(200,300,n);
equation
rho*V*C*der(T[1]) = -h*(T[1]-Tamb)-k*A/(L/n)*(T[1]-T[2]);
rho*V*C*der(T[1]) = -h*(T[1]-Tamb)-k*A*(T[1]-T[2])/(L/n);
for i in 2:(n-1) loop
rho*V*C*der(T[i]) = -k*A/(L/n)*(T[i]-T[i-1])-k*A/(L/n)*(T[i]-T[i+1]);
rho*V*C*der(T[i]) = -k*A*(T[i]-T[i-1])/(L/n)-k*A*(T[i]-T[i+1])/(L/n);
end for;
rho*V*C*der(T[end]) = -h*(T[end]-Tamb)-k*A/(L/n)*(T[end]-T[end-1]);
rho*V*C*der(T[end]) = -h*(T[end]-Tamb)-k*A*(T[end]-T[end-1])/(L/n);
end Rod_ForLoop;
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ model Rod_VectorNotation
initial equation
T = linspace(200,300,n);
equation
rho*V*C*der(T[1]) = -h*(T[1]-Tamb)-k*A/(L/n)*(T[1]-T[2]);
rho*V*C*der(T[2:n-1]) = -k*(L/n)*(T[2:n-1]-T[1:n-2])-k*A/(L/n)*(T[2:n-1]-T[3:n]);
rho*V*C*der(T[end]) = -h*(T[end]-Tamb)-k*A/(L/n)*(T[end]-T[end-1]);
rho*V*C*der(T[1]) = -h*(T[1]-Tamb)-k*A*(T[1]-T[2])/(L/n);
rho*V*C*der(T[2:n-1]) = -k*A*(T[2:n-1]-T[1:n-2])/(L/n)-k*A*(T[2:n-1]-T[3:n])/(L/n);
rho*V*C*der(T[end]) = -h*(T[end]-Tamb)-k*A*(T[end]-T[end-1])/(L/n);
end Rod_VectorNotation;
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ model Rod_VectorNotationNoSubscripts
initial equation
T = linspace(200,300,n);
equation
Qleft = {if i==1 then -h*(T[i]-Tamb) else -k*A/(L/n)*(T[i]-T[i-1]) for i in 1:n};
Qright = {if i==n then -h*(T[i]-Tamb) else -k*A/(L/n)*(T[i]-T[i+1]) for i in 1:n};
Qleft = {if i==1 then -h*(T[i]-Tamb) else -k*A*(T[i]-T[i-1])/(L/n) for i in 1:n};
Qright = {if i==n then -h*(T[i]-Tamb) else -k*A*(T[i]-T[i+1])/(L/n) for i in 1:n};
rho*V*C*der(T) = Qleft+Qright;
end Rod_VectorNotationNoSubscripts;

0 comments on commit a87d4af

Please sign in to comment.