FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
CNorrbinTanker.h
1#ifndef CNorrbinTanker_H
2#define CNorrbinTanker_H
3
171#include <Eigen/Eigen>
172
173#include <fhsim/simobject/SimObject.h>
174#include <fhsim_environment/BodyFlowInteraction.h>
175#include <fhsim_environment/EnvironmentProvider.h>
176#include <fhsim_environment/WakeSourceSet.h>
177#include <string>
178
179
180class CNorrbinTanker : public SimObject
181{
182 public:
183 EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
184
186 CNorrbinTanker(std::string sSimObjectName, ISimObjectCreator* pCreator);
187
188 void FinalSetup(const double T, const double* const X, ISimObjectCreator* const creator);
189
190 void OdeFcn(const double dT, const double* const adX, double* const adXDot) const;
191
193 void PreOdeFcn(double T, const double* X) override;
194
195#ifdef FH_VISUALIZATION
197 virtual void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator);
198
200 virtual void RenderUpdate(const double T, const double* const X);
201#endif
202
203 static double* tanker_CX; // wind drag coefficient surge
204 static double* tanker_CY; // wind drag coefficient sway
205 static double* tanker_CN; // wind drag coefficient yaw
206 static double* tanker_CK; // wind drag coefficient roll
207
208 Eigen::Matrix<double, 1, 9> DWT;
209 Eigen::Matrix<double, 1, 9> DISPL;
210 Eigen::Matrix<double, 1, 9> Lpp;
211 Eigen::Matrix<double, 1, 9> B;
212 Eigen::Matrix<double, 1, 9> D;
213 Eigen::Matrix<double, 1, 9> TT;
214 Eigen::Matrix<double, 1, 9> U0;
215 Eigen::Matrix<double, 1, 9> RPM0;
216
217 Eigen::Matrix<double, 1, 9> T;
218
219 Eigen::Matrix<double, 1, 9> Xdu;
220 Eigen::Matrix<double, 1, 9> Xuu;
221 Eigen::Matrix<double, 1, 9> Xvr;
222 Eigen::Matrix<double, 1, 9> Xvv;
223
224 Eigen::Matrix<double, 3, 9> Xccdd;
225 Eigen::Matrix<double, 1, 9> Xccbd;
226
227
228 Eigen::Matrix<double, 1, 9> Xduz;
229 Eigen::Matrix<double, 1, 9> Xuuz;
230 Eigen::Matrix<double, 1, 9> Xvrz;
231 Eigen::Matrix<double, 1, 9> Xvvzz;
232
233 Eigen::Matrix<double, 1, 9> Ydv;
234 Eigen::Matrix<double, 1, 9> Yur;
235 Eigen::Matrix<double, 1, 9> Yuv;
236 Eigen::Matrix<double, 1, 9> Yvv;
237
238 Eigen::Matrix<double, 3, 9> Yccd;
239 Eigen::Matrix<double, 1, 9> Yccbbd;
240
241 Eigen::Matrix<double, 1, 9> Yt;
242
243 Eigen::Matrix<double, 1, 9> Ydvz;
244 Eigen::Matrix<double, 1, 9> Yurz;
245 Eigen::Matrix<double, 1, 9> Yuvz;
246 Eigen::Matrix<double, 1, 9> Yvvz;
247 Eigen::Matrix<double, 1, 9> Yccbbdz;
248
249 Eigen::Matrix<double, 1, 9> kk_Ndr;
250 Eigen::Matrix<double, 1, 9> Nur_xg;
251 Eigen::Matrix<double, 1, 9> Nuv;
252 Eigen::Matrix<double, 1, 9> Nvr;
253
254 Eigen::Matrix<double, 3, 9> Nccd;
255
256 Eigen::Matrix<double, 1, 9> Nccbbd;
257 Eigen::Matrix<double, 1, 9> Nt;
258
259 Eigen::Matrix<double, 1, 9> Ndrz;
260 Eigen::Matrix<double, 1, 9> Nurz;
261 Eigen::Matrix<double, 1, 9> Nuvz;
262 Eigen::Matrix<double, 1, 9> Nvrz;
263 Eigen::Matrix<double, 1, 9> Nccbbdz;
264
265 Eigen::Matrix<double, 1, 9> Tuu;
266 Eigen::Matrix<double, 1, 9> Tun;
267 Eigen::Matrix<double, 1, 9> Tnn;
268
269 // C equation
270 Eigen::Matrix<double, 1, 9> Cun;
271 Eigen::Matrix<double, 1, 9> Cnn;
272
273 // Q equation
274 Eigen::Matrix<double, 1, 9> kk_Qn;
275 Eigen::Matrix<double, 1, 9> Qf;
276 Eigen::Matrix<double, 1, 9> Quu;
277 Eigen::Matrix<double, 1, 9> Qun;
278 Eigen::Matrix<double, 1, 9> Qnn;
279 Eigen::Matrix<double, 1, 9> Qn;
280 Eigen::Matrix<double, 1, 9> Qmu;
281
282 protected:
283 int m_indexStateRPM;
284 int m_indexStateDelta;
285 int m_indexStateVelocity;
286 int m_indexStateOmega;
287 int m_indexStateRotation;
288 int m_indexStatePosition;
289 double m_rhoWater;
290
294 class TankerCaster final : public environment::wake::PropelledObject
295 {
296 public:
297 explicit TankerCaster(const CNorrbinTanker& tanker)
298 : m_tanker(tanker)
299 {
300 }
301
303 environment::wake::WakeCastState Reference(double T, const double* X) const override;
305 void CurrentLoad(double T, const double* X, const double freeStream[3], const double flowDir[3], double force[3], double& frontalArea,
306 double rearCentre[3]) const override;
308 environment::wake::PropellerJetInput PropellerJet(double T, const double* X) const override;
309
310 private:
311 const CNorrbinTanker& m_tanker;
312 };
313
315 environment::wake::BodyFlowInteraction m_flow;
316 double m_propellerDiameter = 0.0;
317 double m_propellerPosition[3] = {0.0, 0.0, 0.0};
318
320 void SetUpWakes(ISimObjectCreator* creator);
321
323 void HullInflow(double T, const double* X, double current[3]) const;
324
325 virtual const double* Position(const double dT, const double* const adX);
326 virtual const double* Velocity(const double dT, const double* const adX);
327 virtual const double* Rotation(const double dT, const double* const adX);
328 virtual const double* Omega(const double dT, const double* const adX);
329
330 ISignalPort* m_InEngineControl;
331 ISignalPort* m_InRudderControl;
332
333 double comp_beta(double u, double v) const;
334 double comp_c(double u, double n) const;
335 double comp_ndot(double u, double n, double my) const;
336 double compute_gT(double u, double n) const;
337
338 double rudder_gln(double beta, double c, double delta, double z) const;
339 double rudder_gy(double beta, double c, double delta, double z) const;
340 double rudder_gx(double beta, double c, double delta) const;
341
342 double comp_Yuv(double z) const;
343 double comp_m11(double z) const;
344 double comp_m22(double z) const;
345 double comp_m33(double z) const;
346 double nlin_N(double u, double v, double r, double z) const;
347 double nlin_Y(double u, double v, double r, double z) const;
348 double nlin_X(double u, double v, double r, double z) const;
350 double HullSurgeLoad(double u, double v, double r, double z) const;
351
352 public:
353 bool HasJacobians() const override;
354 void OdeJacobian(double simTime, const double* X, double* J, int nStates) override;
355 int GetJacobianSparsity(int nStates, int* rowPtr, int* colIdx) override;
356
357 unsigned int m_tankerType;
358 unsigned int m_rudderType;
359
360 ISignalPort* m_pInForce;
361 ISignalPort* m_pInTorque;
362
363 environment::EnvironmentProvider* m_Environment;
364
365#ifdef FH_VISUALIZATION
366 std::string m_sMaterial;
367 std::string m_sMeshName;
368 double m_dScale;
369 Ogre::Entity* m_pRenderEntity;
370 Ogre::SceneNode* m_pRenderNode;
371 Ogre::SceneManager* m_pSceneMgr;
372
374 void AttachHullMesh(const Ogre::Vector3& userScale);
375#endif
376};
377
378
379#endif
Definition CNorrbinTanker.h:295
void CurrentLoad(double T, const double *X, const double freeStream[3], const double flowDir[3], double force[3], double &frontalArea, double rearCentre[3]) const override
rho DISPL (HullSurgeLoad, nlin_Y) at the free stream, rotated to NED: no thrust, rudder or external f...
environment::wake::PropellerJetInput PropellerJet(double T, const double *X) const override
The propeller at PropellerPos, shaft along the body x axis, T_eff = rho DISPL gT (1 - t),...
environment::wake::WakeCastState Reference(double T, const double *X) const override
The Position and Velocity states.
Definition CNorrbinTanker.h:181
ISignalPort * m_pInForce
A pointer to the input force.
Definition CNorrbinTanker.h:360
CNorrbinTanker(std::string sSimObjectName, ISimObjectCreator *pCreator)
The constructor sets the pointer to the output object and the parser object.
environment::wake::BodyFlowInteraction m_flow
The hull wake and jet the tanker casts and the wakes it receives; still water without an Environment ...
Definition CNorrbinTanker.h:315
void HullInflow(double T, const double *X, double current[3]) const
The water velocity at the hull without the waves, its own wake and jet excluded; zero without an Envi...
double m_propellerDiameter
D_p [m]; with CastWake, from PropellerDiameter or 0.65 TT in FinalSetup.
Definition CNorrbinTanker.h:316
void PreOdeFcn(double T, const double *X) override
With an Environment: rebuilds the cast hull wake and jet when due and takes the other objects' wakes ...
double HullSurgeLoad(double u, double v, double r, double z) const
nlin_X with u|u| for u^2 in the Xuu and Xuuz term, for the hull wake's load only: the resistance oppo...
TankerCaster m_caster
The tanker for its wakes; declared before m_flow, which keeps a pointer to it.
Definition CNorrbinTanker.h:314
void SetUpWakes(ISimObjectCreator *creator)
Reads the propeller parameters' defaults and registers the wakes in the Environment,...
ISignalPort * m_pInTorque
A pointer to the input force.
Definition CNorrbinTanker.h:361
double m_propellerPosition[3]
Propeller centre in the body frame, z down [m]; with CastWake, from PropellerPos or (-Lpp/2,...
Definition CNorrbinTanker.h:317
double m_rhoWater
Water density the force and torque inputs are normalised with [kg/m^3] (BASE-0054).
Definition CNorrbinTanker.h:289