Numerical Modelling in Geosciences. Lecture 1 Introduction and basic mathematics for PDEs

Similar documents
Getting started: CFD notation

Numerical Modelling in Geosciences. Lecture 6 Deformation

Chapter 5. The Differential Forms of the Fundamental Laws

Continuum mechanism: Stress and strain

Multiple Integrals and Vector Calculus (Oxford Physics) Synopsis and Problem Sets; Hilary 2015

EKC314: TRANSPORT PHENOMENA Core Course for B.Eng.(Chemical Engineering) Semester II (2008/2009)

Chapter 1. Continuum mechanics review. 1.1 Definitions and nomenclature

A Study on Numerical Solution to the Incompressible Navier-Stokes Equation

In this section, mathematical description of the motion of fluid elements moving in a flow field is

Multiple Integrals and Vector Calculus: Synopsis

12. Stresses and Strains

Introduction to PDEs and Numerical Methods Lecture 1: Introduction

Dynamics of Glaciers

FMIA. Fluid Mechanics and Its Applications 113 Series Editor: A. Thess. Moukalled Mangani Darwish. F. Moukalled L. Mangani M.

Lagrange Multipliers

Numerical Heat and Mass Transfer

PEAT SEISMOLOGY Lecture 2: Continuum mechanics

Uniformity of the Universe

Chapter 9: Differential Analysis

Rock Rheology GEOL 5700 Physics and Chemistry of the Solid Earth

AE/ME 339. Computational Fluid Dynamics (CFD) K. M. Isaac. Momentum equation. Computational Fluid Dynamics (AE/ME 339) MAEEM Dept.

Chapter 9: Differential Analysis of Fluid Flow

Math background. Physics. Simulation. Related phenomena. Frontiers in graphics. Rigid fluids

? D. 3 x 2 2 y. D Pi r ^ 2 h, r. 4 y. D 3 x ^ 3 2 y ^ 2, y, y. D 4 x 3 y 2 z ^5, z, 2, y, x. This means take partial z first then partial x

Chain Rule. MATH 311, Calculus III. J. Robert Buchanan. Spring Department of Mathematics

2.20 Fall 2018 Math Review

Numerical Implementation of Transformation Optics

M E 320 Professor John M. Cimbala Lecture 10

Sections minutes. 5 to 10 problems, similar to homework problems. No calculators, no notes, no books, no phones. No green book needed.

MATH 19520/51 Class 5

Lecture: Wave-induced Momentum Fluxes: Radiation Stresses

CHAPTER 7 DIV, GRAD, AND CURL

Introduction to Fluid Dynamics

V (r,t) = i ˆ u( x, y,z,t) + ˆ j v( x, y,z,t) + k ˆ w( x, y, z,t)

Basic Equations of Elasticity

Lecture 8: Tissue Mechanics

Computer Applications in Engineering and Construction Programming Assignment #9 Principle Stresses and Flow Nets in Geotechnical Design

Chapter 1 Fluid Characteristics

AE/ME 339. K. M. Isaac Professor of Aerospace Engineering. 12/21/01 topic7_ns_equations 1

3D Elasticity Theory

L3: Review of linear algebra and MATLAB

Mechanics of materials Lecture 4 Strain and deformation

Macroscopic theory Rock as 'elastic continuum'

Created by T. Madas VECTOR OPERATORS. Created by T. Madas

A DARK GREY P O N T, with a Switch Tail, and a small Star on the Forehead. Any

The Generalized Interpolation Material Point Method

Chapter 4: Fluid Kinematics

Chapter 2: Basic Governing Equations

Mathematical Concepts & Notation

Notes 19 Gradient and Laplacian

Electromagnetism HW 1 math review

100 CHAPTER 4. SYSTEMS AND ADAPTIVE STEP SIZE METHODS APPENDIX

Introduction to Environment System Modeling

Lecture 8 Analyzing the diffusion weighted signal. Room CSB 272 this week! Please install AFNI

ENGI Gradient, Divergence, Curl Page 5.01

Dynamics of the Mantle and Lithosphere ETH Zürich Continuum Mechanics in Geodynamics: Equation cheat sheet

Module 2: Governing Equations and Hypersonic Relations

Jim Lambers MAT 280 Summer Semester Practice Final Exam Solution. dy + xz dz = x(t)y(t) dt. t 3 (4t 3 ) + e t2 (2t) + t 7 (3t 2 ) dt

Rheology of Soft Materials. Rheology

Stress, Strain, Mohr s Circle

MAT 419 Lecture Notes Transcribed by Eowyn Cenek 6/1/2012

Continuum Mechanics. Continuum Mechanics and Constitutive Equations

Mechanics of Earthquakes and Faulting

Lecture 10. (2) Functions of two variables. Partial derivatives. Dan Nichols February 27, 2018

GG303 Lecture 6 8/27/09 1 SCALARS, VECTORS, AND TENSORS

KINEMATICS OF CONTINUA

MATERIAL REDUCTION & SYMMETRY PLANES

Physics 584 Computational Methods

7a3 2. (c) πa 3 (d) πa 3 (e) πa3

DO NOT BEGIN THIS TEST UNTIL INSTRUCTED TO START

Introduction to Fluid Mechanics

Stress/Strain. Outline. Lecture 1. Stress. Strain. Plane Stress and Plane Strain. Materials. ME EN 372 Andrew Ning

Mathematical Theory of Non-Newtonian Fluid

Introduction and Vectors Lecture 1

INTEGRALSATSER VEKTORANALYS. (indexräkning) Kursvecka 4. and CARTESIAN TENSORS. Kapitel 8 9. Sidor NABLA OPERATOR,

Course no. 4. The Theory of Electromagnetic Field

OCN/ATM/ESS 587. The wind-driven ocean circulation. Friction and stress. The Ekman layer, top and bottom. Ekman pumping, Ekman suction

Fast Multipole Methods: Fundamentals & Applications. Ramani Duraiswami Nail A. Gumerov

q v = - K h = kg/ν units of velocity Darcy's Law: K = kρg/µ HYDRAULIC CONDUCTIVITY, K Proportionality constant in Darcy's Law

Vector Calculus. A primer

Unit IV State of stress in Three Dimensions

Continuum Mechanics Lecture 5 Ideal fluids

Divergence Theorem and Its Application in Characterizing

Exercises for Multivariable Differential Calculus XM521

Computational Seismology: An Introduction

GeoPDEs. An Octave/Matlab software for research on IGA. R. Vázquez. IMATI Enrico Magenes, Pavia Consiglio Nazionale della Ricerca

Math 4263 Homework Set 1

MECH 5312 Solid Mechanics II. Dr. Calvin M. Stewart Department of Mechanical Engineering The University of Texas at El Paso

UNIVERSITY of LIMERICK OLLSCOIL LUIMNIGH

Lecture Administration. 7.2 Continuity equation. 7.3 Boussinesq approximation

Introduction to Seismology Spring 2008

1 2D Stokes equations on a staggered grid using primitive variables

THREE-DIMENSIONAL SIMULATION OF THERMAL OXIDATION AND THE INFLUENCE OF STRESS

Lecture 3: 1. Lecture 3.

EULERIAN DERIVATIONS OF NON-INERTIAL NAVIER-STOKES EQUATIONS

Vector Calculus - GATE Study Material in PDF

CHAPTER 7 SEVERAL FORMS OF THE EQUATIONS OF MOTION

The Divergence Theorem Stokes Theorem Applications of Vector Calculus. Calculus. Vector Calculus (III)

pyoptfem Documentation

Math 207 Honors Calculus III Final Exam Solutions

Transcription:

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