---
title: "Reference"
---

```julia
Honghu
```

A three-dimensional radiation-magnetohydrodynamics code in pure Julia.

The Euler equations are solved with an unsplit finite-volume method-of-lines
scheme: piecewise-constant, -linear or -parabolic reconstruction of the
primitive variables, a choice of Riemann solver (HLLC or LLF), and a
strong-stability-preserving Runge-Kutta integrator. With `mhd = true` it
solves ideal MHD instead, with the field face-centred and advanced by
constrained transport (HLLD or LLF, the Q26 EMF and LD04 averaging).

Radiation is treated with the two-moment (M1) approximation, grey or resolved
into `NG` frequency groups (see `RadiationGroups`). Transport uses
an HLL solver built on the M1 closure, and the stiff matter-radiation coupling
is solved implicitly, the two being combined by the second-order,
asymptotic-preserving IMEX PD-ARS scheme. Radiation subcycles inside each hydro
step at the reduced speed of light.

The algorithms follow Quokka (Wibking & Krumholz 2022; He, Wibking & Krumholz
2024).

## Getting started

```julia
using Honghu

sim = Simulation(n = (256, 1, 1), boundaries = Boundaries(Outflow()),
                 eos = IdealGas(gamma = 1.4))
set_initial_conditions!(sim) do x, y, z
    x < 0.5 ? (rho = 1.0, p = 1.0) : (rho = 0.125, p = 0.1)
end
run!(sim, tmax = 0.2)
```

or start from one of the built-in problems:

```julia
sim = Honghu.Problems.kelvin_helmholtz(n = 256)
run!(sim, tmax = 2.0, outdir = "kh", dtout = 0.02)
```

## Pages

