namespace JSBSim {
-static const char *IdSrc = "$Id: FGFDMExec.cpp,v 1.113 2011/09/07 02:37:04 jberndt Exp $";
+static const char *IdSrc = "$Id: FGFDMExec.cpp,v 1.114 2011/09/11 11:36:04 bcoconni Exp $";
static const char *IdHdr = ID_FDMEXEC;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GroundReactions->in.TotalDeltaT = dT * GroundReactions->GetRate();
GroundReactions->in.WOW = GroundReactions->GetWOW();
GroundReactions->in.Location = Propagate->GetLocation();
- for (unsigned int i=0; i<GroundReactions->GetNumGearUnits(); i++) {
+ for (int i=0; i<GroundReactions->GetNumGearUnits(); i++) {
GroundReactions->in.vWhlBodyVec[i] = MassBalance->StructuralToBody(GroundReactions->GetGearUnit(i)->GetLocation());
}
break;
Aerodynamics->in.Wingspan = Aircraft->GetWingSpan();
Auxiliary->in.Wingspan = Aircraft->GetWingSpan();
Auxiliary->in.Wingchord = Aircraft->Getcbar();
- for (unsigned int i=0; i<GroundReactions->GetNumGearUnits(); i++) {
+ for (int i=0; i<GroundReactions->GetNumGearUnits(); i++) {
GroundReactions->in.vWhlBodyVec[i] = MassBalance->StructuralToBody(GroundReactions->GetGearUnit(i)->GetLocation());
}
temperature = fgGetNode("/environment/temperature-degc",true);
pressure = fgGetNode("/environment/pressure-inhg",true);
pressureSL = fgGetNode("/environment/pressure-sea-level-inhg",true);
- density = fgGetNode("/environment/density-slugft3",true);
ground_wind = fgGetNode("/environment/config/boundary/entry[0]/wind-speed-kt",true);
turbulence_gain = fgGetNode("/environment/turbulence/magnitude-norm",true);
turbulence_rate = fgGetNode("/environment/turbulence/rate-hz",true);
Winds->SetProbabilityOfExceedence(0.0);
}
- fgic->SetSeaLevelRadiusFtIC( get_Sea_level_radius() );
fgic->SetWindNEDFpsIC( -wind_from_north->getDoubleValue(),
-wind_from_east->getDoubleValue(),
-wind_from_down->getDoubleValue() );
//Atmosphere->SetExTemperature(get_Static_temperature());
//Atmosphere->SetExPressure(get_Static_pressure());
//Atmosphere->SetExDensity(get_Density());
- SG_LOG(SG_FLIGHT,SG_INFO,"T,p,rho: " << fdmex->GetAtmosphere()->GetTemperature()
- << ", " << fdmex->GetAtmosphere()->GetPressure()
- << ", " << fdmex->GetAtmosphere()->GetDensity() );
+ SG_LOG(SG_FLIGHT,SG_INFO,"T,p,rho: " << Atmosphere->GetTemperature()
+ << ", " << Atmosphere->GetPressure()
+ << ", " << Atmosphere->GetDensity() );
// deprecate egt_degf for egt-degf to have consistent naming
// TODO: remove this for 2.6.0
FCS->SetDfPos( ofNorm, globals->get_controls()->get_flaps() );
+ needTrim = startup_trim->getBoolValue();
common_init();
+ fgic->SetSeaLevelRadiusFtIC( get_Sea_level_radius() );
copy_to_JSBsim();
fdmex->RunIC(); //loop JSBSim once w/o integrating
}
}
- if ( startup_trim->getBoolValue() ) {
+ if ( needTrim ) {
FGLocation cart(fgic->GetLongitudeRadIC(), fgic->GetLatitudeRadIC(),
get_Sea_level_radius() + fgic->GetAltitudeASLFtIC());
double cart_pos[3], contact[3], d[3], vel[3], agl;
// Positions of Visual Reference Point
FGLocation l = Auxiliary->GetLocationVRP();
- _updateGeocentricPosition( l.GetLatitude(), l.GetLongitude(),
- l.GetRadius() - get_Sea_level_radius() );
+ _updatePosition(SGGeoc::fromRadFt( l.GetLongitude(), l.GetLatitude(),
+ l.GetRadius() ));
_set_Altitude_AGL( Propagate->GetDistanceAGL() );
{
void FGJSBsim::set_Latitude(double lat)
{
static SGConstPropertyNode_ptr altitude = fgGetNode("/position/altitude-ft");
- double alt;
+ double alt = altitude->getDoubleValue();
double sea_level_radius_meters, lat_geoc;
- if ( altitude->getDoubleValue() > -9990 )
- alt = altitude->getDoubleValue();
- else
- alt = 0.0;
+ if ( alt < -9990 ) alt = 0.0;
SG_LOG(SG_FLIGHT,SG_INFO,"FGJSBsim::set_Latitude: " << lat );
SG_LOG(SG_FLIGHT,SG_INFO," cur alt (ft) = " << alt );
sgGeodToGeoc( lat, alt * SG_FEET_TO_METER,
&sea_level_radius_meters, &lat_geoc );
- _set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET );
+
+ double sea_level_radius_ft = sea_level_radius_meters * SG_METER_TO_FEET;
+ _set_Sea_level_radius( sea_level_radius_ft );
if (needTrim) {
- fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET );
+ fgic->SetSeaLevelRadiusFtIC( sea_level_radius_ft );
fgic->SetLatitudeRadIC( lat_geoc );
}
else {
+ Propagate->SetSeaLevelRadius( sea_level_radius_ft );
Propagate->SetLatitude(lat_geoc);
FGInterface::set_Latitude(lat);
}
SGPropertyNode_ptr temperature;
SGPropertyNode_ptr pressure;
SGPropertyNode_ptr pressureSL;
- SGPropertyNode_ptr density;
SGPropertyNode_ptr ground_wind;
SGPropertyNode_ptr turbulence_gain;
SGPropertyNode_ptr turbulence_rate;
namespace JSBSim {
-static const char *IdSrc = "$Id: FGAtmosphere.cpp,v 1.48 2011/07/10 20:18:14 jberndt Exp $";
+static const char *IdSrc = "$Id: FGAtmosphere.cpp,v 1.49 2011/09/11 11:36:04 bcoconni Exp $";
static const char *IdHdr = ID_ATMOSPHERE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
break;
case eKelvin:
targetTemp = t*9.0/5.0;
+ break;
+ default:
+ break;
}
return targetTemp;
GLOBAL DATA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-static const char *IdSrc = "$Id: FGLGear.cpp,v 1.88 2011/08/30 21:05:56 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGLGear.cpp,v 1.89 2011/09/11 11:36:04 bcoconni Exp $";
static const char *IdHdr = ID_LGEAR;
// Body To Structural (body frame is rotated 180 deg about Y and lengths are given in
FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number, const struct Inputs& inputs) :
FGForce(fdmex),
+ in(inputs),
GearNumber(number),
SteerAngle(0.0),
Castered(false),
- StaticFriction(false),
- in(inputs)
+ StaticFriction(false)
{
Element *force_table=0;
Element *dampCoeff=0;
namespace JSBSim {
-static const char *IdSrc = "$Id: FGOutput.cpp,v 1.59 2011/08/14 20:15:56 jberndt Exp $";
+static const char *IdSrc = "$Id: FGOutput.cpp,v 1.60 2011/09/11 11:36:04 bcoconni Exp $";
static const char *IdHdr = ID_OUTPUT;
// (stolen from FGFS native_fdm.cxx)
const FGPropagate* Propagate = FDMExec->GetPropagate();
const FGAccelerations* Accelerations = FDMExec->GetAccelerations();
const FGFCS* FCS = FDMExec->GetFCS();
- const FGInertial* Inertial = FDMExec->GetInertial();
const FGGroundReactions* GroundReactions = FDMExec->GetGroundReactions();
const FGExternalReactions* ExternalReactions = FDMExec->GetExternalReactions();
const FGBuoyantForces* BuoyantForces = FDMExec->GetBuoyantForces();
void FGOutput::SocketDataFill(FGNetFDM* net)
{
- const FGAerodynamics* Aerodynamics = FDMExec->GetAerodynamics();
const FGAuxiliary* Auxiliary = FDMExec->GetAuxiliary();
const FGPropulsion* Propulsion = FDMExec->GetPropulsion();
- const FGMassBalance* MassBalance = FDMExec->GetMassBalance();
const FGPropagate* Propagate = FDMExec->GetPropagate();
const FGFCS* FCS = FDMExec->GetFCS();
const FGGroundReactions* GroundReactions = FDMExec->GetGroundReactions();
namespace JSBSim {
-static const char *IdSrc = "$Id: FGPropagate.cpp,v 1.95 2011/08/21 16:11:25 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGPropagate.cpp,v 1.96 2011/09/17 15:36:35 bcoconni Exp $";
static const char *IdHdr = ID_PROPAGATE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PropertyManager->Tie("position/h-sl-ft", this, &FGPropagate::GetAltitudeASL, &FGPropagate::SetAltitudeASL, true);
PropertyManager->Tie("position/h-sl-meters", this, &FGPropagate::GetAltitudeASLmeters, &FGPropagate::SetAltitudeASLmeters, true);
- PropertyManager->Tie("position/lat-gc-rad", this, &FGPropagate::GetLatitude, &FGPropagate::SetLatitude);
- PropertyManager->Tie("position/long-gc-rad", this, &FGPropagate::GetLongitude, &FGPropagate::SetLongitude);
- PropertyManager->Tie("position/lat-gc-deg", this, &FGPropagate::GetLatitudeDeg, &FGPropagate::SetLatitudeDeg);
- PropertyManager->Tie("position/long-gc-deg", this, &FGPropagate::GetLongitudeDeg, &FGPropagate::SetLongitudeDeg);
+ PropertyManager->Tie("position/lat-gc-rad", this, &FGPropagate::GetLatitude, &FGPropagate::SetLatitude, false);
+ PropertyManager->Tie("position/long-gc-rad", this, &FGPropagate::GetLongitude, &FGPropagate::SetLongitude, false);
+ PropertyManager->Tie("position/lat-gc-deg", this, &FGPropagate::GetLatitudeDeg, &FGPropagate::SetLatitudeDeg, false);
+ PropertyManager->Tie("position/long-gc-deg", this, &FGPropagate::GetLongitudeDeg, &FGPropagate::SetLongitudeDeg, false);
PropertyManager->Tie("position/lat-geod-rad", this, &FGPropagate::GetGeodLatitudeRad);
PropertyManager->Tie("position/lat-geod-deg", this, &FGPropagate::GetGeodLatitudeDeg);
PropertyManager->Tie("position/geod-alt-ft", this, &FGPropagate::GetGeodeticAltitude);
namespace JSBSim {
-static const char *IdSrc = "$Id: FGPropulsion.cpp,v 1.50 2011/08/03 03:21:06 jberndt Exp $";
+static const char *IdSrc = "$Id: FGPropulsion.cpp,v 1.51 2011/09/11 11:36:04 bcoconni Exp $";
static const char *IdHdr = ID_PROPULSION;
extern short debug_lvl;
bool FGPropulsion::Load(Element* el)
{
string type, engine_filename;
- bool ThrottleAdded = false;
Debug(2);
namespace JSBSim {
-static const char *IdSrc = "$Id: FGStandardAtmosphere.cpp,v 1.18 2011/08/17 23:56:01 jberndt Exp $";
+static const char *IdSrc = "$Id: FGStandardAtmosphere.cpp,v 1.19 2011/09/11 11:36:04 bcoconni Exp $";
static const char *IdHdr = ID_STANDARDATMOSPHERE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGStandardAtmosphere::FGStandardAtmosphere(FGFDMExec* fdmex) : FGAtmosphere(fdmex),
- TemperatureDeltaGradient(0.0),
- TemperatureBias(0.0)
+ TemperatureBias(0.0),
+ TemperatureDeltaGradient(0.0)
{
Name = "FGStandardAtmosphere";
namespace JSBSim {
-static const char *IdSrc = "$Id: FGWinds.cpp,v 1.4 2011/09/07 02:37:04 jberndt Exp $";
+static const char *IdSrc = "$Id: FGWinds.cpp,v 1.5 2011/09/11 11:36:04 bcoconni Exp $";
static const char *IdHdr = ID_WINDS;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
double
T_V = in.totalDeltaT, // for compatibility of nomenclature
sig_p = 1.9/sqrt(L_w*b_w)*sig_w, // Yeager1998, eq. (8)
- sig_q = sqrt(M_PI/2/L_w/b_w), // eq. (14)
- sig_r = sqrt(2*M_PI/3/L_w/b_w), // eq. (17)
+ //sig_q = sqrt(M_PI/2/L_w/b_w), // eq. (14)
+ //sig_r = sqrt(2*M_PI/3/L_w/b_w), // eq. (17)
L_p = sqrt(L_w*b_w)/2.6, // eq. (10)
tau_u = L_u/in.V, // eq. (6)
tau_w = L_w/in.V, // eq. (3)
// this is the native frame - and the default.
oneMinusCosineGust.vWindTransformed = oneMinusCosineGust.vWind;
break;
+ default:
+ break;
}
}
namespace JSBSim {
-static const char *IdSrc = "$Id: FGFCSComponent.cpp,v 1.33 2011/06/21 04:41:54 jberndt Exp $";
+static const char *IdSrc = "$Id: FGFCSComponent.cpp,v 1.34 2011/09/11 11:36:04 bcoconni Exp $";
static const char *IdHdr = ID_FCSCOMPONENT;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFCSComponent::Delay(void)
{
output_array[index] = Output;
- if (index == delay-1) index = 0;
+ if ((unsigned int)index == delay-1) index = 0;
else index++;
Output = output_array[index];
}
namespace JSBSim {
-static const char *IdSrc = "$Id: FGEngine.cpp,v 1.46 2011/08/17 23:56:01 jberndt Exp $";
+static const char *IdSrc = "$Id: FGEngine.cpp,v 1.47 2011/09/11 11:36:04 bcoconni Exp $";
static const char *IdHdr = ID_ENGINE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGEngine::FGEngine(FGFDMExec* exec, Element* engine_element, int engine_number, struct Inputs& input)
- : EngineNumber(engine_number), in(input)
+ : in(input), EngineNumber(engine_number)
{
Element* local_element;
FGColumnVector3 location, orientation;
namespace JSBSim {
-static const char *IdSrc = "$Id: FGPiston.cpp,v 1.64 2011/08/04 13:45:42 jberndt Exp $";
+static const char *IdSrc = "$Id: FGPiston.cpp,v 1.65 2011/09/11 12:06:54 bcoconni Exp $";
static const char *IdHdr = ID_PISTON;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RatedAltitude[2] = el->FindElementValueAsNumberConvertTo("ratedaltitude3", "FT");
}
- while(table_element = el->FindNextElement("table")) {
+ while((table_element = el->FindNextElement("table")) != 0) {
name = table_element->GetAttributeValue("name");
try {
if (name == "COMBUSTION") {
namespace JSBSim {
-static const char *IdSrc = "$Id: FGPropeller.cpp,v 1.36 2011/08/03 03:21:06 jberndt Exp $";
+static const char *IdSrc = "$Id: FGPropeller.cpp,v 1.37 2011/09/11 12:06:54 bcoconni Exp $";
static const char *IdHdr = ID_PROPELLER;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ConstantSpeed = (int)prop_element->FindElementValueAsNumber("constspeed");
if (prop_element->FindElement("reversepitch"))
ReversePitch = prop_element->FindElementValueAsNumber("reversepitch");
- while(table_element = prop_element->FindNextElement("table")) {
+ while((table_element = prop_element->FindNextElement("table")) != 0) {
name = table_element->GetAttributeValue("name");
try {
if (name == "C_THRUST") {
namespace JSBSim {
-static const char *IdSrc = "$Id: FGRotor.cpp,v 1.13 2011/08/03 03:21:06 jberndt Exp $";
+static const char *IdSrc = "$Id: FGRotor.cpp,v 1.16 2011/09/17 16:39:19 bcoconni Exp $";
static const char *IdHdr = ID_ROTOR;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
: FGThruster(exec, rotor_element, num),
rho(0.002356), // environment
Radius(0.0), BladeNum(0), // configuration parameters
- Sense(1.0), NominalRPM(0.0), ExternalRPM(0),
- RPMdefinition(0), ExtRPMsource(NULL),
+ Sense(1.0), NominalRPM(0.0), MinimalRPM(0.0), MaximalRPM(0.0),
+ ExternalRPM(0), RPMdefinition(0), ExtRPMsource(NULL),
BladeChord(0.0), LiftCurveSlope(0.0), BladeTwist(0.0), HingeOffset(0.0),
BladeFlappingMoment(0.0), BladeMassMoment(0.0), PolarMoment(0.0),
InflowLag(0.0), TipLossB(0.0),
// make sure that v_tip (omega*r) is below 0.7mach ~ 750ft/s
estimate = (750.0/Radius)/(2.0*M_PI) * 60.0; // 7160/Radius
NominalRPM = ConfigValue(rotor_element, "nominalrpm", estimate, yell);
+ NominalRPM = Constrain(2.0, NominalRPM, 1e9);
+
+ MinimalRPM = ConfigValue(rotor_element, "minrpm", 1.0);
+ MinimalRPM = Constrain(1.0, MinimalRPM, NominalRPM - 1.0);
+
+ MaximalRPM = ConfigValue(rotor_element, "maxrpm", 2.0*NominalRPM);
+ MaximalRPM = Constrain(NominalRPM, MaximalRPM, 1e9);
estimate = Constrain(0.07, 2.0/Radius , 0.14); // guess solidity
estimate = estimate * M_PI*Radius/BladeNum;
double mu2;
mu = Uw/(Omega*Radius); // /SH79/ eqn(24)
+ if (mu > 0.7) mu = 0.7;
mu2 = sqr(mu);
ct_t0 = (1.0/3.0*B[3] + 1.0/2.0 * TipLossB*mu2 - 4.0/(9.0*M_PI) * mu*mu2 ) * theta_0;
RPM = ExtRPMsource->getDoubleValue() / GearRatio;
}
- if (RPM < 1.0) { // kludge, otherwise calculations go bananas
- RPM = 1.0;
- }
+ // MinimalRPM is always >= 1. MaximalRPM is always >= NominalRPM
+ RPM = Constrain(MinimalRPM, RPM, MaximalRPM);
Omega = (RPM/60.0)*2.0*M_PI;
double ExcessTorque = PowerAvailable / Omega;
double deltaOmega = ExcessTorque / PolarMoment * in.TotalDeltaT;
RPM += deltaOmega/(2.0*M_PI) * 60.0;
- if (RPM < 0.0) RPM = 0.0; // Engine won't turn backwards
}
+ RPM = Constrain(MinimalRPM, RPM, MaximalRPM); // trim again
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
cout << " Gear Ratio = " << GearRatio << endl;
cout << " Sense = " << Sense << endl;
cout << " Nominal RPM = " << NominalRPM << endl;
+ cout << " Minimal RPM = " << MinimalRPM << endl;
+ cout << " Maximal RPM = " << MaximalRPM << endl;
if (ExternalRPM) {
if (RPMdefinition == -1) {
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_ROTOR "$Id: FGRotor.h,v 1.9 2011/03/10 01:35:25 dpculp Exp $"
+#define ID_ROTOR "$Id: FGRotor.h,v 1.10 2011/09/17 16:39:19 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
<numblades> {number} </numblades>
<gearratio> {number} </gearratio>
<nominalrpm> {number} </nominalrpm>
+ <minrpm> {number} </minrpm>
+ <maxrpm> {number} </maxrpm>
<chord unit="{LENGTH}"> {number} </chord>
<liftcurveslope Xunit="1/RAD"> {number} </liftcurveslope>
<twist unit="{ANGLE}"> {number} </twist>
\<diameter> - Rotor disk diameter (2x R).
\<numblades> - Number of blades (b).
\<gearratio> - Ratio of (engine rpm) / (rotor rpm), usually > 1.
- \<nominalrpm> - RPM at which the rotor usally operates.
+ \<nominalrpm> - RPM at which the rotor usally operates.
+ \<minrpm> - Lowest RPM used in the model, optional and defaults to 1.
+ \<maxrpm> - Largest RPM used in the model, optional and defaults to 2 x nominalrpm.
\<chord> - Blade chord, (c).
\<liftcurveslope> - Slope of curve of section lift against section angle of attack,
per rad (a).
</dl>
@author Thomas Kreitler
- @version $Id: FGRotor.h,v 1.9 2011/03/10 01:35:25 dpculp Exp $
+ @version $Id: FGRotor.h,v 1.10 2011/09/17 16:39:19 bcoconni Exp $
*/
double Sense;
double NominalRPM;
+ double MinimalRPM;
+ double MaximalRPM;
int ExternalRPM;
int RPMdefinition;
FGPropertyManager* ExtRPMsource;