Technische Universität Berlin SS 2015 Institut für Mathematik Prof. Dr. G. Bärwolff Sekr. MA

Σχετικά έγγραφα
D Alembert s Solution to the Wave Equation

Finite difference method for 2-D heat equation

Areas and Lengths in Polar Coordinates

Areas and Lengths in Polar Coordinates

Partial Differential Equations in Biology The boundary element method. March 26, 2013

Exercises 10. Find a fundamental matrix of the given system of equations. Also find the fundamental matrix Φ(t) satisfying Φ(0) = I. 1.

Homework 3 Solutions

- 1+x 2 - x 3 + 7x x x x x x 2 - x 3 - -

1 String with massive end-points

Homework 8 Model Solution Section

Solutions to Exercise Sheet 5

1. (a) (5 points) Find the unit tangent and unit normal vectors T and N to the curve. r(t) = 3cost, 4t, 3sint

Discontinuous Hermite Collocation and Diagonally Implicit RK3 for a Brain Tumour Invasion Model

ECE Spring Prof. David R. Jackson ECE Dept. Notes 2

Parametrized Surfaces

Numerical Analysis FMN011

Example Sheet 3 Solutions

Variational Wavefunction for the Helium Atom

High order interpolation function for surface contact problem

Chapter 6: Systems of Linear Differential. be continuous functions on the interval

Jesse Maassen and Mark Lundstrom Purdue University November 25, 2013

Lecture 26: Circular domains

derivation of the Laplacian from rectangular to spherical coordinates

ES440/ES911: CFD. Chapter 5. Solution of Linear Equation Systems

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS

The Pohozaev identity for the fractional Laplacian

Section 8.3 Trigonometric Equations

Απόκριση σε Μοναδιαία Ωστική Δύναμη (Unit Impulse) Απόκριση σε Δυνάμεις Αυθαίρετα Μεταβαλλόμενες με το Χρόνο. Απόστολος Σ.

CHAPTER 48 APPLICATIONS OF MATRICES AND DETERMINANTS

Second Order Partial Differential Equations

k A = [k, k]( )[a 1, a 2 ] = [ka 1,ka 2 ] 4For the division of two intervals of confidence in R +

Mean bond enthalpy Standard enthalpy of formation Bond N H N N N N H O O O

DESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0.

ΜΑΣ 473/673: Μέθοδοι Πεπερασμένων Στοιχείων

Solution to Review Problems for Midterm III

Ηλεκτρονικοί Υπολογιστές IV

Matrices and Determinants

Review Test 3. MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Lifting Entry (continued)

Daewoo Technopark A-403, Dodang-dong, Wonmi-gu, Bucheon-city, Gyeonggido, Korea LM-80 Test Report

( ) 2 and compare to M.

( y) Partial Differential Equations

Approximation of distance between locations on earth given by latitude and longitude

Forced Pendulum Numerical approach

Written Examination. Antennas and Propagation (AA ) April 26, 2017.

Problem Set 9 Solutions. θ + 1. θ 2 + cotθ ( ) sinθ e iφ is an eigenfunction of the ˆ L 2 operator. / θ 2. φ 2. sin 2 θ φ 2. ( ) = e iφ. = e iφ cosθ.

b. Use the parametrization from (a) to compute the area of S a as S a ds. Be sure to substitute for ds!

Chapter 6: Systems of Linear Differential. be continuous functions on the interval

EE101: Resonance in RLC circuits

1. A fully continuous 20-payment years, 30-year term life insurance of 2000 is issued to (35). You are given n A 1

Integrals in cylindrical, spherical coordinates (Sect. 15.7)

Practice Exam 2. Conceptual Questions. 1. State a Basic identity and then verify it. (a) Identity: Solution: One identity is csc(θ) = 1

If we restrict the domain of y = sin x to [ π, π ], the restrict function. y = sin x, π 2 x π 2

Ηλεκτρονικοί Υπολογιστές IV

ΚΕΦΑΛΑΙΟ 2. Περιγραφή της Κίνησης. 2.1 Κίνηση στο Επίπεδο

