]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/FGBuoyantForces.h
86f5d696f38194ce58bb7dd060b0fcebc1e88c6f
[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 #ifdef FGFS
43 #  include <simgear/compiler.h>
44 #  ifdef SG_HAVE_STD_INCLUDES
45 #    include <vector>
46 #    include <map>
47 #  else
48 #    include <vector.h>
49 #    include <map.h>
50 #  endif
51 #else
52 #  include <vector>
53 #  include <map>
54 #endif
55
56 #include "FGModel.h"
57 #include "FGGasCell.h"
58 #include <math/FGColumnVector3.h>
59 #include <input_output/FGXMLFileRead.h>
60
61 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 DEFINITIONS
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
64
65 #define ID_BUOYANTFORCES "$Id$"
66
67 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
68 FORWARD DECLARATIONS
69 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
70
71 namespace JSBSim {
72
73 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74 CLASS DOCUMENTATION
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
76
77 /** Encapsulates the Buoyant forces calculations.
78     This class owns and contains the list of force/coefficients that define the
79     Buoyant properties of an air vehicle.
80     
81     Here's an example of a gas cell specification:
82
83     @code
84     <buoyant_forces>
85       <gas_cell type="HYDROGEN">
86         <location unit="M">
87           <x> 18.8 </x>
88           <y> 0.0 </y>
89           <z> 0.0 </z>
90         </location>
91         <x_radius unit="M"> 22.86 </x_radius>
92         <y_radius unit="M">  4.55 </y_radius>
93         <z_radius unit="M">  4.55 </z_radius>
94         <max_overpressure unit="PA"> 340.0 </max_overpressure> 
95         <valve_coefficient unit="M4*SEC/KG"> 0.015 </valve_coefficient>
96       </gas_cell>
97       
98       ... {other gass cells} ...
99       
100     </buoyant_forces>
101     @endcode
102
103     See FGGasCell for the full configuration file format for gas cells.
104
105     @author Anders Gidenstam, Jon S. Berndt
106     @version $Id$
107 */
108
109 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
110 CLASS DECLARATION
111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
112
113 class FGBuoyantForces : public FGModel, public FGXMLFileRead
114 {
115
116 public:
117   /** Constructor
118       @param Executive a pointer to the parent executive object */
119   FGBuoyantForces(FGFDMExec* Executive);
120   /// Destructor
121   ~FGBuoyantForces();
122
123   bool InitModel(void);
124
125   /** Runs the Buoyant forces model; called by the Executive
126       @return false if no error */
127   bool Run(void);
128
129   /** Loads the Buoyant forces model.
130       The Load function for this class expects the XML parser to
131       have found the Buoyant_forces keyword in the configuration file.
132       @param element pointer to the current XML element for Buoyant forces parameters.
133       @return true if successful */
134   bool Load(Element* element);
135
136   /** Gets the total Buoyant force vector.
137       @return a force vector. */
138   FGColumnVector3 GetForces(void) {return vTotalForces;}
139
140   /** Gets the total Buoyancy moment vector.
141       @return a moment vector. */
142   FGColumnVector3 GetMoments(void) {return vTotalMoments;}
143
144   /** Gets the total gas mass. The gas mass is part of the aircraft's
145       inertia.
146       @return mass in slugs. */
147   double GetGasMass(void);
148
149   /** Gets the total moment from the gas mass.
150       @return a moment vector. */
151   FGColumnVector3& GetGasMassMoment(void);
152
153   /** Gets the total moments of inertia for the gas mass.
154       @return . */
155   FGMatrix33& GetGasMassInertia(void);
156
157   /** Gets the strings for the current set of gas cells.
158       @param delimeter either a tab or comma string depending on output type
159       @return a string containing the descriptive names for all parameters */
160   string GetBuoyancyStrings(string delimeter);
161
162   /** Gets the coefficient values.
163       @param delimeter either a tab or comma string depending on output type
164       @return a string containing the numeric values for the current set of
165       parameters */
166   string GetBuoyancyValues(string delimeter);
167
168 private:
169   vector <FGGasCell*> Cells;
170   // Buoyant forces and moments. Excluding the gas weight.
171   FGColumnVector3 vTotalForces;
172   FGColumnVector3 vTotalMoments;
173
174   // Gas mass related masses, inertias and moments.
175   FGMatrix33 gasCellJ;
176   FGColumnVector3 vGasCellXYZ;
177   FGColumnVector3 vXYZgasCell_arm;
178
179   bool NoneDefined;
180
181   void bind(void);
182   void unbind(void);
183
184   void Debug(int from);
185 };
186
187 } // namespace JSBSim
188
189 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
190 #endif
191