FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
DiskDrag.h
1#pragma once
4
5#include "DiskBase.h"
6
7#include <cmath>
8
10namespace disk_drag
11{
14{
15 double normal;
16 double tangential;
17};
18
29inline DragFactors Factors(double rho, double cdNormal, double cdTangential, double diskD, double diskT, double cableD)
30{
31 return {DiskBase::DragForceNormal(rho, cdNormal, diskD, diskT, cableD, 1.0, 1.0),
32 DiskBase::DragForceTangential(rho, cdTangential, diskD, diskT, cableD, 1.0, 1.0)};
33}
34
42inline void Decompose(const double n[3], const double v[3], double vNormal[3], double vTang[3])
43{
44 const double along = n[0] * v[0] + n[1] * v[1] + n[2] * v[2];
45 for (int i = 0; i < 3; i++) {
46 vNormal[i] = along * n[i];
47 vTang[i] = v[i] - vNormal[i];
48 }
49}
50
52inline double Norm(const double w[3])
53{
54 return std::sqrt(w[0] * w[0] + w[1] * w[1] + w[2] * w[2]);
55}
56
67inline void DragForce(const double n[3], const double relVel[3], const DragFactors& k, double force[3])
68{
69 double vNormal[3], vTang[3];
70 Decompose(n, relVel, vNormal, vTang);
71 const double speedNormal = Norm(vNormal);
72 const double speedTang = Norm(vTang);
73 for (int i = 0; i < 3; i++)
74 force[i] = -k.normal * speedNormal * vNormal[i] - k.tangential * speedTang * vTang[i];
75}
76
88inline void DragVelocityJacobian(const double n[3], const double relVel[3], const DragFactors& k, double dForceDv[9])
89{
90 double vNormal[3], vTang[3];
91 Decompose(n, relVel, vNormal, vTang);
92 const double speedNormal = Norm(vNormal);
93 const double speedTang = Norm(vTang);
94 for (int i = 0; i < 3; i++) {
95 for (int j = 0; j < 3; j++) {
96 const double identity = (i == j) ? 1.0 : 0.0;
97 const double projNormal = n[i] * n[j];
98 const double projTang = identity - projNormal;
99 double dNormal = speedNormal * projNormal;
100 if (speedNormal > 0.0) dNormal += vNormal[i] * vNormal[j] / speedNormal;
101 double dTang = speedTang * projTang;
102 if (speedTang > 0.0) dTang += vTang[i] * vTang[j] / speedTang;
103 dForceDv[3 * i + j] = -k.normal * dNormal - k.tangential * dTang;
104 }
105 }
106}
107} // namespace disk_drag
Quadratic drag on a Net/Disk (MARE-0098).
Definition DiskDrag.h:11
void Decompose(const double n[3], const double v[3], double vNormal[3], double vTang[3])
Splits a velocity into its components along and across the disk axis.
Definition DiskDrag.h:42
double Norm(const double w[3])
Euclidean length of a 3-vector.
Definition DiskDrag.h:52
void DragForce(const double n[3], const double relVel[3], const DragFactors &k, double force[3])
The drag force on the disk (lead ruling R24).
Definition DiskDrag.h:67
DragFactors Factors(double rho, double cdNormal, double cdTangential, double diskD, double diskT, double cableD)
The drag factors of a disk, with the areas of DiskBase.
Definition DiskDrag.h:29
void DragVelocityJacobian(const double n[3], const double relVel[3], const DragFactors &k, double dForceDv[9])
The derivative of DragForce with respect to relVel, for a fixed axis.
Definition DiskDrag.h:88
The factor ½ρCA of each drag component.
Definition DiskDrag.h:14
double tangential
½ρ C_t A_t, with the edge area A_t [kg/m].
Definition DiskDrag.h:16
double normal
½ρ C_n A_n, with the face area A_n [kg/m].
Definition DiskDrag.h:15