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