3.5 - Boundary Conditions for Potential Flow

Appendix A. Curvilinear coordinates. A.1 Lamé coefficients. Consider set of equations. ξ i = ξ i (x 1,x 2,x 3 ), i = 1,2,3

If we restrict the domain of y = sin x to [ π 2, π 2

Εφαρμογή της μεθόδου πεπερασμένων διαφορών στην εξίσωση θερμότητας

Thin Film Chip Resistors

Math 5440 Problem Set 4 Solutions

Inverse trigonometric functions & General Solution of Trigonometric Equations

The Simply Typed Lambda Calculus

w o = R 1 p. (1) R = p =. = 1

Discretization of Generalized Convection-Diffusion

Second Order RLC Filters

Ηλεκτρονικοί Υπολογιστές IV

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 19/5/2007

Solutions - Chapter 4

Section 7.6 Double and Half Angle Formulas

4.6 Autoregressive Moving Average Model ARMA(1,1)

New bounds for spherical two-distance sets and equiangular lines

Odometry Calibration by Least Square Estimation

Phys460.nb Solution for the t-dependent Schrodinger s equation How did we find the solution? (not required)

DATA SHEET Surface mount NTC thermistors. BCcomponents

Assignment 1 Solutions Complex Sinusoids

Section 8.2 Graphs of Polar Equations

Other Test Constructions: Likelihood Ratio & Bayes Tests

Mock Exam 7. 1 Hong Kong Educational Publishing Company. Section A 1. Reference: HKDSE Math M Q2 (a) (1 + kx) n 1M + 1A = (1) =

Volume of a Cuboid. Volume = length x breadth x height. V = l x b x h. The formula for the volume of a cuboid is

ΜΑΘΗΜΑΤΙΚΗ ΠΡΟΣΟΜΟΙΩΣΗ ΤΗΣ ΔΥΝΑΜΙΚΗΣ ΤΟΥ ΕΔΑΦΙΚΟΥ ΝΕΡΟΥ ΣΤΗΝ ΠΕΡΙΠΤΩΣΗ ΑΡΔΕΥΣΗΣ ΜΕ ΥΠΟΓΕΙΟΥΣ ΣΤΑΛΑΚΤΗΦΟΡΟΥΣ ΣΩΛΗΝΕΣ ΣΕ ΔΙΑΣΤΡΩΜΕΝΑ ΕΔΑΦΗ

Concrete Mathematics Exercises from 30 September 2016

Problem Set 3: Solutions

Overview. Transition Semantics. Configurations and the transition relation. Executions and computation

*H31123A0228* 1. (a) Find the value of at the point where x = 2 on the curve with equation. y = x 2 (5x 1). (6)

UNIVERSITY OF CALIFORNIA. EECS 150 Fall ) You are implementing an 4:1 Multiplexer that has the following specifications:

Spherical Coordinates

Section 9.2 Polar Equations and Graphs

Higher Derivative Gravity Theories

συνήθων µεθόδων καθαίρεσης. ΜΟΝΑ Α ΜΕΤΡΗΣΗΣ: κυβικό µέτρο (m3) πραγµατικού όγκου προ της καθαιρέσεως () ΠΟΣΟΤΗΤΑ: 5,00

Local Approximation with Kernels

Chapter 7 Transformations of Stress and Strain

CHAPTER 101 FOURIER SERIES FOR PERIODIC FUNCTIONS OF PERIOD

Answer sheet: Third Midterm for Math 2339

Graded Refractive-Index

CHAPTER 12: PERIMETER, AREA, CIRCUMFERENCE, AND 12.1 INTRODUCTION TO GEOMETRIC 12.2 PERIMETER: SQUARES, RECTANGLES,

ηµιουργία αρχείου στον matlab editor Πληκτρολόγηση ακολουθίας εντολών

Space Physics (I) [AP-3044] Lecture 1 by Ling-Hsiao Lyu Oct Lecture 1. Dipole Magnetic Field and Equations of Magnetic Field Lines

Note: Please use the actual date you accessed this material in your citation.

