Definition of a Hamiltonian Lorenz model - cchandre/HamLorenz GitHub Wiki

Custom Hamiltonian Lorenz Models

A custom Hamiltonian Lorenz model can be defined by specifying either f, phi, or both (if they are mathematically compatible, i.e., $f(x)\phi\prime(x)=1$) when creating an instance of the class. For example:

hl = HamLorenz(100, phi=sp.sinh(x))

If provided, f and phi must be SymPy expressions. The model requires computing the inverse of the function $\phi$. This is done in two steps:

  1. Symbolic inversion:
    SymPy first attempts to compute the inverse using sympy.solve.

    • If multiple branches are found, the user is prompted to choose which one to use.
  2. Numerical fallback:
    If symbolic inversion fails, the inverse is computed numerically using SciPy’s root_scalar with Newton’s method.

    • Note: This numerical method is significantly slower than symbolic inversion.

Notes

  • The default model uses a cubic nonlinearity: $\phi(x) = x + \frac{x^3}{3}$.
  • If only f is specified, the code symbolically computes the corresponding phi using SymPy before converting it to a NumPy function.
  • Likewise, if only phi is specified, f is derived symbolically.
  • If both are provided, the code checks their consistency, ensuring that $f(x)\phi\prime(x) = 1$.

Correlation in the Model

Correlation is introduced through a correlation length $K$ and a coefficient vector ($\xi_1$,..., $\xi_{K}$).
By default:

  • $K = 1$
  • $\xi = 1$

Notes

  • If xi has fewer than K elements, it is automatically expanded to length K by repeating $\xi_1$. A UserWarning is issued.
  • If xi has more than K elements, it is truncated to the first K entries. A UserWarning is also issued in this case.