1 

2 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
3 
% 
4 
% Copyright (c) 20032009 by University of Queensland 
5 
% Earth Systems Science Computational Center (ESSCC) 
6 
% http://www.uq.edu.au/esscc 
7 
% 
8 
% Primary Business: Queensland, Australia 
9 
% Licensed under the Open Software License version 3.0 
10 
% http://www.opensource.org/licenses/osl3.0.php 
11 
% 
12 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
13 

14 
\section{Two Dimensional Heat Diffusion for a basic Magmatic Intrusion} 
15 
%\label{Sec:2DHD} 
16 
Building upon our success from the 1D models it is now prudent to expand our domain by another dimension. For this example we will again be using an intrusion as the basis for our model. The simulattion will be a single event where some molten granite has formed a hemisphericle dome at the base of some cold sandstone country rock. \editor{the aim of this example is to introduce the second dimension, as well as some more complicated boundary and initial conditions} . A hemisphere is semetric so taking a crosssection through its centre will effectively model a 3D problem in 2D. 
17 

18 
To expand upon our 1D problem, the domain must first be expanded. This will be done in our definition phase by creating a square domain in $x$ and $y$ that is 600 meters along eacy side. The number of discrete spatial cells will be 100. The radius of the intrusion will be 200 meters And the location of the centre of the intrusion will be at the 300 meter mark on the xaxis. This is done with the following block of code: 
19 
\begin{verbatim} 
20 
mx = 600 # model lenght 
21 
my = 600 # model width 
22 
ndx = 100 # steps in x direction 
23 
ndy = 100 # steps in y direction 
24 
r = 200 # radius of intrusion 
25 
ic = [300, 0] #centre of intrusion 
26 
\end{verbatim} 
27 
The next step is to define our variables for each material in the model in a manner similar to the previous tutorial. Note that each material has its own unique set of values. The time steps and set up for the domain remain as before. Prior to setting up the PDE the boundary between the two materials must be established. The distance $s$ between two points in car cartesian coordinates is defined as: 
28 
\begin{equation} 
29 
(x_{1}x_{0})^{2}+(y_{1}y_{0})^{2} = s^{2} 
30 
\end{equation} 
31 
If $[x_{0},y_{0}]$ is the point $c$ the centre of the semicircle that defines our intrusion then for all the points $[x,y]$ in our solution space we can define a distance to $c$. Hence, and points that fall within the radius $r$ of our intrusion will have a coresponding value $s < r$ and all those belonging to the country rock will have a value $s > r$. By subtracting $r$ from both of these conditions we find $sr < 0$ for all intrusion points and $sr > 0$ for all country rock points. Defining these conditions into the code is quite simple and is done using the following command: 
32 
\begin{verbatim} 
33 
bound = length(xic)r #where the boundary will be located 
34 
\end{verbatim} 
35 
This definition of the boundary can now be used with the \verb wherePositive() and \verb whereNegative() commands from before to help define the material constants and temperatures in our domain. By examining the general form we solved in the earlier tutorials, it is obvious that both \verb A and \verb D depend on the predefined variables. To set these variables accordingly and complete our PDE we use: 
36 
\begin{verbatim} 
37 
A = (kappai)*whereNegative(bound)+(kappac)*wherePositive(bound) 
38 
D = (rhocpi/h)*whereNegative(bound)+(rhocpc/h)*wherePositive(bound) 
39 

40 
mypde.setValue(A=A*kronecker(model),D=D,d=eta,y=eta*Tc) 
41 
\end{verbatim} 
42 
Our PDE has now been properly established. The initial conditions for temperature are set out in a similar matter: 
43 
\begin{verbatim} 
44 
T= Ti*whereNegative(bound)+Tc*wherePositive(bound) #defining the initial temperatures. 
45 
\end{verbatim} 
46 
The itteration process now begins as before, but using our new conditions for \verb D as defined above. Additionally we will also save a copy of the boundary to *.xml so that it can be used for visualisation purposes in \verb mayavi . 