FloatingArrayDesign / MoorDyn

a lumped-mass mooring line model intended for coupling with floating structure codes
BSD 3-Clause "New" or "Revised" License
64 stars 37 forks source link

Body negative local drag coefficients #205

Closed AlexWKinley closed 2 months ago

AlexWKinley commented 2 months ago

Strictly speaking, this is a bug that I encountered on our internal MoorDyn fork, which is somewhat out of date. I don't see anything in the latest public code that would address this, but I haven't directly tested this behavior with the latest branch of this repo.

When bodies are in certain orientations, the computed global drag coefficients can end up having negative values.

The code at fault is https://github.com/FloatingArrayDesign/MoorDyn/blob/99cd2b6e6afa7e5d58e2ac7ac3a4b05e127f1f72/source/Body.cpp#L496-L501

An example of a case where this fails to work is when the body's pitch is -90 degrees. The rotation matrix in this case will be

[  0.0,  0.0, -1.0;
   0.0,  1.0,  0.0;
   1.0,  0.0,  0.0 ]

The cda variable will look like bodyCda * [1, 1, -1, 1, 1, -1]. Which leads to a negative drag coefficient in the z axis, which is a destabilizing force that is both not physical and will eventually cause the simulation to error out.

I'm making this issue because I'm not sure what the correct solution to this issue is. I think it's valid to just take the absolute value of the rotated drag coefficients, but I'll defer to others for how they want to address this.