Skip to content

Commit

Permalink
feat: Summary stats can depend on constants
Browse files Browse the repository at this point in the history
Allow summary statistics to depend on constants in the simulation.  This
allows correct calculation of statistics like the gravitational
potential energy.

BREAKING CHANGE: Custom summary statistics will need fixing.
  • Loading branch information
musoke committed Mar 22, 2022
1 parent 8fdfc0d commit 1e8ad49
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "UltraDark"
uuid = "1c8d022d-dfc0-4b41-80ab-3fc7e88cdfea"
authors = ["Nathan Musoke <[email protected]>"]
version = "0.3.0"
version = "0.4.0"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand Down
2 changes: 1 addition & 1 deletion src/UltraDark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function take_steps!(grids, t_start, Δt, n, output_config, a, constants)
add_external_potential!(t, grids, constants)
auxiliary_step!(Δt, grids, t, constants)

output_summary_row(grids, output_config, t, a(t), Δt)
output_summary_row(grids, output_config, t, a(t), Δt, constants)
end

outer_step!(Δt/2, grids, constants)
Expand Down
12 changes: 6 additions & 6 deletions src/summary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ end
Write a new row to the summary file
"""
function output_summary_row(grids, output_config, t, a, Δt)
summary = output_config.summary_statistics(Dates.now(), t, a, Δt, grids)
function output_summary_row(grids, output_config, t, a, Δt, constants)
summary = output_config.summary_statistics(Dates.now(), t, a, Δt, grids, constants)
line = generate_summary_row(summary)
open(joinpath(output_config.directory, "summary.csv"), "a") do file
write(file, line)
Expand All @@ -50,10 +50,10 @@ Write a new row to the summary file
If the grids is a PencilGrids, this uses `MPI.Reduce` to compute partial
summaries in each task and combine them.
"""
function output_summary_row(grids::PencilGrids, output_config, t, a, Δt)
function output_summary_row(grids::PencilGrids, output_config, t, a, Δt, constants)
root = 0
summary = MPI.Reduce(
output_config.summary_statistics(Dates.now(), t, a, Δt, grids),
output_config.summary_statistics(Dates.now(), t, a, Δt, grids, constants),
pool_summarystat,
root,
grids.MPI_COMM
Expand Down Expand Up @@ -83,7 +83,7 @@ struct SummaryStatistics
Δt::Float64
end

function SummaryStatistics(wall_time, sim_time, a, Δt, grids)
function SummaryStatistics(wall_time, sim_time, a, Δt, grids, constants)
SummaryStatistics(wall_time, sim_time, a, Δt)
end

Expand Down Expand Up @@ -111,7 +111,7 @@ struct SummaryStatisticsMeanMaxRms
n::Int64
end

function SummaryStatisticsMeanMaxRms(wall_time, sim_time, a, Δt, grids)
function SummaryStatisticsMeanMaxRms(wall_time, sim_time, a, Δt, grids, constants)
ρx_mean = mean(grids.ρx)
ρx_max = maximum(grids.ρx)
δx_rms = mean(((grids.ρx .- ρx_mean).^2))^0.5
Expand Down

2 comments on commit 1e8ad49

@musoke
Copy link
Owner Author

@musoke musoke commented on 1e8ad49 Mar 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/57051

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.0 -m "<description of version>" 1e8ad49898d5fafd4a699e74405e0ab5afb01ded
git push origin v0.4.0

Please sign in to comment.