OpenDrift / opendrift

Open source framework for ocean trajectory modelling
https://opendrift.github.io
GNU General Public License v2.0
245 stars 120 forks source link

Backwards buoyancy? #1076

Closed AndresSepulveda closed 1 year ago

AndresSepulveda commented 1 year ago

Hi,

Can the backwards trajectory be applied to a particle (e.g. larvae) with a given buoyancy or settling velocity?

I understand that u, v, and w are considered in a "backward" way, but does the settling velocity changes sign?

knutfrode commented 1 year ago

Hi,

Presently, the sign is not changed for the settling velocity. I believe a consideration for negative time step (as for advection) could be quite easily implemented. I can do that soon, if you find it worth to have?

For objects/elements with constant terminal velocity, the change could also be changed by the user at seed time. See e.g. this example: https://opendrift.github.io/gallery/example_vertical_mixing.html

AndresSepulveda commented 1 year ago

Hi Knut,

Yes, it would be great if you implement that. We would be using it.

knutfrode commented 1 year ago

Hi,

I did not check this before, but it actually turns out that the correct sign is applied also to buoyancy, through the internal multiplication of settling/rising speed with self.time_step.total_seconds()

You can test with this minimalistic example:

from datetime import datetime, timedelta
from opendrift.models.oceandrift import OceanDrift
o = OceanDrift(loglevel=50)
o.seed_elements(lon=3, lat=60, time=datetime.now(), z=-100, terminal_velocity=.01)
o.run(duration=timedelta(hours=3), time_step=600)
o.plot_property('z')

Here the particle with positive buoyancy (1 cm/s) rises from -100m to the surface within the 3 hours. If you change timestep in second last line to -600 (i.e. backwards simulation), it will instead sink to -200m So everything seems as it should be.

You can close this issue if you agree.

AndresSepulveda commented 1 year ago

Very cool, thanks.