Professional Documents
Culture Documents
Geoscienze-Modelli Numerici. Introduzione
Geoscienze-Modelli Numerici. Introduzione
Geoscienze-Modelli Numerici. Introduzione
Geosciences
Lecture 1
Introduction and basic
mathematics for PDEs
Useful information
Slides and exercises: download at my homepage:
http://www.geoscienze.unipd.it/users/faccenda-manuele
Textbooks:
• Gerya, T. Introduction to numerical geodynamic modelling.
Cambridge University Press, 345 pp. (2010).
DT Conservation of energy
ρc P = −∇ ⋅ q + H
Dt
To close the system we need rock physical properties from lab. experiments:
€
• density
• thermal conductivity, expansivity
• heat capacity
• rock mechanical properties
• melting/metamorphic reactions
2D mechanical models
Boudinage Buckling/folding
3D petrological-thermo-
mechanical models
400oC
800oC
1200o C
Temperature
Viscosity 200oC
400oC
600oC
800oC
1000o C
1200o C
Bulk Strain
Computational resources
1D/2D models:
• computation and visualization can be mostly done on local
machines with moderate to high RAM and 1 to 8 CPUs
(depending on the numerical resolution = problem size)(€
1.500-4.000)
Workstation
3D models:
• computation on supercomputing clusters (e.g., PLX, EURORA
and FERMI at CINECA, Italy) with 100s to 1.000.000s CPUs. If
many users, “problems” may arise due to long queuing times.
• alternatively, with about € 100.000 it is possible to buy medium
size clusters (e.g., 384-786 CPUs) that could serve the whole FERMI at CINECA, Bologna,
Italy
department.
• visualization requires powerful GPUs (€ 2.000-10.0000) and can
be done on local machines or remotely using cluster’s GPUs.
Programming languages:
C/C++, Fortran, MatLab (€ 500-1000 à Octave for free!)
Visualization softwares:
MatLab, Paraview, Amira, etc.
In this course we will use the finite difference method to operate differentiation
and numerically solve for PDEs
Finite difference method
First derivative of function f(x) (1D case): Example:
∂f ( x ) f ( x + Δx ) − f ( x ) ∂T ΔT T2 − T1
f !( x) = ≈ lim ≈ =
∂x Δx→0
(x + Δx) − ( x ) ∂x Δx x2 − x1
" ∂T %
Analytical vs Numerical $ '
T1 # ∂x & T2
x
x1 x2
Δx
∂T ΔT T t+Δt − T t
≈ =
∂t Δt Δt
PDEs in this course and field variables
Continuum mechanics PDEs
DT Conservation of energy
ρc P = −∇ ⋅ q + H
Dt
# ∂T ∂T ∂T &
Gradient (gives a vector): grad(T ) = ∇T = % ; ; (
$ ∂x ∂y ∂z '
#∂ ∂ ∂&
where del= ∇ =% ; ; ( is a vector differential operator
$ ∂x ∂y ∂z '
2 2 2
Laplacian (gives a scalar): ΔT = ∇ ⋅ ∇T = ∇ T = 2 ∂ T ∂ T ∂ T
2
+ 2+ 2
∂x ∂y ∂z
2
% ∂ 2
∂ 2
∂ 2
(
where Δ = ∇ ⋅ ∇ = ∇ = ' + 2 + 2 * is the Laplace operator
2
& ∂x ∂y ∂z )
Vector
It has a magnitude (length) and direction, the physical quantity is split into its
components à velocity ( v ), heat flux ( q ), gravity ( g )
!v x $
# &
2
Magnitude (invariant): v = vx + vy + vz 2 2 vi = #vy &
(or Euclidean norm) #v &
" z%
∂vx ∂vy ∂vz
Divergence (gives a scalar, invariant): div(v) = ∇ ⋅ v = + +
$∂ ∂ ∂' ∂x ∂y ∂z
where: ∇⋅ = & + +
)
% ∂x ∂y ∂z (
Divergence of a vector represents the extent to which there is incoming or
outgoing flux of a given physical quantity:
∂ ∂
0 −
∂z ∂y % (
vx
∂ ∂ ' * + ∂vz ∂vy . + ∂vx ∂vz . + ∂vy ∂vx .
curl(v) = ∇ × v = 0 − 'v y * = - − 0+- − 0+- − 0
∂z ∂x ' * , ∂y ∂z / , ∂z ∂x / , ∂x ∂y /
∂ ∂ & vz )
− 0
∂y ∂x
1
Vorticity: ω = ∇ × v
2
!σ xx σ xy σ xz $
# &
σ ij = #σ yx σ yy σ yz &
#σ σ σ &
" zx zy zz %
σ = 1 σ ij2 = 1 (σ xx2 + σ xy2 + σ xz2 + σ yx2 + σ yy2 + σ yz2 + σ zx2 + σ zy2 + σ zz2 )
2 2
- Third invariant à determinant
Tensor
Divergence (gives a vector):
$ ∂σ xx ∂σ xy ∂σ xz '
& + + )
& ∂x ∂y ∂z )
∂σ ij & ∂σ yx ∂σ yy ∂σ yz )
∇ ⋅ σ ij = =& + + )
∂j & ∂x ∂y ∂z )
& ∂σ zx ∂σ zy ∂σ zz )
& + + )
% ∂x ∂y ∂z (
Exercise
Write the following equations using partial derivatives in 2D:
DT Conservation of energy
ρc P = −∇ ⋅ q + H
Dt
$ ∂f xx ∂f xy ∂f xz '
& + + )
# ∂f ∂f ∂f & & ∂x ∂y ∂z )
€ grad( f ) = ∇f = % ; ; (
$ ∂x ∂y ∂z ' ∂fij & ∂f yx ∂f yy ∂f yz )
∇ ⋅ fij = =& + + )
∂f ∂f y ∂f ∂j & ∂x ∂y ∂z )
div( f ) = ∇ ⋅ f = x + + z & ∂fzx ∂fzy ∂fzz )
∂x ∂y ∂z & + + )
% ∂x ∂y ∂z (
Few other rules…
Product rule (Leibniz’s law): ( f (x)⋅ g(x))" = f (x )" ⋅ g(x) + g(x )" ⋅ f (x)
Example: divergence of mass flux à div ( ρ v ) = ∇ ⋅ ( ρ v ) = ρ∇ ⋅ v + v ⋅ ∇ρ
Example:
d ρ (T, P) ∂ρ dT ∂ρ dP
= +
dt ∂T dt ∂P dt
Numerical Modelling in
Geosciences
Practice 1
…ok, now real action!
Useful information
Programming language & software: MatLab (any version)
____________________________________________________________
If not available, use Octave: open source, reads MatLab scripts and uses the same
programming language and API (application programming interface).
___________________________________________________________________
https://sites.google.com/site/guioctave/
It a very useful tool for beginners because many algorithms are already built in,
and we can readily analyze and visualize model results.
depends
Character string char on the %s,%c -
length of
the string
By default MatLab assignes to any number a double precision, i.e., maximum storage capacity.
If you want to reduce the storage, you need to specify the variable precision.
Practice with MatLab
Exercise by:
• using help function and manual
• open a script file, how to run it and debug it.
• comment and semicolon
• defining scalar, vector, matrix and perform operations with them (e.g., a+b, a-
b, a*b and a.*b, a/b, a\b)
• exercise with functions exp, log, sin, sind, asin, asind, cos, tg, ctg.
• produce and plot 1D data (Practice 1)
• initialize empty arrays and matrices (i.e., a=zeros(2,1,'int8'))
• programming loops (for,while,end) and conditions (if,else,elseif,end, logical
(~,&&,||) and relational (<,>,==,>=,<=,~=) operators) (Practice 1)
• produce and plot 2D data (Practice 1b)
• open,close files (fopen,fclose) (Practice 1b)
• save,load data in different formats (save, load, fprintf, fread, fwrite, fscanf,
hdf5write, hdf5read) (Practice 1b)
Numerical Modelling in
Geosciences
Practice 1b
Call external function
In a given m-script we call an external function (i.e., here we name it test_function)
In a different m-script named as the external function we can perform any operation,
Homework