10 
% http://www.opensource.org/licenses/osl3.0.php 
% http://www.opensource.org/licenses/osl3.0.php 
11 
% 
% 
12 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
13 


14 


15 

\section{Example 2: One Dimensional Heat Diffusion in an Iron Rod} 
16 

\sslist{example02.py} 
17 


18 

\label{Sec:1DHDv0} 
19 
\begin{figure}[ht] 
\begin{figure}[ht] 
20 
\centerline{\includegraphics[width=4.in]{figures/onedheatdiff002}} 
\centerline{\includegraphics[width=4.in]{figures/onedheatdiff002}} 
21 
\caption{Example 2: One dimensional model of an Iron bar.} 
\caption{Example 2: One dimensional model of an Iron bar.} 
22 
\label{fig:onedhdmodel} 
\label{fig:onedhdmodel} 
23 
\end{figure} 
\end{figure} 
24 


25 
\section{Example 2: One Dimensional Heat Diffusion in an Iron Rod} 
Our second example is of a cold iron bar at a constant temperature of $T\hackscore{ref}=20^{\circ} C$, see \reffig{fig:onedhdmodel}. The bar is perfectly insulated on all sides with a heating element at one end keeping the the temperature at a constant level $T\hackscore0=100^{\circ} C$. As heat is applied; energy will disperse along the bar via conduction. With time the bar will reach a constant temperature equivalent to that of the heat source. 

\sslist{example02.py} 


\label{Sec:1DHDv0} 





Our second example is a cold iron bar at a constant temperature of $T\hackscore{ref}=20^{\circ} C$, see \reffig{fig:onedhdmodel}. The bar is perfectly insulated on all sides with a heating element at one end keeping the the temperature at a constant level $T\hackscore0=100^{\circ} C$. as heat is applied; energy will disperse along the bar via conduction. With time the bar will reach a constant temperature equivalent to that of the heat source. 

26 


27 
This problem is very similar to the example of temperature diffusion in granite blocks presented in the previous section~\ref{Sec:1DHDv00}. So we will modify the script we have already developed for the granite blocks to adjust 
This problem is very similar to the example of temperature diffusion in granite blocks presented in the previous section~\ref{Sec:1DHDv00}. Thus, it is possible to modify the script we have already developed for the granite blocks to suit the iron bar problem. 

it to the iron bar problem. 

28 
The obvious difference between the two problems are the dimensions of the domain and different materials involved. This will change the time scale of the model from years to hours. 
The obvious difference between the two problems are the dimensions of the domain and different materials involved. This will change the time scale of the model from years to hours. 
29 
The new settings are; 
The new settings are; 
30 
\begin{python} 
\begin{python} 
55 
\end{python} 
\end{python} 
56 


57 
\subsection{Dirichlet Boundary Conditions} 
\subsection{Dirichlet Boundary Conditions} 
58 
In iron rod model we want to keep the initial temperature $T\hackscore0$ on the left side of the domain over time. 
In the iron rod model we want to keep the initial temperature $T\hackscore0$ on the left side of the domain constant with time. 
59 
So when we solve the PDE~\refEq{eqn:hddisc} the solution must have the value $T\hackscore0$ on the left hand 
This implies that when we solve the PDE~\refEq{eqn:hddisc}, the solution must have the value $T\hackscore0$ on the left hand 
60 
side of the domain. As mentioned already in Section~\ref{SEC BOUNDARY COND} where we discussed 
side of the domain. As mentioned already in Section~\ref{SEC BOUNDARY COND} where we discussed 
61 
boundary condition this kind of condition are called a \textbf{Dirichlet boundary condition}. Some people also 
boundary conditions, this kind of scenario can be expressed using a \textbf{Dirichlet boundary condition}. Some people also 
62 
use the term \textbf{constraint} for the PDE. 
use the term \textbf{constraint} for the PDE. 
63 


64 
To define a Dirichlet boundary condition we need to define where to apply the condition and what value the 
To define a Dirichlet boundary condition we need to identify where to apply the condition and determine what value the 
65 
solution should have at these locations. In \esc we use $q$ and $r$ to define the Dirichlet boundary conditions 
solution should have at these locations. In \esc we use $q$ and $r$ to define the Dirichlet boundary conditions 
66 
for a PDE. The solution $u$ of the PDE is set to $r$ for all sample points where $q$ has a positive value. 
for a PDE. The solution $u$ of the PDE is set to $r$ for all sample points where $q$ has a positive value. 
67 
Mathematically this is expressed in the form; 
Mathematically this is expressed in the form; 
74 
q=whereZero(x[0]) 
q=whereZero(x[0]) 
75 
r=T0 
r=T0 
76 
\end{python} 
\end{python} 
77 
to prescribe the value $T0$ for the temperature at the left end of the rod where $x\hackscore{0}=0$. 
to prescribe the value $T\hackscore{0}$ for the temperature at the left end of the rod where $x\hackscore{0}=0$. 
78 
Here we use the \verbwhereZero function again which we have already used to set the initial value. 
Here we use the \verbwhereZero function again which we have already used to set the initial value. 
79 
Notice that $r$ is set to the constant value $r$ for all sample points. In fact, 
Notice that $r$ is set to the constant value $T\hackscore{0}$ for all sample points. In fact, 
80 
values of $r$ are used only where $q$ is positive. Where $q$ is nonpositive, 
values of $r$ are used only where $q$ is positive. Where $q$ is nonpositive, 
81 
$r$ may have any value as these values are not used by the PDE solver. 
$r$ may have any value as these values are not used by the PDE solver. 
82 


90 
mypde.setValue(A=A, D=rhocp/h, q=q, r=T0) 
mypde.setValue(A=A, D=rhocp/h, q=q, r=T0) 
91 
\end{python} 
\end{python} 
92 
It is important to remark here that the Dirichlet condition \textbf{overwrites} any Neuman boundary 
It is important to remark here that the Dirichlet condition \textbf{overwrites} any Neuman boundary 
93 
condition \esc sets by default (or you may set). 
condition \esc sets by default (or those defined by the user). 
94 


95 
\begin{figure} 
\begin{figure} 
96 
\begin{center} 
\begin{center} 
113 
Besides some cosmetic modification this all we need to change. The total energy over time is shown in \reffig{fig:onedheatout1 002}. As heat 
Besides some cosmetic modification this all we need to change. The total energy over time is shown in \reffig{fig:onedheatout1 002}. As heat 
114 
is transfered into the rod by the heater the total energy is growing over time but reaches a plateau 
is transfered into the rod by the heater the total energy is growing over time but reaches a plateau 
115 
when the temperature is constant is the rod, see \reffig{fig:onedheatout 002}. 
when the temperature is constant is the rod, see \reffig{fig:onedheatout 002}. 
116 
YOu will notice that the time scale of this model is several order of magnitudes faster than 
You will notice that the time scale of this model is several order of magnitudes faster than 
117 
for the granite rock problem due to the different length scale and material parameters. 
for the granite rock problem due to the different length scale and material parameters. 
118 
In practice it can take a few models run before the right time scale has been chosen\footnote{An estimate of the 
In practice it can take a few models run before the right time scale has been chosen\footnote{An estimate of the 
119 
time scale for a diffusion problem is given by the formula $\frac{\rho c\hackscore{p} L\hackscore{0}^2}{4 \kappa}$, see 
time scale for a diffusion problem is given by the formula $\frac{\rho c\hackscore{p} L\hackscore{0}^2}{4 \kappa}$, see 