Snapshot from this documentation build. SHA-256: 7dee59c461d7a0ffcc2a0e927139f894cc6471df758d1a71e448af8334ddc1f7
1 """
2 PMFGLM
3
4 Single-node primordial magnetic field MHD, photon moments, primordial chemistry,
5 and particle gravity. CPU, CUDA, and Metal kernels share KernelAbstractions.jl
6 implementations. See `RunConfig`, `run_simulation`, and the bundled examples.
7 """
8 module PMFGLM
9
10 import MHDKernels
11 import PoissonKernels
12 import ChemistryKernels
13 import EmissionKernels
14 import KernelAbstractions
15 using Dates
16 using SHA
17 using TOML
18
19 export MHDKernels, PoissonKernels, ChemistryKernels, EmissionKernels
20 export RunConfig, load_config, validate_config, run_simulation, run_environment
21 export backend, allocate_state, init_pmf_batchelor!, pmf_batchelor_field
22 export step!, evolve!, compute_dt, fields_to_host, max_divb, source_fingerprint
23 export magnetic_code_amplitude
24
25 const backend = MHDKernels.backend
26 const allocate_state = MHDKernels.allocate_state
27 const init_pmf_batchelor! = MHDKernels.init_pmf_batchelor!
28 const pmf_batchelor_field = MHDKernels.pmf_batchelor_field
29 const step! = MHDKernels.step!
30 const evolve! = MHDKernels.evolve!
31 const compute_dt = MHDKernels.compute_dt
32 const fields_to_host = MHDKernels.fields_to_host
33 const max_divb = MHDKernels.max_divb
34 const PACKAGE_ROOT = dirname(@__DIR__)
35
36 include("configuration.jl")
37 include("provenance.jl")
38
39 "Convert comoving nG to B/sqrt(4pi*rho)/velocity_unit at the initial redshift."
40 function magnetic_code_amplitude(b0_ng::Real,z::Real;
41 h::Real=0.674,omega_b::Real=0.17037*0.315,velocity_unit_cms::Real=8e5)
42 all(isfinite,(b0_ng,z,h,omega_b,velocity_unit_cms)) &&
43 b0_ng >= 0 && z >= 0 && h > 0 && omega_b > 0 && velocity_unit_cms > 0 ||
44 throw(ArgumentError("finite nonnegative B,z and positive h,omega_b,velocity units required"))
45 rho = omega_b*1.8788e-29*h^2*(1+z)^3
46 b0_ng*1e-9*(1+z)^2/(velocity_unit_cms*sqrt(4pi*rho))
47 end
48
49 end