Answers - Worksheet A ALGEBRA PMT. 1 a = 7 b = 11 c = 1 3. e = 0.1 f = 0.3 g = 2 h = 10 i = 3 j = d = k = 3 1. = 1 or 0.5 l =

Transcript:

Technische Universität Berlin SS 2015 Institut für Mathematik Prof. Dr. G. Bärwolff Sekr. MA 4-5 29.06.2015 6. Exercise sheet FV/FD-Methods for the solution of pde s Discussion: 13.7.15-17.7.15 1) Exercise Construct a Finite-Volume scheme to solve the 3D heat-conduction initial-boundary value problem 3) of exercise sheet 4 in spherical coordinates for Dirichlet bc and for the bc of problem 3) of sheet 4. Determine the numerical steady state solution for the Dirichlet bc u b = u(x, y, z) = 263 K + sin(arccos z x 2 + y 2 + z 2 )45 K on the boundary Γ = {(x, y, z) x 2 + y 2 + z 2 = 25 cm 2 }. Validate your approximation by solving the 1D problem of sheet 4 with the full 3D scheme. Solution: The following program solves the problem with the above noted Dirichlet boundary data. A ghost points r n+1 jk in r-direction is used and the ghost-value u n+1 jk is eliminated using the FV-approximation of the equation at the points r n jk and the interpolation of the boundary value u b by (u n+1 jk + u n jk )/2 = u b. Listing 1: source code 1 % hot potato problem 3D 2 % 3 n = 2 0 ; % z e n t r a l e Gitterpunkte in r a d i a l e r Richtung 4 m = 1 5 ; % z e n t r a l e Gitterpunkte vom Nordpol beginnend auf einem Laengenkreis 5 p = 4 ; % z e n t r a l e Gitterpunkte auf dem Aequator ( B r e i t e n k r e i s ) 6 R0 = 0. ; 7 R1 = 1. 0 / 2 0. ; % Radius der Kugel 8 drho = ( R1 R0 ) /n ; 9 dth = pi/m; 10 dphi = 2 pi/p ; 11 % 12 % Zentralpunkte der F i n i t e n Zellen 13 rho = linspace ( R0+drho /2,R1 drho /2,n ) ; 14 th = linspace ( dth /2,pi dth /2,m) ; 15 s i n t h = sin ( th ) ; 16 % Randpunkte der F i n i t e n Zellen 17 rhop = linspace ( R0, R1, n+1) ; 18 thp = linspace ( 0, pi,m+1) ; 19 sinthp = sin ( thp ) ; 20 for i =1:m 21 s i n t h i n v ( i ) = 1/ s i n t h ( i ) ; 22 end 23 for i =1:n 24 rho2 ( i ) = rho ( i ) ˆ 2 ; 25 end 26 for i =1:m 27 t h s i n t h ( i ) = th ( i ) s i n t h ( i ) ; 28 end 29 % Matrixaufbau Ar, Ath, Aphi

