• No results found

440 Geophysics: Heat flow with finite differences

N/A
N/A
Protected

Academic year: 2021

Share "440 Geophysics: Heat flow with finite differences"

Copied!
5
0
0

Loading.... (view fulltext now)

Full text

(1)

440 Geophysics: Heat flow with finite differences

Thorsten Becker, University of Southern California, 03/2005

Some physical problems, such as heat flow, can be tricky or impossible to solve analytically in any but the simplest situations. This is why we use numerical methods to model system behavior. All numerical methods suffer from general limitations, such as finite accuracy (resolution) and stability (robustness against “blowing up”). This means that you will have to proceed carefully when using computers to get answers for geophysical problems, always being aware of the simplifications and approximations. However, with (nowadays) basic computer tools, you can solve relevant problems. For example, you may estimate the temperature distribution around a dike intrusion as a function of time and space, and this distribution will be reflected in the geological record.

One method used to solve certain kinds of partial differential equations numerically is by finite differences (FD). Consider the heat flow equation in one dimension:

∂T ∂t =κ ∂2T ∂x2 + H ρcp . (1)

where T is temperature, κ thermal diffusivity, H volumetric heat production rate,ρ density, and cp heat capacity. T dependence on space, x, and time t is implied, butκ is assumed constant for

eq. (1). Should the conductivity, k, be a function of x instead, we would have had to write 1 ρcp ∂ ∂x k(x) ∂ ∂xT (2)

instead ofκx22T for the heat flow term, sinceκ=ρkcp.

In any numerical scheme, one has to discretize the spatial domain, and go from a continuous medium to individual points (or elements for the other main numerical scheme, finite elements). Let’s subdivide the model region of extent 0. . .L in x direction into n nodes so that the i-th location is

xi=x0+ (i−1)∆x, (3)

with

∆x=L/(n−1), (4)

which gives a range for x from xi=1=0 (for x0 =0) to xi=n=L. A larger number of nodes n

therefore gives you finer spatial resolution,∆x.

What FD does then is approximate the ∂/∂t and∂/∂x (as in eq. (1)) by finite differences be-tween nodes, as opposed to infinitesimal partial derivatives in a continuum. Say, you need∂f/∂x at xi, then you could approximate it from

forward differences using the slope from the function value f(xi)at xito the next node at xi+1= xi+∆x like

f

∂x(xi)≈∆xf =

f(xi+1)−f(xi)

∆x . (5)

This will be useful when you don’t have a xi−1node, as on the left domain boundary. Alter-natively, you could use

(2)

backward differences where

f

∂x(xi)≈∆bx =

f(xi)−f(xi−1)

∆x , (6)

for instance at the right domain boundary. However, it turns out that in general the best approximation to∂f/∂x error-wise is by

central differences. Those are obtained by averagingxf and∆bx such that

fx(xi)≈∆ c x= ∆f x+∆bx 2 = f(xi+1)−f(xi−1) 2∆x . (7)

If we need second-order derivatives, those can be obtained from the finite difference between ∆f x and∆bx as ∂2f ∂x2(xi)≈∆ c x2 = ∆f x−∆bx ∆x = f(xi+1)−2 f(xi) +f(xi−1) (∆x)2 . (8)

(To be precise, the second order difference eq. (8) is properly derived by computing central dif-ferences of a forward difference at node xi+1/2 and a backward difference at node xi−1/2. This distinction can be important for k(x)type problems.)

With those approximate finite differences at hand, we can now rewrite eq. (1). For simplicity, we will take κconstant and H =0. The simplest way of rewriting the diffusion equation is by a Forward Time, Centered Space (FTCS) scheme

f tT(xi,tj) = κ ∆xc2T(xi,tj) (9) T(xi,tj+1)−T(xi,tj) ∆t = κ (∆x)2 T(xi+1,tj)−2T(xi,tj) +T(xi−1,tj) . (10)

Time therefore needs to be discretized as well, and we have used i indices for space, and j for time, i.e. the temperature at time tj+1=tj+∆t is T(xi,tj+1). We can march an initial solution at time tj

forward by a time step∆t as

T(xi,tj+1) =T(xi,tj) +∆T =T(xi,tj) +

κ∆t

(∆x)2 T(xi+1,tj)−2T(xi,tj) +T(xi−1,tj)

. (11) Because the incremental change of temperature from tj to tj+1, ∆T , can be directly determined from the old temperature solution at tj, this method is called explicit.

While FTCS is a really bad idea for advection problems (the method blows up), it is an OK (not the most efficient) approach for our diffusion problem, under certain conditions. Those stabil-ity conditions will be explored in class (see appendix). The general solution strategy for any heat flow, finite difference problem is thus to define an initial condition for T(x,t =0), and boundary conditions (BCs) for the domain, i.e. at x=0 and x=L. The latter are typically either constant temperature T =C (Dirichlet BC), or constant heat flow,∂T/∂x=C (Neumann BC). Then, dis-cretize the spatial dimension, initialize the Ti,j variables, and march the solution forward in time

according to eq. (11) with some adequately chosen∆t.

(3)

%

