2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-10-02 23:07:30 +00:00
|
|
|
|
|
|
|
Header: FGPropulsion.h
|
|
|
|
Author: Jon S. Berndt
|
|
|
|
Date started: 08/20/00
|
|
|
|
|
|
|
|
------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
|
|
Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
Further information about the GNU General Public License can also be found on
|
|
|
|
the world wide web at http://www.gnu.org.
|
|
|
|
|
|
|
|
HISTORY
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
08/20/00 JSB Created
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-10-02 23:07:30 +00:00
|
|
|
SENTRY
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
2000-10-02 23:07:30 +00:00
|
|
|
|
|
|
|
#ifndef FGPROPULSION_H
|
|
|
|
#define FGPROPULSION_H
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-10-02 23:07:30 +00:00
|
|
|
INCLUDES
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
2000-10-02 23:07:30 +00:00
|
|
|
|
|
|
|
#ifdef FGFS
|
|
|
|
# include <simgear/compiler.h>
|
2001-06-05 20:58:48 +00:00
|
|
|
# ifdef SG_HAVE_STD_INCLUDES
|
2000-10-02 23:07:30 +00:00
|
|
|
# include <vector>
|
2001-06-05 20:58:48 +00:00
|
|
|
# include <iterator>
|
2000-10-02 23:07:30 +00:00
|
|
|
# else
|
|
|
|
# include <vector.h>
|
2001-06-05 20:58:48 +00:00
|
|
|
# include <iterator.h>
|
2000-10-02 23:07:30 +00:00
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
# include <vector>
|
2001-06-05 20:58:48 +00:00
|
|
|
# include <iterator>
|
2000-10-02 23:07:30 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "FGModel.h"
|
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
#include "FGRocket.h"
|
|
|
|
#include "FGPiston.h"
|
|
|
|
#include "FGTurboShaft.h"
|
|
|
|
#include "FGTurboJet.h"
|
|
|
|
#include "FGTurboProp.h"
|
2000-10-02 23:07:30 +00:00
|
|
|
#include "FGTank.h"
|
2001-03-30 01:04:50 +00:00
|
|
|
#include "FGPropeller.h"
|
|
|
|
#include "FGNozzle.h"
|
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
DEFINITIONS
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
#define ID_PROPULSION "$Id$"
|
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
FORWARD DECLARATIONS
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
CLASS DOCUMENTATION
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
|
|
|
/** Propulsion management class.
|
|
|
|
FGPropulsion manages all aspects of propulsive force generation, including
|
|
|
|
containment of engines, tanks, and thruster class instances in STL vectors,
|
|
|
|
and the interaction and communication between them.
|
|
|
|
@author Jon S. Berndt
|
|
|
|
@version $Id$
|
|
|
|
@see FGEngine
|
|
|
|
@see FGTank
|
|
|
|
@see FGThruster
|
2002-04-06 16:03:16 +00:00
|
|
|
@see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGPropulsion.h?rev=HEAD&content-type=text/vnd.viewcvs-markup">
|
|
|
|
Header File </a>
|
|
|
|
@see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGPropulsion.cpp?rev=HEAD&content-type=text/vnd.viewcvs-markup">
|
|
|
|
Source File </a>
|
2001-03-30 01:04:50 +00:00
|
|
|
*/
|
2000-10-02 23:07:30 +00:00
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-10-02 23:07:30 +00:00
|
|
|
CLASS DECLARATION
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
2000-10-02 23:07:30 +00:00
|
|
|
|
2002-04-06 16:03:16 +00:00
|
|
|
class FGPropulsion : public FGModel
|
|
|
|
{
|
2000-10-02 23:07:30 +00:00
|
|
|
public:
|
2002-04-06 16:03:16 +00:00
|
|
|
/// Constructor
|
2000-10-02 23:07:30 +00:00
|
|
|
FGPropulsion(FGFDMExec*);
|
2002-04-06 16:03:16 +00:00
|
|
|
/// Destructor
|
2001-03-30 01:04:50 +00:00
|
|
|
~FGPropulsion();
|
|
|
|
|
|
|
|
/** Executes the propulsion model.
|
|
|
|
The initial plan for the FGPropulsion class calls for Run() to be executed,
|
|
|
|
performing the following tasks:
|
|
|
|
<ol>
|
|
|
|
<li>Determine the drag - or power required - for the attached thrust effector
|
|
|
|
for this engine so that any feedback to the engine can be performed. This
|
|
|
|
is done by calling FGThruster::CalculatePReq()</li>
|
|
|
|
<li>Given 1, above, calculate the power available from the engine. This is
|
|
|
|
done by calling FGEngine::CalculatePAvail()</li>
|
|
|
|
<li>Next, calculate the thrust output from the thruster model given the power
|
|
|
|
available and the power required. This may also result in new performance
|
|
|
|
numbers for the thruster in the case of the propeller, at least. This
|
|
|
|
result is returned from a call to Calculate().</li></ol>
|
2000-10-02 23:07:30 +00:00
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
[Note: Should we be checking the Starved flag here?] */
|
2000-10-02 23:07:30 +00:00
|
|
|
bool Run(void);
|
2001-03-30 01:04:50 +00:00
|
|
|
|
|
|
|
/** Loads the propulsion system (engine[s], tank[s], thruster[s]).
|
|
|
|
Characteristics of the propulsion system are read in from the config file.
|
|
|
|
@param AC_cfg pointer to the config file instance that describes the
|
|
|
|
aircraft being modeled.
|
|
|
|
@return true if successfully loaded, otherwise false */
|
2001-07-10 15:56:38 +00:00
|
|
|
bool Load(FGConfigFile* AC_cfg);
|
2001-03-30 01:04:50 +00:00
|
|
|
|
|
|
|
/// Retrieves the number of engines defined for the aircraft.
|
2002-03-20 12:45:02 +00:00
|
|
|
inline unsigned int GetNumEngines(void) const {return Engines.size();}
|
2001-03-30 01:04:50 +00:00
|
|
|
|
|
|
|
/** Retrieves an engine object pointer from the list of engines.
|
|
|
|
@param index the engine index within the vector container
|
|
|
|
@return the address of the specific engine, or zero if no such engine is
|
|
|
|
available */
|
|
|
|
inline FGEngine* GetEngine(unsigned int index) {
|
|
|
|
if (index <= Engines.size()-1) return Engines[index];
|
|
|
|
else return 0L; }
|
|
|
|
|
2002-01-19 05:32:28 +00:00
|
|
|
// Retrieves the number of tanks defined for the aircraft.
|
2002-03-20 12:45:02 +00:00
|
|
|
inline unsigned int GetNumTanks(void) const {return Tanks.size();}
|
2002-01-19 05:32:28 +00:00
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
/** Retrieves a tank object pointer from the list of tanks.
|
|
|
|
@param index the tank index within the vector container
|
|
|
|
@return the address of the specific tank, or zero if no such tank is
|
|
|
|
available */
|
|
|
|
inline FGTank* GetTank(unsigned int index) {
|
|
|
|
if (index <= Tanks.size()-1) return Tanks[index];
|
|
|
|
else return 0L; }
|
|
|
|
|
|
|
|
/** Retrieves a thruster object pointer from the list of thrusters.
|
|
|
|
@param index the thruster index within the vector container
|
|
|
|
@return the address of the specific thruster, or zero if no such thruster is
|
|
|
|
available */
|
|
|
|
inline FGThruster* GetThruster(unsigned int index) {
|
|
|
|
if (index <= Thrusters.size()-1) return Thrusters[index];
|
|
|
|
else return 0L; }
|
|
|
|
|
|
|
|
/** Returns the number of fuel tanks currently actively supplying fuel */
|
2002-03-20 12:45:02 +00:00
|
|
|
inline int GetnumSelectedFuelTanks(void) const {return numSelectedFuelTanks;}
|
2001-03-30 01:04:50 +00:00
|
|
|
|
|
|
|
/** Returns the number of oxidizer tanks currently actively supplying oxidizer */
|
2002-03-20 12:45:02 +00:00
|
|
|
inline int GetnumSelectedOxiTanks(void) const {return numSelectedOxiTanks;}
|
2001-03-30 01:04:50 +00:00
|
|
|
|
2001-11-06 22:33:05 +00:00
|
|
|
/** Loops the engines/thrusters until thrust output steady (used for trimming) */
|
2001-03-30 01:04:50 +00:00
|
|
|
bool GetSteadyState(void);
|
2001-11-06 22:33:05 +00:00
|
|
|
|
|
|
|
/** starts the engines in IC mode (dt=0). All engine-specific setup must
|
|
|
|
be done before calling this (i.e. magnetos, starter engage, etc.) */
|
|
|
|
bool ICEngineStart(void);
|
|
|
|
|
2001-04-02 03:12:38 +00:00
|
|
|
string GetPropulsionStrings(void);
|
|
|
|
string GetPropulsionValues(void);
|
2001-03-30 01:04:50 +00:00
|
|
|
|
2001-12-07 17:10:17 +00:00
|
|
|
inline FGColumnVector3& GetForces(void) {return vForces; }
|
2002-03-20 12:45:02 +00:00
|
|
|
inline double GetForces(int n) const { return vForces(n);}
|
2001-12-07 17:10:17 +00:00
|
|
|
inline FGColumnVector3& GetMoments(void) {return vMoments;}
|
2002-03-20 12:45:02 +00:00
|
|
|
inline double GetMoments(int n) const {return vMoments(n);}
|
2001-06-05 20:58:48 +00:00
|
|
|
|
2001-10-05 20:19:59 +00:00
|
|
|
FGColumnVector3& GetTanksCG(void);
|
2001-11-20 22:34:24 +00:00
|
|
|
double GetTanksWeight(void);
|
2001-06-05 20:58:48 +00:00
|
|
|
|
2001-11-20 22:34:24 +00:00
|
|
|
double GetTanksIxx(const FGColumnVector3& vXYZcg);
|
|
|
|
double GetTanksIyy(const FGColumnVector3& vXYZcg);
|
|
|
|
double GetTanksIzz(const FGColumnVector3& vXYZcg);
|
|
|
|
double GetTanksIxz(const FGColumnVector3& vXYZcg);
|
|
|
|
double GetTanksIxy(const FGColumnVector3& vXYZcg);
|
2002-03-20 12:45:02 +00:00
|
|
|
|
|
|
|
void bind();
|
|
|
|
void unbind();
|
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
private:
|
|
|
|
vector <FGEngine*> Engines;
|
|
|
|
vector <FGTank*> Tanks;
|
2001-06-05 20:58:48 +00:00
|
|
|
vector <FGTank*>::iterator iTank;
|
2001-03-30 01:04:50 +00:00
|
|
|
vector <FGThruster*> Thrusters;
|
|
|
|
unsigned int numSelectedFuelTanks;
|
|
|
|
unsigned int numSelectedOxiTanks;
|
|
|
|
unsigned int numFuelTanks;
|
|
|
|
unsigned int numOxiTanks;
|
|
|
|
unsigned int numEngines;
|
|
|
|
unsigned int numTanks;
|
|
|
|
unsigned int numThrusters;
|
2001-11-20 22:34:24 +00:00
|
|
|
double dt;
|
2001-12-07 17:10:17 +00:00
|
|
|
FGColumnVector3 vForces;
|
|
|
|
FGColumnVector3 vMoments;
|
2001-10-05 20:19:59 +00:00
|
|
|
FGColumnVector3 vXYZtank;
|
2001-12-13 04:48:34 +00:00
|
|
|
void Debug(int from);
|
2000-10-02 23:07:30 +00:00
|
|
|
};
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2000-10-02 23:07:30 +00:00
|
|
|
#endif
|
|
|
|
|