30 Ar = zeros ( n, n ) ; 31 Ath = zeros (m,m) ; 32 Aphi = zeros ( p, p ) ; 33 % 34 ntend = 9 0 0 ; 35 tau = 1. 0 / 1 0. ; 36 Ubound = 3 3 3 ; 37 U0 = 3 7 3. ; 38 Uu = 2 9 1. ; 39 a = 5.6/3600 1.0 e 4; 40 lambda = 0. 1 6 ; 41 alpha = 3 0 ; 42 % Skalierung 43 s k a l = 1. 0 ; 44 % 45 nmp = n m p ; 46 % Matrixaufbau Ar 47 Ualt = zeros (nmp, 1 ) ; 48 R = zeros (nmp, 1 ) ; 49 % 50 % Laplacian in Kugelkoordinaten 51 % 52 %U = [ u ( 1, 1, 1 ),..., u ( n, 1, 1 ), 53 % u ( 1, 2, 1 ),..., u ( n, 2, 1 ), 54 % u ( 1, 3, 1 ),..., u ( n, 3, 1 ), 55 % 56 % u ( 1,m, 1 ),..., u ( n,m, 1 ), 57 % u ( 1, 1, 2 ),..., u ( n, 1, 2 ), 58 % u ( 1, 2, 2 ),..., u ( n, 2, 2 ), 59 % u ( 1, 3, 2 ),..., u ( n, 3, 2 ), 60 % 61 % u ( 1,m, 2 ),..., u ( n,m, 2 ), 62 % 63 %..., u ( 1, 1, p ),..., u ( n, 1, p ), 64 %..., u ( 1, 2, p ),..., u ( n, 2, p ), 65 %..., u ( 1, 3, p ),..., u ( n, 3, p ), 66 % 67 %..., u ( 1,m, p ),..., u ( n,m, p ) ] 68 % 69 for i =2: n 1 70 Ar ( i, i ) = a ( rhop ( i +1) ˆ2 + rhop ( i ) ˆ 2 ) /drho ; 71 Ar ( i, i 1) = a rhop ( i ) ˆ2/ drho ; 72 Ar ( i, i +1) = a rhop ( i +1) ˆ2/ drho ; 73 end 74 Ar ( 1, 1 ) = a ( rhop ( 1 ) ˆ2 + rhop ( 2 ) ˆ 2 ) /drho ; 75 Ar ( 1, 2 ) = a rhop ( 2 ) ˆ2/ drho ; 76 %%% RB : u = u R, ( u {N+1} + u n ) /2 = u R 77 Ar ( n, n ) = a ( rhop ( n ) ˆ2 + 2 rhop ( n+1) ˆ 2 ) /drho ; 78 %%% h i e r muss die j e w e i l i g e RB an der Kugeloberflaeche eingebaut werden, 79 %%% d. h. U {N+ 1... } muss aus RB und Laplacian D i s k r e t i s i e r u n g am Punkt x {N... } e l i m i n i e r t werden 80 Ar ( n, n 1) = a rhop ( n ) ˆ2/ drho ; 81 % 82 for i =2:m 1 83 Ath ( i, i ) = a (sin ( thp ( i ) ) + sin ( thp ( i +1) ) ) /dth ; 84 Ath ( i, i 1) = a sin ( thp ( i ) ) /dth ; 85 Ath ( i, i +1) = a sin ( thp ( i +1) ) /dth ; 86 end 87 Ath ( 1, 1 ) = a (sin ( thp ( 1 ) ) + sin ( thp ( 2 ) ) ) /dth ; 88 Ath ( 1, 2 ) = a sin ( thp ( 2 ) ) /dth ; 89 Ath (m,m) = a (sin ( thp (m) ) + sin ( thp (m+1) ) ) /dth ; 90 Ath (m,m 1) = a sin ( thp (m) ) /dth ; 91 for i =2: p 1 92 Aphi ( i, i ) = a 2./ dphi ; 93 Aphi ( i, i 1) = a 1./ dphi ; 94 Aphi ( i, i +1) = a 1./ dphi ; 95 end 96 Aphi ( 1, 1 ) = a 2./ dphi ; 97 Aphi ( 1, 2 ) = a 1./ dphi ; 98 Aphi ( p, p ) = a 2./ dphi ; 99 Aphi ( p, p 1) = a 1./ dphi ;

