Seite - 148 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Bild der Seite - 148 -
Text der Seite - 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
Programming for Computations – Python
A Gentle Introduction to Numerical Simulations with Python
- Titel
- Programming for Computations – Python
- Untertitel
- A Gentle Introduction to Numerical Simulations with Python
- Autoren
- Svein Linge
- Hans Petter Langtangen
- Verlag
- Springer Open
- Datum
- 2016
- Sprache
- englisch
- Lizenz
- CC BY-NC 4.0
- ISBN
- 978-3-319-32428-9
- Abmessungen
- 17.8 x 25.4 cm
- Seiten
- 248
- Schlagwörter
- Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
- Kategorie
- Informatik