]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/FGBuoyantForces.h
4cd87259fab0b72e27d701378a540e4eaed3c848
[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  Anders Gidenstam               -------------
8  ------------- Copyright (C) 2008  Jon S. Berndt (jsb@hal-pc.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$"
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       <gas_cell type="HYDROGEN">
75         <location unit="M">
76           <x> 18.8 </x>
77           <y> 0.0 </y>
78           <z> 0.0 </z>
79         </location>
80         <x_radius unit="M"> 22.86 </x_radius>
81         <y_radius unit="M">  4.55 </y_radius>
82         <z_radius unit="M">  4.55 </z_radius>
83         <max_overpressure unit="PA"> 340.0 </max_overpressure> 
84         <valve_coefficient unit="M4*SEC/KG"> 0.015 </valve_coefficient>
85       </gas_cell>
86       
87       ... {other gass cells} ...
88       
89     </buoyant_forces>
90     @endcode
91
92     See FGGasCell for the full configuration file format for gas cells.
93
94     @author Anders Gidenstam, Jon S. Berndt
95     @version $Id$
96 */
97
98 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
99 CLASS DECLARATION
100 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
101
102 class FGBuoyantForces : public FGModel, public FGXMLFileRead
103 {
104
105 public:
106   /** Constructor
107       @param Executive a pointer to the parent executive object */
108   FGBuoyantForces(FGFDMExec* Executive);
109   /// Destructor
110   ~FGBuoyantForces();
111
112   bool InitModel(void);
113
114   /** Runs the Buoyant forces model; called by the Executive
115       @return false if no error */
116   bool Run(void);
117
118   /** Loads the Buoyant forces model.
119       The Load function for this class expects the XML parser to
120       have found the Buoyant_forces keyword in the configuration file.
121       @param element pointer to the current XML element for Buoyant forces parameters.
122       @return true if successful */
123   bool Load(Element* element);
124
125   /** Gets the total Buoyant force vector.
126       @return a force vector. */
127   FGColumnVector3 GetForces(void) {return vTotalForces;}
128
129   /** Gets the total Buoyancy moment vector.
130       @return a moment vector. */
131   FGColumnVector3 GetMoments(void) {return vTotalMoments;}
132
133   /** Gets the total gas mass. The gas mass is part of the aircraft's
134       inertia.
135       @return mass in slugs. */
136   double GetGasMass(void);
137
138   /** Gets the total moment from the gas mass.
139       @return a moment vector. */
140   FGColumnVector3& GetGasMassMoment(void);
141
142   /** Gets the total moments of inertia for the gas mass.
143       @return . */
144   FGMatrix33& GetGasMassInertia(void);
145
146   /** Gets the strings for the current set of gas cells.
147       @param delimeter either a tab or comma string depending on output type
148       @return a string containing the descriptive names for all parameters */
149   string GetBuoyancyStrings(string delimeter);
150
151   /** Gets the coefficient values.
152       @param delimeter either a tab or comma string depending on output type
153       @return a string containing the numeric values for the current set of
154       parameters */
155   string GetBuoyancyValues(string delimeter);
156
157 private:
158   vector <FGGasCell*> Cells;
159   // Buoyant forces and moments. Excluding the gas weight.
160   FGColumnVector3 vTotalForces;
161   FGColumnVector3 vTotalMoments;
162
163   // Gas mass related masses, inertias and moments.
164   FGMatrix33 gasCellJ;
165   FGColumnVector3 vGasCellXYZ;
166   FGColumnVector3 vXYZgasCell_arm;
167
168   bool NoneDefined;
169
170   void bind(void);
171   void unbind(void);
172
173   void Debug(int from);
174 };
175
176 } // namespace JSBSim
177
178 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
179 #endif
180