Diff of /trunk/doc/cookbook/example02.tex

revision 2974 by artak, Wed Mar 3 01:21:09 2010 UTC revision 2975 by ahallam, Thu Mar 4 05:44:12 2010 UTC
# Line 10  Line 10
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 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}
# Line 54  T= T0*whereZero(x[0])+Tref*(1-whereZero( Line 55  T= T0*whereZero(x[0])+Tref*(1-whereZero(
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;
# Line 73  we can set; Line 74  we can set;
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 \verb|whereZero| function again which we have already used to set the initial value.  Here we use the \verb|whereZero| 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 non-positive,  values of $r$ are used only where $q$ is positive. Where $q$ is non-positive,
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
# Line 89  q=whereZero(x[0]) Line 90  q=whereZero(x[0])
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}

Legend:
 Removed from v.2974 changed lines Added in v.2975