|
1
|
|
|
""" |
|
2
|
|
|
Classes for representing boundary value problems. |
|
3
|
|
|
|
|
4
|
|
|
@author : David R. Pugh |
|
5
|
|
|
|
|
6
|
|
|
""" |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
class TwoPointBVPLike(object): |
|
10
|
|
|
|
|
11
|
|
|
@property |
|
12
|
|
|
def bcs_lower(self): |
|
13
|
|
|
""" |
|
14
|
|
|
Function that calculates the difference between the lower boundary |
|
15
|
|
|
conditions and the current values of the model dependent variables. |
|
16
|
|
|
|
|
17
|
|
|
:getter: Return the current boundary condition. |
|
18
|
|
|
:type: function |
|
19
|
|
|
|
|
20
|
|
|
""" |
|
21
|
|
|
return self._bcs_lower |
|
22
|
|
|
|
|
23
|
|
|
@property |
|
24
|
|
|
def bcs_upper(self): |
|
25
|
|
|
""" |
|
26
|
|
|
Function that calculates the difference between the upper boundary |
|
27
|
|
|
conditions and the current values of the model dependent variables. |
|
28
|
|
|
|
|
29
|
|
|
:getter: Return the current boundary condition. |
|
30
|
|
|
:type: function |
|
31
|
|
|
|
|
32
|
|
|
""" |
|
33
|
|
|
return self._bcs_upper |
|
34
|
|
|
|
|
35
|
|
|
@property |
|
36
|
|
|
def number_bcs_lower(self): |
|
37
|
|
|
""" |
|
38
|
|
|
The number of lower boundary conditions (BCS). |
|
39
|
|
|
|
|
40
|
|
|
:getter: Return the number of lower BCS. |
|
41
|
|
|
:type: int |
|
42
|
|
|
|
|
43
|
|
|
""" |
|
44
|
|
|
return self._number_bcs_lower |
|
45
|
|
|
|
|
46
|
|
|
@property |
|
47
|
|
|
def number_odes(self): |
|
48
|
|
|
""" |
|
49
|
|
|
The number of Ordinary Differential Equations (ODEs) in the system. |
|
50
|
|
|
|
|
51
|
|
|
:getter: Return the number of ODEs. |
|
52
|
|
|
:type: int |
|
53
|
|
|
|
|
54
|
|
|
""" |
|
55
|
|
|
return self._number_odes |
|
56
|
|
|
|
|
57
|
|
|
@property |
|
58
|
|
|
def params(self): |
|
59
|
|
|
""" |
|
60
|
|
|
A dictionary of parameters. |
|
61
|
|
|
|
|
62
|
|
|
:getter: Return the current parameters. |
|
63
|
|
|
:type: function |
|
64
|
|
|
|
|
65
|
|
|
""" |
|
66
|
|
|
return self._params |
|
67
|
|
|
|
|
68
|
|
|
@property |
|
69
|
|
|
def rhs(self): |
|
70
|
|
|
""" |
|
71
|
|
|
Function which calculates the value of the right-hand side of a |
|
72
|
|
|
system of Ordinary Differential Equations (ODEs). |
|
73
|
|
|
|
|
74
|
|
|
:getter: Return the current rhs. |
|
75
|
|
|
:type: function |
|
76
|
|
|
|
|
77
|
|
|
""" |
|
78
|
|
|
return self._rhs |
|
79
|
|
|
|
|
80
|
|
|
|
|
81
|
|
|
class TwoPointBVP(TwoPointBVPLike): |
|
82
|
|
|
r""" |
|
83
|
|
|
Class for representing Two-Point Boundary Value Problems (BVP). |
|
84
|
|
|
|
|
85
|
|
|
Attributes |
|
86
|
|
|
---------- |
|
87
|
|
|
bcs_lower : function |
|
88
|
|
|
Function that calculates the difference between the lower boundary |
|
89
|
|
|
conditions and the current values of the model dependent variables. |
|
90
|
|
|
bcs_upper : function |
|
91
|
|
|
Function that calculates the difference between the upper boundary |
|
92
|
|
|
conditions and the current values of the model dependent variables. |
|
93
|
|
|
number_bcs_lower : int |
|
94
|
|
|
The number of lower boundary conditions (BCS). |
|
95
|
|
|
number_odes : int |
|
96
|
|
|
The number of Ordinary Differential Equations (ODEs) in the system. |
|
97
|
|
|
params : dict(str: float) |
|
98
|
|
|
A dictionary of parameters. |
|
99
|
|
|
rhs : function |
|
100
|
|
|
Function which calculates the value of the right-hand side of a |
|
101
|
|
|
system of Ordinary Differential Equations (ODEs). |
|
102
|
|
|
|
|
103
|
|
|
""" |
|
104
|
|
|
|
|
105
|
|
|
def __init__(self, bcs_lower, bcs_upper, number_bcs_lower, number_odes, |
|
106
|
|
|
params, rhs): |
|
107
|
|
|
self._bcs_lower = bcs_lower |
|
108
|
|
|
self._bcs_upper = bcs_upper |
|
109
|
|
|
self._number_bcs_lower = number_bcs_lower |
|
110
|
|
|
self._number_odes = number_odes |
|
111
|
|
|
self._params = dict(params) # shallow copy! |
|
112
|
|
|
self._rhs = rhs |
|
113
|
|
|
|