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

Bug for asynchronous specs of skip_step and save_every in ExportCallBack #128

Closed
mstoelzle opened this issue Jul 4, 2022 · 1 comment · Fixed by #125
Closed

Bug for asynchronous specs of skip_step and save_every in ExportCallBack #128

mstoelzle opened this issue Jul 4, 2022 · 1 comment · Fixed by #125
Labels
bug Something isn't working
Milestone

Comments

@mstoelzle
Copy link
Contributor

Describe the bug
If save_every is not a multiple of step_skip, the condition (current_step + 1) % self.save_every == 0 (https://github.com/GazzolaLab/PyElastica/blob/master/elastica/callback_functions.py#L205) will never be trigged and the data will never be saved, if the condition about the buffer size does not become active neither.

To Reproduce
This code snippet below has a time-step of 0.1ms. It should save the data to the buffer every 20ms and it should dump the buffer to the file every 1.0001ms.

dt = 1e-4
step_skip = 2e2
save_every = 10001
callback = ExportCallBack(step_skip, ".", "tempfile", save_every=10)
simulator.collect_diagnostics(stretchable_rod).using(
     callback, 
     step_skip=step_skip, 
     path=".", method="tempfile", 
     save_every=save_every,
)

However, in this case the (current_step + 1) % self.save_every == 0 will never be triggered, as it never reaches there as this time-step is skipped by step_skip=2e2. PR #125 would fix this.

Environment

  • Python=3.10.5, pip=22.1.2
  • Numpy/numba version: 22.1.2
  • PyElastica version: 0.2.3
  • OS, Device: macOS / macBook Pro 15'' 2019

Expected behavior
By specifying save_every, the data should be saved every save_every time-steps, irrespective of the chosen skip_step setting.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

@mstoelzle mstoelzle added the bug Something isn't working label Jul 4, 2022
@skim0119 skim0119 linked a pull request Jul 4, 2022 that will close this issue
skim0119 added a commit that referenced this issue Jul 4, 2022
* Fix bug with `save_every` condition in ExportCallBack
* minimizing any potential delays for saving into storage

Co-authored-by: Seung Hyun Kim <[email protected]>
@skim0119
Copy link
Collaborator

skim0119 commented Jul 4, 2022

Resolved with #128.

@skim0119 skim0119 closed this as completed Jul 4, 2022
@skim0119 skim0119 added this to the Version 0.2.4 milestone Jul 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants