Closed simonweppe closed 4 years ago
Hi, yes this is a known bug. I made now a fix (https://github.com/OpenDrift/opendrift/commit/0ddd8424b38734705c288e2cf5eca38e1e89d85a), which was simpler than I had anticipated. I added also a basic test, but some more interactive testing should also be done. So please report if you face any problems.
Hi KnutFrode. Thanks for the prompt reply !
I still have a couple of issues. I think it needs to also skip some code in the time loop of run()
. For now the code calls get_environment()
even if the number of elements is zero, and doesnt like it.
I've quickly tried adding something like this, line 2211 in basemodel.py
try:
# Release elements
self.release_elements()
if self.num_elements_active() == 0:
print(self.time)
self.time = self.time + self.time_step
continue
which seemed to do the trick, but have just realized now that the timesteps when there are no active elements are not correctly written to the netcdf file. I'll try to have a look later on.
The internal book-keeping is rather complicated, since there are many concerns: e.g. the calculation and output time steps are generally different, time step may be negative, for the non-stranding case one has to store the previous position of all elements, etc.
But I now shortcuted more of the run-loop, keeping only the parts which should be essential: https://github.com/OpenDrift/opendrift/commit/66eee1bea85c6aa6af8bfff3b6f4b4e10cf2f0ee
The test case was very basic, but when I add a reader it still works. Hopefully it also works for your case?
Some of the post-processing/analysis methods (including plot/animation methods) might still not work correctly with the new possibility that there are time steps with no active elements. However, this can be fixed after first making sure that at least the simulations complete.
So please report any further errors you might encounter.
Hi Knut-Frode - Yes I totally understand that...that's why I was a bit reticent to start messing with things in there. That new commit is fixing my issues - thanks for that.
Hi there, Im releasing particles at the start of each day as a one-off release. Sometimes all these particles will become deactivated because they may reach the shore or seabed for example. This makes the simulation stop, even though there are more particles to be released later on.
Is there a workaround to keep the simulation going ?
in basemodel.py line 2252
if self.num_elements_active() == 0: raise ValueError('No more active elements, quitting.')