FlightGear next
FGTank.h
Go to the documentation of this file.
1/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Header: FGTank.h
4 Author: Jon S. Berndt
5 Date started: 01/21/99
6
7 ------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org) -------------
8
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser General Public License as published by the Free
11 Software Foundation; either version 2 of the License, or (at your option) any
12 later version.
13
14 This program is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
17 details.
18
19 You should have received a copy of the GNU Lesser General Public License along
20 with this program; if not, write to the Free Software Foundation, Inc., 59
21 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23 Further information about the GNU Lesser General Public License can also be
24 found on the world wide web at http://www.gnu.org.
25
26FUNCTIONAL DESCRIPTION
27--------------------------------------------------------------------------------
28
29Based on Flightgear code, which is based on LaRCSim. This class simulates
30a generic Tank.
31
32HISTORY
33--------------------------------------------------------------------------------
3401/21/99 JSB Created
35
36%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37SENTRY
38%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
39
40#ifndef FGTank_H
41#define FGTank_H
42
43/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44INCLUDES
45%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
46
47#include "FGJSBBase.h"
49
50/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51FORWARD DECLARATIONS
52%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
53
54namespace JSBSim {
55
56class Element;
58class FGFDMExec;
59class FGFunction;
60
61/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62CLASS DOCUMENTATION
63%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
64
196
197/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
198CLASS DECLARATION
199%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
200
201class FGTank : public FGJSBBase
202{
203public:
211 FGTank(FGFDMExec* exec, Element* el, int tank_number);
213 ~FGTank();
214
217
224 double Drain(double used);
225
232 double Calculate(double dt, double TempC);
233
237 int GetType(void) const {return Type;}
238
240 void ResetToIC(void);
241
244 bool GetSelected(void) const {return Selected;}
245
248 double GetPctFull(void) const {return PctFull;}
249
252 double GetCapacity(void) const {return Capacity;}
253
256 double GetCapacityGallons(void) const {return Capacity/Density;}
257
260 double GetContents(void) const {return Contents;}
261
264 double GetContentsGallons(void) const {return Contents/Density;}
265
271 double GetTemperature_degC(void) const {return Temperature;}
272
278 double GetTemperature(void) const {return CelsiusToFahrenheit(Temperature);}
279
282 double ProcessFuelName(const std::string& name);
283
286 double GetUnusable(void) const {return UnusableVol*Density;}
287
290 double GetUnusableVolume(void) const {return UnusableVol;}
291
294 void SetUnusableVolume(double volume) {UnusableVol = volume;}
295
296 double GetIxx(void) const {return Ixx;}
297 double GetIyy(void) const {return Iyy;}
298 double GetIzz(void) const {return Izz;}
299
300 inline double GetLocationX(void) const { return vXYZ(eX); }
301 inline double GetLocationY(void) const { return vXYZ(eY); }
302 inline double GetLocationZ(void) const { return vXYZ(eZ); }
303 inline void SetLocationX(double x) { vXYZ(eX) = x; }
304 inline void SetLocationY(double y) { vXYZ(eY) = y; }
305 inline void SetLocationZ(double z) { vXYZ(eZ) = z; }
306
307 double GetStandpipe(void) const {return Standpipe;}
308
309 int GetPriority(void) const {return Priority;}
310 void SetPriority(int p) { Priority = p; Selected = p>0 ? true:false; }
311
314 double GetDensity(void) const {return Density;}
317 void SetDensity(double d) { Density = d; }
318
319 double GetExternalFlow(void) const {return ExternalFlow;}
320 void SetExternalFlow(double f) { ExternalFlow = f; }
321
322 FGColumnVector3 GetXYZ(void) const;
323 double GetXYZ(int idx) const;
324
325 GrainType GetGrainType(void) const {return grainType;}
326
327 double Fill(double amount);
328 void SetContents(double amount);
329 void SetContentsGallons(double gallons);
330 void SetTemperature(double temp) { Temperature = temp; }
331 void SetStandpipe(double amount) { Standpipe = amount; }
332 void SetSelected(bool sel) { sel==true ? SetPriority(1):SetPriority(0); }
333
334private:
335 TankType Type;
336 GrainType grainType;
337 int TankNumber;
338 std::string type;
339 std::string strGType;
340 double ixx_unit;
341 double iyy_unit;
342 double izz_unit;
343 FGColumnVector3 vXYZ;
344 FGColumnVector3 vXYZ_drain;
345 FGFunction* function_ixx;
346 FGFunction* function_iyy;
347 FGFunction* function_izz;
348 double Capacity, UnusableVol;
349 double Radius;
350 double InnerRadius;
351 double Length;
352 double Volume;
353 double Density;
354 double Ixx;
355 double Iyy;
356 double Izz;
357 double InertiaFactor;
358 double PctFull;
359 double Contents, InitialContents;
360 double Area;
361 double Temperature, InitialTemperature;
362 double Standpipe, InitialStandpipe;
363 double ExternalFlow;
364 bool Selected;
365 int Priority, InitialPriority;
366
367 void CalculateInertias(void);
368 void bind(FGPropertyManager* PropertyManager);
369 void Debug(int from);
370};
371}
372//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
373#endif
#define p(x)
This class implements a 3 element column vector.
Represents a mathematical function.
Definition FGFunction.h:753
FGJSBBase()
Constructor for FGJSBBase.
Definition FGJSBBase.h:81
static constexpr double CelsiusToFahrenheit(double celsius)
Converts from degrees Celsius to degrees Fahrenheit.
Definition FGJSBBase.h:237
bool GetSelected(void) const
If the tank is set to supply fuel, this function returns true.
Definition FGTank.h:244
void SetContentsGallons(double gallons)
Definition FGTank.cpp:323
double GetPctFull(void) const
Gets the tank fill level.
Definition FGTank.h:248
double GetLocationY(void) const
Definition FGTank.h:301
void SetUnusableVolume(double volume)
Sets the volume of unusable fuel in the tank.
Definition FGTank.h:294
double GetCapacity(void) const
Gets the capacity of the tank.
Definition FGTank.h:252
~FGTank()
Destructor.
Definition FGTank.cpp:233
double GetContentsGallons(void) const
Gets the contents of the tank.
Definition FGTank.h:264
void ResetToIC(void)
Resets the tank parameters to the initial conditions.
Definition FGTank.cpp:240
double GetUnusableVolume(void) const
Returns the unusable volume of fuel in the tank.
Definition FGTank.h:290
double Drain(double used)
Removes fuel from the tank.
Definition FGTank.cpp:266
double GetTemperature_degC(void) const
Gets the temperature of the fuel.
Definition FGTank.h:271
double GetTemperature(void) const
Gets the temperature of the fuel.
Definition FGTank.h:278
double GetContents(void) const
Gets the contents of the tank.
Definition FGTank.h:260
double GetLocationZ(void) const
Definition FGTank.h:302
double GetIyy(void) const
Definition FGTank.h:297
void SetExternalFlow(double f)
Definition FGTank.h:320
double GetIxx(void) const
Definition FGTank.h:296
double GetStandpipe(void) const
Definition FGTank.h:307
double Calculate(double dt, double TempC)
Performs local, tanks-specific calculations, such as fuel temperature.
Definition FGTank.cpp:331
void SetTemperature(double temp)
Definition FGTank.h:330
void SetSelected(bool sel)
Definition FGTank.h:332
int GetType(void) const
Retrieves the type of tank: Fuel or Oxidizer.
Definition FGTank.h:237
void SetLocationX(double x)
Definition FGTank.h:303
void SetPriority(int p)
Definition FGTank.h:310
void SetDensity(double d)
Sets the fuel density.
Definition FGTank.h:317
void SetLocationZ(double z)
Definition FGTank.h:305
double GetLocationX(void) const
Definition FGTank.h:300
void SetLocationY(double y)
Definition FGTank.h:304
void SetStandpipe(double amount)
Definition FGTank.h:331
double GetCapacityGallons(void) const
Gets the capacity of the tank.
Definition FGTank.h:256
double GetIzz(void) const
Definition FGTank.h:298
double ProcessFuelName(const std::string &name)
Returns the density of a named fuel type.
Definition FGTank.cpp:419
FGColumnVector3 GetXYZ(void) const
Definition FGTank.cpp:252
int GetPriority(void) const
Definition FGTank.h:309
double Fill(double amount)
Definition FGTank.cpp:287
void SetContents(double amount)
Definition FGTank.cpp:308
double GetUnusable(void) const
Returns the amount of unusable fuel in the tank.
Definition FGTank.h:286
double GetExternalFlow(void) const
Definition FGTank.h:319
double GetDensity(void) const
Returns the fuel density.
Definition FGTank.h:314
GrainType GetGrainType(void) const
Definition FGTank.h:325
FGTank(FGFDMExec *exec, Element *el, int tank_number)
Constructor.
Definition FGTank.cpp:51
const char * name