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

Page - 173 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Image of the Page - 173 -

Image of the Page - 173 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Text of the Page - 173 -

5.1 FiniteDifferenceMethods 173 Fig.5.3 Snapshots of thedimensionless solutionofa scaledproblem rhs[1:N-1] = (beta/dx**2)*(u[2:N+1] - 2*u[1:N] + u[0:N-1]) + g(x[1:N], t) This rewrite speedsup thecodebyabout a factor of 10. Acomplete code is found in thefilerod_FE_vec.py. 5.1.6 UsingOdespytoSolvetheSystemofODEs LetusnowshowhowtoapplyageneralODEpackagelikeOdespy(seeSect.4.3.6) to solveourdiffusionproblem.As longaswehavedefineda right-handside func- tionrhs this isverystraightforward: import odespy solver = odespy.RKFehlberg(rhs) solver.set_initial_condition(U_0) T = 1.2 N_t = int(round(T/float(dt))) time_points = linspace(0, T, N_t+1) u, t = solver.solve(time_points)
back to the  book Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python
Title
Programming for Computations – Python
Subtitle
A Gentle Introduction to Numerical Simulations with Python
Authors
Svein Linge
Hans Petter Langtangen
Publisher
Springer Open
Date
2016
Language
English
License
CC BY-NC 4.0
ISBN
978-3-319-32428-9
Size
17.8 x 25.4 cm
Pages
248
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