% 1D Diffusion, explicit finite difference scheme %

% Equation solved:

% dT/dt = kappa*(dˆ2 T/dxˆ2)

%

% using Forward Time Centered Space (FTCS) % explicit method

% % i.e. %

% T(t_{i+1}) = T(t_i) + kappa * dt * (T(x_{j+1})-2*T(x_j)+T(x_{j-1})/dxˆ2; %

% Matlab script by Boris Kaus, March 2005 %

clear all;

% Input parameters

L = 1000; % length of model domain in m

W_dike = 100; % Width of intruding dike

T_bg = 1000; % Background temperature [C]

T_dike = 1300; % Temperature of intruding dike

kappa = 1e-6; % Thermal diffusivity [mˆ2/s]

dt = 1; % Timestep in years

% Numerical parameters

nx = 101; % Number of gridpoints in x-direction

num_time= 100; % Number of timesteps

year = 3600*24*365.25; % Seconds/year

dt = dt*year;

% Initialization

dx = L/(nx-1); % Spacing in x-direction

x = -L/2:dx:L/2; % Numerical grid in x-direction

T = ones(1,nx)*T_bg;

ind = find(abs(x)<W_dike/2); % spatial region where dike is found

(4)

% Time loop

for itime=1:num_time

% save old temperature

T_old = T;

% Compute finite difference scheme

ind = 2:nx-1; % index array

T2nd = (T(ind+1)-2*T(ind)+T(ind-1))/dxˆ2; % dT/dxˆ2

T(ind) = kappa*dt*T2nd + T_old(ind);

% Set BC (constant temperature)

T(1) = T_old(1); T(nx) = T_old(nx); % Plotting figure(1), clf plot(x,T) xlabel(’Distance [m]’) ylabel(’Temperature [ˆo C]’)

title([’Time = ’,num2str(itime*dt/year),’ years’]) drawnow

pause(1/10) end

TheMatlabsoftware allows you to write computer programs quickly, and plot the results eas-ily. You can read more about theMatlablanguage at http://www.mathworks.com/access/helpdesk/ help/techdoc/matlab.html/. One nifty, yet sometimes perplexing, feature ofMatlabis that it works with vectors. For instance, the lines

dx = L/(nx-1); % Spacing in x-direction

x = -L/2:dx:L/2; % Numerical grid in x-direction

tell the program to actually make an array x = {x1, x2, . . . , xn} with nx elements x1 =−L/2,

(5)

Addendum: stability of FTCS and more

As you noticed from the exercises in class, there exists a stability criterion for which the FTCS scheme works stably for the diffusion problem. The criterion says that you have to choose the time step∆t small enough for a given spatial resolution∆x and diffusivityκso that

∆t≤ (∆x)

2

2κ (12)

holds. This condition can be derived by means of von Neumann stability analysis, and makes physical sense:∆t is of order of the characteristic diffusion time for numerical noise as determined by the grid spacing (note factor two).

As you might have also noted, one needs to march the solution forward by a large number of time steps so that the essential processes of heat conduction can be captured if ∆t is limited by the above criterion. This makes FTCS as an explicity method a bad idea if efficiency is required. One would therefore rather use implicit schemes (such as Crank-Nicholson), but we don’t have the time to discuss these in class. If you want to read more about solving the heat conduction (or any diffusion) equation, you might start with, e.g., Press et al. (1993), sec. 19.2. For advection problems, see sec. 19.1 in that same “cookbook” text. If you need more detail and explanations, a great resource is Spiegelman (2004). Marc teaches what has to be an awesome class (judging from his lecture notes) at Columbia University on numerical modeling. His chapter 6 (http://www.ldeo. columbia.edu/∼mspieg/mmm/Diffusion.pdf) deals with diffusion problems.

References

Press, W. H., Teukolsky, S. A., Vetterling, W. T., and Flannery, B. P. (1993). Numerical Recipes in C: The Art of Scientific Computing. Cambridge University Press, Cambridge, 2 edition.

Spiegelman, M. (2004). Myths and Methods in Modeling. Columbia University Course Lecture Notes, http://www.ldeo.columbia.edu/∼mspieg/mmm/.

References

Related documents

Todavia, nos anos 1800, essas práticas já não eram vistas com tanta naturalidade, pelos menos pelas instâncias de poder, pois não estava de acordo com uma sociedade que se

In order to assist Proposers in preparing their bids, the attached document has been developed which incorporates many of those questions/requests, together with the School

In June of 2005, the Faculty of the Social-Organizational Psychology Program, Department of Organization and Leadership, Teachers College, Columbia University launched a

Except as expressly provided otherwise in these Terms of Use, we will provide you notices and other information regarding your Eligible Account or the Account Services through

Communications Director at the Washington Low Income Housing Alliance, a statewide affordable housing advocacy organization... Housing

Here, we focus on the crystallization dynamics of amorphous LPCVD and PECVD Si 3 N 4 layers, implanted with different species after thermal annealing at 1100 ◦ C. Data were

This paper provides an overview of the creation of reusable learning objects (RLOs) at the Institute of Technology Tallaght (ITT Dublin) and how the development of these