opendrift icon indicating copy to clipboard operation
opendrift copied to clipboard

Negative sign of xleeway velocity in leeway module

Open Kostas84B opened this issue 4 years ago • 4 comments

Dear Knut-Frode, good morning! I am a new user of Opendrift, and I would like to why do you insert -x_leeway instead of x_leeway in self.update_positions in leeway.py?

Kostas84B avatar Apr 28 '21 07:04 Kostas84B

Good morning Kostas!

I agree that this looks a bit strange. However, it is a consequence of the choices that have been made in the previous lines, in particular:

winddir = np.arctan2(self.environment.x_wind, self.environment.y_wind)
....
sinth = np.sin(winddir)
costh = np.cos(winddir)
....
x_leeway = -downwind_leeway*sinth+crosswind_leeway*costh

The last definition of x_leeway could have used opposite signs to make it positive eastwards, and not westwards, which explains the need for the - before x_leeway in the call to update_positions. So this is simply a consequence of the way the geometrical helper drawing was made a long time ago. I don't have this drawing at hand, but you may check that it gives correct results with the following snippet:

from datetime import datetime, timedelta
from opendrift.models.leeway import Leeway
lw = Leeway()
lw.set_config('environment:constant:x_sea_water_velocity', 0)
lw.set_config('environment:constant:y_sea_water_velocity', 0)
lw.set_config('environment:constant:x_wind', 10)  # eastwards wind
lw.set_config('environment:constant:y_wind', 0)
lw.seed_elements(lon=2, lat=60, number=1000, time=datetime.now(), object_type=26)
lw.run(duration=timedelta(hours=48))
lw.plot(fast=True)

So if you remove the - in the call to update_positions, you will get westwards drift, instead of eastwards as expected.

knutfrode avatar Apr 29 '21 10:04 knutfrode

Thanks!

I see. So, in case I want to add an extra velocity (let's say a paddling velocity along the direction of object motion) I could do it using the negative sign as follows:

#first define the direction of motion w.r.t the east direction theta_11 = np.arctan( (y_leeway+self.environment.y_sea_water_velocity) / (self.environment.x_sea_water_velocity-x_leeway) ) #add an x and y velocity component to the already velocity components due to wind and ambient currents x_pad = cacc * np.cos(theta_11) y_pad = cacc * np.sin(theta_11) self.update_positions(x_pad, y_pad)

Kostas84B avatar Apr 29 '21 12:04 Kostas84B

This seems to make sense. But you could do some simple sensitivity tests like the sample above to check whether it works as you intended.

knutfrode avatar Apr 29 '21 12:04 knutfrode

Thanks for the help!!

Kostas84B avatar Apr 29 '21 12:04 Kostas84B