Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support output for dt < 1 #439

Merged
merged 1 commit into from
Oct 23, 2021
Merged

support output for dt < 1 #439

merged 1 commit into from
Oct 23, 2021

Conversation

trontrytel
Copy link
Member

When running with dt < 1s we generate no output. This is because our output is decided based on:

if mod(sim.TS.t, sim.Stats.frequency) == 0

which runs into rounding errors when the arguments are not integers. Seems like the namelist key is labelled frequency, but we use it in the code more like output interval.

We could instead start using it like this (i.e. more like a frequency - "every how many steps we should do output)". This way we would avoid floating point issues:

if mod(iter, sim.Stats.frequency) == 0

If we want to keep the current output specification, some ugly workaround solution could look like this:

if (sim.TS.t - sim.Stats.frequency * div(sim.TS.t, sim.Stats.frequency, RoundNearest)) < eps(1.0) * sim.TS.t_max

Let me know what you think. If we go with the integer friendly way I'm not sure if I should change something more in the NetCDF io files.

Copy link
Member

@charleskawczynski charleskawczynski left a comment

Choose a reason for hiding this comment

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

This looks fine to me (assuming that the output frequency translates well for the plots). I suppose this will all disappear when we use OrdinaryDiffEq for timestepping since they have an API for callback frequency.

@ilopezgp
Copy link
Contributor

I prefer having the output frequency as time units, not timestep units. If this is difficult using seconds, we can just use milliseconds internally.

@trontrytel
Copy link
Member Author

Looks like we want to keep specifying output in seconds and not time steps. @charleskawczynski are you ok with the proposed alternative to mod?

@charleskawczynski
Copy link
Member

Looks like we want to keep specifying output in seconds and not time steps. @charleskawczynski are you ok with the proposed alternative to mod?

I'm fine with that if it works

@trontrytel
Copy link
Member Author

Ended up with this:

if mod(round(Int, sim.TS.t), round(Int, sim.Stats.frequency)) == 0

It does not change the behaviour for cases where dt is an int. And provides a reasonable output for cases there dt < 1

@trontrytel
Copy link
Member Author

bors r+

@bors
Copy link
Contributor

bors bot commented Oct 23, 2021

Build succeeded:

@bors bors bot merged commit daf6597 into main Oct 23, 2021
@bors bors bot deleted the aj/output_frequency branch October 23, 2021 00:11
charleskawczynski referenced this pull request Oct 25, 2021
449: Bump version for new release r=charleskawczynski a=charleskawczynski



Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants