• Keine Ergebnisse gefunden

Courant and all that

N/A
N/A
Protected

Academic year: 2021

Aktie "Courant and all that"

Copied!
30
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Courant and all that

¾ Consistency, Convergence

¾ Stability

¾ Numerical Dispersion

¾ Computational grids and numerical anisotropy

The goal of this lecture is to understand how to find suitable parameters (i.e., grid spacing dx and time increment dt) for a numerical simulation and knowing what can go wrong.

≈ 1

≤ ε dx

c dt

(2)

A simple example: Newtonian Cooling

Numerical solution to first order ordinary differential equation

) , ( T t dt f

dT =

We can not simply integrate this equation. We have to solve it numerically! First we need to discretise time:

jdt t

t

j

=

0

+

and for Temperature T

) (

j

j

T t

T =

(3)

A finite-difference approximation

Let us try a forward difference:

)

1

(

dt dt O

T T

dt

dT

j j

t

t j

− +

=

+

=

... which leads to the following explicit scheme :

) , (

1 j

dt

j j

j

T f T t

T

+

≈ +

This allows us to calculate the Temperature T as a function of time and the forcing inhomogeneity f(T,t). Note that there will be an error O(dt) which will accumulate over time.

(4)

Coffee?

Let’s try to apply this to the Newtonian cooling problem:

TAir

TCappucino

How does the temperature of the liquid evolve as a function of time and temperature difference to the air?

(5)

Newtonian Cooling

The rate of cooling (dT/dt) will depend on the temperature difference (Tcap-Tair) and some constant (thermal conductivity).

This is called Newtonian Cooling.

With T= Tcap-Tair being the temperature difference and τ the

time scale of cooling then f(T,t)=-T/ τ and the differential equation describing the system is

τ

/ dt T

dT = −

with initial condition T=Ti at t=0 and τ>0.

(6)

Analytical solution

This equation has a simple analytical solution:

How good is our finite-difference appoximation?

For what choices of dt will we obtain a stable solution?

) / exp(

)

( t T t τ

T =

i

Our FD approximation is:

) 1

1

τ ( τ

T dt dt T

T

T

j+

=

j

j

=

j

− ) 1

1

( τ

T dt

T

j+

=

j

(7)

FD Algorithm

) 1

1

( τ

T dt

T

j+

=

j

1. Does this equation approximation converge for dt -> 0?

2. Does it behave like the analytical solution?

With the initial condition T=T0 at t=0:

) 1

0

