From a87d4afffb653b859186417628e28d72639bd3e2 Mon Sep 17 00:00:00 2001 From: Michael Tiller Date: Fri, 11 Apr 2014 13:43:25 -0400 Subject: [PATCH] Fixed an error in the left hand terms conduction terms While revising the equations for one dimensional heat transfer (see #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. --- .../ArrayEquations/HeatTransfer/Rod_ArrayComprehensions.mo | 6 +++--- .../ArrayEquations/HeatTransfer/Rod_ForLoop.mo | 6 +++--- .../ArrayEquations/HeatTransfer/Rod_VectorNotation.mo | 6 +++--- .../HeatTransfer/Rod_VectorNotationNoSubscripts.mo | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ModelicaByExample/ArrayEquations/HeatTransfer/Rod_ArrayComprehensions.mo b/ModelicaByExample/ArrayEquations/HeatTransfer/Rod_ArrayComprehensions.mo index 7cf03c1e..a95a2599 100644 --- a/ModelicaByExample/ArrayEquations/HeatTransfer/Rod_ArrayComprehensions.mo +++ b/ModelicaByExample/ArrayEquations/HeatTransfer/Rod_ArrayComprehensions.mo @@ -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; diff --git a/ModelicaByExample/ArrayEquations/HeatTransfer/Rod_ForLoop.mo b/ModelicaByExample/ArrayEquations/HeatTransfer/Rod_ForLoop.mo index e6ec7086..7ee2db4b 100644 --- a/ModelicaByExample/ArrayEquations/HeatTransfer/Rod_ForLoop.mo +++ b/ModelicaByExample/ArrayEquations/HeatTransfer/Rod_ForLoop.mo @@ -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; diff --git a/ModelicaByExample/ArrayEquations/HeatTransfer/Rod_VectorNotation.mo b/ModelicaByExample/ArrayEquations/HeatTransfer/Rod_VectorNotation.mo index e17ba05c..09c356a3 100644 --- a/ModelicaByExample/ArrayEquations/HeatTransfer/Rod_VectorNotation.mo +++ b/ModelicaByExample/ArrayEquations/HeatTransfer/Rod_VectorNotation.mo @@ -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; diff --git a/ModelicaByExample/ArrayEquations/HeatTransfer/Rod_VectorNotationNoSubscripts.mo b/ModelicaByExample/ArrayEquations/HeatTransfer/Rod_VectorNotationNoSubscripts.mo index 01488699..078cf038 100644 --- a/ModelicaByExample/ArrayEquations/HeatTransfer/Rod_VectorNotationNoSubscripts.mo +++ b/ModelicaByExample/ArrayEquations/HeatTransfer/Rod_VectorNotationNoSubscripts.mo @@ -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;