FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
ViscousShip.h
1#ifndef CViscousShip_h__
2#define CViscousShip_h__
3
4#include <vector>
5#include "HelperFunctions.h"
6#include <deque>
7#include <string>
8
9#include <Eigen/Eigen>
10
11#include "HullData/HullData.h"
12namespace Ship{
14 {
15 public :
16 enum EFileType
17 {
18 FILE_TYPE_VERES,
19 FILE_TYPE_WAMIT
20 };
21
23
24 void SetupFromFile( std::string fname, EFileType type, HullData *H);
25
26 void SetHullData( HullData *HD ){ myHullData = HD; }
27 // 0 = ITTC, 1= SeaWay
28 void SetTheoryFormulation( int theory ){ rollDampingTheory = theory;}
29 // The window [s] of the roll amplitude: the amplitude is the largest |roll| of the last @p horizon seconds. It is also
30 // the roll period of the ITTC friction coefficient. Must be positive (set it before the first AddToRollTimeHistory)
32 void SetManoeuvreMinSpeed(double speed){m_manoeuvreMinSpeed = speed;}
33 void SetPhiAmplitudeHorizon(double horizon){phiAmplitudeHorizon = horizon;}
34
35
36 void GetViscousAddedMass(double u, double v, double r, Eigen::Matrix3d &Mat) const;
37
38 double GetViscousSurge(double u, double v, double r) const;
39 double GetViscousSway(double u, double v, double r) const;
40 double GetViscousYaw(double u, double v, double r) const;
41
42 double GetViscousRoll(double phiDot, double u = 0) const;
44 bool IsSkegStation( int station ) const;
45 double EddieDamping( double phiDot, double u = 0) const;
46 double BilgeKeelDamping( double phiDot, double u = 0) const;
47 double FricitonDamping( double phiDot, double u = 0) const;
48 double LiftDamping( double phiDot, double u = 0) const;
49 double SkegDamping( double phiDot, double u = 0) const;
50
51 double SkegLiftDamping( double phiDot, double u ) const;
52
54 double RollAmplitude() const { return phiAmplitude; }
55 void AddToRollTimeHistory( const double T, double RollAngle, const bool bIsMajorTimeStep );
57 bool MakeBildgeKeel( double m_BilgeKeelStartPosition, double m_BilgeKeelEndPosition, double m_BilgeKeelHeight );
59 void SetSkeg( int startSection, int endSection, const std::vector<int>& startPoints, const std::vector<int>& endPoints );
62
63 void SetHorizontalDampingBlend(double blendSpeed, double blendFraction=0.5);
64 void SetDpDampingX(double Xu, double Xv, double Xr);
65 void SetDpDampingY(double Yu, double Yv, double Yr);
66 void SetDpDampingN(double Nu, double Nv, double Nr);
67
69 const std::vector<double>& GetSectionLength() const { return SectionLength; }
70
71 double ManeuverReferenceSpeed() const { return m_maneuverReferenceSpeed; }
72 void ManeuverReferenceSpeed(double val) { m_maneuverReferenceSpeed = val; }
73 protected:
74
75 double deltaWingKP(double A_ratio) const;
76 double deltaWingKV(double A_ratio) const;
77 double deltaWingCL(double alfa, double Kp, double Kv) const;
78
79 double ManoeuvreSpeed(double u) const;
80 double m_manoeuvreMinSpeed = 0.1;
81 double m_maneuverReferenceSpeed;
82 double m_viscousDampingBlender;
83
84 public:
85 // The coefficients the ship sets from its parameters
86 double Yv_man, Yr_man, Yrd_man, Yvd_man;
87 double Nv_man, Nr_man, Nrd_man, Nvd_man;
88 double Xrr_man, Xud_man, Xvr_man, Xvv_man, Xvvvv_man;
89
90 double Xu_dp, Yu_dp, Nu_dp;
91 double Xv_dp, Yv_dp, Nv_dp;
92 double Xr_dp, Yr_dp, Nr_dp;
93 int m_withSkeg;
94 bool m_skegLift;
95 bool m_hullLift;
96 protected:
97
98 int m_bilgeKeelStartSection;
99 int m_bilgeKeelEndSection;
100 double m_startSectionFractionBK;
101 double m_endSectionFractionBK;
102
103 int rollDampingTheory;
104
105 int SkegStartSection;
106 int SkegEndSection;
107 std::vector<int> SkegStartPoints;
108 std::vector<int> SkegEndPoints;
109
110 protected:
111 void ReadMainDimensionsVeres( std::string fname );
112 void ReadMainDimensionsWamit( std::string fname );
113 HullData *myHullData;
114
115 double surfaceOfHull;
116 double kinematicViscosity;
117
118 std::vector<double> bilgeKeelHeight;
119
120 std::vector<double> Ds;
121 std::vector<double> Bs;
122 std::vector<double> H0;
123 std::vector<double> SigmaS;
124 std::vector<double> A1;
125 std::vector<double> A3;
126 std::vector<double> Ms;
127
128 double Lpp = kNotRead, B = kNotRead, T = kNotRead;
129 double Cb = kNotRead, VCG = kNotRead;
130
131 double Lo,Lr,Kn;
132
133 std::vector<double> SectionLength;
134 std::deque<double> phi_history;
135 std::deque<double> time_history;
136 double phiAmplitude;
137 double phiAmplitudeTime;
138 double m_rf;
139 double OG;
140 double phiAmplitudeHorizon = 2.75*3.1622776601683795;
141 int numberOfStations;
142 };
143}
144#endif // CViscousShip_h__
Definition HullData.h:15
Definition ViscousShip.h:14
void SetManoeuvreMinSpeed(double speed)
Smallest speed [m/s] in v/u and r Lpp/u of the manoeuvring terms (the speed is held to it); must be p...
Definition ViscousShip.h:32
bool HullHasTheSkegStations() const
True when the hull has more than SkegEndSection stations and every skeg station has more vertices tha...
double phiAmplitudeHorizon
2.75 sqrt(10) s, as before the horizon was read
Definition ViscousShip.h:140
bool MakeBildgeKeel(double m_BilgeKeelStartPosition, double m_BilgeKeelEndPosition, double m_BilgeKeelHeight)
False (and no bilge keel) when a start or end station of the range has no neighbour station on both s...
double RollAmplitude() const
The roll amplitude of the history: the largest value of |roll| within the amplitude horizon.
Definition ViscousShip.h:54
const std::vector< double > & GetSectionLength() const
The length of each station's section (half the spacing to each neighbour)
Definition ViscousShip.h:69
void SetSkeg(int startSection, int endSection, const std::vector< int > &startPoints, const std::vector< int > &endPoints)
Sets the skeg stations startSection..endSection and, per station, the first and last vertex index of ...
bool IsSkegStation(int station) const
True when the skeg is on (WithSkeg not 0) and station is one of its stations: the eddy damping is zer...
Simple waypoint object.
Definition CableAttach.h:58
constexpr double kNotRead
The value of a dimension that has not been read from a file yet.
Definition HelperFunctions.h:16