]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/FGBuoyantForces.h
sync with JSB JSBSim CVS
[flightgear.git] / src / FDM / JSBSim / models / FGBuoyantForces.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGBuoyantForces.h
4  Author:       Anders Gidenstam, Jon S. Berndt
5  Date started: 01/21/08
6
7  ------------- Copyright (C) 2008 - 2011  Anders Gidenstam        -------------
8  ------------- Copyright (C) 2008  Jon S. Berndt (jon@jsbsim.org) -------------
9
10  This program is free software; you can redistribute it and/or modify it under
11  the terms of the GNU Lesser General Public License as published by the Free Software
12  Foundation; either version 2 of the License, or (at your option) any later
13  version.
14
15  This program is distributed in the hope that it will be useful, but WITHOUT
16  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
18  details.
19
20  You should have received a copy of the GNU Lesser General Public License along with
21  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22  Place - Suite 330, Boston, MA  02111-1307, USA.
23
24  Further information about the GNU Lesser General Public License can also be found on
25  the world wide web at http://www.gnu.org.
26
27 HISTORY
28 --------------------------------------------------------------------------------
29 01/21/08   JSB   Created
30
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 SENTRY
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
34
35 #ifndef FGBUOYANTFORCES_H
36 #define FGBUOYANTFORCES_H
37
38 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 INCLUDES
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
41
42 #include <vector>
43 #include <map>
44
45 #include "FGModel.h"
46 #include "FGGasCell.h"
47 #include "math/FGColumnVector3.h"
48 #include "input_output/FGXMLFileRead.h"
49
50 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 DEFINITIONS
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
53
54 #define ID_BUOYANTFORCES "$Id: FGBuoyantForces.h,v 1.16 2011/10/31 14:54:41 bcoconni Exp $"
55
56 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 FORWARD DECLARATIONS
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59
60 namespace JSBSim {
61
62 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63 CLASS DOCUMENTATION
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
65
66 /** Encapsulates the Buoyant forces calculations.
67     This class owns and contains the list of force/coefficients that define the
68     Buoyant properties of an air vehicle.
69     
70     Here's an example of a gas cell specification:
71
72     @code
73     <buoyant_forces>
74
75       <!-- Interface properties -->
76       <property>ballonets/in-flow-ft3ps[0]</property>
77
78       <gas_cell type="HYDROGEN">
79         <location unit="M">
80           <x> 18.8 </x>
81           <y> 0.0 </y>
82           <z> 0.0 </z>
83         </location>
84         <x_radius unit="M"> 22.86 </x_radius>
85         <y_radius unit="M">  4.55 </y_radius>
86         <z_radius unit="M">  4.55 </z_radius>
87         <max_overpressure unit="PA"> 340.0 </max_overpressure> 
88         <valve_coefficient unit="M4*SEC/KG"> 0.015 </valve_coefficient>
89       </gas_cell>
90       
91       ... {other gas cells} ...
92       
93     </buoyant_forces>
94     @endcode
95
96     See FGGasCell for the full configuration file format for gas cells.
97
98     @author Anders Gidenstam, Jon S. Berndt
99     @version $Id: FGBuoyantForces.h,v 1.16 2011/10/31 14:54:41 bcoconni Exp $
100 */
101
102 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
103 CLASS DECLARATION
104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
105
106 class FGBuoyantForces : public FGModel, public FGXMLFileRead
107 {
108
109 public:
110   /** Constructor
111       @param Executive a pointer to the parent executive object */
112   FGBuoyantForces(FGFDMExec* Executive);
113   /// Destructor
114   ~FGBuoyantForces();
115
116   bool InitModel(void);
117
118   /** Runs the Buoyant forces model; called by the Executive
119       Can pass in a value indicating if the executive is directing the simulation to Hold.
120       @param Holding if true, the executive has been directed to hold the sim from 
121                      advancing time. Some models may ignore this flag, such as the Input
122                      model, which may need to be active to listen on a socket for the
123                      "Resume" command to be given.
124       @return false if no error */
125   bool Run(bool Holding);
126
127   /** Loads the Buoyant forces model.
128       The Load function for this class expects the XML parser to
129       have found the Buoyant_forces keyword in the configuration file.
130       @param element pointer to the current XML element for Buoyant forces parameters.
131       @return true if successful */
132   bool Load(Element* element);
133
134   /** Gets the total Buoyant force vector.
135       @return a force vector in lbs. */
136   const FGColumnVector3& GetForces(void) const {return vTotalForces;}
137
138   /** Gets a component of the total Buoyant force vector.
139       @return a component of the force vector in lbs. */
140   double GetForces(int idx) const {return vTotalForces(idx);}
141
142   /** Gets the total Buoyancy moment vector.
143       @return a moment vector in the body frame in lbs ft. */
144   const FGColumnVector3& GetMoments(void) const {return vTotalMoments;}
145
146   /** Gets a component of the total Buoyancy moment vector.
147       @return a component of the moment vector in the body frame in lbs ft. */
148   double GetMoments(int idx) const {return vTotalMoments(idx);}
149
150   /** Gets the total gas mass. The gas mass is part of the aircraft's
151       inertia.
152       @return mass in slugs. */
153   double GetGasMass(void) const;
154
155   /** Gets the total moment from the gas mass.
156       @return a moment vector in the structural frame in lbs in. */
157   const FGColumnVector3& GetGasMassMoment(void);
158
159   /** Gets the total moments of inertia for the gas mass in the body frame.
160       @return moments of inertia matrix in the body frame
161       in slug ft<sup>2</sup>. */
162   const FGMatrix33& GetGasMassInertia(void);
163
164   /** Gets the strings for the current set of gas cells.
165       @param delimeter either a tab or comma string depending on output type
166       @return a string containing the descriptive names for all parameters */
167   string GetBuoyancyStrings(const string& delimeter);
168
169   /** Gets the coefficient values.
170       @param delimeter either a tab or comma string depending on output type
171       @return a string containing the numeric values for the current set of
172       parameters */
173   string GetBuoyancyValues(const string& delimeter);
174
175   FGGasCell::Inputs in;
176
177 private:
178   vector <FGGasCell*> Cells;
179   // Buoyant forces and moments. Excluding the gas weight.
180   FGColumnVector3 vTotalForces;  // [lbs]
181   FGColumnVector3 vTotalMoments; // [lbs ft]
182
183   // Gas mass related masses, inertias and moments.
184   FGMatrix33 gasCellJ;             // [slug ft^2]
185   FGColumnVector3 vGasCellXYZ;
186   FGColumnVector3 vXYZgasCell_arm; // [lbs in]
187
188   bool NoneDefined;
189
190   void bind(void);
191
192   void Debug(int from);
193 };
194
195 } // namespace JSBSim
196
197 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
198 #endif
199