Summary statistics

It is often useful to collect summary statistics as a simulation runs and avoid storing complete simulation boxes. The UltraDark.Summary module makes this easy.

Example

Say you want to extract the minimum density at each time step. Define a struct to contain this data:

struct MinDensity
    ρx_min::Float64
end

and a function to construct it

function MaxDensity(sim_time, a, Δt, grids, constants, external_states)
    ρx_min = minimum(grids.ρx)

    MinDensity(ρx_max)
end
MaxDensity (generic function with 1 method)

Passing this object into a simulation will add a column to $output_path/summary.csv containing the single value contained by MinDensity.

More complex statistics are also possible.

Docstrings

UltraDark.SummaryModule
Summary

The Summary module contains utilities for computing and outputting summary statistics at each time step.

source
UltraDark.Summary.AngularMomentumType
struct AngularMomentum

Total angular momentum in each of 3 directions

Examples

A stationary field has no angular momentum

```jldoctest julia> using UltraDark

julia> g = Grids(1.0, 16);

julia> g.ψx .= 1;

julia> Summary.AngularMomentum(0., 1., 1e-1, g, nothing) UltraDark.Summary.AngularMomentum(0.0, 0.0, 0.0)

Fields

  • Lx::Float64

  • Ly::Float64

  • Lz::Float64

source
UltraDark.Summary.MaxDensityIndexType
struct MaxDensityIndex

This struct contains 4 useful pieces of information: the maxiumum value and three indices. Each is output to a summary.

Fields

  • ρx_max::Float64: max of density

  • max_index_x::Int32: x index of max density

  • max_index_y::Int32: y index of max density

  • max_index_z::Int32: z index of max density

source
UltraDark.Summary.MeanDensityType
struct MeanDensity

Summary statistic containing the mean density and the number of cells over which it was calculated.

Examples

julia> using UltraDark

julia> g = Grids(1.0, 16);

julia> Summary.MeanDensity(g)
UltraDark.Summary.MeanDensity(0.0, 4096)

Fields

  • ρx_mean::Float64: mean of density

  • n::Int64: number of grid points summarized

source
UltraDark.Summary.TotalMassType
struct TotalMass

Total mass on a grid

Examples

julia> using UltraDark

julia> g = Grids(1.0, 16);

julia> Summary.TotalMass(0.0, 1.0, 1e-1, g, nothing, ())
UltraDark.Summary.TotalMass(0.0)

Fields

  • mass::Float64
source
UltraDark.Summary.WallTimeType
struct WallTime

The current time in the real world.

Examples

WallTime created after another contains a later time.

julia> using UltraDark

julia> t1 = Summary.WallTime();

julia> t2 = Summary.WallTime(0.0, 1.0, 1e-1, Grids(1.0, 16), nothing, ());

julia> t1.date <= t2.date
true

Fields

  • date::Dates.DateTime: wall time
source
UltraDark.Summary.column_titleMethod
column_title(summary_struct)

Get column title

Assumes that the desired column title is the name of the first field. This can be refined for other structs by defining a specialization for the given datatype.

Note that the input argument is of type Val{T}, so that one can dispatch on T.

source
UltraDark.Summary.get_relevant_dataMethod
get_relevant_data(summary_struct)

Format column entry as string

By default, assumes that the desired data is in the first field of the struct. This can be refined for other structs by defining a specialization for the given datatype and returning a comma separated string.

source
UltraDark.Summary.output_summary_headerMethod
output_summary_header(output_config) -> Int64

Write a header for a summary file

The header contains labels for each column of the summary CSV file. This function overwrites the current contents of the file.

source