| 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 ([email protected]) ------------- |
| 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 | |
| 49 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 50 | FORWARD DECLARATIONS |
| 51 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 52 | |
| 53 | namespace JSBSim { |
| 54 | |
| 55 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 56 | CLASS DOCUMENTATION |
| 57 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 58 | |
| 59 | /** Encapsulates the Buoyant forces calculations. |
| 60 | This class owns and contains the list of force/coefficients that define the |
| 61 | Buoyant properties of an air vehicle. |
| 62 | |
| 63 | Here's an example of a gas cell specification: |
| 64 | |
| 65 | @code |
| 66 | <buoyant_forces> |
| 67 | |
| 68 | <!-- Interface properties --> |
| 69 | <property>ballonets/in-flow-ft3ps[0]</property> |
| 70 | |
| 71 | <gas_cell type="HYDROGEN"> |
| 72 | <location unit="M"> |
| 73 | <x> 18.8 </x> |
| 74 | <y> 0.0 </y> |
| 75 | <z> 0.0 </z> |
| 76 | </location> |
| 77 | <x_radius unit="M"> 22.86 </x_radius> |
| 78 | <y_radius unit="M"> 4.55 </y_radius> |
| 79 | <z_radius unit="M"> 4.55 </z_radius> |
| 80 | <max_overpressure unit="PA"> 340.0 </max_overpressure> |
| 81 | <valve_coefficient unit="M4*SEC/KG"> 0.015 </valve_coefficient> |
| 82 | </gas_cell> |
| 83 | |
| 84 | ... {other gas cells} ... |
| 85 | |
| 86 | </buoyant_forces> |
| 87 | @endcode |
| 88 | |
| 89 | See FGGasCell for the full configuration file format for gas cells. |
| 90 | |
| 91 | @author Anders Gidenstam, Jon S. Berndt |
| 92 | */ |
| 93 | |
| 94 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 95 | CLASS DECLARATION |
| 96 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 97 | |
| 98 | class FGBuoyantForces : public FGModel |
| 99 | { |
| 100 | |
| 101 | public: |
| 102 | /** Constructor |
| 103 | @param Executive a pointer to the parent executive object */ |
| 104 | FGBuoyantForces(FGFDMExec* Executive); |
| 105 | /// Destructor |
| 106 | ~FGBuoyantForces() override; |
| 107 | |
| 108 | bool InitModel(void) override; |
| 109 | |
| 110 | /** Runs the Buoyant forces model; called by the Executive |
| 111 | Can pass in a value indicating if the executive is directing the simulation to Hold. |
| 112 | @param Holding if true, the executive has been directed to hold the sim from |
| 113 | advancing time. Some models may ignore this flag, such as the Input |
| 114 | model, which may need to be active to listen on a socket for the |
| 115 | "Resume" command to be given. |
| 116 | @return false if no error */ |
| 117 | bool Run(bool Holding) override; |
| 118 | |
| 119 | /** Loads the Buoyant forces model. |
| 120 | The Load function for this class expects the XML parser to |
| 121 | have found the Buoyant_forces keyword in the configuration file. |
| 122 | @param element pointer to the current XML element for Buoyant forces parameters. |
| 123 | @return true if successful */ |
| 124 | bool Load(Element* element) override; |
| 125 | |
| 126 | /** Gets the total Buoyant force vector. |
| 127 | @return a force vector in lbs. */ |
| 128 | const FGColumnVector3& GetForces(void) const {return vTotalForces;} |
| 129 | |
| 130 | /** Gets a component of the total Buoyant force vector. |
| 131 | @return a component of the force vector in lbs. */ |
| 132 | double GetForces(int idx) const {return vTotalForces(idx);} |
| 133 | |
| 134 | /** Gets the total Buoyancy moment vector. |
| 135 | @return a moment vector in the body frame in lbs ft. */ |
| 136 | const FGColumnVector3& GetMoments(void) const {return vTotalMoments;} |
| 137 | |
| 138 | /** Gets a component of the total Buoyancy moment vector. |
| 139 | @return a component of the moment vector in the body frame in lbs ft. */ |
| 140 | double GetMoments(int idx) const {return vTotalMoments(idx);} |
| 141 | |
| 142 | /** Gets the total gas mass. The gas mass is part of the aircraft's |
| 143 | inertia. |
| 144 | @return mass in slugs. */ |
| 145 | double GetGasMass(void) const; |
| 146 | |
| 147 | /** Gets the total moment from the gas mass. |
| 148 | @return a moment vector in the structural frame in lbs in. */ |
| 149 | const FGColumnVector3& GetGasMassMoment(void); |
| 150 | |
| 151 | /** Gets the total moments of inertia for the gas mass in the body frame. |
| 152 | @return moments of inertia matrix in the body frame |
| 153 | in slug ft<sup>2</sup>. */ |
| 154 | const FGMatrix33& GetGasMassInertia(void); |
| 155 | |
| 156 | /** Gets the strings for the current set of gas cells. |
| 157 | @param delimeter either a tab or comma string depending on output type |
| 158 | @return a string containing the descriptive names for all parameters */ |
| 159 | std::string GetBuoyancyStrings(const std::string& delimeter); |
| 160 | |
| 161 | /** Gets the coefficient values. |
| 162 | @param delimeter either a tab or comma string depending on output type |
| 163 | @return a string containing the numeric values for the current set of |
| 164 | parameters */ |
| 165 | std::string GetBuoyancyValues(const std::string& delimeter); |
| 166 | |
| 167 | FGGasCell::Inputs in; |
| 168 | |
| 169 | private: |
| 170 | std::vector <FGGasCell*> Cells; |
| 171 | // Buoyant forces and moments. Excluding the gas weight. |
| 172 | FGColumnVector3 vTotalForces; // [lbs] |
| 173 | FGColumnVector3 vTotalMoments; // [lbs ft] |
| 174 | |
| 175 | // Gas mass related masses, inertias and moments. |
| 176 | FGMatrix33 gasCellJ; // [slug ft^2] |
| 177 | FGColumnVector3 vGasCellXYZ; |
| 178 | FGColumnVector3 vXYZgasCell_arm; // [lbs in] |
| 179 | |
| 180 | bool NoneDefined; |
| 181 | |
| 182 | void bind(void); |
| 183 | |
| 184 | void Debug(int from) override; |
| 185 | }; |
| 186 | |
| 187 | } // namespace JSBSim |
| 188 | |
| 189 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 190 | #endif |