Types

Core data structures

AstroNbodySim.Simulation — Type
struct Simulation{D}
  • config::Any

  • id::Pair{Int64, Int64}

  • pids::Vector{Int64}

  • simdata::Any

  • timeinfo::Any: ::TimeInfo

  • outputinfo::Any: ::OutputInfo

  • loginfo::Any: ::LogInfo

  • physics::Any: ::PhysicsInfo

  • stream::Any: ::StreamInfo

  • visinfo::Any: ::VisualizationInfo

  • buffer::Any: ::Buffer

  • bgforce::Any

  • bgpotential::Any

  • poststep::Any

source
AstroNbodySim.SimConfig — Type
struct SimConfig{F, U}
  • name::String

  • author::String

  • daytime::Dates.DateTime

  • floattype::Any: Numeric type of float numbers

  • units::Any: Prefered units in simulation. Default is uAstro. See PhysicalParticles: uAstro, uSI, uGadget2, uCGS. To run without units, use nothing

  • ZeroValues::Any: ZeroValue. Pre-constructed zero values for different types to simplify function arguments

  • constants::Any: Constant. Physical constants

  • loggingmode::Any: Choose how to display status of simulation. Supported: NormalMode, ProgressMode, SilentMode. Default is ProgressMode displaying progress bars

  • time::Any: TimeConfig

  • output::Any: OutputConfig

  • solver::Any: SolverConfig

  • grav::Any: GravityConfig

  • device::Any: DeviceConfig

Examples

SimConfig(; GravitySolver = Tree())
SimConfig(; device = GPU(), TimeStep = 1.0e-5u"Gyr")
SimConfig(; units = uGadget2)
SimConfig(; units = nothing, ForceSofteningTable = [0.01 for i in 1:6])
SimConfig(; TimeEnd = 1.0u"Gyr", OutputDir = "Test/Dir")
source
AstroNbodySim.LogInfo — Type
struct LogInfo
  • timers::Dict{String, Int64}: Timer enum names to access timing (continuously starting from 1)

  • timing::Vector{UInt64}: Timings defined by timer enums

  • analysers::Dict{String, Function}: Analyse on the whole simulation

Examples #TODO

Use uppercase letters to avoid

source
AstroNbodySim.StreamInfo — Type
mutable struct StreamInfo
  • loggingio::IO: Stream for general logging

  • timerio::IO: Stream for per-step timing CSV

  • analyserio::IO: Stream for analyser CSV

StreamInfo is a holder of IO streams used by the logger. The default constructor uses in-memory IOBuffers so that no system file is opened until setuploggers runs. The fields are typed as IO (the abstract supertype of IOStream, IOBuffer, and any other I/O handle) which keeps the struct flexible and type-stable.

source
AstroNbodySim.TimeInfo — Type
mutable struct TimeInfo{T<:Number, I<:Integer}
  • dt::Number: Time interval between neighbor time steps

  • system_time_int::Integer

  • system_time_float::Number

  • last_system_time_int::Integer

  • last_system_time_float::Number

  • next_output_time_int::Integer

  • next_output_time_float::Number

  • redshift::Float64

  • scalefactor::Float64

  • min_endstep::Integer

  • stepcount::Integer

source
AstroNbodySim.VisualizationInfo — Type
mutable struct VisualizationInfo
  • progress::ProgressMeter.Progress

  • PlotData::Any

  • size::Any

  • fig::Any

  • Realtime::Bool

  • RenderTime::Float64

  • last_plot_time::Float64

  • xlims::Any

  • ylims::Any

  • zlims::Any

  • markersize::Float64

source
AstroNbodySim.GravityConfig — Type
struct GravityConfig{Len, GM, OBL, BC}
  • ForceSofteningTable::StaticArraysCore.MVector{6}: Gravitational softening lengths for different type of particles

  • model::Any: Gravity model. Supported: Newton, MOND1983Milgrom, QUMOND

  • MOND_nuIndex::Float64: Index of Mondian interpolation function

  • outbound::Any: ::OutboundLimiter. Choose how to handle particles out of the non-periodic simulation box. Supported: - Delete: delete outbound particles - DS: use direct summation method to compute forces - CoarseMesh: Construct a coarse mesh to overlap all particles Default is DS.

  • enlarge::Float64: Enlarge the simulation box by enlarge compared to the extent of system. Default is 3.0

  • boundary::Any: Boundary condition. Supported: Vacuum, Periodic, Dirichlet. Default is Vacuum

  • sparse::Bool: Use sparse matrix to improve performance

