-
Notifications
You must be signed in to change notification settings - Fork 622
/
itotaylor.py
170 lines (136 loc) · 5.07 KB
/
itotaylor.py
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
from . import _sode
from .sode import _Explicit_Simple_Integrator, _Implicit_Simple_Integrator
from ..stochastic import StochasticSolver, SMESolver
__all__ = [
"EulerSODE", "Milstein_SODE", "Taylor1_5_SODE", "Explicit1_5_SODE",
"Implicit_Milstein_SODE", "Implicit_Taylor1_5_SODE"
]
class EulerSODE(_Explicit_Simple_Integrator):
"""
A simple generalization of the Euler method for ordinary
differential equations to stochastic differential equations. Only
solver which could take non-commuting ``sc_ops``.
- Order: 0.5
"""
integrator_options = {
"dt": 0.001,
"tol": 1e-10,
}
stepper = _sode.Euler
N_dw = 1
_stepper_options = ["measurement_noise"]
class Milstein_SODE(_Explicit_Simple_Integrator):
"""
An order 1.0 strong Taylor scheme. Better approximate numerical
solution to stochastic differential equations. See eq. (3.12) of
chapter 10.3 of Peter E. Kloeden and Exkhard Platen,
*Numerical Solution of Stochastic Differential Equations*..
- Order strong 1.0
"""
integrator_options = {
"dt": 0.001,
"tol": 1e-10,
}
stepper = _sode.Milstein
N_dw = 1
_stepper_options = ["measurement_noise"]
class Taylor1_5_SODE(_Explicit_Simple_Integrator):
"""
Order 1.5 strong Taylor scheme. Solver with more terms of the
Ito-Taylor expansion. See eq. (4.6) of chapter 10.4 of Peter E. Kloeden and
Exkhard Platen, *Numerical Solution of Stochastic Differential Equations*.
- Order strong 1.5
"""
integrator_options = {
"dt": 0.001,
"tol": 1e-10,
"derr_dt": 1e-6,
}
stepper = _sode.Taylor15
N_dw = 2
@property
def options(self):
"""
Supported options by Order 1.5 strong Taylor Stochastic Integrators:
dt : float, default: 0.001
Internal time step.
tol : float, default: 1e-10
Relative tolerance.
derr_dt : float, default: 1e-6
Finite time difference used to compute the derrivative of the
hamiltonian and ``sc_ops``.
"""
return self._options
@options.setter
def options(self, new_options):
_Explicit_Simple_Integrator.options.fset(self, new_options)
class Explicit1_5_SODE(_Explicit_Simple_Integrator):
"""
Explicit order 1.5 strong schemes. Reproduce the order 1.5 strong
Taylor scheme using finite difference instead of derivatives.
Slower than ``taylor15`` but usable when derrivatives cannot be
analytically obtained.
See eq. (2.13) of chapter 11.2 of Peter E. Kloeden and Exkhard Platen,
*Numerical Solution of Stochastic Differential Equations.*
- Order: strong 1.5
"""
stepper = _sode.Explicit15
N_dw = 2
class Implicit_Milstein_SODE(_Implicit_Simple_Integrator):
"""
An order 1.0 implicit strong Taylor scheme. Implicit Milstein
scheme for the numerical simulation of stiff stochastic
differential equations. Eq. (2.11) with alpha=0.5 of
chapter 12.2 of Peter E. Kloeden and Exkhard Platen,
*Numerical Solution of Stochastic Differential Equations*.
- Order strong 1.0
"""
stepper = _sode.Milstein_imp
N_dw = 1
class Implicit_Taylor1_5_SODE(_Implicit_Simple_Integrator):
"""
Order 1.5 implicit strong Taylor scheme. Solver with more terms of the
Ito-Taylor expansion. Eq. (2.18) with ``alpha=0.5`` of chapter 12.2 of
Peter E. Kloeden and Exkhard Platen,
*Numerical Solution of Stochastic Differential Equations*.
- Order strong 1.5
"""
integrator_options = {
"dt": 0.001,
"tol": 1e-10,
"solve_method": None,
"solve_options": {},
"deff_dt": 1e-6
}
stepper = _sode.Taylor15_imp
N_dw = 2
@property
def options(self):
"""
Supported options by Implicit Order 1.5 strong Taylor Stochastic
Integrators:
dt : float, default: 0.001
Internal time step.
tol : float, default: 1e-10
Tolerance for the time steps.
solve_method : str, default: None
Method used for solver the ``Ax=b`` of the implicit step.
Accept methods supported by :func:`qutip.core.data.solve`.
When the system is constant, the inverse of the matrix ``A`` can be
used by entering ``inv``.
solve_options : dict, default: {}
Options to pass to the call to :func:`qutip.core.data.solve`.
derr_dt : float, default: 1e-6
Finite time difference used to compute the derrivative of the
hamiltonian and ``sc_ops``.
"""
return self._options
@options.setter
def options(self, new_options):
_Implicit_Simple_Integrator.options.fset(self, new_options)
StochasticSolver.add_integrator(EulerSODE, "euler")
StochasticSolver.add_integrator(Explicit1_5_SODE, "explicit1.5")
SMESolver.add_integrator(Taylor1_5_SODE, "taylor1.5")
SMESolver.add_integrator(Milstein_SODE, "milstein")
SMESolver.add_integrator(Implicit_Milstein_SODE, "milstein_imp")
SMESolver.add_integrator(Implicit_Taylor1_5_SODE, "taylor1.5_imp")