Module vorts.py.integ

Integration routines and time steppers in Python.

In addition to the sub-par handwritten RK and FT schemes, SciPy RK routines (which are written in Python as well) are also available.

Global variables

var MANUAL_STEPPERS

Time steppers (return new positions after stepping forward in time once).

Functions

def FT_step(G, x0, y0, dt: float, *, tend_fn=CPUDispatcher(<function calc_tend>))

Step using 1st-O forward-in-time.

Calculate tendencies / integrate all vortons at once.

def FT_step_1b1(G, x0, y0, dt: float)

Step using 1st-O forward-in-time.

Calculate tendencies / integrate one vorton by one. This doesn't affect the result for FT, but for RK4 it does (since sub-steps are used)…

def RK4_step(G, x0, y0, dt: float, *, tend_fn=CPUDispatcher(<function calc_tend>))

Step using RK4.

Whole system at once – matrix math version.

def RK4_step_1b1(G, x0_all, y0_all, dt: float)

Step using RK4.

One vorton at a time.

Warning

This doesn't work for RK4 since we have sub-steps where the tendencies due to all other vortons need to be up to date or we introduce error.

So don't use this if you want to get a good solution.

def calc_C(G, x, y)

Calculate $C$ at time $l$ (see equation and info in Vortons.C()).

We use deparature from $C_0$ (initial value of $C$) in the adaptive stepping to see if we need to go back and step with smaller $\delta t$.

def calc_lsqd_diff(dx, dy)

Calculate intervortical distance $l^2$, passing in already-computed dx and dy.

def calc_lsqd_xy(x1, y1, x2, y2)

Calculate intervortical distance $l^2$, using positions to compute dx and dy.

def calc_tend(G, x, y)

Calculate tendencies for each vorton (or tracer). Using explicit loops intead of vector(ized) operations.

Note

This function is wrapped with numba.njit.

def calc_tend_one(xi, yi, Gn, xn, yn)

Calculate tendencies for one position (xi, yi) based on others (Gn, xn, yn). Using explicit loops intead of vector(ized) operations.

def calc_tend_vec(G, x, y)

Calculate both $x$- and $y$-tend written in a vectorized way.

def calc_tend_vec_premesh(G, X, Y)

Calculate both $x$- and $y$-tend vectorized, but they must be passed in in meshgrid form.

Note that Numba doesn't support numpy.meshgrid.

Note

This function is wrapped with numba.njit.

def integrate_manual(G, x0, y0, C_0: float, t_eval, stepper, *, adapt_tstep: bool = False, use_tqdm: bool = True, C_err_reltol: float = 1e-09, dt_min: float = 0.0001)

Integration routine for use with my handwritten FT/RK4 steppers.

Optional naive adaptive time-stepping by setting adapt_tstep=True.

Parameters

G, x0, y0 : array_like
Vectors of $\Gamma$ and initial positions ($x$, $y$) for the system of vortons.
C_0 : float
Initial of value of $C$ (see description in Vortons.C()) to compare to if doing adaptive time stepping.
t_eval : array_like
Times to store (not including $t=0$, which has already been stored).
stepper
A time stepping function that returns new positions after one step, e.g., one from the MANUAL_STEPPERS dict.
adapt_tstep : bool
Whether to apply adaptive time-stepping.
use_tqdm : bool, str
If True, or 'console', the console version of tqdm is used. Pass 'notebook' to activate the Jupyter widget version of tqdm.
def integrate_scipy(y0, t_eval, G_col, *, method: str = 'RK45', max_step: float, **options)

Integrate using scipy.integrate.solve_ivp, to which **options are passed, along with t_eval, method, and max_step.

Parameters

y0 : array_like
Vorton state ($x$ and $y$ only) as a single column.
G_col : array_like
Array of $\Gamma$ values as a column vector, e.g., from Vortons.G_col.