100 Aphi ( 1, p ) = a 1./ dphi ; 101 Aphi ( p, 1 ) = a 1./ dphi ; 102 % 103 Idn = eye ( n, n ) ; 104 Idm = eye (m,m) ; 105 Idp = eye ( p, p ) ; 106 % 107 AAA = kron ( dphi Idp, kron ( dth diag ( s i n t h ), Ar ) )... 108 + kron ( dphi Idp, kron ( Ath, drho Idn ) )... 109 + kron ( kron ( Aphi, diag ( s i n t h i n v ) ), drho dth Idn ) ; 110 % 111 for i =1:nmp 112 Ualt ( i ) = U0 ; 113 end 114 Umax = U0 ; 115 nt = 0 ; 116 % r e c h t e S e i t e ( Beruecksichtigung des Q u e l lglieds ) 117 R = zeros (nmp, 1 ) ; 118 for i =1: n 119 for j =1:m 120 for k =1: p 121 ind = i + ( j 1) n + ( k 1) n m; 122 if ( i < n ) R( i ) = 0 ; end 123 if ( i == n ) 124 %%% h i e r muss die j e w e i l i g e RB an der Kugeloberflaeche eingebaut werden, 125 %%% d. h. die Loesungs unabhaengige r e c h t e S e i t e, die bei der Eliminierung von U {N+ 1... } 126 %%% aus RB und Laplacian D i s k r e t i s i e r u n g am Punkt x {N... } e n t s t e h t 127 R( ind ) = a dphi dth s i n t h ( j ) 2 rhop ( n+1) ˆ2/ drho ( 2 6 3. 0 + s i n t h ( j ) 45) ;... 128 end 129 end 130 end 131 % 132 % Loesung 133 U = AAA\R ; 134 % 135 % 136 U3 = reshape (U, n,m, p ) ; 137 % p l o t 138 mesh (U3 ( 1 : n, 1 :m, 1 ) ) 139 title ( Temperatur Feld \ phi = const. ) 140 zlabel ( T(\ rho, \ t h e t a ) ) 141 xlabel ( r ) 142 ylabel ( \ t h e t a ) 143 end 144 % P l o t The full 3D scheme is validated with the program 1 % hot potato problem 3D 2 % 3 n = 2 0 ; 4 m = 4 ; 5 p = 6 ; 6 R0 = 0. ; 7 R1 = 1. 0 / 2 0. ; 8 drho = ( R1 R0 ) /n ; 9 dth = pi/m; 10 dphi = 2 pi/p ; 11 % 12 % Zentralpunkte der F i n i t e n Zellen 13 rho = linspace ( R0+drho /2,R1 drho /2,n ) ; 14 th = linspace ( dth /2,pi dth /2,m) ; 15 s i n t h = sin ( th ) ; 16 % Randpunkte der F i n i t e n Zellen 17 rhop = linspace ( R0, R1, n+1) ; 18 thp = linspace ( 0, pi,m+1) ; 19 sinthp = sin ( thp ) ; 20 for i =1:m Listing 2: source code

