#include <iostream>
#include <iterator>
#include <cstdlib>
+#include <iomanip>
#include "FGFDMExec.h"
#include "models/atmosphere/FGStandardAtmosphere.h"
#include "models/FGInput.h"
#include "models/FGOutput.h"
#include "initialization/FGTrim.h"
-#include "initialization/FGSimplexTrim.h"
-#include "initialization/FGLinearization.h"
#include "input_output/FGScript.h"
#include "input_output/FGXMLFileRead.h"
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGFDMExec.cpp,v 1.182 2015/11/24 13:06:24 ehofman Exp $");
+IDENT(IdSrc,"$Id: FGFDMExec.cpp,v 1.185 2015/12/13 08:01:50 bcoconni Exp $");
IDENT(IdHdr,ID_FDMEXEC);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Terminate = false;
StandAlone = false;
ResetMode = 0;
+ RandomSeed = 0;
IncrementThenHolding = false; // increment then hold is off by default
TimeStepsUntilHold = -1;
// this is to catch errors in binding member functions to the property tree.
try {
Allocate();
- } catch ( string msg ) {
+ } catch (const string& msg ) {
cout << "Caught error: " << msg << endl;
exit(1);
}
Constructing = true;
typedef int (FGFDMExec::*iPMF)(void) const;
-// instance->Tie("simulation/do_trim_analysis", this, (iPMF)0, &FGFDMExec::DoTrimAnalysis, false);
instance->Tie("simulation/do_simple_trim", this, (iPMF)0, &FGFDMExec::DoTrim, false);
- instance->Tie("simulation/do_simplex_trim", this, (iPMF)0, &FGFDMExec::DoSimplexTrim);
- instance->Tie("simulation/do_linearization", this, (iPMF)0, &FGFDMExec::DoLinearization);
instance->Tie("simulation/reset", this, (iPMF)0, &FGFDMExec::ResetToInitialConditions, false);
instance->Tie("simulation/disperse", this, &FGFDMExec::GetDisperse);
- instance->Tie("simulation/randomseed", this, (iPMF)0, &FGFDMExec::SRand, false);
+ instance->Tie("simulation/randomseed", this, (iPMF)&FGFDMExec::SRand, &FGFDMExec::SRand, false);
instance->Tie("simulation/terminate", (int *)&Terminate);
instance->Tie("simulation/sim-time-sec", this, &FGFDMExec::GetSimTime);
instance->Tie("simulation/dt", this, &FGFDMExec::GetDeltaT);
instance->Tie("simulation/frame", (int *)&Frame, false);
instance->Tie("simulation/trim-completed", (int *)&trim_completed, false);
- // simplex trim properties
- instanceRoot->SetDouble("trim/solver/rtol",0.0001);
- instanceRoot->SetDouble("trim/solver/speed",2);
- instanceRoot->SetDouble("trim/solver/abstol",0.001);
- instanceRoot->SetDouble("trim/solver/iterMax",2000);
- instanceRoot->SetInt("trim/solver/debugLevel",0);
- instanceRoot->SetDouble("trim/solver/random",0);
- instanceRoot->SetBool("trim/solver/showSimplex",false);
- instanceRoot->SetBool("trim/solver/showConvergence",false);
- instanceRoot->SetBool("trim/solver/pause",false);
- instanceRoot->SetBool("trim/solver/variablePropPitch",false);
-
- instanceRoot->SetDouble("trim/solver/throttleGuess",0.50);
- instanceRoot->SetDouble("trim/solver/throttleMin",0.0);
- instanceRoot->SetDouble("trim/solver/throttleMax",1.0);
- instanceRoot->SetDouble("trim/solver/throttleStep",0.1);
-
- instanceRoot->SetDouble("trim/solver/aileronGuess",0);
- instanceRoot->SetDouble("trim/solver/aileronMin",-1.00);
- instanceRoot->SetDouble("trim/solver/aileronMax",1.00);
- instanceRoot->SetDouble("trim/solver/aileronStep",0.1);
-
- instanceRoot->SetDouble("trim/solver/rudderGuess",0);
- instanceRoot->SetDouble("trim/solver/rudderMin",-1.00);
- instanceRoot->SetDouble("trim/solver/rudderMax",1.00);
- instanceRoot->SetDouble("trim/solver/rudderStep",0.1);
-
- instanceRoot->SetDouble("trim/solver/elevatorGuess",-0.1);
- instanceRoot->SetDouble("trim/solver/elevatorMin",-1.0);
- instanceRoot->SetDouble("trim/solver/elevatorMax",1.0);
- instanceRoot->SetDouble("trim/solver/elevatorStep",0.1);
-
- instanceRoot->SetDouble("trim/solver/alphaGuess",0.05);
- instanceRoot->SetDouble("trim/solver/alphaMin",-0.1);
- instanceRoot->SetDouble("trim/solver/alphaMax",.18);
- instanceRoot->SetDouble("trim/solver/alphaStep",0.05);
-
- instanceRoot->SetDouble("trim/solver/betaGuess",0);
- instanceRoot->SetDouble("trim/solver/betaMin",-0.1);
- instanceRoot->SetDouble("trim/solver/betaMax",0.1);
- instanceRoot->SetDouble("trim/solver/betaStep",0.0001);
-
Constructing = false;
}
FDMctr = 0;
}
}
- } catch ( string msg ) {
+ } catch (const string& msg ) {
cout << "Caught error: " << msg << endl;
}
cout << endl << fgblue << highint
<< "End of vehicle configuration loading." << endl
<< "-------------------------------------------------------------------------------"
- << reset << setprecision(6) << endl;
+ << reset << std::setprecision(6) << endl;
}
for (unsigned int n=0; n < propulsion->GetNumEngines(); ++n) {
if (IC->IsEngineRunning(n)) {
try {
propulsion->InitRunning(n);
- } catch (string str) {
+ } catch (const string& str) {
cerr << str << endl;
return false;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGFDMExec::LoadScript(const string& script, double deltaT, const string initfile)
+bool FGFDMExec::LoadScript(const string& script, double deltaT, const string& initfile)
{
bool result;
bool FGFDMExec::LoadModel(const string& model, bool addModelToPath)
{
- string token;
string aircraftCfgFileName;
- Element* element = 0L;
bool result = false; // initialize result to false, indicating input file not yet read
modelName = model; // Set the class modelName attribute
if (IsChild) debug_lvl = saved_debug_lvl;
// Process the fileheader element in the aircraft config file. This element is OPTIONAL.
- element = document->FindElement("fileheader");
+ Element* element = document->FindElement("fileheader");
if (element) {
result = ReadFileHeader(element);
if (!result) {
void FGFDMExec::BuildPropertyCatalog(struct PropertyCatalogStructure* pcs)
{
struct PropertyCatalogStructure* pcsNew = new struct PropertyCatalogStructure;
- int node_idx = 0;
for (int i=0; i<pcs->node->nChildren(); i++) {
string access="";
pcsNew->base_string = pcs->base_string + "/" + pcs->node->getChild(i)->getName();
- node_idx = pcs->node->getChild(i)->getIndex();
+ int node_idx = pcs->node->getChild(i)->getIndex();
if (node_idx != 0) {
pcsNew->base_string = CreateIndexedPropertyName(pcsNew->base_string, node_idx);
}
// Load the model given the aircraft name
// reset debug level to prior setting
- string token;
-
struct childData* child = new childData;
child->exec = new FGFDMExec(Root, FDMctr);
{
if (Constructing) return;
- if (mode < 0 || mode > JSBSim::tNone) {
+ if (mode < 0 || mode > JSBSim::tNone)
throw("Illegal trimming mode!");
- return;
- }
-
FGTrim trim(this, (JSBSim::TrimMode)mode);
- if ( !trim.DoTrim() ) {
- throw("Trim Failed");
- return;
- }
+ bool success = trim.DoTrim();
trim.Report();
- trim_completed = 1;
-}
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ if (!success)
+ throw("Trim Failed");
-void FGFDMExec::DoSimplexTrim(int mode)
-{
- double saved_time;
- if (Constructing) return;
- if (mode < 0 || mode > JSBSim::tNone) {
- cerr << endl << "Illegal trimming mode!" << endl << endl;
- return;
- }
- saved_time = sim_time;
- FGSimplexTrim trim(this, (JSBSim::TrimMode)mode);
- Setsim_time(saved_time);
- std::cout << "dT: " << dT << std::endl;
trim_completed = 1;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-void FGFDMExec::DoLinearization(int mode)
-{
- double saved_time;
- if (Constructing) return;
- saved_time = sim_time;
- FGLinearization lin(this,mode);
- Setsim_time(saved_time);
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
void FGFDMExec::SRand(int sr)
{
+ RandomSeed = sr;
gaussian_random_number_phase = 0;
- srand(sr);
+ srand(RandomSeed);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
namespace JSBSim {
-IDENT(IdSrc,"$Id: FGMassBalance.cpp,v 1.53 2015/03/28 14:49:02 bcoconni Exp $");
+IDENT(IdSrc,"$Id: FGMassBalance.cpp,v 1.54 2015/12/09 04:28:18 jberndt Exp $");
IDENT(IdHdr,ID_MASSBALANCE);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<< " Mass Properties Report (English units: lbf, in, slug-ft^2)"
<< reset << endl;
cout << " " << underon << " Weight CG-X CG-Y"
- << " CG-Z Ixx Iyy Izz" << underoff << endl;
+ << " CG-Z Ixx Iyy Izz"
+ << " Ixy Ixz Iyz" << underoff << endl;
cout.precision(1);
cout << highint << setw(34) << left << " Base Vehicle " << normint
- << right << setw(10) << EmptyWeight << setw(8) << vbaseXYZcg(eX) << setw(8)
- << vbaseXYZcg(eY) << setw(8) << vbaseXYZcg(eZ) << setw(12) << baseJ(1,1)
- << setw(12) << baseJ(2,2) << setw(12) << baseJ(3,3) << endl;
+ << right << setw(10) << EmptyWeight
+ << setw(8) << vbaseXYZcg(eX) << setw(8) << vbaseXYZcg(eY) << setw(8) << vbaseXYZcg(eZ)
+ << setw(12) << baseJ(1,1) << setw(12) << baseJ(2,2) << setw(12) << baseJ(3,3)
+ << setw(12) << baseJ(1,2) << setw(12) << baseJ(1,3) << setw(12) << baseJ(2,3) << endl;
for (unsigned int i=0;i<PointMasses.size();i++) {
PointMass* pm = PointMasses[i];
cout << highint << left << setw(4) << i << setw(30) << pm->GetName() << normint
<< right << setw(10) << pmweight << setw(8) << pm->GetLocation()(eX)
<< setw(8) << pm->GetLocation()(eY) << setw(8) << pm->GetLocation()(eZ)
- << setw(12) << pm->GetPointMassMoI(1,1) << setw(12) << pm->GetPointMassMoI(2,2)
- << setw(12) << pm->GetPointMassMoI(3,3) << endl;
+ << setw(12) << pm->GetPointMassMoI(1,1) << setw(12) << pm->GetPointMassMoI(2,2) << setw(12) << pm->GetPointMassMoI(3,3)
+ << setw(12) << pm->GetPointMassMoI(1,2) << setw(12) << pm->GetPointMassMoI(1,3) << setw(12) << pm->GetPointMassMoI(2,3) << endl;
}
cout << FDMExec->GetPropulsionTankReport();
- cout << underon << setw(104) << " " << underoff << endl;
+ cout << " " << underon << setw(136) << " " << underoff << endl;
cout << highint << left << setw(30) << " Total: " << right << setw(14) << Weight
<< setw(8) << vXYZcg(eX)
<< setw(8) << vXYZcg(eY)
<< setw(12) << mJ(1,1)
<< setw(12) << mJ(2,2)
<< setw(12) << mJ(3,3)
+ << setw(12) << mJ(1,2)
+ << setw(12) << mJ(1,3)
+ << setw(12) << mJ(2,3)
<< normint << endl;
cout.setf(ios_base::fixed);