Web-Books
im Austria-Forum
Austria-Forum
Web-Books
Informatik
Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Seite - 205 -
  • Benutzer
  • Version
    • Vollversion
    • Textversion
  • Sprache
    • Deutsch
    • English - Englisch

Seite - 205 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition

Bild der Seite - 205 -

Bild der Seite - 205 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition

Text der Seite - 205 -

8.1 FillingaWaterTank:TwoCases 205 8.1 FillingaWaterTank:TwoCases If “ordinarydifferential equation” is notamongyour favoriteexpressions, then this section is foryou. Consider a 25 L tank that will be filled with water in two different ways. In the firstcase, thewatervolumethatenters the tankper time (rateofvolumeincrease) is piecewiseconstant,while in the secondcase, it is continuously increasing. Foreachof these twocases,weareaskedtodevelopacodethatcanpredict (i.e., compute)how the total water volumeV in the tank will developwith time t overa period of 3s. Our calculations must be based on the information given: the initial volume of water (1L in both cases), and the volume of water entering the tank per time. 8.1.1 Case1:PiecewiseConstantRate In this simplercase, there is initially1Lofwater in the tank, i.e., V(0)=1L, while the ratesofvolume increasearegivenas: r=1Ls−1, 0s<t<1s, r=3Ls−1, 1s≤ t <2s, r=7Ls−1, 2s≤ t≤3s. Before turning to the programming,we shouldworkout theexact solutionbyhand for thisproblem,since that is rather straight forward.Suchasolutionwill of course be useful for verifying our implementation. In fact, comparing program output to thesehandcalculationsshouldsuffice for thisparticularproblem. Exact Solution by Hand Our reasoning goes like this: For each of the given sub- intervals (on the time axis), the total volumeV of water in the tank will increase linearly. Thus, if we computeV after 1, 2 and 3s, we will have what we need. We get V(0)=1L, V(1)=1L+(1s)(1Ls−1)=2L, V(2)=2L+(1s)(3Ls−1)=5L, V(3)=5L+(1s)(7Ls−1)=12L. We also have what is required for plotting the exact solution, since we can just tell Pythontoplot thecomputedV valuesagainst t for t=0,1,2,3,and letPythonfill
zurück zum  Buch Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Titel
Programming for Computations – Python
Untertitel
A Gentle Introduction to Numerical Simulations with Python 3.6
Band
Second Edition
Autoren
Svein Linge
Hans Petter Langtangen
Verlag
Springer Open
Datum
2020
Sprache
englisch
Lizenz
CC BY 4.0
ISBN
978-3-319-32428-9
Abmessungen
17.8 x 25.4 cm
Seiten
356
Schlagwörter
Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
Kategorie
Informatik
Web-Books
Bibliothek
Datenschutz
Impressum
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python