Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
dee14f0
Add photochemistry
James471 Mar 2, 2026
96c22a0
WIP: Add RadStreamingPhotoionization test problem
James471 Mar 2, 2026
cf68a52
WIP: Add StromgrenSphereConstTemp test problem
James471 Mar 2, 2026
157e99e
WIP: Fixes for GPU build
James471 Mar 5, 2026
25978d0
Add julia code for testing one zone photoionization
James471 Mar 6, 2026
e7ffd58
Add code for comparing quokka and julia output
James471 Mar 6, 2026
b7f398e
WIP: Add correct runtime parameters for 8 cubed Stromgren sphere test…
James471 Mar 6, 2026
75cc87f
Add Stromgren sphere analysis code
James471 Mar 6, 2026
6de577d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 6, 2026
a76c639
WIP: Fix photon flux equation in photochemical network
James471 Mar 6, 2026
17bf2ce
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 26, 2026
06d7450
Cleanup julia code, change project environment to include CVODE_BDF a…
James471 Apr 14, 2026
a256f92
Minor fixes
James471 Apr 14, 2026
615f72d
Change chemically active radiation array variable name to prevent con…
James471 Apr 14, 2026
dd6dbde
Remove redundant network, add collisional ionization, heating and coo…
James471 Apr 14, 2026
3843fad
Cleanup one zone test
James471 Apr 14, 2026
3349ad5
Cleanup and GPU fixes for calculating radiation quanta
James471 Apr 17, 2026
59c4494
Cleanup Stromgren sphere test
James471 Apr 17, 2026
9a0b951
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 20, 2026
cbcc942
Change to toml files in photoionization tests and remove format.h
James471 Apr 20, 2026
0bd5214
Remove ununsed variable
James471 Apr 21, 2026
cda1dd6
Remove julia manifest.toml from codespell check
James471 Apr 21, 2026
7f2e9d9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 20, 2026
1b68ffe
Change stromgren sphere error calculation
James471 Apr 21, 2026
fcc43df
Fix bug in radiation deposition
James471 May 3, 2026
14ebc37
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 3, 2026
ef9807e
Add sharp ionization front flag
James471 May 5, 2026
9fe568f
Add in-flight photons in analytical solution of stromgren sphere
James471 May 5, 2026
48a3055
Change sharp ionization front default
James471 May 5, 2026
0d6fbf7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 5, 2026
8fdf995
Fix potential division by zero in network
James471 May 13, 2026
d8e96e1
Cleanup, change microphysics hash and fix julia eos
James471 May 13, 2026
745efbd
Use analytical jacobian
James471 Jun 4, 2026
8a43faa
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 4, 2026
217c1cc
dummy change
chongchonghe Jun 5, 2026
a5346e1
set Microphysics to chongchong fork
chongchonghe Jun 5, 2026
dd6b977
Minor fixes
James471 Jun 5, 2026
5e93284
Merge branch 'photoionization' of https://github.com/quokka-astro/quo…
James471 Jun 5, 2026
3bd3093
Merge branch 'development' into photoionization
BenWibking Jun 5, 2026
ee55bfa
Minor fix
James471 Jun 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extern/Microphysics
Submodule Microphysics updated 44 files
+3 −3 .github/workflows/cuda.yml
+15 −0 CHANGES.md
+48 −1 CMakeLists.txt
+16 −3 Docs/source/conf.py
+3 −0 EOS/photoionization/Make.package
+16 −0 EOS/photoionization/_parameters
+232 −0 EOS/photoionization/actual_eos.H
+11 −0 EOS/photoionization/actual_eos_data.H
+4 −0 EOS/photoionization/actual_eos_data.cpp
+18 −1 integration/VODE/vode_dvhin.H
+24 −0 integration/VODE/vode_dvode.H
+51 −0 integration/VODE/vode_dvstep.H
+11 −2 integration/VODE/vode_type.H
+31 −4 integration/_parameters
+10 −0 integration/integrator_data.H
+48 −0 integration/integrator_setup_strang.H
+6 −0 integration/integrator_type.H
+19 −0 integration/integrator_type_strang.H
+4 −4 integration/nse_update_sdc.H
+5 −0 integration/utils/nonaka_plot.H
+31 −1 interfaces/burn_type.H
+8 −2 interfaces/eos.H
+20 −0 interfaces/eos_type.H
+3 −1 networks/he-burn/ase/Make.package
+127 −80 networks/he-burn/ase/actual_network.H
+0 −6 networks/he-burn/ase/actual_network_data.cpp
+243 −535 networks/he-burn/ase/actual_rhs.H
+355 −0 networks/he-burn/ase/approximate_rates.H
+ networks/he-burn/ase/ase.png
+787 −445 networks/he-burn/ase/derived_rates.H
+1 −1 networks/he-burn/ase/interp_tools.H
+112 −0 networks/he-burn/ase/modified_rates.H
+28 −28 networks/he-burn/ase/partition_functions.H
+1 −1 networks/he-burn/ase/pynucastro-info.txt
+25 −0 networks/he-burn/ase/rate_type.H
+1,118 −701 networks/he-burn/ase/reaclib_rates.H
+6 −6 networks/he-burn/ase/table_rates.H
+2 −1 networks/he-burn/ase/temperature_table_rates.H
+2 −0 networks/rhs.H
+8 −8 nse_solver/nse_check.H
+2 −2 nse_solver/nse_eqns.H
+2 −2 unit_test/test_sdc/main.cpp
+1 −1 unit_test/test_sdc/react_zones.H
+4 −1 util/build_scripts/write_probin.py
2,957 changes: 2,957 additions & 0 deletions extern/photoionization-julia/Manifest.toml

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions extern/photoionization-julia/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Sundials = "c3572dad-4567-51f8-b174-8c6c989267f4"
136 changes: 136 additions & 0 deletions extern/photoionization-julia/fraction.jl
Comment thread
James471 marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
using Pkg
PATH = dirname(PROGRAM_FILE)
Pkg.activate(PATH)
Pkg.instantiate()

