You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Equation numbers are those of the published paper, Yu et al. 2020, MNRAS 492, 3179
(arXiv:2001.04384). Everything in the code is in cgs units. The code is a port of the paper's
own code (CRline.py), which produced Figs. 6–9; where that code makes a choice the paper does
not spell out, the port copies it and this page says so.
Symbols
Paper
Code
Meaning
r, r_sb
radius, starburst_radius
radius; radius of the injection region
v, ρ, P, P_C
v, rho, P, Pc
wind velocity, gas density, gas and cosmic-ray (CR) pressure
WindEquations holds one parameter set and returns d(v, P, P_C)/dr (paper §2.4, eqs. 36–52).
Method
Paper
Notes
WindEquations.derivatives
eqs. 36–43 with 50–52
outer eqs. 36–38 or inner eqs. 39–43, plus the radiation and cooling terms of eqs. 50–52 and gravity (eqs. 28–29)
WindEquations.density
eq. 13
with the code's inner/outer switch
WindEquations.alfven_speed
eq. 34
with the code's inner/outer switch
WindEquations.sound_speed_squared
eq. 35
at r > 0
WindEquations.cooling_rate
eq. 10
C = ρ²Λ(T)/μ²; zero unless cooling is on
Inner/outer switch (code convention). The paper uses the inner equations (39–43, with the
injection terms q, Q_th, Q_CR) for r ≤ r_sb and the outer ones (36–38) beyond. The paper code
switches on the Mach number instead: inner equations while v² ≤ c*², outer once the flow is
supersonic. The two agree for a wind whose sonic point is at r_sb, which is what the solver
looks for. The radiative force uses the same switch. The density and Alfvén speed, by contrast,
switch at r_sb (density for r < r_sb, Alfvén speed for r ≤ r_sb). The port follows the code.
Boundary conditions and the central-density search (boundary.py)
Function
Paper
Notes
central_state, CentralState
eqs. 44–45
P₀ and P_C,0 from ρ₀
central_sound_speed_squared
eq. 35 at r = 0
with the L'Hôpital ratio v_A/v
sonic_trial, _sonic_trial, SonicTrial
§2.3.2, §2.4 (code: rsonic())
integrate from r = 0 until sonic or turning over
_sonic_trial_python
§2.3.2 (code: rsonic())
the trial in plain Python, the readable reference
_compiled_kernel, compiled_trials_available
§2.3.2 (compiled copy of rsonic())
the Numba copy in _compiled.py, used when installed; bit-identical
_bisect
§2.3.2 (code: gss())
bisection on ρ₀
_brent, sonic_radius_mismatch
§2.3.2 (not in the paper code; replaces the last gss() stage)
Brent's method on r_s(ρ₀) − r_sb (default)
find_central_density
§2.3.2, §2.4 (code: CRline())
ρ₀ for which the sonic radius is r_sb
The search: start at ρ₀ = 0.1 M☉/pc³, multiply by 10 until a trial turns over or reaches r_sb,
bisect for the critical ("peak") ρ₀, then find the ρ₀ whose sonic radius is r_sb. The paper
code bisects in that last stage; by default the port uses Brent's method (scipy's brentq)
there, to the same precision with fewer trials (method="bisection" gives the paper code's
search). Trials use the inner density and Alfvén forms at every radius (the code's 'find0'
tag).
If Numba is installed (pip install -e ".[fast]"), each trial runs in _compiled.py, a
compiled line-by-line copy of physics.py, equations.py, integrator.py and
_sonic_trial_python (without cooling). It gives bit-for-bit the same floats; read the Python
modules for the physics. boundary.USE_COMPILED_TRIALS = False switches it off.
Solver (solver.py, integrator.py)
solve_wind finds ρ₀ and calls integrate_outward, which integrates from r = 0 to the outer
radius, or stops when the wind falls back to subsonic beyond 1.1 r_sb (a stalled wind).
integrator.cash_karp_step: Cash–Karp Runge–Kutta 4(5) (Press et al., Numerical Recipes);
the fourth-order solution is kept and (5th − 4th) is the error estimate, as in the paper code.
integrator.relative_error: the largest |error/value|, skipping components that are zero.
integrator.next_step_size: h ← 0.9 h (tol/δ)^0.2 (accepted) or ^0.25 (rejected); tol = 1e-12.