API
Index
UltraDark.ConfigUltraDark.OutputUltraDark.SummaryUltraDark.AbstractGridsUltraDark.Config.SimulationConfigUltraDark.Config.TimeStepOptionsUltraDark.Config.TimeStepOptionsUltraDark.GridsUltraDark.Output.OutputConfigUltraDark.Output.OutputConfigUltraDark.PencilGridsUltraDark.Summary.AngularMomentumUltraDark.Summary.EnergyGravityUltraDark.Summary.EnergyKineticQuantumUltraDark.Summary.MaxDensityUltraDark.Summary.MaxDensityIndexUltraDark.Summary.MeanDensityUltraDark.Summary.RmsDensityContrastUltraDark.Summary.ScaleFactorUltraDark.Summary.SimulationTimeUltraDark.Summary.TimeStepUltraDark.Summary.TotalMassUltraDark.Summary.WallTimeUltraDark.Config.constant_scale_factorUltraDark.E_gravUltraDark.E_gravity_densityUltraDark.E_kqUltraDark.E_totalUltraDark.Initialise.add_fdm_soliton!UltraDark.Output.output_external_stateUltraDark.Output.output_external_state_headerUltraDark.Output.output_external_states_headersUltraDark.Output.output_gridsUltraDark.Output.output_output_timesUltraDark.Output.output_stateUltraDark.Output.output_xyzUltraDark.Summary.column_titleUltraDark.Summary.column_titlesUltraDark.Summary.generate_summary_rowUltraDark.Summary.get_relevant_dataUltraDark.Summary.map_summary_statisticsUltraDark.Summary.output_summary_headerUltraDark.Summary.output_summary_rowUltraDark.Summary.pool_summarystatUltraDark.Summary.pool_summarystatUltraDark.Summary.pool_summarystatUltraDark.Summary.pool_summarystatUltraDark.Summary.pool_summarystatUltraDark.Summary.pool_summarystatUltraDark.Summary.pool_summarystatUltraDark.Summary.pool_summarystatUltraDark.actual_time_stepUltraDark.add_external_potential!UltraDark.angular_momentumUltraDark.angular_momentum_densityUltraDark.auxiliary_step!UltraDark.azimuthal_angleUltraDark.dVUltraDark.evolve_to!UltraDark.good_phase_diffUltraDark.inner_step!UltraDark.k_normUltraDark.k_vecUltraDark.massUltraDark.max_normed_phase_diffUltraDark.max_time_stepUltraDark.max_time_step_externalUltraDark.max_time_step_gridsUltraDark.outer_step!UltraDark.phase_diffUltraDark.phase_diffUltraDark.polar_angleUltraDark.radius_cylindricalUltraDark.radius_sphericalUltraDark.rk_normUltraDark.rk_vecUltraDark.simulate!UltraDark.take_steps!UltraDark.update_gravitational_potential!
Docstrings
UltraDark.AbstractGrids — TypeAbstractGridsabstract type AbstractGridsAbstract type for grids containing simulation data
UltraDark.Grids — Typestruct Grids <: UltraDark.AbstractGridsGrids(length, resol::Int)
Grids(length_tuple, resol_tuple::Tuple{Int, Int, Int})struct containing grids used in a simulation
Fields
x::Array{Float64, 3}: Array of x positionsy::Array{Float64, 3}: Array of y positionsz::Array{Float64, 3}: Array of z positionskx::Array{Float64, 3}: Array of x Fourier modesky::Array{Float64, 3}: Array of y Fourier modeskz::Array{Float64, 3}: Array of z Fourier modesk::Array{Float64, 3}: Fourier space postition arrayrkx::Array{Float64, 3}: Array of x Fourier modes for use withrfftrky::Array{Float64, 3}: Array of y Fourier modes for use withrfftrkz::Array{Float64, 3}: Array of z Fourier modes for use withrfftrk::Array{Float64, 3}: Fourier space postition array for use withrfftψx::Array{ComplexF64, 3}: ψ fieldψk::Array{ComplexF64, 3}: ψ field in Fourier spaceρx::Array{Float64, 3}: density field ρρk::Array{ComplexF64, 3}: density field ρ in Fourier spaceΦx::Array{Float64, 3}: gravitational potential field ΦΦk::Array{ComplexF64, 3}: gravitational potential field Φ in fourier spacefft_plan::Any: FFT plan for complex-to-complex transformsrfft_plan::Any: FFT plan for real-to-complex transformsk_vanish_indices::Vector{CartesianIndex{3}}: Indices at which k==0.0rk_vanish_indices::Any: Indices at which rk==0.0
Examples
Create an empty grid with length length and resolution resol
julia> using UltraDark
julia> length = 1;
julia> resol = 16;
julia> Grids(length, resol);
julia> size(ans.ψx)
(16, 16, 16)Create an empty length[1]xlength[2]xlength[3] grid with resolution resol[1]xresol[2]xresol[3].
julia> using UltraDark
julia> Grids((1.0, 1.0, 0.5), (64, 64, 32));
julia> size(ans.ψx)
(64, 64, 32)UltraDark.PencilGrids — TypePencilGrids(length, resol)
PencilGrids(length_tuple, resol_tuple::Tuple{Int, Int, Int})struct containing grids used in a simulation
Each grid is a PencilArray, allowing multiprocess FFTs. This comes with significant overhead so is only useful when running in a multi-node environment.
Fields
x::Array{Float64, 3}: Array of x positionsy::Array{Float64, 3}: Array of y positionsz::Array{Float64, 3}: Array of z positionskx::Array{Float64, 3}: Array of x Fourier modesky::Array{Float64, 3}: Array of y Fourier modeskz::Array{Float64, 3}: Array of z Fourier modesk::Any: Fourier space postition arrayrkx::Array{Float64, 3}: Array of x Fourier modes for use withrfftrky::Array{Float64, 3}: Array of y Fourier modes for use withrfftrkz::Array{Float64, 3}: Array of z Fourier modes for use withrfftrk::Any: Fourier space postition array for use withrfftψx::Any: ψ fieldψk::Any: ψ field in Fourier spaceρx::Any: density field ρρk::Any: density field ρ in Fourier spaceΦx::Any: gravitational potential field ΦΦk::Any: gravitational potential field Φ in fourier spacefft_plan::Any: FFT plan for complex-to-complex transformsrfft_plan::Any: FFT plan for real-to-complex transformsk_vanish_indices::Vector{CartesianIndex{3}}: Indices at which k==0.0rk_vanish_indices::Any: Indices at which rk==0.0MPI_COMM::Any: MPI communicator
Examples
Create an empty grid with length length and resolution resol. Uses PencilFFTs to create PencilArrays.
julia> using UltraDark
julia> len = 1;
julia> resol = 16;
julia> PencilGrids(len, resol);
Create an empty length[1]xlength[2]xlength[3] grid with resolution resol[1]xresol[2]xresol[3].
julia> using UltraDark
julia> PencilGrids((1.0, 1.0, 0.5), (64, 64, 32));
UltraDark.E_grav — MethodE_grav(grids)
E_grav(grids, psi)Gravitational potential energy
UltraDark.E_gravity_density — MethodE_gravity_density(psi::Number, Phi::Real) -> Real
Gravitational energy density of field psi in gravitational potential Phi
UltraDark.E_kq — MethodE_kq(grids)
E_kq(grids, psi)Sum of kinetic and quantum energies
UltraDark.E_total — MethodE_total(grids; constants)
Total energy of the scalar field: the sum of the kinetic and quantum energies.
UltraDark.actual_time_step — Methodactual_time_step(max_time_step, time_interval, time_step_options)Actual size and number of time steps that should be taken if the maximum is max_time_step. No more than time_step_options.update_period steps should be taken, and they should fit in time_interval.
Examples
julia> using UltraDark: actual_time_step, TimeStepOptions
julia> actual_time_step(0.11, 1, TimeStepOptions())
(0.1, 10)UltraDark.add_external_potential! — Methodadd_external_potential!(t, grids, constants)Add a gravitational potential to the grid. By default this does nothing, but can be overridden in multiple dispatch.
UltraDark.angular_momentum — Methodangular_momentum(grids)
angular_momentum(grids, ψx, ρx)Calculate total angular momentum
Returns
L: AbstractArray with length 3
UltraDark.angular_momentum_density — Methodangular_momentum_density(grids)
angular_momentum_density(grids, ψx, ρx)Calculate angular momentum density at each grid point
Returns
L: AbstractArray with dimensions 3 x resolx x resoly x resol_z
UltraDark.auxiliary_step! — Methodauxiliary_step!(Δt, grids, t, constants)
auxiliary_step!(Δt, grids, t, constants, s; a = 1.0)Do an auxiliary inner step. By default this does nothing, but can be overridden in multiple dispatch.
UltraDark.azimuthal_angle — Methodazimuthal_angle(x, y, z)
azimuthal_angle(grids)
azimuthal_angle(grids, r0)Calculate the azimuthal angle in spherical or cylindrical coordinates
This is \phi in conventional physics notation.
UltraDark.dV — MethoddV(grids) -> Any
Calculate the volume of each grid cell
Examples
julia> using UltraDark
julia> box_length = 1.0;
julia> resol = 16;
julia> g = Grids(box_length, resol);
julia> dV(g) * resol^3 == box_length^3
trueUltraDark.evolve_to! — Methodevolve_to!(
t_start,
t_end,
grids,
output_config,
sim_config;
constants,
external_states
) -> Any
Evolve grids forward from t_start to t_end
UltraDark.good_phase_diff — Methodbad_phase_diff(grids, config)Check if the phase of the ψ field is in a trustable regime.
Returns
UltraDark.inner_step! — Methodinner_step!(Δt, grids, constants; a=1.0)
inner_step!(Δt, grids, constants, s; a=1.0)Perform the "inner" time step in the symmetrized split-step Fourier method.
This step applies the diffusion terms and updates the gravitational potential.
UltraDark.k_norm — Methodk_norm(lengths, resols) -> Any
UltraDark.k_vec — Methodk_vec(
lengths,
resols
) -> Tuple{AbstractFFTs.Frequencies, AbstractFFTs.Frequencies, AbstractFFTs.Frequencies}
Calculate the Fourier frequencies of a box with side lengths lengths and resolutions resols
Examples
julia> using UltraDark: k_vec
julia> kvec = k_vec((2π, 2π, 2π), (4, 4, 4));
julia> kvec[1]
4-element AbstractFFTs.Frequencies{Float64}:
0.0
1.0
-2.0
-1.0UltraDark.mass — Methodmass(grids)
mass(grids, rho)Calculate total mass of a density field
Examples
julia> using UltraDark
julia> g = Grids(1.0, 16);
julia> g.ρx .= 0.0;
julia> g.ρx[1, 1, 1] = 1.0;
julia> UltraDark.mass(g) == 1.0 * (1.0 / 16)^3
trueUltraDark.max_normed_phase_diff — Methodnormed_max_phase_grad(grids)Compute maximum phase gradient of a grid
Normalised to ignore large gradients in regions with low density. These tend to be anomalous.
UltraDark.max_time_step — Methodmax_time_step(grids, a, external_states)Consolidate the maximum time step implied by grids and each member of external_states.
UltraDark.max_time_step_external — Methodmax_time_step_external(grids, a, state)Calculate the maximum time step implied by an external state
UltraDark.max_time_step_grids — Methodmax_time_step_grids(grids, a)
max_time_step_grids(grids::PencilGrids, a)Calculate an upper bound on the time step from grid properties
This time step depends on the gravitational potential and the resolution.
UltraDark.outer_step! — Methodouter_step!(Δt, grids, constants; a=1.0)
outer_step!(Δt, grids, constants, s; a=1.0)Perform the "outer" time step in the symmetrized split-step Fourier method.
This step only updates the phase of ψ applying accelerations due to gravity, the amplitude is not changed.
UltraDark.phase_diff — Methodphase_diff(field, dir)Compute point-to-point difference of phase on a grid along a direction
Returns an array of size (size(field)[1], size(field)[2], size(field)[3]) containing differences in direction dir.
UltraDark.phase_diff — Methodphase_diff(field::PencilArray, dir)Compute point-to-point difference of phase on a grid along a direction
Returns an array of size (size(field)[1], size(field)[2], size(field)[3]) containing differences in direction dir.
UltraDark.polar_angle — Methodpolar_angle(x, y, z)
polar_angle(grids)
polar_angle(grids, r0)Calculate the polar angle in spherical coordinates
This is \theta in conventional physics notation.
UltraDark.radius_cylindrical — Methodradius_cylindrical(x, y, z)
radius_cylindrical(grids)
radius_cylindrical(grids, r0)Calculate the radial coordinate in cylindrical coordinates
Examples
julia> using UltraDark
julia> import UltraDark: radius_cylindrical, azimuthal_angle
julia> box_length = 1.0;
julia> resol = 16;
julia> g = Grids(box_length, resol);
julia> all(radius_cylindrical(g) .* cos.(azimuthal_angle(g)) .≈ g.x)
true
julia> all(
radius_cylindrical(g, (0.0, 0.0, 1.0)) .* cos.(azimuthal_angle(g, (0.0, 0.0, 1.0))) .≈
g.x,
)
trueUltraDark.radius_spherical — Methodradius_spherical(x, y, z)
radius_spherical(grids)
radius_spherical(grids, r0)Calculate the radial coordinate in a spherical coordinate system
Examples
julia> using UltraDark
julia> import UltraDark: radius_spherical, polar_angle, azimuthal_angle
julia> box_length = 1.0;
julia> resol = 16;
julia> g = Grids(box_length, resol);
julia> all(radius_spherical(g) .* sin.(polar_angle(g)) .* cos.(azimuthal_angle(g)) .≈ g.x)
true
julia> all(
radius_spherical(g, (1.0, 0.0, 0.0)) .* sin.(polar_angle(g, (1.0, 0.0, 0.0))) .*
cos.(azimuthal_angle(g, (1.0, 0.0, 0.0))) .+ 1.0 .≈ g.x,
)
trueUltraDark.rk_norm — Methodrk_norm(lengths, resols) -> Any
UltraDark.rk_vec — Methodrk_vec(
lengths,
resols
) -> Tuple{AbstractFFTs.Frequencies, AbstractFFTs.Frequencies, AbstractFFTs.Frequencies}
UltraDark.simulate! — Methodsimulate!(grids, output_config::OutputConfig; constants = nothing, external_states = (),)
simulate!(grids, sim_config, output_config::OutputConfig; constants = nothing, external_states = (),)simulate! is the main entry point into a simulation
simulate! evolves grids and external_states forward, writing output as specified by output_config.
Arguments
grids::AbstractGrids Contains coordinate systems and the scalar field ψ.
sim_config::UltraDark.Config gives further control over the way the simulation is done.
output_config::OutputConfig controls what output is written and when.
constants::Any can be used to overload other functions in the evolution, for example to introduce self-interactions.
external_states::Tuple{Any} can be used in combination with overloading to add other dynamical objects to a simulation.
UltraDark.take_steps! — MethodTake n steps with time step Δt
Examples
julia> using UltraDark: take_steps!, Grids, OutputConfig, Config
julia> take_steps!(
Grids(1.0, 16),
0,
0.5,
10,
OutputConfig(mktempdir(), []),
Config.constant_scale_factor,
nothing,
(),
)
5.0UltraDark.update_gravitational_potential! — Methodupdate_gravitational_potential!(grids; a = 1.0)
update_gravitational_potential!(grids, constants; a = 1.0)Update density grids.ρx and the gravitational potential grids.Φx based on grids.ψx