21 s i n t h i n v ( i ) = 1/ s i n t h ( i ) ; 22 s i n t h i n v 2 ( i ) = 1/ s i n t h ( i ) ˆ 2 ; 23 end 24 for i =1:n 25 rho2 ( i ) = rho ( i ) ˆ 2 ; 26 rho2inv ( i ) = 1./ rho ( i ) ˆ 2 ; 27 end 28 for i =1:m 29 t h s i n t h ( i ) = th ( i ) s i n t h ( i ) ; 30 end 31 % Matrixaufbau Ar, Ath, Aphi 32 Ar = zeros ( n, n ) ; 33 Ath = zeros (m,m) ; 34 Aphi = zeros ( p, p ) ; 35 % 36 ntend = 9 0 0 ; 37 tau = 1. 0 / 1 0. ; 38 Ubound = 3 3 3 ; 39 U0 = 3 7 3. ; 40 Uu = 2 9 1. ; 41 a = 5.6/3600 1.0 e 4; 42 lambda = 0. 1 6 ; 43 alpha = 3 0 ; 44 % Skalierung 45 s k a l = 1. 0 ; 46 % 47 nmp = n m p ; 48 % Matrixaufbau Ar 49 Ualt = zeros (nmp, 1 ) ; 50 R = zeros (nmp, 1 ) ; 51 % 52 % Laplacian in Kugelkoordinaten 53 % 54 %U = [ u ( 1, 1, 1 ),..., u ( n, 1, 1 ), 55 % u ( 1, 2, 1 ),..., u ( n, 2, 1 ), 56 % u ( 1, 3, 1 ),..., u ( n, 3, 1 ), 57 % 58 % u ( 1,m, 1 ),..., u ( n,m, 1 ), 59 % u ( 1, 1, 2 ),..., u ( n, 1, 2 ), 60 % u ( 1, 2, 2 ),..., u ( n, 2, 2 ), 61 % u ( 1, 3, 2 ),..., u ( n, 3, 2 ), 62 % 63 % u ( 1,m, 2 ),..., u ( n,m, 2 ), 64 % 65 %..., u ( 1, 1, p ),..., u ( n, 1, p ), 66 %..., u ( 1, 2, p ),..., u ( n, 2, p ), 67 %..., u ( 1, 3, p ),..., u ( n, 3, p ), 68 % 69 %..., u ( 1,m, p ),..., u ( n,m, p ) ] 70 % 71 for i =2: n 1 72 Ar ( i, i ) = a ( rhop ( i +1) ˆ2 + rhop ( i ) ˆ 2 ) /drho rho2inv ( i ) ; 73 Ar ( i, i 1) = a rhop ( i ) ˆ2/ drho rho2inv ( i ) ; 74 Ar ( i, i +1) = a rhop ( i +1) ˆ2/ drho rho2inv ( i ) ; 75 end 76 Ar ( 1, 1 ) = a ( rhop ( 1 ) ˆ2 + rhop ( 2 ) ˆ 2 ) /drho rho2inv ( 1 ) ; 77 Ar ( 1, 2 ) = a rhop ( 2 ) ˆ2/ drho rho2inv ( 1 ) ; 78 Ar ( n, n ) = a ( rhop ( n ) ˆ2 + rhop ( n+1) ˆ 2 ) /drho rho2inv ( n )... 79 a rhop ( n+1) ˆ2/ drho ( lambda/drho ) /(lambda/drho + alpha ) rho2inv ( n ) ; 80 Ar ( n, n 1) = a rhop ( n ) ˆ2/ drho rho2inv ( n ) ; 81 % 82 for i =2:m 1 83 Ath ( i, i ) = a (sin ( thp ( i ) ) + sin ( thp ( i +1) ) ) /dth/sin ( th ( i ) ) ; 84 Ath ( i, i 1) = a sin ( thp ( i ) ) /dth/sin ( th ( i ) ) ; 85 Ath ( i, i +1) = a sin ( thp ( i +1) ) /dth/sin ( th ( i ) ) ; 86 end 87 Ath ( 1, 1 ) = a (sin ( thp ( 1 ) ) + sin ( thp ( 2 ) ) ) /dth/sin ( th ( 1 ) ) ; 88 Ath ( 1, 2 ) = a sin ( thp ( 2 ) ) /dth/sin ( th ( 1 ) ) ; 89 Ath (m,m) = a (sin ( thp (m) ) + sin ( thp (m+1) ) ) /dth/sin ( th (m) ) ; 90 Ath (m,m 1) = a sin ( thp (m) ) /dth/sin ( th (m) ) ; 91 for i =2: p 1

