Position and Trajectory#
Classes for representing particle positions and trajectories during integration.
Position Tracking#
- class lagrangian.core.Position#
Base class for tracking particle positions during integration.
- __init__()
Default constructor
Note
This constructor may lead to an error in diagnostic because start time is set to zero: if stencil has not been advected then delta_t is equal to minus advection starting time (
-start_time
) which is not correct.
- __init__(self: lagrangian.core.Position, start_time: lagrangian::DateTime, spherical_equatorial: bool = True) None #
Constructor with start_time setting
- Parameters:
start_time – Advection starting time particles
spherical_equatorial – True if the coordinates system is Lon/lat otherwise false
Key Methods
compute()
: Advance position using Runge-Kutta integrationstrain_tensor()
: Calculate the strain tensor at current positionmax_distance()
: Get maximum distance from initial position
Properties
is_completed
: Whether integration is completetime
: Current time of integration
- compute(self: lagrangian.core.Position, rk4: lagrangian.core.RungeKutta, it: Iterator, cell: lagrangian.core.CellProperties) bool #
To move a particle with a velocity field.
- Parameters:
rk (lagrangian.RungeKutta) – Runge-Kutta handler
it (lagrangian.Iterator) – Iterator
cell (lagrangian.CellProperties) – Cell properties of the grid used for the interpolation.
- Returns:
True if the particle could be moved otherwise false
- Return type:
- strain_tensor(self: lagrangian.core.Position) tuple #
- max_distance(self: lagrangian.core.Position) float #
Compute the distance max
- xi(self: lagrangian.core.Position) numpy.typing.NDArray[numpy.float64] #
Returns the x-axis of the point
- yi(self: lagrangian.core.Position) numpy.typing.NDArray[numpy.float64] #
Returns the y-axis of the point
- property is_completed#
Test if the integration is over
- property time#
Returns the time at the end of the integration
Stencil Configurations#
- class lagrangian.core.Stencil#
Enumeration of stencil types for finite difference calculations:
TRIPLET
: 3-point stencilQUINTUPLET
: 5-point stencil
Triplet Position#
- class lagrangian.core.Triplet#
Bases:
lagrangian.Position
3-point stencil for computing Lyapunov exponents using three particles.
The triplet method uses three particles arranged in a specific pattern to compute the finite-time Lyapunov exponents. This is computationally efficient but may be less accurate than the quintuplet method.
Examples
Creating a triplet configuration:
import lagrangian from datetime import datetime triplet = lagrangian.Triplet( x=10.0, # Initial longitude y=45.0, # Initial latitude delta=0.01, # Initial separation start_time=datetime(2010, 1, 1), spherical_equatorial=True )
Quintuplet Position#
- class lagrangian.core.Quintuplet#
5-point stencil for computing Lyapunov exponents using five particles.
The quintuplet method uses five particles (one central particle plus four surrounding particles) to compute finite-time Lyapunov exponents. This provides higher accuracy than the triplet method at the cost of additional computation.
Examples
Creating a quintuplet configuration:
import lagrangian from datetime import datetime quintuplet = lagrangian.Quintuplet( x=10.0, # Initial longitude y=45.0, # Initial latitude delta=0.01, # Initial separation start_time=datetime(2010, 1, 1), spherical_equatorial=True )