pyoculus 0.1.1
|
Abstract class that used to drive calculation. More...
Public Member Functions | |
__init__ (self) | |
f (self, t, y, *args) | |
Returns ODE RHS. | |
f_tangent (self, t, y, *args) | |
Returns ODE RHS, with tangent. | |
convert_coords (self, coord1) | |
Converts coordinates (for example \(s,\theta,\zeta\) to \(R,Z,\varphi\)) | |
Public Attributes | |
int | problem_size = 2 |
str | poincare_plot_type = "yx" |
str | poincare_plot_xlabel = "y" |
str | poincare_plot_ylabel = "x" |
Abstract class that used to drive calculation.
This is an abstract class, should never be used as an instance.
All problems should be a derived type of BaseProblem. They should contain the ODEs to solve, as specified by the Hamiltonian system of that problem.
If the Hamiltonian system is 1.5 dimensional, the Hamiltonian takes the form \(H=H(p,q,t)\). The Hamilton's equations are given by
\[ \frac{dq}{dt} = \frac{\partial H}{\partial p}, \quad \frac{dp}{dt} = -\frac{\partial H}{\partial q}. \quad\]
If the Hamiltonian system is two-dimensional, the Hamiltonian takes the form \(H=H(p_1,q_1,p_2,q_2)\). The Hamilton's equations are given by
\[ \frac{dq_i}{dt} = \frac{\partial H}{\partial p_i}, \quad \frac{dp_i}{dt} = -\frac{\partial H}{\partial q_i}, \quad\]
in which \(i=1,2\).
The Hamiltonian \(H\) itself is a constant of motion, i.e. \(dH/dt=0\).
Given \( p_1, q_1, q_2\), we can invert \(H=H(p_1,q_1,p_2,q_2)=\mbox{const} \) to get \(p_2 = p_2(p_1, q_1, q_2)\).
If further \(q_2 \) is monotonically increasing with \(t\), one can replace \(t\) by \(q_2\) and get
\[ \frac{dq_1}{dq_2} = \left.\frac{\frac{\partial H}{\partial p_1}}{\frac{\partial H}{\partial p_2}} \right|_{p_2(p_1, q_1, q_2)}, \]
\[ \frac{dp_1}{dq_2} = \left.\frac{-\frac{\partial H}{\partial q_1} }{\frac{\partial H}{\partial p_2}}\right|_{p_2(p_1, q_1, q_2)}, \]
after computing which the value of \(p_2\) is substituted into these equations.
The Hamilton's equations, after converted can be combined and written as
\[ \frac{d y_1}{dt} = F_1(t, y_1, y_2),\]
\[ \frac{d y_2}{dt} = F_2(t, y_1, y_2).\]
The tangent of the above ODEs are given by
\[ \frac{d}{dt} \begin{bmatrix}\Delta y_1\\ \Delta y_2 \end{bmatrix} = \begin{bmatrix} \partial_{y_1}F_1 & \partial_{y_2}F_1 \\ \partial_{y_1}F_2 & \partial_{y_2}F_2 \end{bmatrix} \cdot \begin{bmatrix}\Delta y_1\\ \Delta y_2 \end{bmatrix}, \]
where the partial derivatives are evaluated at \(y_1(t), y_2(t)\) as the solution of the original ODEs.
All problem classes should inherit the BaseProblem class.
class SomeProblem(BaseProblem): def __init__(self, params): """some codes to initialize the problem""" def f(self, t, y, *args): """some codes compute the RHS (F) of the ODEs given t and y""" def f_tangent(self, t, y, *args): """some codes compute the ODEs and the tangent the ODEs given t and y, y contains two tangent vectors""" def convert_coords(self, coord1): """some codes compute the coordinate transformation"""
The member function f
should be implemented in any case. The tangent
and convert_coords
functions are optional for some solvers.
pyoculus.problems.base_problem.BaseProblem.__init__ | ( | self | ) |
Reimplemented in pyoculus.problems.cartesian_bfield.CartesianBfield, pyoculus.problems.cylindrical_bfield.CylindricalBfield, pyoculus.problems.cylindrical_problem.CylindricalProblem, pyoculus.problems.m3dc1_bfield.M3DC1Bfield, pyoculus.problems.qfm_bfield.QFMBfield, pyoculus.problems.simsgeo_biot_savart.SimsgeoBiotSavart, pyoculus.problems.spec_bfield.SPECBfield, pyoculus.problems.toroidal_bfield.ToroidalBfield, pyoculus.problems.toroidal_problem.ToroidalProblem, and pyoculus.problems.two_waves.TwoWaves.
pyoculus.problems.base_problem.BaseProblem.convert_coords | ( | self, | |
coord1 ) |
Converts coordinates (for example \(s,\theta,\zeta\) to \(R,Z,\varphi\))
coords1 | the coordinates to convert |
Reimplemented in pyoculus.problems.qfm_bfield.QFMBfield, pyoculus.problems.spec_bfield.SPECBfield, pyoculus.problems.toroidal_problem.ToroidalProblem, and pyoculus.problems.two_waves.TwoWaves.
pyoculus.problems.base_problem.BaseProblem.f | ( | self, | |
t, | |||
y, | |||
* | args ) |
Returns ODE RHS.
t | time in ODE |
y | variables in ODE |
*args | parameter for the ODE |
Reimplemented in pyoculus.problems.cylindrical_problem.CylindricalProblem, pyoculus.problems.toroidal_bfield.ToroidalBfield, and pyoculus.problems.toroidal_problem.ToroidalProblem.
pyoculus.problems.base_problem.BaseProblem.f_tangent | ( | self, | |
t, | |||
y, | |||
* | args ) |
Returns ODE RHS, with tangent.
t | time in ODE |
y | \(\bf y\) variables in ODE and \(\Delta \mathbf{y}_1\), \(\Delta \mathbf{y}_2\) |
*args | parameter for the ODE |
Reimplemented in pyoculus.problems.cylindrical_problem.CylindricalProblem, pyoculus.problems.toroidal_bfield.ToroidalBfield, and pyoculus.problems.toroidal_problem.ToroidalProblem.
str pyoculus.problems.base_problem.BaseProblem.poincare_plot_type = "yx" |
str pyoculus.problems.base_problem.BaseProblem.poincare_plot_xlabel = "y" |
str pyoculus.problems.base_problem.BaseProblem.poincare_plot_ylabel = "x" |
int pyoculus.problems.base_problem.BaseProblem.problem_size = 2 |