92 Aphi ( i, i ) = a 2./ dphi ; 93 Aphi ( i, i 1) = a 1./ dphi ; 94 Aphi ( i, i +1) = a 1./ dphi ; 95 end 96 Aphi ( 1, 1 ) = a 2./ dphi ; 97 Aphi ( 1, 2 ) = a 1./ dphi ; 98 Aphi ( p, p ) = a 2./ dphi ; 99 Aphi ( p, p 1) = a 1./ dphi ; 100 Aphi ( 1, p ) = a 1./ dphi ; 101 Aphi ( p, 1 ) = a 1./ dphi ; 102 % 103 Idn = eye ( n, n ) ; 104 Idm = eye (m,m) ; 105 Idp = eye ( p, p ) ; 106 % 107 AAA = kron ( Idp, kron ( Idm, Ar ) ) /drho... 108 + kron ( Idp, kron ( Ath, diag ( rho2inv ) Idn ) ) /dth... 109 + kron ( kron ( Aphi, diag ( s i n t h i n v 2 ) ),diag ( rho2inv ) Idn ) /dphi ; 110 % 111 u0 = ones (nmp, 1 ) U0 ; 112 % r e c h t e S e i t e ( Beruecksichtigung des Q u e l lglieds ) 113 R1 = zeros ( n, 1 ) ; 114 for i =1: n 115 if ( i < n ) R1 ( i ) = 0 ; end 116 if ( i == n ) 117 R1 ( n ) =... 118 + a rhop ( n+1) ˆ2 alpha/drho /( lambda/drho + alpha ) Uu/( rho ( n ) ˆ2 drho ) ; end 119 end 120 R = kron ( Idp ones ( p, 1 ),kron ( Idm ones (m, 1 ), R1 ) ) ; 121 % 122 Time min =80; %time in minutes 123 Time=Time min 60; % time in seconds 124 % matlab 125 odefun=@( t, x ) AAA x+r ; % function of r i g h t side 126 [ T,U]= ode23s (@( t, x ) odefun ( t, x ), [ 0, Time ], u0 ) ; %ode23s works f a s t e r f o r s t i f f 127 % 128 for i =1:length ( T ) 129 % f o r i =1:p 130 plot (U( i, 1 : n ) ) 131 end 132 133 % 2) Exercise Use characteristic l 0 length, time t 0 and temperature u c to write down the problem 3) of sheet 4 in a dimensionless form. Solution: With the characteristic values u c, t 0 and l 0 we define the dimensionless temperature, time and radius ū = u, t = t and r = r. u c t 0 l 0 For the heat conduction equation we get (ūu c ) ( tt 0 ) = a 1 ( rl 0 ) 2 For the boundary condition we come to ( rl 0 ) [( rl 0) 2 (ūu c) ( rl 0 ) λ (ūu c) ( rl 0 ) = α(ūu c u ) The initial condition in dimensionless form reads as ū = 373 K u c. ] ū t = at 0 l 2 0 λ ū αl 0 r = ū u. u c 1 ū r 2 [ r2 r r ].

