Differential Equation Solving System: Difference between revisions

From GM-RKB
Jump to navigation Jump to search
No edit summary
No edit summary
Line 6: Line 6:
Python Implementation in [[Euler Solver]]
Python Implementation in [[Euler Solver]]


import math
import math\\
import ma t p lo t lib . p y p lo t a s p l t
import ma t p lo t lib . p y p lo t a s p l t
# I n i t i a l c o n d i t i o n s
# I n i t i a l c o n d i t i o n s

Revision as of 13:35, 14 January 2016

A Differential Equation Solving System is an equation solving system that can apply a differential equation solving algorithm to solve a differential equation solving task.

Python Implementation in Euler Solver

import math\\ import ma t p lo t lib . p y p lo t a s p l t

  1. I n i t i a l c o n d i t i o n s

y0 = 2 .0

  1. Time s t e p and f i n a l t i me

dt = 1 .0 # days t f = 3 6 4 .0 # days

  1. Empty l i s t s t o h o ld t h e t i me and s o l u t i o n

t t = [ ] yy = [ ]

  1. Append i n i t i a l v a l u e s

t t . append ( 0 . 0 ) yy . append ( y0 )

  1. Paramet ers o f our e q u a t i o n

a = 0 .0 1 omega = 2 .0 *math . p i / 3 6 5 .0

  1. I t e r a t i o n

while t t [ − 1] < = t f : r = a * yy [ − 1] * (1+math . s i n ( omega *t t [ − 1 ]) ) yy . append ( yy[ −1]+ r *dt ) t t . append ( t t [ −1]+ dt ) p l t . f i g u r e ( 1 ) p l t . p lo t ( t t , yy , '. ') p l t . x l a b e l ( 'Time [ days ] ') p l t . y l a b e l ( 'Rats [ r a t s ] ') p l t . t i t l e ( 'Euler S o lu t io n ') p l t . show ( )