Web-Books
in the Austria-Forum
Austria-Forum
Web-Books
Informatik
Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition
Page - 304 -
  • User
  • Version
    • full version
    • text only version
  • Language
    • Deutsch - German
    • English

Page - 304 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition

Image of the Page - 304 -

Image of the Page - 304 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition

Text of the Page - 304 -

304 9 SolvingPartialDifferentialEquations temperature has then fallen. We are interested in how the temperature varies down in thegroundbecauseof temperatureoscillationson thesurface. Assuming homogeneous horizontal properties of the ground, at least locally, and no variations of the temperature at the surface at a fixed point of time, we can neglect the horizontal variations of the temperature. Then a one-dimensional diffusion equation governs the heat propagationalong a vertical axis calledx. The surfacecorrespondstox=0andthex axispointdownwardsintotheground.There isnosourcetermintheequation(actually,if rocksinthegroundareradioactive,they emitheatandthatcanbemodeledbyasourceterm,but thiseffect isneglectedhere). Atsomedepthx=Lweassumethat theheatchangesinxvanish,so∂u/∂x=0 is an appropriate boundary condition at x = L. We assume a simple sinusoidal temperaturevariationat the surface: u(0,t)=T0+Ta sin ( 2π P t ) , whereP is the period, taken here as 24h (24 ·60 ·60s). Theβ coefficient may be set to 10−6 m2/s. Time is then measured in seconds. Set appropriate values forT0 andTa. a) Showthat thepresentproblemhasananalytical solutionof the form u(x,t)=A+Be−rx sin(ωt−rx), forappropriatevaluesofA,B, r, andω. b) Solve this heat propagation problem numerically for some days and animate the temperature. You may use the Forward Euler method in time. Plot both the numerical and analytical solution. As initial condition for the numerical solution, use the exact solution during program development, and when the curves coincide in the animation for all times, your implementation works, and you can then switch to a constant initial condition: u(x,0) = T0. For this latter initial condition, how many periods of oscillations are necessary before there is a good(visual)matchbetween thenumericalandexact solution(despite differencesat t=0)? Filename:ground_temp.py. Exercise9.3:CompareImplicit Methods An equally stable, but more accurate method than the Backward Euler scheme, is the so-called 2-step backward scheme, which for an ODE u′ = f(u,t) can be expressedby 3un+1−4un+un−1 2Δt =f(un+1,tn+1). TheOdespy packageoffers this methodasodespy.Backward2Step.Thepurpose of this exercise is tocompare threemethodsandanimate the threesolutions: 1. TheBackwardEulermethodwithΔt=0.001 2. Thebackward2-stepmethodwithΔt=0.001
back to the  book Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition
Title
Programming for Computations – Python
Subtitle
A Gentle Introduction to Numerical Simulations with Python 3.6
Volume
Second Edition
Authors
Svein Linge
Hans Petter Langtangen
Publisher
Springer Open
Date
2020
Language
English
License
CC BY 4.0
ISBN
978-3-319-32428-9
Size
17.8 x 25.4 cm
Pages
356
Keywords
Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
Category
Informatik
Web-Books
Library
Privacy
Imprint
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python