3) Exercise Solve the 2D shallow water problem U t + F (U) x + G(U) y = S(U, B) (1) with the conservative variables U = h hu hv =: q 1 q 2 q 3, the flux function F (U) = hu hu 2 + 1 2 gh2 huv, G(U) = hv huv hv 2 + 1 2 gh2, and the source term S(U, B) = 0 hgb x hgb y h denotes the water height, hu, hv the water amount in the x- and y-direction, u and v are averaged velocities, and B describes the topography of the ground. The body force constant g is set to 1. We consider the spatial domain Ω =]0, 1[ 2 and the time interval [0, 5]. The initial values are { 1 x 1 h(x, y, 0) = 10, y 1 10, 0.5 otherwise and hu = hv = 0 on Ω. On the boundary we use homogeneous Neumann boundary conditions. Consider the cases B = 0 and. B(x, y) = x(1 x)/10. Use a conservative Finite-Volume method (for example Upwind, Lax-Friedrichs or Lax- Wendroff). The numerical Lax-Friedrichs-flux in 2D is for example F num (U, V ) = x 4τ (U V )+ 1 2 [F (U)+F (V )], G num(u, V ) = y 4τ (U V )+ 1 [G(U)+G(V )]. 2 Solution: The FV-method to solve the shallow water problem is implemented in the following program. Listing 3: source code 1 % shallow water 2D e x e r c i s e 6. 3 2 % 3 n = 3 0 ; % Anzahl innerer Gitterpunkte in x Richtung 4 m = 2 5 ; % Anzahl innerer Gitterpunkte in y Richtung 5 dx = 1/(n+1) ; 6 dy = 1/(m+1) ; 7 % 8 a =0; b =1; 9 c =0; d=1; 10 g = 9. 8 1 ; 11 % Zentralpunkte der F i n i t e n Zellen 12 xp = linspace ( a dx, b+dx, n+2) ; 13 x = linspace ( a dx/2, b+dx/2,n+1) ;

14 yp = linspace ( c dy, d+dy,m+2) ; 15 y = linspace ( c dy/2,d+dy/2,m+1) ; 16 % Anfangsbedingungen 17 % U( x, y, 1 ) =: h 18 % U( x, y, 2 ) =: hu 19 % U( x, y, 3 ) =: hv 20 % 21 for i =1: n+1 22 for j =1:m+1 23 U( i, j, 1 ) = 0. 5 ; 24 U( i, j, 2 ) = 0 ; 25 U( i, j, 3 ) = 0 ; 26 if ( x ( i ) < ( b a ) /10 && y ( j ) < ( d c ) /10) U( i, j, 1 ) = 1. 0 ; end 27 end 28 end 29 % 30 % Berechnung in Z e i t r i c h t u n g 31 % 32 tau = 1 / 1 0 0 0 0. ; 33 ntend = 1 0 00; 34 nt = 0 ; 35 while ( nt < ntend ) 36 % 37 % Randbedingungen 38 for k =1:3 39 % 40 for i =2:n 41 U( i, 1, k ) = U( i, 2, k ) ; 42 U( i,m+1,k ) = U( i,m, k ) ; 43 end 44 for j =2:m 45 U( 1, j, k ) = U( 2, j, k ) ; 46 U( n+1, j, k ) = U( n, j, k ) ; 47 end 48 % 49 for i =2:n 50 for j =2:m 51 % Lax F r i e d r i c h s Methode 52 % Un( i, j, k ) = U( i, j, k ) tau/dx ( dx/tau /4 (U( i, j, k ) U( i +1, j, k ) ) + 0. 5 ( F (U, i, j, k, g ) + F (U, i +1, j, k, g ) )... 53 % ( ( dx/tau /4 (U( i 1, j, k ) U( i, j, k ) ) + 0. 5 ( F (U, i 1, j, k, g ) + F (U, i, j, k, g ) ) ) ) )... 54 % tau/dy ( dy/tau /4 (U( i, j, k ) U( i, j +1,k ) ) + 0. 5 (G(U, i, j, k, g ) + G(U, i, j +1,k, g ) )... 55 % ( ( dy/tau /4 (U( i, j 1,k ) U( i, j, k ) ) + 0. 5 (G(U, i, j 1,k, g ) + G(U, i, j, k, g ) ) ) ) )... 56 U( i, j, k ) = 0. 2 5 (U( i +1, j, k ) + U( i 1, j, k ) + U( i, j +1,k ) + U( i, j 1,k ) )... 57 tau 0. 5 ( ( F (U, i +1, j, k, g ) F (U, i 1, j, k, g ) ) /dx... 58 + ( G(U, i, j +1,k, g ) G(U, i, j 1,k, g ) ) /dy )... 59 tau U( i, j, 1 ) g S ( x, y, i, j, k ) ; 60 end 61 end 62 % end k 63 end 64 nt = nt + 1 ; 65 mesh (U( 2 : n, 2 :m, 1 ) ) 66 title ( Wasserhoehe h ( x, y ) ) 67 zlabel ( h ( x, y ) ) 68 xlabel ( x ) 69 ylabel ( y ) 70 end 71 % p l o t 72 mesh (U( 2 : n, 2 :m, 1 ) ) 73 title ( Wasserhoehe h ( x, y ) ) 74 zlabel ( h ( x, y ) ) 75 xlabel ( x ) 76 ylabel ( y ) 77 % P l o t 78 79 function f = F (U, i, j, k, g ) 80 if ( k == 1) f = U( i, j, 2 ) ; end

81 if ( k == 2) f = U( i, j, 2 ) ˆ2/U( i, j, 1 ) + 0.5 g U( i, j, 1 ) ˆ 2 ; end 82 if ( k == 3) f = U( i, j, 2 ) U( i, j, 3 ) /U( i, j, 1 ) ; end 83 % endfunction 84 85 function g = G(U, i, j, k, g ) 86 if ( k == 1) g = U( i, j, 3 ) ; end 87 if ( k == 2) g = U( i, j, 2 ) U( i, j, 3 ) /U( i, j, 1 ) ; end 88 if ( k == 3) g = U( i, j, 3 ) ˆ2/U( i, j, 1 ) + 0.5 g U( i, j, 1 ) ˆ 2 ; end 89 % endfunction 90 91 function s = S ( x, y, i, j, k ) 92 if ( k == 1) s = 0. 0 ; end 93 if ( k == 2) s = 0. 1 0.2 x ( i ) ; end 94 if ( k == 3) s = 0. 0 ; end 95 % endfunction