56#include "FGAccelerations.h" 
   71  Name = 
"FGAccelerations";
 
   74  vPQRidot.InitMatrix();
 
   75  vUVWidot.InitMatrix();
 
   77  vBodyAccel.InitMatrix();
 
 
   94  if (!FGModel::InitModel()) 
return false;
 
   96  vPQRidot.InitMatrix();
 
   97  vUVWidot.InitMatrix();
 
   99  vBodyAccel.InitMatrix();
 
 
  112  if (Holding) 
return false;
 
  118    CalculateFrictionForces(in.
DeltaT * rate);  
 
 
  138void FGAccelerations::CalculatePQRdot(
void)
 
  157    vPQRdot.InitMatrix();
 
  183void FGAccelerations::CalculateUVWdot(
void)
 
  185  if (FDMExec->
GetHoldDown() && !FDMExec->GetTrimStatus())
 
  186    vBodyAccel.InitMatrix();
 
  199    vUVWdot.InitMatrix();
 
  213    vUVWdot.InitMatrix();
 
  214    vPQRdot.InitMatrix();
 
 
  232void FGAccelerations::CalculateFrictionForces(
double dt)
 
  235  size_t n = multipliers.size();
 
  237  vFrictionForces.InitMatrix();
 
  238  vFrictionMoments.InitMatrix();
 
  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;
 
  259      a[i*n+j] = DotProduct(U, v1 + v2*r);
 
  266  FGColumnVector3 vdot = vUVWdot;
 
  271  FGColumnVector3 wdot = vPQRdot;
 
  279  for (
unsigned int i=0; i < n; i++) {
 
  281    FGColumnVector3 U = multipliers[i]->ForceJacobian;
 
  282    FGColumnVector3 r = multipliers[i]->LeverArm;
 
  284    rhs[i] = -DotProduct(U, vdot + wdot*r)/d;
 
  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)
 
  364  PropertyManager->Tie(
"accelerations/gravity-ft_sec2", 
this, &FGAccelerations::GetGravAccelMagnitude);
 
  365  PropertyManager->Tie(
"simulation/gravitational-torque", &gravTorque);
 
  366  PropertyManager->Tie(
"forces/fbx-weight-lbs", 
this, eX, (PMF)&FGAccelerations::GetWeight);
 
  367  PropertyManager->Tie(
"forces/fby-weight-lbs", 
this, eY, (PMF)&FGAccelerations::GetWeight);
 
  368  PropertyManager->Tie(
"forces/fbz-weight-lbs", 
this, eZ, (PMF)&FGAccelerations::GetWeight);
 
  370  PropertyManager->Tie(
"forces/fbx-total-lbs", 
this, eX, (PMF)&FGAccelerations::GetForces);
 
  371  PropertyManager->Tie(
"forces/fby-total-lbs", 
this, eY, (PMF)&FGAccelerations::GetForces);
 
  372  PropertyManager->Tie(
"forces/fbz-total-lbs", 
this, eZ, (PMF)&FGAccelerations::GetForces);
 
  373  PropertyManager->Tie(
"moments/l-total-lbsft", 
this, eL, (PMF)&FGAccelerations::GetMoments);
 
  374  PropertyManager->Tie(
"moments/m-total-lbsft", 
this, eM, (PMF)&FGAccelerations::GetMoments);
 
  375  PropertyManager->Tie(
"moments/n-total-lbsft", 
this, eN, (PMF)&FGAccelerations::GetMoments);
 
  377  PropertyManager->Tie(
"moments/l-gear-lbsft", 
this, eL, (PMF)&FGAccelerations::GetGroundMoments);
 
  378  PropertyManager->Tie(
"moments/m-gear-lbsft", 
this, eM, (PMF)&FGAccelerations::GetGroundMoments);
 
  379  PropertyManager->Tie(
"moments/n-gear-lbsft", 
this, eN, (PMF)&FGAccelerations::GetGroundMoments);
 
  380  PropertyManager->Tie(
"forces/fbx-gear-lbs", 
this, eX, (PMF)&FGAccelerations::GetGroundForces);
 
  381  PropertyManager->Tie(
"forces/fby-gear-lbs", 
this, eY, (PMF)&FGAccelerations::GetGroundForces);
 
  382  PropertyManager->Tie(
"forces/fbz-gear-lbs", 
this, eZ, (PMF)&FGAccelerations::GetGroundForces);
 
  404void FGAccelerations::Debug(
int from)
 
  406  if (debug_lvl <= 0) 
return;
 
  413  if (debug_lvl & 2 ) { 
 
  414    if (from == 0) cout << 
"Instantiated: FGAccelerations" << endl;
 
  415    if (from == 1) cout << 
"Destroyed:    FGAccelerations" << endl;
 
  417  if (debug_lvl & 4 ) { 
 
  419  if (debug_lvl & 8 && from == 2) { 
 
  421  if (debug_lvl & 16) { 
 
  423  if (debug_lvl & 64) {
 
Handles the calculation of accelerations.
 
void InitializeDerivatives(void)
Initializes the FGAccelerations class prior to a new execution.
 
const FGColumnVector3 & GetUVWidot(void) const
Retrieves the body axis acceleration in the ECI frame.
 
const FGColumnVector3 & GetUVWdot(void) const
Retrieves the body axis acceleration.
 
FGAccelerations(FGFDMExec *Executive)
Constructor.
 
~FGAccelerations()
Destructor.
 
bool Run(bool Holding) override
Runs the state propagation model; called by the Executive Can pass in a value indicating if the execu...
 
bool InitModel(void) override
Initializes the FGAccelerations class after instantiation and prior to first execution.
 
const FGColumnVector3 & GetPQRdot(void) const
Retrieves the body axis angular acceleration vector.
 
const FGColumnVector3 & GetPQRidot(void) const
Retrieves the axis angular acceleration vector in the ECI frame.
 
void SetHoldDown(bool hd)
Sets the property forces/hold-down.
 
This class implements a 3 element column vector.
 
double Magnitude(void) const
Length of the vector.
 
Encapsulates the JSBSim simulation executive.
 
bool GetHoldDown(void) const
Gets the value of the property forces/hold-down.
 
static constexpr double Constrain(double min, double value, double max)
Constrain a value between a minimum and a maximum value.
 
Base class for all scheduled JSBSim models.
 
virtual bool Run(bool Holding)
Runs the model; called by the Executive.