-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathode1ivp.py
More file actions
executable file
·73 lines (60 loc) · 1.98 KB
/
ode1ivp.py
File metadata and controls
executable file
·73 lines (60 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
"""
ODE1IVP - Base class for 1st-order ordinary differential equation initial-
value problems
This module provides the base functionality for all 1st-order ordinary
differential equation initial-value problem objects used in the nnode software.
Example:
Create an empty ODE1IVP object.
ode1ivp = ODE1IVP()
Create an ODE1IVP object from a Python module.
ode1ivp = ODE1IVP(modname)
Attributes:
name - String containing name of equation definition module
G - Function for equation
ic - Scalar for initial condition Y(0)
dG_dY - Function for derivative of Gf wrt Y
dG_ddYdx - Function for derivative of Gf wrt dY/dx
Ya - (Optional) function for analytical solution Ya(x)
dYa_dx - (Optional) function for analytical derivative dY_x(x)
Methods:
Todo:
"""
from importlib import import_module
from ode1 import ODE1
class ODE1IVP(ODE1):
"""Base class for all 1st-order ordinary differential equation initial-
value problem objects"""
def __init__(self, diffeqmod=None):
"""
Constructor
Parameters:
diffeqmod - The name of the Python module containing the problem definition.
"""
super().__init__()
self.name = None
self.G = None
self.ic = None
self.dG_dY = None
self.dG_ddYdx = None
self.Ya = None
self.dYa_dx = None
if diffeqmod:
self.name = diffeqmod
odemod = import_module(diffeqmod)
assert odemod.G
assert odemod.ic is not None
assert odemod.dG_dY
assert odemod.dG_ddYdx
self.G = odemod.G
self.ic = odemod.ic
self.dG_dY = odemod.dG_dY
self.dG_ddYdx = odemod.dG_ddYdx
if odemod.Ya:
self.Ya = odemod.Ya
if odemod.dYa_dx:
self.dYa_dx = odemod.dYa_dx
if __name__ == '__main__':
ode1ivp = ODE1IVP()
print(ode1ivp)
ode1ivp = ODE1IVP('lagaris_01')
print(ode1ivp)