using DifferentialEquations
using Sundials
using Plots
using CSV
using DataFrames

const m_p = 1.672621777e-24
const m_e = 9.10938291e-28
const c = 2.99792458e10
const k_B = 1.3806488e-16
const n_A = 6.02214129e23
const h = 6.62606957e-27
const R = k_B * n_A
const σ_v = 1.5e-18
const E_ion = 6.4e-12

struct State
n_spec::Vector{Float64}
n_rad::Vector{Float64}
γ_vec::Vector{Float64}
spec_mass::Vector{Float64}
E::Float64
end

function get_ρ(state::State)
ρ = 0.0
for i in 1:length(state.n_spec)
ρ += state.n_spec[i] * state.spec_mass[i]
end
return ρ
end

function get_γ_inv(state::State)
γ = 0.0
for i in 1:length(state.n_spec)
γ += state.n_spec[i] / (state.γ_vec[i] - 1.0)
end
return γ / sum(state.n_spec)
end

function get_T(state::State)
γ_inv = get_γ_inv(state)
ρ = get_ρ(state)
sum_ni = sum(state.n_spec)
T = state.E * ρ / (k_B * γ_inv * sum_ni)
return T
end

function get_E(state::State, T::Float64)
# The state should contain a dummy value for energy
γ_inv = get_γ_inv(state)
sum_ni = sum(state.n_spec)
E = γ_inv * k_B * T * sum_ni / get_ρ(state)
return E
end

function rhs!(df::Vector{Float64}, f::Vector{Float64}, params, t)
energy_switch = params[1]
γ_e, γ_HI, γ_HII = params[2:4]
m_e, m_HI, m_HII = params[5:7]

# Unpack the state variables
state = State(f[1:3], f[4:5], [γ_e, γ_HI, γ_HII], [m_e, m_HI, m_HII], f[6])
n_spec = state.n_spec
n_rad = state.n_rad
ρ = get_ρ(state)
T = get_T(state)

n_e = n_spec[1]
n_HI = n_spec[2]
n_HII = n_spec[3]
n_photon = n_rad[1]
flux_photon = n_rad[2]

α_rec = 2.6e-13 * (1 + energy_switch * ((T / 1.0e4)^(-0.7) - 1.0))
ionization_term = n_HI * c * σ_v * n_photon
recombination_term = α_rec * n_e * n_HII

df[1] = ionization_term - recombination_term
df[2] = -ionization_term + recombination_term
df[3] = ionization_term - recombination_term
df[4] = -ionization_term
df[5] = -ionization_term * flux_photon / n_photon
df[6] = energy_switch * (ionization_term * E_ion - recombination_term * k_B * T * (0.684 - 0.0416 * log(T / 1.0e4))) / ρ
end

function make_problem(state::State, tend::Float64, params::Tuple)
f = vcat(state.n_spec, state.n_rad, state.E)
prob = ODEProblem(rhs!, f, (0.0, tend), params)
return prob
end

function parse_fraction(s)
if occursin("/", s)
num, den = split(s, "/")
return parse(Float64, num) / parse(Float64, den)
else
return parse(Float64, s)
end
end

n_photon0 = parse(Float64, ARGS[1])
n_e, n_HI, n_HII = parse.(Float64, ARGS[2:4])
γ_e, γ_HI, γ_HII = parse_fraction.(ARGS[5:7])
T0 = parse(Float64, ARGS[8])
energy_switch = parse(Int64, ARGS[9])
tend = parse(Float64, ARGS[10])
constant_dt = parse(Float64, ARGS[11])
abstol, reltol = parse.(Float64, ARGS[12:13])
save_path = ARGS[14]

m_HI = m_p + m_e
m_HII = m_p

E0 = get_E(State([n_e, n_HI, n_HII], [n_photon0, 0], [γ_e, γ_HI, γ_HII], [m_e, m_HI, m_HII], 0.0), T0)
state = State(
[n_e, n_HI, n_HII], # n_spec: [n_e, n_HI, n_HII]
[n_photon0, 0], # n_rad: [n_photon, flux_photon]
[γ_e, γ_HI, γ_HII], # γ_vec
[m_e, m_HI, m_HII], # spec_mass
E0 # E
)
params = (energy_switch, γ_e, γ_HI, γ_HII, m_e, m_HI, m_HII)
prob = make_problem(state, tend, params)
sol = solve(prob, saveat=constant_dt, CVODE_BDF(); reltol=reltol, abstol=abstol)

T_values = [get_T(State(sol[i][1:3], sol[i][4:5], [γ_e, γ_HI, γ_HII], [m_e, m_HI, m_HII], sol[i][6])) for i in eachindex(sol)]
rho_values = [get_ρ(State(sol[i][1:3], sol[i][4:5], [γ_e, γ_HI, γ_HII], [m_e, m_HI, m_HII], sol[i][6])) for i in eachindex(sol)]

results = DataFrame(time=sol.t, n_e=sol[1, :], n_HI=sol[2, :], n_HII=sol[3, :], n_gamma=sol[4, :], Egas=sol[6, :] .* rho_values, gas_temp=T_values)
CSV.write(save_path, results)
Loading
Loading