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