astronomix._fluid_equations._eigen_hydro

astronomix._fluid_equations._eigen_hydro#

Computations of the eigenvalues and eigenvectors for the Euler (hydrodynamics) equations.

Problems for differentiation largely follow from square roots and divisions: The derivative of sqrt(x) is 1/(2*sqrt(x)) and of 1/x is -1/x^2, where both expressions are problematic for small x, especially when multiplying gradients in the backward pass, -> exploding gradients.

Module Contents#

Functions#

diff_safe_sqrt

Square root with a small floor, so its derivative stays finite at x = 0.

API#

astronomix._fluid_equations._eigen_hydro.diff_safe_sqrt(x)[source]#

Square root with a small floor, so its derivative stays finite at x = 0.

The derivative of sqrt(x) is 1 / (2 sqrt(x)), which blows up as x -> 0; clamping the argument to a tiny epsilon keeps the backward pass well-behaved.