WSF
WsfSixDOF_FuelTank.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2020 Infoscitex, a DCS Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef WSFSIXDOFFUELTANK_HPP
13#define WSFSIXDOFFUELTANK_HPP
14
15#include "wsf_six_dof_export.h"
16
17#include <cinttypes>
18#include <string>
19
20class UtInput;
21#include "UtVec3dX.hpp"
23#include "WsfSixDOF_Object.hpp"
24
25namespace wsf
26{
27namespace six_dof
28{
30
31// The FuelTank class serves as a fuel container for propulsion objects.
32// It maintains a quantity of fuel and provides functions to allow other
33// objects to take or add fuel from/to the container (fuel tank).
34class WSF_SIX_DOF_EXPORT FuelTank : public Object
35{
36 friend class PropulsionSystem;
37
38public:
39 explicit FuelTank();
40 ~FuelTank();
41
42 FuelTank& operator=(const FuelTank& other) = delete;
43
44 FuelTank* Clone() const;
45
46 bool ProcessInput(UtInput& aInput);
47 bool Initialize(int64_t aSimTime_nanosec);
48
49 // Update should be called every frame. It clears the temp attributes and
50 // sets the current attributes. The other 'update functions' (UpdateFuelBurn,
51 // UpdateFuelFill, and UpdateFuelTransfer) should be called prior to calling
52 // the Update function.
53 void Update(int64_t aSimTime_nanosec);
54
55 // This returns a pointer to the mass properties or null, if none exist
57
58 // SetPropulsionSystem sets the PropulsionSystem parent
60
61 // FuelFlowPathIntact returns true if there is a viable path for fuel to flow.
62 // This essentially confirms that the tank is 'connected' to the fuel system
63 // and not in a tank that is separate from the system getting the fuel
64 bool FuelFlowPathIntact(const PropulsionSystem* aSystemDrawingFuel);
65
66 // CalculateFuelBurn determines if the requested amount of fuel can be
67 // available for burning and also provides the new fuel mass and cg
68 // location. It does not change the state of the fuel object. To change
69 // the state, call UpdateFuelBurn instead.
70 bool CalculateFuelBurn(double aDeltaT_sec,
71 double aFuelBurnRequest_lbs,
72 double& aFuelActuallyProvided_lbs,
73 double& aNewFuelMass_lbs,
74 UtVec3dX& aCgLocation_ft);
75
76 // UpdateFuelBurn burns the requested amount of fuel and confirms that
77 // the fuel is fully available for burning. It also provides the new
78 // fuel mass and cg location. It changes the state of the fuel object.
79 // To perform calculations without changing state, call CalculateFuelBurn
80 // instead.
81 bool UpdateFuelBurn(double aDeltaT_sec,
82 double aFuelBurnRequest_lbs,
83 double& aFuelActuallyProvided_lbs,
84 double& aNewFuelMass_lbs,
85 UtVec3dX& aCgLocation_ft);
86
87 // CalculateFuelFill determines if the requested amount of fuel can be
88 // added to the fuel container and also provides the new fuel mass and
89 // cg location. It does not change the state of the fuel object. To
90 // change the state, call UpdateFuelFill instead.
91 // Fuel fill implies external refueling while fuel transfer implies tank-to-tank.
92 bool CalculateFuelFill(double aDeltaT_sec,
93 double aFuelAddRequest_lbs,
94 double& aFuelActuallyProvided_lbs,
95 double& aNewFuelMass_lbs,
96 UtVec3dX& aCgLocation_ft);
97
98 // UpdateFuelFill adds the requested amount of fuel and to confirms that
99 // the fuel can be added to the container. It also provides the new fuel
100 // mass and cg location. It changes the state of the fuel object. To
101 // perform calculations without changing state, call CalculateFuelFill
102 // instead.
103 // Fuel fill implies external refueling while fuel transfer implies tank-to-tank.
104 bool UpdateFuelFill(double aDeltaT_sec,
105 double aFuelAddRequest_lbs,
106 double& aFuelActuallyProvided_lbs,
107 double& aNewFuelMass_lbs,
108 UtVec3dX& aCgLocation_ft);
109
110 // CalculateFuelTransfer determines if the requested amount of fuel can be
111 // added to the fuel container and also provides the new fuel mass and
112 // cg location. It does not change the state of the fuel object. To
113 // change the state, call UpdateFuelTransfer instead. The aFuelAddRequest_lbs
114 // can be either positive (adding fuel) or negative (removing fuel).
115 // Fuel fill implies external refueling while fuel transfer implies tank-to-tank.
116 bool CalculateFuelTransfer(double aDeltaT_sec,
117 double aFuelAddRequest_lbs,
118 double& aFuelActuallyProvided_lbs,
119 double& aNewFuelMass_lbs,
120 UtVec3dX& aCgLocation_ft);
121
122 // UpdateFuelTransfer adds the requested amount of fuel and to confirms that
123 // the fuel can be added to the container. It also provides the new fuel
124 // mass and cg location. It changes the state of the fuel object. To
125 // perform calculations without changing state, call CalculateFuelTransfer
126 // instead. The aFuelAddRequest_lbs can be either positive (adding fuel) or
127 // negative (removing fuel).
128 // Fuel fill implies external refueling while fuel transfer implies tank-to-tank.
129 bool UpdateFuelTransfer(double aDeltaT_sec,
130 double aFuelAddRequest_lbs,
131 double& aFuelActuallyProvided_lbs,
132 double& aNewFuelMass_lbs,
133 UtVec3dX& aCgLocation_ft);
134
135 // SetMaxFuelQuantity sets the maximum amount of fuel in the container.
136 void SetMaxFuelQuantity(double aFuelQuantity_lbs);
137
138 // GetFuelCapacity_lbs returns the maximum amount of fuel (capacity) of the container.
139 double GetFuelCapacity_lbs() const;
140
141 // GetPercentFull returns the current percent full -- 100.0 is returned if full
142 double GetPercentFull() const;
143
144 // SetCurrentFuelQuantity sets the current amount of fuel in the container.
145 void SetCurrentFuelQuantity(double aFuelQuantity_lbs);
146
147 // GetCurrentFuelQuantity_lbs returns the current amount of fuel in the container.
148 double GetCurrentFuelQuantity_lbs() const;
149
150 // GetFuelFraction returns a normalized value of current fuel to maximum fuel
151 // for the container. For example, 0.4 is returned when 40% fuel is remaining.
152 double GetFuelFraction() const;
153
154 // GetFuelFlow_pps returns the current fuel flow rate in lbs per second.
155 double GetFuelFlow_pps() const;
156
157 // GetFuelFlow_pph returns the current fuel flow rate in lbs per hour.
158 double GetFuelFlow_pph() const;
159
160 // GetFuelFillRate_pps returns the current fuel fill rate in lbs per second.
161 double GetFuelFillRate_pps() const;
162
163 // GetFuelFillRate_pph returns the current fuel fill rate in lbs per hour.
164 double GetFuelFillRate_pph() const;
165
166 // GetMaxFuelTransferRate_pps returns the max fuel transfer rate in lbs per second.
167 double GetMaxFuelTransferRate_pps() const;
168
169 // GetFuelTransferRate_pps returns the current fuel transfer rate in lbs per second.
170 double GetFuelTransferRate_pps() const;
171
172 // GetFuelTransferRate_pph returns the current fuel transfer rate in lbs per hour.
173 double GetFuelTransferRate_pph() const;
174
175 // SetFullCgLocation_ft sets the cg location relative to its parent when the
176 // container is full. This is typically the mid-point of the fuel tank.
177 void SetFullCgLocation_ft(const UtVec3dX& aCgLocation_ft);
178
179 // SetEmptyCgLocation_ft sets the cg location relative to its parent when the
180 // container is empty. This is typically the bottom of the fuel tank.
181 void SetEmptyCgLocation_ft(const UtVec3dX& aCgLocation_ft);
182
183 // GetCurrentCgLocation_ft returns the current cg location relative to its parent.
184 // It is based on the full and empty cg locations and the ratio of current fuel
185 // to maximum fuel.
186 UtVec3dX GetCurrentCgLocation_ft() const;
187
188 // GetFullCgLocation_ft returns the full cg location relative to its parent.
189 UtVec3dX GetFullCgLocation_ft() const;
190
191 // GetEmptyCgLocation_ft returns the empty cg location relative to its parent.
192 UtVec3dX GetEmptyCgLocation_ft() const;
193
194 // SetMaxFlowRate_pps sets the maximum flow rate supported by the tank.
195 // This function is typically used for testing.
196 void SetMaxFlowRate_pps(double aMaxFlowRate_pps) { mMaxFlowRate_pps = aMaxFlowRate_pps; }
197
198 // This calculates the current mass properties, including those
199 // from fuel tanks as well as some thrust producers such as
200 // solid-propellant rockets
201 void CalculateCurrentMassProperties();
202
203protected:
204 explicit FuelTank(const FuelTank& aSrc);
205
206 // CalcCgLocation_ft returns cg location relative to its parent, based on fuel quantity
207 UtVec3dX CalcCgLocation_ft(double aFuelQuantity_lbs);
208
211
212 double mMaxFlowRate_pps = 0.0; // Maximum output fuel rate to engines
213 double mMaxFillRate_pps = 0.0; // Maximum fuel input rate during refueling
214 double mMaxTransferRate_pps = 0.0; // Maximum fuel transfer rate between tanks
215 double mMaxQuantity_lbs = 0.0; // Maximum fuel quantity of tank
216
217 double mCurrentFuelFlow_pps = 0.0; // Current fuel flow rate to engines
218 double mCurrentFillRate_pps = 0.0; // Current fuel fill rate
219 double mCurrentTransferRate_pps = 0.0; // Current fuel transfer rate
220 double mCurrentQuantity_lbs = 0.0; // Current amount of fuel in tank
221
222 double mTempCurrentFuelFlow_pps = 0.0; // Current fuel flow rate to engines
223 double mTempCurrentFillRate_pps = 0.0; // Current fuel fill rate
224 double mTempCurrentTransferRate_pps = 0.0; // Current fuel transfer rate
225
226 UtVec3dX mCurrentCgLocation_ft; // Current fuel cg location, rel to parent
227 UtVec3dX mFullCgLocation_ft; // Typically the center of the tank
228 UtVec3dX mEmptyCgLocation_ft; // Typically the bottom of the tank
229 UtVec3dX mCgEmptyToFullVector; // Vector pointing from empty to full
230
232};
233} // namespace six_dof
234} // namespace wsf
235
236#endif
aObjectPtr Update(simTime)
Definition WsfSixDOF_FuelTank.hpp:35
UtVec3dX mEmptyCgLocation_ft
Definition WsfSixDOF_FuelTank.hpp:228
bool Initialize(int64_t aSimTime_nanosec)
Definition WsfSixDOF_FuelTank.cpp:205
void SetMaxFlowRate_pps(double aMaxFlowRate_pps)
Definition WsfSixDOF_FuelTank.hpp:196
double mTempCurrentTransferRate_pps
Definition WsfSixDOF_FuelTank.hpp:224
double mTempCurrentFillRate_pps
Definition WsfSixDOF_FuelTank.hpp:223
FuelTank()
Definition WsfSixDOF_FuelTank.cpp:23
double mMaxFlowRate_pps
Definition WsfSixDOF_FuelTank.hpp:212
friend class PropulsionSystem
Definition WsfSixDOF_FuelTank.hpp:36
double mCurrentTransferRate_pps
Definition WsfSixDOF_FuelTank.hpp:219
bool ProcessInput(UtInput &aInput)
Definition WsfSixDOF_FuelTank.cpp:63
double mMaxFillRate_pps
Definition WsfSixDOF_FuelTank.hpp:213
PropulsionSystem * mPropulsionSystem
Definition WsfSixDOF_FuelTank.hpp:209
double mMaxTransferRate_pps
Definition WsfSixDOF_FuelTank.hpp:214
FuelTank & operator=(const FuelTank &other)=delete
UtVec3dX mFullCgLocation_ft
Definition WsfSixDOF_FuelTank.hpp:227
UtVec3dX mCgEmptyToFullVector
Definition WsfSixDOF_FuelTank.hpp:229
void SetPropulsionSystem(PropulsionSystem *aParent)
Definition WsfSixDOF_FuelTank.hpp:59
double mTempCurrentFuelFlow_pps
Definition WsfSixDOF_FuelTank.hpp:222
int64_t mLastSimTime_nanosec
Definition WsfSixDOF_FuelTank.hpp:231
const MassProperties & GetMassProperties() const
Definition WsfSixDOF_FuelTank.hpp:56
UtVec3dX mCurrentCgLocation_ft
Definition WsfSixDOF_FuelTank.hpp:226
double mCurrentFuelFlow_pps
Definition WsfSixDOF_FuelTank.hpp:217
FuelTank * Clone() const
Definition WsfSixDOF_FuelTank.cpp:33
double mMaxQuantity_lbs
Definition WsfSixDOF_FuelTank.hpp:215
MassProperties mMassProperties
Definition WsfSixDOF_FuelTank.hpp:210
double mCurrentQuantity_lbs
Definition WsfSixDOF_FuelTank.hpp:220
double mCurrentFillRate_pps
Definition WsfSixDOF_FuelTank.hpp:218
Definition WsfSixDOF_MassProperties.hpp:29
Definition WsfSixDOF_PropulsionSystem.hpp:35
Definition WsfSA_Processor.hpp:35
Function definitions for those who need run-time access to the version.
Definition WsfComm.cpp:32
Copyrights Multiple, All Rights Reserved