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

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

Image of the Page - 148 -

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

Text of the Page - 148 -

148 4 SolvingOrdinaryDifferentialEquations videdthesignumfunctionsign.x/ isdefinedtobezeroforxD0 (numpy.signhas thisproperty). Tocheck that thesigns in thedefinitionoff are right, recall that the actual physical force is f and this is positive (i.e.,f <0)when itworksagainst thebodymovingwithvelocityu0 <0. Thenonlinearspring force is takenas s.u/D k˛ 1 tanh.˛u/; which is approximately ku for smallu, but stabilizes at˙k=˛ for large˙˛u. Here is aplotwithkD1000andu2 Œ 0:1;0:1 for three˛values: If there is noexternal excitation force actingon thebody,wehave the equation ofmotion mu00C mgsign.u0/Ck˛ 1 tanh.˛u/D0: Let us simulate a situationwhere a bodyofmass 1 kg slides on a surfacewith D 0:4, while attached to a springwith stiffness k D 1000kg=s2. The initial displacement of the body is 10 cm, and the˛ parameter in s.u/ is set to 60 1/m. Using theEulerCromer function from theosc_EC_generalcode, we canwrite a functionsliding_frictionfor solving thisproblem: def sliding_friction(): from numpy import tanh, sign f = lambda v: mu*m*g*sign(v) alpha = 60.0 s = lambda u: k/alpha*tanh(alpha*u) F = lambda t: 0 g = 9.81 mu = 0.4 m = 1 k = 1000
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