irfpy.util.streamline
¶
Tracing a field to make a stream line
Code author: Yoshifumi Futaana
Any vector field,
See also the sample script at streamline_sample
.
- class irfpy.util.streamline.SimpleTracing(initpos, vector_field, dt)[source]¶
Bases:
object
Simple tracing
The differential equations are
For numerical calculation, we use Runge-Kutta 4.
where r denotes (x, y, z). Each coefficients are
If one wants to backward trace, you may instance another object that gives -vector_field in the constructor.
An example is shown.
Assume a vector field as
The vector_field should be a function that returns a vector, i.e.,
>>> vfield = lambda p: np.array((p[0], 0, np.sqrt(p[0]**2+p[2]**2)))
The vector_field should take np.array, returning np.array() object.
>>> tracer = SimpleTracing([1, 0, 1], vfield, 0.001) >>> tracer.step_forward() >>> print(tracer.x, tracer.y, tracer.z, tracer.tlist[-1]) 1.0010005001667084 0.0 1.0014150674450009 0.001