Skip to content

Commit

Permalink
Zero-initialise the dSdt array
Browse files Browse the repository at this point in the history
  • Loading branch information
johnomotani committed Nov 26, 2023
1 parent cc3e880 commit e16e04c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/initial_conditions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ function init_pdf_and_moments!(pdf, moments, boundary_distributions, geometry,
end
end

# Zero-initialise the dSdt diagnostic to avoid writing uninitialised values, as the

This comment has been minimized.

Copy link
@mrhardman

mrhardman Nov 26, 2023

Collaborator

Something that I think I had arranged in the original development branch was the initialisation of dSdt with data from the restart/output files if the simulation is restarting. I think if you restart a simulation at the moment then dSdt isn't calculated correctly for the first time point (it can only be computed during the time advance, so we lack the data for t = 0. Fixing this could be an optimisation, but it doesn't actually affect anything except the diagnostics.

This comment has been minimized.

Copy link
@johnomotani

johnomotani Nov 26, 2023

Author Collaborator

This 'fix' is only for the non-restarting branch - reloading dSdt when restarting seems like the right thing to do.

The t=0 output is written before the first euler_time_advance!() is called, so the collision operator hasn't been calculated, so there is no sensible value to write for dSdt. I think before this commit we were writing uninitialised values (there's a debug option that checks for that, which was throwing an error, which is why I noticed this to add an intialisation). Doesn't really make a difference (apart from avoiding triggering the debug check), since we should know to ignore dSdt from the t=0 output, but it's probably nicer to always have zeros written than to write out the random numbers from an uninitialised array. We could also initialise with NaN, but I was worried that might break some plotting or analysis routine...

# collision operator will not be calculated before the initial values are written to
# file.
@serial_region begin
moments.charged.dSdt .= 0.0
end

init_boundary_distributions!(boundary_distributions, pdf, vz, vr, vzeta, vpa, vperp,
z, r, composition)

Expand Down

0 comments on commit e16e04c

Please sign in to comment.