Numerical Modelling in 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). Turcotte, D.L., Schubert, G. Geodynamics. Cambridge University Press, 456 pp., 2 nd edition (2002). Any trouble?: just ask + Thursday 11:00-13:00 (???) Final exam: oral discussion about: the physics behind geological/geodynamical processes. used numerical techniques. the thermo-mechanical code the student will program through the course.
Why numerical modelling in geosciences? 1. Most of the geological processes occur at timescales and depths such that they cannot be observed directly. Max. human timescale Accessible by drilling (max 10 km) Unaccessible
Why numerical modelling in geosciences? 2. Direct measurements of, for example, stress, deformation (strain rate), composition, temperature, pressure, etc., are limited to few rock samples. With numerical models we can know their distribution everywhere in our computational domain.
Why numerical modelling in geosciences? 3. Numerical modelling is an indispensable tool to understand the evolution of complex geological systems together with laboratory experiments (input) and field and geophysical observations (output). Field and geophysical data Analogue/numerical modeling Understanding geological processes Lab. analysis/experiments and theory
What is numerical modelling in geosciences? Fundamental PDEs in this course Discretization: FD,FE,FV Eulerian+Lagrangian meshes v = 0 Conservation of mass for incompressible media σ # P = ρg Conservation of momentum for slowly flowing continuous media ρc P DT Dt = q + H Conservation of energy 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-thermomechanical models 3D subduction + patterns of deformation
Visualization is important! Sibylla von Cleve als Braut, Lukas Cranach d. Ä. (1472-1553) Noble dame, 1959 Succession Picasso / VG Bild-Kunst, Bonn 20
6.00E+03 9.00E+03 0.00E+00-1.69E-09 0 196 1157 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 7.00E+03Numerical 9.00E+03 0.00E+00 modeling 1.10E-09without -1.49E-09 visualization 0 227 1188 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 8.00E+03 9.00E+03 0.00E+00 1.10E-09-1.29E-09 0 258 1219 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 9.00E+03 9.00E+03 0.00E+00 1.10E-09-1.10E-09 0 289 1250 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 1.00E+04 9.00E+03 0.00E+00 1.10E-09-8.96E-10 0 320 1281 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 1.10E+04 9.00E+03 0.00E+00 1.10E-09-6.97E-10 0 351 1312 1.00E+19 3.00E-05 3.15E+02 0.00E+00 1.00E+03 1.20E+04 9.00E+03 0.00E+00 1.10E-09-4.98E-10 0 382 1343 1.00E+19 3.01E-05 3.81E+02 0.00E+00 1.00E+03 1.30E+04 9.00E+03 0.00E+00 1.10E-09-2.99E-10 0 413 1374 1.00E+19 3.01E-05 3.98E+02 0.00E+00 1.00E+03 1.40E+04 9.00E+03 0.00E+00 1.10E-09-9.96E-11 0 444 1405 1.00E+19 3.01E-05 3.98E+02 0.00E+00 1.00E+03 1.50E+04 9.00E+03 0.00E+00 1.10E-09 9.96E-11 0 475 1436 1.00E+19 3.01E-05 3.98E+02 0.00E+00 1.00E+03 1.60E+04 9.00E+03 0.00E+00 1.10E-09 2.99E-10 0 506 1467 1.00E+19 3.01E-05 3.98E+02 0.00E+00 1.00E+03 1.70E+04 9.00E+03 0.00E+00 1.10E-09 4.98E-10 0 537 1498 1.00E+19 3.01E-05 3.98E+02 0.00E+00 1.00E+03 1.80E+04 9.00E+03 0.00E+00 1.10E-09 6.97E-10 0 568 1529 1.00E+19 3.01E-05 3.81E+02 0.00E+00 1.00E+03 1.90E+04 9.00E+03 0.00E+00 1.10E-09 8.96E-10 0 599 1560 1.00E+19 3.00E-05 3.15E+02 0.00E+00 1.00E+03 2.00E+04 9.00E+03 0.00E+00 1.10E-09 1.10E-09 0 630 1591 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 2.10E+04 9.00E+03 0.00E+00 1.10E-09 1.29E-09 0 661 1622 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 2.20E+04 9.00E+03 0.00E+00 1.10E-09 1.49E-09 0 692 1653 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 2.30E+04 9.00E+03 0.00E+00 1.10E-09 1.69E-09 0 723 1684 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 2.40E+04 9.00E+03 0.00E+00 1.10E-09 1.89E-09 0 754 1715 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 2.50E+04 9.00E+03 0.00E+00 1.10E-09 2.09E-09 0 785 1746 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 2.60E+04 9.00E+03 0.00E+00 1.10E-09 2.29E-09 0 816 1777 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 2.70E+04 9.00E+03 0.00E+00 1.10E-09 2.49E-09 0 847 1808 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 2.80E+04 9.00E+03 0.00E+00 1.10E-09 2.69E-09 0 878 1839 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 2.90E+04 9.00E+03 0.00E+00 1.10E-09 2.89E-09 0 909 1870 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 3.00E+04 9.00E+03 0.00E+00 1.10E-09 0.00E+00 0 940 1901 1.00E+19 3.00E-05 2.98E+02 2.02E+03 1.00E+03 0.00E+00 9.00E+03 0.00E+00 1.10E-09-2.89E-09 0 10 971 1.00E+19 3.00E-05 2.98E+02 1.99E+03 1.00E+03 1.00E+03 9.00E+03 0.00E+00 1.10E-09-2.69E-09 0 41 1002 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 2.00E+03 9.00E+03 0.00E+00 1.10E-09-2.49E-09 0 72 1033 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 3.00E+03 9.00E+03 0.00E+00 1.10E-09-2.29E-09 0 103 1064 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 4.00E+03 9.00E+03 0.00E+00 1.10E-09-2.09E-09 0 134 1095 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 5.00E+03 9.00E+03 0.00E+00 1.10E-09-1.89E-09 0 165 1126 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 6.00E+03 9.00E+03 0.00E+00 1.10E-09-1.69E-09 0 196 1157 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 7.00E+03 9.00E+03 0.00E+00 1.10E-09-1.49E-09 0 227 1188 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 8.00E+03 9.00E+03 0.00E+00 1.10E-09-1.29E-09 0 258 1219 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 9.00E+03 9.00E+03 0.00E+00 1.10E-09-1.10E-09 0 289 1250 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 1.00E+04 9.00E+03 0.00E+00 1.10E-09-8.96E-10 0 320 1281 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 1.10E+04 9.00E+03 0.00E+00 1.10E-09-6.97E-10 0 351 1312 1.00E+19 3.00E-05 3.15E+02 0.00E+00 1.00E+03 1.20E+04 9.00E+03 0.00E+00 1.10E-09-4.98E-10 0 382 1343 1.00E+19 3.01E-05 3.81E+02 0.00E+00 1.00E+03 1.30E+04 9.00E+03 0.00E+00 1.10E-09-2.99E-10 0 413 1374 1.00E+19 3.01E-05 3.98E+02 0.00E+00 1.00E+03 1.40E+04 9.00E+03 0.00E+00 1.10E-09-9.96E-11 0 444 1405 1.00E+19 3.01E-05 3.98E+02 0.00E+00 1.00E+03 1.50E+04 9.00E+03 0.00E+00 1.10E-09 9.96E-11 0 475 1436 1.00E+19 3.01E-05 3.98E+02 0.00E+00 1.00E+03 1.60E+04 9.00E+03 0.00E+00 1.10E-09 2.99E-10 0 506 1467 1.00E+19 3.01E-05 3.98E+02 0.00E+00 1.00E+03 1.70E+04 9.00E+03 0.00E+00 1.10E-09 4.98E-10 0 537 1498 1.00E+19 3.01E-05 3.98E+02 0.00E+00 1.00E+03 1.80E+04 9.00E+03 0.00E+00 1.10E-09 6.97E-10 0 568 1529 1.00E+19 3.01E-05 3.81E+02 0.00E+00 1.00E+03 1.90E+04 9.00E+03 0.00E+00 1.10E-09 8.96E-10 0 599 1560 1.00E+19 3.00E-05 3.15E+02 0.00E+00 1.00E+03 2.00E+04 9.00E+03 0.00E+00 1.10E-09 1.10E-09 0 630 1591 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03 2.10E+04 9.00E+03 0.00E+00 1.10E-09 1.29E-09 0 661 1622 1.00E+19 3.00E-05 2.98E+02 0.00E+00 1.00E+03
Numerical modeling with visualization 400 o C 800 o C 1200 o C Temperature Viscosity 200 o C 400 o C 600 o C 800 o C 1000 o C 1200 o 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) 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 department. visualization requires powerful GPUs ( 2.000-10.0000) and can be done on local machines or remotely using cluster s GPUs. Workstation FERMI at CINECA, Bologna, Italy Programming languages: C/C++, Fortran, MatLab ( 500-1000 à Octave for free!) Visualization softwares: MatLab, Paraview, Amira, etc. This is not a coffee vending machine!
end of the introduction and now action
Mathematics First of all: it is simple!!! First and second order derivatives. (Very short) review of the mathematical background needed in this course to handle partial differential equations (PDE): differential equations in which an unknown function is a function of multiple (rather than single) independent variables (space coordinates and time). Example: 3D Heat diffusion equation à T t = k " T 2 x + T 2 2 y + T % $ 2 ' # 2 z 2 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 lim Δx 0 ( ) f ( x) (x + Δx) ( x) f x + Δx T x ΔT Δx = T T 2 1 x 2 x 1 Analytical vs Numerical T 1 " $ # T x % ' x 1 x 2 T 2 x Δx The same is valid for first derivative in time: T t ΔT Δt = T t+δt T t Δt
PDEs in this course and field variables Continuum mechanics PDEs v = 0 Conservation of mass for incompressible media σ # P = ρg Conservation of momentum for slowly flowing continuous media ρc P DT Dt = q + H Conservation of energy The unknown function upon which differentiation is operated describes a given field variable. Field variables describe the physical properties of the medium. Input field variables: viscosity, density, heat capacity, thermal conductivity, initial temperature field, etc. Output field variables: velocity, temperature, pressure, stress, strain rate There are 3 major types of field variables: Scalars Vectors Tensors
Scalar It is a number indicating the magnitude of a physical quantity, independent of the coordinate system (invariant) à pressure (P), temperature (T), density (ρ) and many other rock physical properties Gradient (gives a vector): # = x ; y ; % ( $ z' where del= is a vector differential operator Laplacian (gives a scalar): # grad(t ) = T = T x ; T y ; T % ( $ z ' T ΔT = T = 2 T = 2 x + T 2 2 y + T 2 2 z 2 % Δ = = 2 = 2 x + 2 2 y + ( ' 2 * 2 z 2 ) where is the Laplace operator
Vector It has a magnitude (length) and direction, the physical quantity is split into its components à velocity ( ), heat flux ( ), gravity ( ) Magnitude (invariant): (or Euclidean norm) Divergence (gives a scalar, invariant): where: Divergence of a vector represents the extent to which there is incoming or outgoing flux of a given physical quantity: div(v) < 0 : sink div(v) = 0 : neutral div(v) > 0 : source v $ = x + y + ' ) % z( q v = v x2 + v y2 + v z 2 g v i =! # # # " v x v y v z $ % div( v) = v = v x x + v y y + v z z
Vector Gradient of a vector (gives a matrix, called Jacobian): v = v i j = # % % % % % % % $ v x x v y x v z x v x y v y y v z y v x z v y z v z z ( ( ( ( ( ( ( '
Vector Curl (gives a vector): its magnitude expresses the amount of rotation, while its direction is normal to the plane of rotation (using the right-hand rule). curl( v) = v = 0 z z y y 0 x 0 x % ' ' ' v x v y v z ( * + * = v z * y v y -, z ). + 0+ v x / z v z -, x. + 0+ v y / x v x -, y. 0 / Vorticity: ω = 1 2 v Product rule (Leibniz s law): Example: divergence of mass flux à Chain rule: a x = a b b x ( a b) " = a" b + b" a a or t = a x ( ) = ( ρv ) = ρ v + v ρ div ρv x t + a y y t
Tensor σ Stress ( ), strain ( ), strain rate ( ) ε Invariants (quantities independent of the coordinate system): - First invariant à trace:! σ xx σ xy σ xz $ # σ ij = # σ yx σ yy σ yz # " σ zx σ zy σ zz % - Second invariant à magnitude: - Third invariant à determinant ε tr( σ ) ij = ( σ xx +σ yy +σ ) zz σ = 1 σ 2 ij2 = 1 σ 2 ( 2 xx +σ 2 xy +σ 2 xz +σ 2 yx +σ 2 yy +σ 2 yz +σ 2 zx +σ 2 2 zy +σ ) zz
Tensor Divergence (gives a vector): σ ij = σ ij j $ = % x + σ xy y + σ ' xz ) z ) x + σ yy y + σ ) yz ) z ) x + σ zy y + σ ) zz ) z ( σ xx σ yx σ zx
Exercise Write the following equations using partial derivatives in 2D: v = 0 Conservation of mass for incompressible media σ # P = ρg Conservation of momentum for slowly flowing continuous media ρc P DT Dt = q + H # grad( f ) = f = f x ; f y ; f % ( $ z ' div( f ) = f = f x x + f y y + f z z Conservation of energy f ij = f ij j = $ % f xx x + f xy y + f xz z f yx x + f yy y + f yz z f zx x + f zy y + f zz 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 ρ Chain rule: df (x) dt = f (x) x dx dt or df (x, y) dt = f (x, y) x dx dt + f (x, y) y dy dt Example: dρ(t, P) dt = ρ dt T dt + ρ P dp 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). Download Octave at: http://octave.sourceforge.net/index.html Download the graphical unit interface GUIOctave at: https://sites.google.com/site/guioctave/ For problems related to the installation of Octave softwares, ask (only if indispensable!) to PhD candidate Luca Penasa. Access to PCs in this room: Username: faccenda Password: faccenda2013
What MatLab is? MATLAB is a high-level language and interactive environment for numerical computation, visualization, and programming. Using MATLAB, you can analyze data, develop algorithms, and create models and applications. It a very useful tool for beginners because many algorithms are already built in, and we can readily analyze and visualize model results. Let s check how the graphical interface is organized
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) (see next slide) 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)
See also: http://www.mathworks.com/help/matlab/ref/arithmeticoperators.html
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')) (see next slide) 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)
Types of variables in MatLab and their storage Field type Precision Bytes Specifier in MatLab Numeric range Unsigned integers uint8 1 %u 0 2 8-1 uint16 2 %u 0 2 16-1 uint32 4 %u 0 2 32-1 uint64 8 %lu 0 2 64-1 Signed integers int8 1 %d -2 7 2 7-1 int16 2 %d -2 15 2 15-1 int32 4 %d -2 31 2 31-1 int64 8 %ld -2 63 2 63-1 Floating-point single 4 %f,%e,%g -2 127 2 127 double 8 %f,%e,%g -2 1023 2 1023 1 byte = 8 bits 1 0 1 1 1 0 1 1 2 0 +0+2 2 +2 3 +2 4 +0+2 6 +2 7 = 221 Character string char depends on the length of the string %s,%c - 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 To get motivated, read the Introduction chapter of textbook: Gerya, T. Introduction to numerical geodynamic modelling. Cambridge University Press, 345 pp. (2010) Exercise with MatLab/Octave functions we have seen today Study files Practice1.m and Practice1b.m