- [Simulation and grid](simulation.md): [`Diagnostics`](simulation.md#Diagnostics), [`reset_diagnostics!`](simulation.md#reset_diagnostics-bang), [`SourceOrder`](simulation.md#SourceOrder), [`Simulation`](simulation.md#Simulation), [`set_initial_conditions!`](simulation.md#set_initial_conditions-bang), [`timestep`](simulation.md#timestep), [`step!`](simulation.md#step-bang), [`nrepaired`](simulation.md#nrepaired), [`run!`](simulation.md#run-bang), [`conserved_totals`](simulation.md#conserved_totals), [`primitives`](simulation.md#primitives), [`gas_temperature`](simulation.md#gas_temperature), [`radiation_temperature`](simulation.md#radiation_temperature), [`CartesianGrid`](simulation.md#CartesianGrid), [`Periodic`](simulation.md#Periodic), [`Outflow`](simulation.md#Outflow), [`Reflecting`](simulation.md#Reflecting), [`Fixed`](simulation.md#Fixed), [`FunctionBC`](simulation.md#FunctionBC), [`Boundaries`](simulation.md#Boundaries), [`ForwardEuler`](simulation.md#ForwardEuler), [`SSPRK2`](simulation.md#SSPRK2), [`SSPRK3`](simulation.md#SSPRK3)
- [Hydrodynamics](hydro.md): [`IdealGas`](hydro.md#IdealGas), [`cv_from_mu`](hydro.md#cv_from_mu), [`Floors`](hydro.md#Floors), [`MinMod`](hydro.md#MinMod), [`MonotonizedCentral`](hydro.md#MonotonizedCentral), [`VanLeer`](hydro.md#VanLeer), [`Sweby`](hydro.md#Sweby), [`PCM`](hydro.md#PCM), [`PLM`](hydro.md#PLM), [`PPM`](hydro.md#PPM), [`HLLMHD`](hydro.md#HLLMHD), [`LLF`](hydro.md#LLF), [`LLFMHD`](hydro.md#LLFMHD), [`HydroState`](hydro.md#HydroState), [`HLLD`](hydro.md#HLLD), [`HLLC`](hydro.md#HLLC), [`AbstractRiemannSolver`](hydro.md#AbstractRiemannSolver), [`AbstractMHDRiemannSolver`](hydro.md#AbstractMHDRiemannSolver), [`riemann_flux`](hydro.md#riemann_flux)
- [Magnetohydrodynamics](mhd.md): [`MagneticField`](mhd.md#MagneticField)
- [Radiation transport](radiation.md): [`RadiationPhysics`](radiation.md#RadiationPhysics), [`ngroups`](radiation.md#ngroups), [`LevermoreClosure`](radiation.md#LevermoreClosure), [`EddingtonClosure`](radiation.md#EddingtonClosure), [`planck_integral`](radiation.md#planck_integral), [`RadiationGroups`](radiation.md#RadiationGroups), [`planck_fractions`](radiation.md#planck_fractions), [`ConstantOpacity`](radiation.md#ConstantOpacity), [`PowerLawOpacity`](radiation.md#PowerLawOpacity), [`UserOpacity`](radiation.md#UserOpacity), [`FrequencyOpacity`](radiation.md#FrequencyOpacity)
- [Reduced speed of light](rsla.md): [`AbstractChatLimiter`](rsla.md#AbstractChatLimiter), [`ConstantChat`](rsla.md#ConstantChat), [`StabilityBound`](rsla.md#StabilityBound), [`OpticalDepthFit`](rsla.md#OpticalDepthFit), [`per_group`](rsla.md#per_group), [`flux_form`](rsla.md#flux_form)
- [Matter-radiation coupling](coupling.md): [`AbstractCoupling`](coupling.md#AbstractCoupling), [`QuokkaCoupling`](coupling.md#QuokkaCoupling), [`BracketedCoupling`](coupling.md#BracketedCoupling), [`AdaptiveCoupling`](coupling.md#AdaptiveCoupling), [`AbstractDustModel`](coupling.md#AbstractDustModel), [`NoDust`](coupling.md#NoDust), [`BateKetoDust`](coupling.md#BateKetoDust), [`AbstractJacobianSolve`](coupling.md#AbstractJacobianSolve), [`DenseSolve`](coupling.md#DenseSolve), [`ArrowheadSolve`](coupling.md#ArrowheadSolve)
- [Photoionization chemistry](chemistry.md): [`AbstractNetwork`](chemistry.md#AbstractNetwork), [`NetworkOptions`](chemistry.md#NetworkOptions), [`nspecies`](chemistry.md#nspecies), [`nbands`](chemistry.md#nbands), [`species_names`](chemistry.md#species_names), [`species_masses`](chemistry.md#species_masses), [`network_reactions`](chemistry.md#network_reactions), [`band_edges`](chemistry.md#band_edges), [`AbstractChemSolver`](chemistry.md#AbstractChemSolver), [`RosenbrockChem`](chemistry.md#RosenbrockChem), [`BackwardEulerChem`](chemistry.md#BackwardEulerChem), [`Photochemistry`](chemistry.md#Photochemistry), [`HydrogenIliev1`](chemistry.md#HydrogenIliev1), [`HydrogenIliev2`](chemistry.md#HydrogenIliev2)
- [Output, plotting and comparison](output.md): [`write_vtk`](output.md#write_vtk), [`write_line`](output.md#write_line), [`save_checkpoint`](output.md#save_checkpoint), [`load_checkpoint!`](output.md#load_checkpoint-bang), [`coordinates`](output.md#coordinates), [`available_fields`](output.md#available_fields), [`field`](output.md#field), [`plotstate`](output.md#plotstate), [`plotpanels`](output.md#plotpanels), [`animate_run`](output.md#animate_run), [`plotcompare`](output.md#plotcompare), [`relative_l1`](output.md#relative_l1), [`relative_l2`](output.md#relative_l2), [`default_metrics`](output.md#default_metrics), [`ComparisonTable`](output.md#ComparisonTable), [`compare`](output.md#compare), [`write_comparison`](output.md#write_comparison), [`read_comparison`](output.md#read_comparison), [`convergence_rate`](output.md#convergence_rate)
- [Test problems](problems.md): [`sod_shock_tube`](problems.md#sod_shock_tube), [`radiation_streaming`](problems.md#radiation_streaming), [`radhydro_shock_exact`](problems.md#radhydro_shock_exact), [`brio_wu`](problems.md#brio_wu), [`smooth_advection`](problems.md#smooth_advection), [`stromgren_iliev`](problems.md#stromgren_iliev), [`ryu_jones_2a`](problems.md#ryu_jones_2a), [`kelvin_helmholtz`](problems.md#kelvin_helmholtz), [`radiation_diffusion`](problems.md#radiation_diffusion), [`orszag_tang`](problems.md#orszag_tang), [`interpolate_to`](problems.md#interpolate_to), [`sedov_blast`](problems.md#sedov_blast), [`alfven_wave`](problems.md#alfven_wave), [`diffusion_exact`](problems.md#diffusion_exact), [`sod_exact`](problems.md#sod_exact), [`matter_coupling`](problems.md#matter_coupling), [`rad_dust`](problems.md#rad_dust), [`ionized_radius`](problems.md#ionized_radius), [`rad_dust_reference`](problems.md#rad_dust_reference), [`stromgren_radius_analytic`](problems.md#stromgren_radius_analytic), [`stromgren_radius_finite_c`](problems.md#stromgren_radius_finite_c), [`marshak_wave`](problems.md#marshak_wave), [`radhydro_shock`](problems.md#radhydro_shock), [`radhydro_shock_super`](problems.md#radhydro_shock_super), [`radiation_shadow`](problems.md#radiation_shadow), [`marshak_vaytet`](problems.md#marshak_vaytet), [`total_erad`](problems.md#total_erad), [`radhydro_pulse_dyn`](problems.md#radhydro_pulse_dyn)
- [Utilities and constants](utilities.md): [`CGS.c_light`](utilities.md#CGS-c_light), [`CGS.k_B`](utilities.md#CGS-k_B), [`CGS.m_u`](utilities.md#CGS-m_u), [`CGS.m_H`](utilities.md#CGS-m_H), [`CGS.h_planck`](utilities.md#CGS-h_planck), [`CGS.sigma_SB`](utilities.md#CGS-sigma_SB), [`CGS.a_rad`](utilities.md#CGS-a_rad), [`CGS.G_grav`](utilities.md#CGS-G_grav), [`CGS.M_sun`](utilities.md#CGS-M_sun), [`CGS.parsec`](utilities.md#CGS-parsec), [`CGS.au`](utilities.md#CGS-au), [`CGS.year`](utilities.md#CGS-year), [`CGS.eV`](utilities.md#CGS-eV)