Example

GravityConfig(uAstro)
GravityConfig(nothing)
GravityConfig(;ForceSofteningTable=[0.01u"kpc" for i in 1:6])
source
AstroNbodySim.SolverConfig — Type
struct SolverConfig{SolverG}
  • grav::Any: Gravitational force solver. Supported: DirectSum, Tree, FDM, FFT, ML. Default is DirectSum

  • data::Any: Data specialized for the solver

source
AstroNbodySim.OutputConfig — Type
struct OutputConfig{OT}
  • dir::String: Output directory. Default: joinpath(pwd(), "output")

  • func::Function: Output function. Default: AstroNbodySim.output

  • type::Any: Output Type: traits of gadget2, hdf5, jld2 defined in AstroIO. Default: gadget2()

  • format2::Bool: If true, write in format2 mode for Gadget2 format. Default: true

  • acc::Bool: If true, output acceleration in snapshots. Default: false

  • pot::Bool: If true, output potential in snapshots. Default: false

  • SaveRestart::Bool: If true, save restart files regularly. Default: true

  • SaveRestartFreq::Float64: Regularly after every fraction of the whole simulation time, save restart files. Default: 1.0

Notes on Keywords

  • Keywords are compatible with SimConfig, and can also be overrided by field names of OutputConfig

Example

OutputConfig(; dir = "test", type = jld2(), format2 = false, acc = true, pot = true, SaveRestart = true, SaveRestartFreq = 0.33)
source
AstroNbodySim.TimeConfig — Type
struct TimeConfig{Time, Step, I, TIA}
  • Begin::Any: Physical time at the beginning of the simulation

  • End::Any: Physical time at the end of the simulation

  • BetweenSnapshots::Any: Time interval between snapshots

  • BetweenSnapshotsInt::Any: Integer time interval between snapshots

  • step::Any: Timestep config. Controled by keyword TimeStep. If TimeStep is zero, use AdaptiveTimestep; otherwise use ConstantTimestep

  • algorithm::Any: Time integration algorithm. Supported: Euler, Leapfrog

  • redshift::Float64: Redshift at start

  • scalefactor::Float64: Scale factor at start

Notes on Keywords

  • Keywords are compatible with SimConfig, and can also be overrided by field names of TimeConfig
  • If timestep is non-zero, use ConstantTimestep; otherwise AdaptiveTimesteps
  • TimeBase is the length of integer timeline. Default is 1<<30
  • ErrTolTimestep controls the accuracy of adaptive time integration

Examples

TimeConfig(; TimeEnd = 1.0u"Gyr") # Keyword `End = TimeEnd` by default
TimeConfig(; End = 2.0u"Gyr")     # Override keyword from `SimConfig`
source
AstroNbodySim.DeviceConfig — Type
struct DeviceConfig{Device, GA}
  • type::Any: Supported: CPU, GPU

  • GPU_NumThreads::Int64

  • GPU_Algorithm::Any: ::GPUAlgorithm. Supported: AllPairs, Tiled. Default: AllPairs

source

Tree and mesh data

AstroNbodySim.TreeSimConfig — Type
struct TreeSimConfig

Controls accuracy of tree method

  • TreeOpenAngle::Float64: If the view angle of tree node that relative to the sink point is too large, open this node. In radian unit. Default is 0.1

  • ErrTolAcc::Float64: While opening the tree node, take the last acceleration into account. Improves accuracy at high redshift cosmology. Default is 0.025

source

Trait / marker types

These are singleton types that dispatch the various kernels and integrators at runtime; the traitstring companion returns the short string used for log files and plot titles.

AstroNbodySim.OutboundLimiter — Type
`::OutboundLimiter`. Choose how to handle particles out of the non-periodic simulation box.
Supported:
    - `Delete`: delete outbound particles
    - `DS`: use direct summation method to compute forces 
    - `CoarseMesh`: Construct a coarse mesh to overlap all particles
source
AstroNbodySim.DS — Type

Compute forces using direct summation method if the particles run out of the non-periodic simulation box

source