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
|
{{ objname }}
{{ underline }}
.. plot::
:include-source: False
import openturns as ot
from matplotlib import pyplot as plt
import openturns.viewer as otv
def flow(X):
Y0 = X[0]
Y1 = X[1]
t = X[2]
dY0 = Y0 * (2.0 - Y1)
dY1 = Y1 * (Y0 - 1.0)
return [dY0, dY1]
f = ot.PythonFunction(3, 2, flow)
phi = ot.ParametricFunction(f, [2], [0.0])
solver = ot.{{ objname }}(phi)
initialState = [2.0, 2.0]
nt = 47
dt = 0.1
timeGrid = ot.RegularGrid(0.0, dt, nt)
result = solver.solve(initialState, timeGrid)
xMin = result.getMin()
xMax = result.getMax()
delta = 0.2 * (xMax - xMin)
mesh = ot.IntervalMesher([12]*2).build(ot.Interval(xMin - delta, xMax + delta))
field = ot.Field(mesh, phi(mesh.getVertices()))
ot.ResourceMap.SetAsScalar("Field-ArrowScaling", 0.1)
graph = field.draw()
cloud = ot.Cloud(mesh.getVertices())
cloud.setColor("black")
graph.add(cloud)
curve = ot.Curve(result)
curve.setColor("red")
curve.setLineWidth(2)
graph.add(curve)
graph.setTitle("Lotka-Volterra ODE system")
fig = plt.figure()
ax = fig.add_subplot(111)
otv.View(graph, figure=fig)
plt.xlabel(r'$y_0$')
plt.ylabel(r'$y_1$')
plt.grid()
.. currentmodule:: {{ module }}
.. autoclass:: {{ objname }}
{% block methods %}
.. automethod:: __init__
{% endblock %}
.. minigallery:: {{module}}.{{objname}}
:add-heading: Examples using the class
|