Docsity

ODE Solving: A Computational Approach to First Order Ordinary Differential Equations - Pro, Study notes of Physics

Partial preview of the text

Download ODE Solving: A Computational Approach to First Order Ordinary Differential Equations - Pro and more Study notes Physics in PDF only on Docsity!

Basic ODE Solving

Igor Volobouev

Computational Physics (PHYS 5322)

Texas Tech University

Newton’s Laws

Particle model: physics is simple, andworks for a lot of problems! Usually, force is a function of time,coordinate, and/or velocity (but notacceleration): With the computer we can handle muchmore complex

F

than analytically

a m

F

F

i

i

r

r

r

=

=

(^

v

x

t

F

F

r

r

r

r

Numerical Approach

Let say, we want to know

v

( t

). Taylor

series give If

t^

is small then

K

r

r

r

r

  • Δ + Δ + = Δ +

=

=

2

2 2

1 2

) (

)

(^

t

dt

v d

t

dt

v d

v

t

v

t

t

τ

τ

τ

τ

t

m

v

F

v

t

dt

v d

v

t

v

t

Δ + = Δ + ≈ Δ +

=

) , ( ) ( ) ( ) ( r r r r r r τ

τ

τ

τ

τ

Euler’s Algorithm

Euler’s algorithm moves the systemforward in small steps: Self-starting from an initial condition Choice of a good

t^

value is empirical, and

it depends on the target precision and thetypical time scales in the system

t

t

t

t

m

v

t

F

v

v

i

i

i i

i

i

  • +^1 1

(^

r

r

r

r

Second Order ODEs

Newton’s equation for coordinates: “Second order” due to second derivative Example: Needs more initial conditions

) , , ( 2 2 v x t F

dt

x d m

r r

r

r

=

) (^0). (^0) , (^8). 9 , (^0). (^0) (

2 2

−

=

dt

x d

r

Standard Form for ODEs

Write all ODEs in the following form: Trick: generalize coordinates

m

d

y y t

F

t dy

y

dy dt

dx dt

y

x

y

) , , , ( ,

1 0

0

1

1

0

0

1

0

0

K

= =

=

=

(^

y

t

f

t

d

t

y

d

r

r

r

Callables and Functors

F

can be a complicated function. Best way to represent such a function in Python is to createa “callable” object.

Any object which can be called like a function is a“callable”. To make such an object, implement a classwhich includes the special function call(self, …). Callables can perform a lot of work during theirinitialization stage which can later be used to savecomputing time (no need to repeat the initialization atevery step). In C++ similar objects are called

functors

. They

must provide the function operator “()”.

Let’s Look at Some Code

Examples Now

Go to the course web page:

http://highenergy.phys.ttu.edu/~igv/ComputationalPhysics/Lectures/Le

cture2Examples/

Realistic Physics of Baseball: Escalation of the Air Drag Model

Velocity-dependentdrag coefficient Variable surfaceroughness(“knuckleball”) Head/tail wind Magnus force

Magnus Effect

ball

0

v

S

F

M

r

r

r

×

=

ω

Important fortaking into accountthe effects of ballspin Combination of theBernoulli effectand formation ofboundary layers

Let’s Get to Work

Please code up the air drag models andrun the Euler solver on them. Do yourresults look like something you’d expect?Discuss with your neighbor. By next time, please read Appendix A fromGiordano & Nakanishi