NEDAS.models.qg.python.numerics module
Numerical routines: tridiagonal solvers, Robert-filtered leapfrog timestepper, random forcing, and ring-integral diagnostics.
Translates Fortran numerics_lib.f90.
- NEDAS.models.qg.python.numerics.tridiag_vec(f_in, sub, diag, sup)[source]
Solve a tridiagonal system for many RHS vectors simultaneously.
- Solves A * x = f where A has:
sub : sub-diagonal, shape (nz-1,) or (nmask, nz-1) diag : diagonal, shape (nz,) or (nmask, nz) sup : super-diag, shape (nz-1,) or (nmask, nz-1) f_in : RHS, shape (nmask, nz)
Returns x of shape (nmask, nz).
When sub/diag/sup are 1-D (shared across wavenumbers), they are broadcast. When diag is 2-D the diagonal differs per wavenumber (PV inversion case).
Follows the Thomas algorithm from Fortran tridiag in numerics_lib.f90.
- NEDAS.models.qg.python.numerics.tridiag_cyc_vec(f_in, sub, diag, sup, corner_lo, corner_hi)[source]
Cyclic tridiagonal solver (periodic vertical BC).
corner_lo : sub-diagonal wrap value op(1, -1) -> mat(1, nz) corner_hi : super-diagonal wrap value op(nz, 1) -> mat(nz, 1) Shape conventions same as tridiag_vec.
Follows Fortran tridiag_cyc in numerics_lib.f90 (Sherman-Morrison).
- NEDAS.models.qg.python.numerics.march(f_now, f_o, rhs, dt, rob, calls)[source]
Advance prognostic field one step using leapfrog / Robert filter.
calls=0 : Euler half-step (initialisation) calls=1 : first leapfrog calls>=2 : leapfrog + Robert filter on f_o
Returns (f_new, f_o_new, calls_new).
Arrays can have any shape; operates element-wise. Translates Fortran March2/3 from numerics_lib.f90.
- NEDAS.models.qg.python.numerics.ran_reset(idum)[source]
Seed the portable RNG (negative idum seeds a fresh sequence).