71 Name =
"FGAccelerations";
74 vPQRidot.InitMatrix();
75 vUVWidot.InitMatrix();
77 vBodyAccel.InitMatrix();
96 vPQRidot.InitMatrix();
97 vUVWidot.InitMatrix();
99 vBodyAccel.InitMatrix();
112 if (Holding)
return false;
118 CalculateFrictionForces(
in.DeltaT *
rate);
138void FGAccelerations::CalculatePQRdot(
void)
145 double invRadius = 1.0 /
R.Magnitude();
161 vPQRidot =
in.Jinv * (
in.Moment -
in.vPQRi * (
in.J *
in.vPQRi));
162 vPQRdot = vPQRidot -
in.vPQRi * (
in.Ti2b *
in.vOmegaPlanet);
183void FGAccelerations::CalculateUVWdot(
void)
186 vBodyAccel.InitMatrix();
188 vBodyAccel =
in.Force /
in.Mass;
190 vUVWdot = vBodyAccel - (
in.vPQR + 2.0 * (
in.Ti2b *
in.vOmegaPlanet)) *
in.vUVW;
193 vUVWdot -=
in.Ti2b * (
in.vOmegaPlanet * (
in.vOmegaPlanet *
in.vInertialPosition));
198 vUVWidot =
in.vOmegaPlanet * (
in.vOmegaPlanet *
in.vInertialPosition);
199 vUVWdot.InitMatrix();
202 vUVWdot +=
in.Tec2b *
in.vGravAccel;
203 vUVWidot =
in.Tb2i * vBodyAccel +
in.Tec2i *
in.vGravAccel;
212 vUVWidot =
in.vOmegaPlanet * (
in.vOmegaPlanet *
in.vInertialPosition);
213 vUVWdot.InitMatrix();
214 vPQRidot =
in.vPQRi * (
in.Ti2b *
in.vOmegaPlanet);
215 vPQRdot.InitMatrix();
232void FGAccelerations::CalculateFrictionForces(
double dt)
235 size_t n = multipliers.size();
243 vector<double> a(n*n);
244 vector<double> rhs(n);
247 for (
unsigned int i=0;
i < n;
i++) {
253 for (
unsigned int j=0; j <
i; j++)
256 for (
unsigned int j=
i; j < n; j++) {
257 U = multipliers[j]->ForceJacobian;
258 r = multipliers[j]->LeverArm;
266 FGColumnVector3 vdot = vUVWdot;
268 vdot += (
in.vUVW -
in.Tec2b *
in.TerrainVelocity) / dt;
271 FGColumnVector3 wdot = vPQRdot;
273 wdot += (
in.vPQR -
in.Tec2b *
in.TerrainAngularVel) / dt;
279 for (
unsigned int i=0;
i < n;
i++) {
281 FGColumnVector3 U = multipliers[
i]->ForceJacobian;
282 FGColumnVector3 r = multipliers[
i]->LeverArm;
286 for (
unsigned int j=0; j < n; j++)
291 for (
int iter=0; iter < 50; iter++) {
294 for (
unsigned int i=0;
i < n;
i++) {
295 double lambda0 = multipliers[
i]->value;
296 double dlambda = rhs[
i];
298 for (
unsigned int j=0; j < n; j++)
299 dlambda -= a[
i*n+j]*multipliers[j]->value;
301 multipliers[
i]->value =
Constrain(multipliers[
i]->Min, lambda0+dlambda, multipliers[
i]->Max);
302 dlambda = multipliers[
i]->value - lambda0;
304 norm += fabs(dlambda);
307 if (norm < 1E-5)
break;
312 for (
unsigned int i=0;
i< n;
i++) {
313 double lambda = multipliers[
i]->value;
314 FGColumnVector3 U = multipliers[
i]->ForceJacobian;
315 FGColumnVector3 r = multipliers[
i]->LeverArm;
317 FGColumnVector3 F = lambda * U;
318 vFrictionForces += F;
319 vFrictionMoments += r * F;
322 FGColumnVector3 accel = vFrictionForces /
in.Mass;
323 FGColumnVector3 omegadot =
in.Jinv * vFrictionMoments;
327 vUVWidot +=
in.Tb2i * accel;
329 vPQRidot += omegadot;
339 CalculateFrictionForces(0.);
344void FGAccelerations::bind(
void)
396void FGAccelerations::Debug(
int from)
406 if (from == 0) cout <<
"Instantiated: FGAccelerations" << endl;
407 if (from == 1) cout <<
"Destroyed: FGAccelerations" << endl;
JSBSim::FGFDMExec * FDMExec
~FGAccelerations()
Destructor.
bool InitModel(void) override
Initializes the FGAccelerations class after instantiation and prior to first execution.
double GetGroundMoments(int idx) const
Retrieves the ground moments applied on the body.
void InitializeDerivatives(void)
Initializes the FGAccelerations class prior to a new execution.
double GetForces(int idx) const
Retrieves the total forces applied on the body.
struct JSBSim::FGAccelerations::Inputs in
void SetHoldDown(bool hd)
Sets the property forces/hold-down.
double GetMoments(int idx) const
Retrieves a component of the total moments applied on the body.
double GetWeight(int idx) const
Retrieves the weight applied on the body.
const FGColumnVector3 & GetUVWdot(void) const
Retrieves the body axis acceleration.
double GetGravAccelMagnitude(void) const
bool Run(bool Holding) override
Runs the state propagation model; called by the Executive Can pass in a value indicating if the execu...
double GetGroundForces(int idx) const
Retrieves the ground forces applied on the body.
FGAccelerations(FGFDMExec *Executive)
Constructor.
const FGColumnVector3 & GetPQRdot(void) const
Retrieves the body axis angular acceleration vector.
This class implements a 3 element column vector.
double Magnitude(void) const
Length of the vector.
static constexpr double Constrain(double min, double value, double max)
Constrain a value between a minimum and a maximum value.
FGPropertyManager * PropertyManager
bool InitModel(void) override
FGModel(FGFDMExec *)
Constructor.
virtual bool Run(bool Holding)
Runs the model; called by the Executive.
void Tie(const std::string &name, T *pointer)
Tie a property to an external variable.
double DotProduct(const FGColumnVector3 &v1, const FGColumnVector3 &v2)
Dot product of two vectors Compute and return the euclidean dot (or scalar) product of two vectors v1...