(

1

τ

T dt

T = −

) 1

)(

1 ( )

1

(

0

1

2

τ τ τ

dt T dt

T dt

T = − = − −

leading to : j

dt

j

T

T

0

( 1 )

− τ

=

(8)

Understanding the numerical approximation

j j

T dt

T

0

( 1 )

− τ

=

Let us use dt=tj/j where tj is the total time up to time step j:

j

j

j

T t

T ⎟⎟

⎜⎜ ⎞

⎛ ⎥

⎢ ⎤

⎡ − +

=

0

1 τ

This can be expanded using the binomial theorem

⎥ ⎥

⎢ ⎢

⎡ ⎟⎟ +

⎜⎜ ⎞

⎥ ⎛

⎢ ⎤

⎡ −

⎟⎟ +

⎜⎜ ⎞

⎥ ⎛

⎢ ⎤

⎡ − +

=

...

1 2 1 1

1

2 2

1 0

j j

j t j

T t

T

j j j j

τ

τ

(9)

! )!

(

! r r j

j r

j

= −

⎟⎟ ⎠

⎜⎜ ⎞

... where

we are interested in the case that dt-> 0 which is equivalent to j->∞

j

r

r j

j j

r j j

j = − − − + →

− ( 1 )( 2 )...( 1 )

)!

(

!

as a result

! r j r

j

r

⎟⎟ →

⎜⎜ ⎞

(10)

substituted into the series for Tj we obtain:

⎥ ⎥

⎢ ⎢

⎡ ⎥ +

⎢ ⎤

⎡ −

⎥ +

⎢ ⎤

⎡ − +

→ ...

! 2

! 1 1

2 2

0

τ j τ

t j

j t T j

T

j

which leads to

⎥ ⎥

⎢ ⎢

⎡ +

⎥⎦ ⎤

⎢⎣ ⎡−

⎥⎦ +

⎢⎣ ⎤

⎡−

+

→ ...

! 2 1 1

2

0

τ τ

t T t

T

j

... which is the Taylor expansion for

) /

0

exp( t τ

T

T

j

= −

(11)

So we conclude:

For the Newtonian Cooling problem, the numerical solution converges to the exact solution when the time step dt gets smaller.

How does the numerical solution behave?

) 1

1

( τ

T dt

T

j+

=

j

− )

/

0

exp( t τ

T

T

j

= −

The analytical solution decays monotonically!

What are the conditions so that Tj+1<Tj ?

(12)

Convergence

Convergence means that if we decrease time and/or space increment in our

numerical algorithm we get closer to the true

solution.

(13)

Stability

) 1

1

( τ

T dt

T

j+

=

j

Tj+1<Tj requires

1 1

0 ≤ − <

τ

dt

or

τ

<

dt 0

The numerical solution decays only montonically for a limited range of values for dt! Again we seem to have a conditional stability.

(14)

) 1

1

( τ

T dt

T

j+

=

j

if

τ < dt < 2 τ ( 1 − ) < 0

τ

then

dt

the solution oscillates but converges as |1-dt/τ|<1

if

dt > 2 τ

then

dt / τ > 2

1-dt/τ<-1 and the solution oscillates and diverges ... now let us see how the solution looks like ....

(15)

Matlab solution

% Matlab Program - Newtonian Cooling

% initialise values nt=10;

t0=1.

tau=.7;

dt=1.

% initial condition T=t0;

% time extrapolation for i=1:nt,

T(i+1)=T(i)-dt/tau*T(i);

end

% plotting plot(T)

(16)

Example 1

Blue – numerical Red - analytical

(17)

Example 2

Blue – numerical Red - analytical

(18)

Example 3

Blue – numerical Red - analytical

(19)

Example 4

Blue – numerical Red - analytical

(20)

Stability

Stability of a numerical algorithm means that the numerical solution does not tend to infinite (or zero) while the true solution is finite.

In many case we obtain algoriths with conditional stability. That

means that the solution is stable for values in well-defined intervals.

(21)

Grid anisotropy

In which direction is the solution most accurate and why?

(22)

Grid anisotropy with ac2d.m

FD FD

(23)

… and more … a Green‘s function …

FD

(24)

Grids

Cubed sphere Hexahedral grid

Spectral element implementation

Tetrahedral grid

Discontinuous Galerkin method

(25)

Grid anisotropy

(26)

Grid anisotropy

Grid anisotropy is the directional dependence of the accuracy of your numerical solution if you do not use enough points per

wavelength.

Grid anisotropy depends on the actual grid you are using. Cubic grids display anisotropy, hexagonal grids in 2D do not. In 3D there are no grid with isotropic properties!

Numerical solutions on unstructured grids usually do not have this problem because of averaging effects, but they need more points per wavelength!

(27)

Real problems

36 km 36 km

30 km 30 km

Alluvial Basin Alluvial Basin

VVS S = 300m/s = 300m/s f

fmaxmax = 3Hz = 3Hz

λλmin min = V= VS S/f/fmaxmax = 100m= 100m

Bedrock Bedrock VVSS = 3200m/s = 3200m/s

ffmaxmax = 3Hz = 3Hz λλmin min = V= VS S/f/fmax max = 1066.7m= 1066.7m

(28)

Hexahedral Grid Generation

(29)

Courant …

ε

⎟ ≤

⎜ ⎞

dx v P dt

Largest velocity Smallest grid size Time step

v P

dt ≤ ε dx

(30)

Courant and all that … - Summary

¾ Any numerical solution has to be checked if it converges to the correct solution (as we have seen there are different options when using FD and not all do converge!)

¾ The number of grid points per wavelength is a central concept to all numerical solutions to wave like problems. This desired frequency for a simulation imposes the necessary space

increment.

¾ The Courant criterion, the smallest grid increment and the

largest velocity determine the (global or local) time step of the simulation

Examples on the exercise sheet.

Referenzen

ÄHNLICHE DOKUMENTE

The methods for doing this are the sane as used in Theorem 2, because stability of one step difference - approximation means that the solutions Un(k) depend uniformly continuous (in

Abstract The computations of solutions of the field equations in the Model of Topological Particles, formulated with a scalar SU(2)-field, have shown instabilities leading

First, (P2) does not imply that changes in the mental states of a person are always connected with neurological changes in his brains, but only that these psychological changes are

I n order to compare the integrators, 15 two-point boundary value problems are solved, which arise i n different application areas: mathematics, physics, engineering, space

To match the market stochasticity we introduce the new market-based price probability measure entirely determined by probabilities of random market time-series of the

Return of the exercise sheet: 14.Nov.2019 during the exercise

Our quantitative findings suggest that migrants prefer a remittance to arrive as cash than as groceries when stakes are high ($400), but not when they are low ($200).. This result

En búsqueda del perfeccionamiento del sistema GES para los privados, es posible considerar un estudio realizado por la Superintendencia de Salud con un censo en relación a