Methods
AstroNbodySim.AdaptiveTimestepAstroNbodySim.ConstantTimestepAstroNbodySim.MOG_accAstroNbodySim.MOG_acc!AstroNbodySim.MOG_phiAstroNbodySim.QUMOND_PDM_densityAstroNbodySim.QUMOND_accAstroNbodySim.QUMOND_acc!AstroNbodySim.QUMOND_phiAstroNbodySim.advance_and_find_timestepAstroNbodySim.alter_lineAstroNbodySim.alter_paramAstroNbodySim.compute_accAstroNbodySim.compute_forceAstroNbodySim.compute_force_pairwiseAstroNbodySim.compute_kineticAstroNbodySim.crosstimeAstroNbodySim.dynamicaltimeAstroNbodySim.eccentricityAstroNbodySim.ellipticPeriodAstroNbodySim.ellipticSemiMajorAstroNbodySim.find_next_sync_point_and_driftAstroNbodySim.freefalltimeAstroNbodySim.get_all_dataAstroNbodySim.get_local_dataAstroNbodySim.hubbletimeAstroNbodySim.init_timestepsAstroNbodySim.interactiontimeAstroNbodySim.mainloopAstroNbodySim.meandensityAstroNbodySim.mond_Milgrom1983AstroNbodySim.nuAstroNbodySim.nu1AstroNbodySim.nu2AstroNbodySim.orbitaltimeAstroNbodySim.pseudoNewtonianAccAstroNbodySim.pseudoNewtonianPotentialAstroNbodySim.r_gAstroNbodySim.relaxtimeAstroNbodySim.set_softlen!AstroNbodySim.set_softlen_local!AstroNbodySim.softlenAstroNbodySim.suggest_softlenAstroNbodySim.suggest_softlen!AstroNbodySim.total_angular_momentumAstroNbodySim.total_energyAstroNbodySim.total_kineticAstroNbodySim.total_kinetic_localAstroNbodySim.total_momentumAstroNbodySim.total_potentialAstroNbodySim.typicalvelocityAstroNbodySim.write_gadget2_paramBase.run
Main functions
AstroNbodySim.mainloop — Function
mainloop(sim::Simulation) -> Any
Main integration loop: drift → force → kick → analyse → output → repeat until timeinfo.system_time_float >= config.time.End or the user creates a stop file inside config.output.dir.
Returns a Matrix of analyser values if any analysers were registered, otherwise nothing.
Force / potential
AstroNbodySim.compute_force — Function
compute_force(sim::Simulation)
compute_force(sim::Simulation, pos, SoftLength)Compute gravitational accelerations using the solver and device stored in sim.config. The in-place form updates data.Acc; the position-based form returns the accelerations evaluated at pos with the given softening length.
AstroNbodySim.compute_force_pairwise — Function
function computeforcepairwise(p1::AbstractParticle, p2::AbstractParticle, G::Number, h::Number)
return acc of p1 and p2 in a TupleAstroNbodySim.compute_acc — Function
compute_acc(
m::PhysicalMeshes.MeshCartesianStatic,
dim::Val{3},
mode::PhysicalMeshes.VertexMode
)
Compute accelerations by second-order central differencing of potential on the mesh. Results are stored in acc and return nothing.
AstroNbodySim.softlen — Function
softlen(c::Collection, table::MVector)
softlen(p::AbstractParticle, table::MVector)
softlen(p::AbstractParticle, sim::Simulation)
softlen(c::Collection, sim::Simulation)Retrive softening length from table
AstroNbodySim.suggest_softlen — Function
suggest_softlen(V::Number, N::Int64)
suggest_softlen(data::Union{Array, StructArray})
suggest_softlen(data::Union{Array, StructArray}, collection::Collection)
suggest_softlen(sim::Simulation)return recommended softening length
See also suggest_softlen! and set_softlen!
AstroNbodySim.suggest_softlen! — Function
suggest_softlen!(sim::Simulation)Set all softening lengths to suggested value.
AstroNbodySim.set_softlen! — Function
set_softlen!(sim::Simulation, h)
set_softlen!(sim::Simulation, h, solver, device)Set all entries of sim.config.grav.ForceSofteningTable to h. For distributed particle solvers the new value is broadcast to every worker.
AstroNbodySim.set_softlen_local! — Function
set_softlen_local!(sim::Simulation, c::Collection, h::Number)Set softening length of collection c to h.
set_softlen_local!(sim::Simulation, h::Number)Set all softening lengths to h
AstroNbodySim.compute_kinetic — Function
compute_kinetic(
p::PhysicalParticles.AbstractParticle
) -> Any
Compute kinetic energy of particle: 0.5 * p.Mass * p.Vel * p.Vel
Restart / output
saverestart, loadrestart, restart, check_restartable and redistribute_data are part of the restart machinery driven by run / Simulation; they are internal helpers without user-facing docstrings in this release.
Particle-Mesh
The Poisson solvers are provided by PhysicalFFT.jl and PhysicalFDM.jl (no separate docstrings are attached in this package):
fft_poisson(Δ, Len, rho, boundary, device)andfft_poisson(mesh, G).fft_poisson!(mesh, rho, boundary).fdm_poisson(mesh, Val(dim), G, mode, device, boundary, sparse).
Machine-Learning solver
The ML solver is experimental; see the ML manual page. No stable training API is exposed in this release.
Timestep
AstroNbodySim.ConstantTimestep — Type
ConstantTimestepConstant timestep configuration with step dt. Selected when TimeStep > 0.
AstroNbodySim.AdaptiveTimestep — Type
AdaptiveTimestepAdaptive timestep configuration. The raw step is sqrt(2 * ErrTolTimestep * SofteningLength / |a|), quantised on an integer timeline of length TimeBase and bounded by MinStep and MaxStep.
AstroNbodySim.init_timesteps — Function
init_timesteps(sim::Simulation)Initialise Ti_endstep for every particle from the current acceleration and softening length, using the configured constant or adaptive timestep.
AstroNbodySim.find_next_sync_point_and_drift — Function
find_next_sync_point_and_drift(sim::Simulation, timestep_config, solver, device)Drift particles to the next synchronisation point and update the simulation time. The synchronisation point is determined by the constant or adaptive timestep configuration.
AstroNbodySim.advance_and_find_timestep — Function
advance_and_find_timestep(sim::Simulation, solver, device)Apply the second half of the leapfrog kick and advance Ti_endstep to the next step for every active particle.
Energy & orbits
AstroNbodySim.total_angular_momentum — Function
total_angular_momentum(sim::Simulation) -> Any
Compute total angular momentum vector of the system
AstroNbodySim.total_potential — Function
total_potential(data::StructArrays.StructArray) -> Any
Sum potential energy of particles in data. Potentials need to be computed in advance.
Return nothing if empty.
AstroNbodySim.total_momentum — Function
total_momentum(sim::Simulation, axis::Symbol) -> Any
Compute momentum of the system in the direction of axis
total_momentum(sim::Simulation) -> Any
Compute total momentum vector of the system
AstroNbodySim.total_kinetic — Function
total_kinetic(data::StructArrays.StructArray) -> Any
Sum kinetic energy: 0.5 * data.Mass[i] * data.Vel[i] * data.Vel[i]
total_kinetic(sim::Simulation) -> Any
Compute kinetic energy of particles on workers and return the sum
AstroNbodySim.total_kinetic_local — Function
total_kinetic_local(sim::Simulation) -> Any
Compute and sum kinetic energy of particles in data. Potentials need to be computed in advance.
Return nothing if empty.
AstroNbodySim.total_energy — Function
total_energy(sim::Simulation) -> Any
Total energy (kinetic + potential) of sim data
AstroNbodySim.ellipticSemiMajor — Function
ellipticSemiMajor(
G::Number,
M::Number,
r::Number,
v::Number
) -> Any
Length of semi-major axis of elliptic orbit
G: gravitational constantM: mass of central objectr: orbit radius at specific timev: velocity at radiusr
AstroNbodySim.ellipticPeriod — Function
ellipticPeriod(G::Number, M::Number, a::Number) -> Any
Orbital period of elliptic orbit
G: gravitational constantM: mass of central objecta: length of semi-major axis
AstroNbodySim.eccentricity — Function
eccentricity(
G::Number,
M::Number,
v::Number,
h::Number
) -> Any
Eccentricity of elliptic orbit
G: gravitational constantM: mass of central objectv: velocity at radiusrh: specific relative angular momentum at radiusr
eccentricity(
G::Number,
M::Number,
r::PhysicalParticles.AbstractPoint,
v::PhysicalParticles.AbstractPoint
) -> Any
Eccentricity vector of elliptic orbit
G: gravitational constantM: mass of central objectr: position at specific timev: velocity vector at positionr
Time scales
AstroNbodySim.typicalvelocity — Function
typicalvelocity(G, M, R)v = sqrt(G*M/R)
Typical velocity of a spherical system.
AstroNbodySim.meandensity — Function
meandensity(M, R)ρ = 3*M/(4πR^3)
Mean density of a spherical system.
AstroNbodySim.crosstime — Function
crosstime(R, v)t_cross = R / v
The typical time needed to cross the system.
AstroNbodySim.hubbletime — Function
hubbletime(H0)t_hubble = 1/H0
The age of the universe.
AstroNbodySim.relaxtime — Function
relaxtime(R, v, N)trelax = N/(10 lnN) tcross
Relaxation time: The time over which the change in kinetic energy due to the long-range collisions has accumulated to a value that is comparable to the intrinsic kinetic energy of the particle.
AstroNbodySim.interactiontime — Function
interactiontime(R, v, N)
The typical time between two short-range interactions that cause a change in kinetic energy comparable to the intrinsic kinetic energy of the particle.
tinteraction = N * tcross
AstroNbodySim.dynamicaltime — Function
dynamicaltime(ρ, G)t_dyn = sqrt(3 * π / (16 * G * ρ))
The time required to travel halfway across the system.
AstroNbodySim.freefalltime — Function
freefalltime(ρ, G)t_ff = sqrt(3 * π / (32 * G * ρ))
The time it takes a sphere with zero pressure to collapse to a point.
AstroNbodySim.orbitaltime — Function
orbitaltime(ρ, G)t_orb = sqrt(3π/(Gρ))
The time it takes to complete a (circular) orbit.
Data processing
AstroNbodySim.get_local_data — Function
Access data on GPU
MOND / QUMOND / MOG
AstroNbodySim.nu — Function
nu(y::Number, n::Number = 2)Generalized MOND (MOdified Newtonian Dynamics) interpolation function. See also nu1, nu2
AstroNbodySim.nu1 — Function
nu1(y::Number)MOND (MOdified Newtonian Dynamics) interpolation function with index = 1. See also nu, nu2
AstroNbodySim.nu2 — Function
nu1(y::Number)MOND (MOdified Newtonian Dynamics) interpolation function with index = 2. See also nu, nu1
AstroNbodySim.mond_Milgrom1983 — Function
mond_Milgrom1983(sim::Simulation, data::StructArray)Apply Milgrom 1983 formula of MOND (MOdified Newtonian Dynamics) to accelerations
AstroNbodySim.QUMOND_PDM_density — Function
QUMOND_PDM_density(
m::PhysicalMeshes.MeshCartesianStatic,
ACC0::Number,
G::Number
) -> Any
Compute ρPDM on the RHS (right hand side) of QUMOND (QUasi-linear MOdified Newtonian Dynamics). Return ρPDM
AstroNbodySim.QUMOND_phi — Function
QUMOND_phi(
m::PhysicalMeshes.MeshCartesianStatic,
ACC0::Number,
G::Number
) -> Any
First compute ρ_PDM, then solve QUMOND (QUasi-linear MOdified Newtonian Dynamics) equation on the mesh. Return modified potential
Warning: Currently the Poisson equation is solved with periodic boundary conditions
AstroNbodySim.QUMOND_acc — Function
QUMOND_acc(
m::PhysicalMeshes.MeshCartesianStatic,
ACC0::Number,
G::Number
) -> Any
- Compute ρ_PDM
- Solve modified potential on the mesh
- Compute acceleration by finite differencing the potential
Return acceleration
AstroNbodySim.QUMOND_acc! — Function
QUMOND_acc!(
m::PhysicalMeshes.MeshCartesianStatic,
ACC0::Number,
G::Number
)
Apply QUMOND (QUasi-linear MOdified Newtonian Dynamics) formula to accelerations
AstroNbodySim.MOG_phi — Function
MOG_phi()
AstroNbodySim.MOG_acc — Function
MOG_acc(
m::PhysicalMeshes.MeshCartesianStatic,
ACC0::Number,
G::Number
)
AstroNbodySim.MOG_acc! — Function
MOG_acc!(
m::PhysicalMeshes.MeshCartesianStatic,
ACC0::Number,
G::Number
)
Pseudo-Newtonian (black-hole) potentials
AstroNbodySim.r_g — Function
r_g(G, M, c)r_g = 2 * G * M / c^2
where G is the gravity constant, M is the mass of the central object, c is light speed.
Schwarzchild radius.
AstroNbodySim.pseudoNewtonianPotential — Function
pseudoNewtonianPotential(G, M, c, R)pot = - G * M / (R - r_g(G, M, c))
Pseudo-Newtonian potential around a compat central object. Diverge at gravity radius r_g.
pseudoNewtonianPotential(G, M, rg)
pot = - G * M / (R - rg)
Pseudo-Newtonian potential around a compat central object. Diverge at gravity radius r_g.
AstroNbodySim.pseudoNewtonianAcc — Function
pseudoNewtonianAcc(G, M, c, R, n::AbstractPoint)acc = - G * M / (R - r_g(G, M, c))^2 * n
Pseudo-Newtonian acceleration around a compat central object. Diverge at gravity radius r_g.
pseudoNewtonianAcc(G, M, c, R, n::AbstractPoint)acc = - G * M / (R - rg)^2 * n
Pseudo-Newtonian acceleration around a compat central object. Diverge at gravity radius r_g.
Output & logging
outputparallel, setuploggers, DefaultTimer, mkpathIfNotExist and traitstring are internal plumbing around the output/logging pipeline and are not part of the stable public API in this release (LogInfo is documented on the Types page).
Utilities
AstroNbodySim.write_gadget2_param — Function
function writegadget2param(filename::String, ICfilename::String)
Params
- filename : name of param file
- ICfilename : name of initial conditions
AstroNbodySim.alter_param — Function
alter_param(filename::String, param::String, value)
alter all lines containing param to param value
AstroNbodySim.alter_line — Function
alter_line(filename::String, match::String, newline::String; all = false)
alter the first line containing match to newline
Keywords
- all::Bool = false : If true, alter all lines containing
matchtonewline