WSF
P6DofPropulsionSystem.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 P6DOFPROPULSIONSYSTEM_H
13#define P6DOFPROPULSIONSYSTEM_H
14
15#include "p6dof_export.h"
16
17#include <cinttypes>
18#include <string>
19#include <unordered_map>
20#include <vector>
21
23#include "P6DofObject.hpp"
25#include "UtVec3dX.hpp"
26
29class P6DofFuelTank;
30class P6DofScenario;
31class P6DofVehicle;
32class UtInput;
33
34class P6DOF_EXPORT P6DofPropulsionSystem : public P6DofObject
35{
36public:
37 explicit P6DofPropulsionSystem(P6DofScenario* aScenario);
38 ~P6DofPropulsionSystem() override;
39
41
43
44 void SetParentVehicle(P6DofVehicle* aParentVehicle) override;
45
54
55 // ProcessInput reads initialization data
56 bool ProcessInput(UtInput& aInput);
57 bool Initialize(int64_t aSimTime_nanosec);
58
59 // Update should be called every frame. It clears the temp attributes and
60 // sets the current attributes. The other 'update functions' (UpdateFuelBurn,
61 // UpdateFuelFill, and UpdateFuelTransfer) should be called prior to calling
62 // the Update function.
63 void Update(int64_t aSimTime_nanosec);
64
65 void SetLastSimTime(int64_t aLastSimTime_nanosec) { mLastSimTime_nanosec = aLastSimTime_nanosec; }
66
67 // The CalculatePropulsionFM function is called to calculate the propulsion
68 // forces and moments. It does not change the state of the propulsion object.
69 // To change the state, call UpdatePropulsionFM instead. This version
70 // uses the thrust producer's internal throttle values.
71 void CalculatePropulsionFM(double aDeltaT_sec,
72 double aAlt_ft,
73 double aDynPress_lbsqft,
74 double aStatPress_lbssqft,
75 double aSpeed_fps,
76 double aMach,
77 double aAlpha_rad,
78 double aBeta_rad,
79 P6DofForceAndMomentsObject& aForceAndMoment,
80 double& aFuelBurnRate_pps,
81 double& aFuelBurned_lbs);
82
83 // The UpdatePropulsionFM function is called to calculate the propulsion
84 // forces and moments and update the state of the propulsion object.
85 // To perform F&M calculations without changing the state, call the
86 // CalculatePropulsionFM function instead. This version
87 // uses the thrust producer's internal throttle values.
88 void UpdatePropulsionFM(double aDeltaT_sec,
89 double aAlt_ft,
90 double aDynPress_lbsqft,
91 double aStatPress_lbssqft,
92 double aSpeed_fps,
93 double aMach,
94 double aAlpha_rad,
95 double aBeta_rad,
96 P6DofForceAndMomentsObject& aForceAndMoment,
97 double& aFuelBurnRate_pps,
98 double& aFuelBurned_lbs);
99
100 // GetFuelTankByName returns the fuel tank with the specified name
101 P6DofFuelTank* GetFuelTank(const std::string& aName) const;
102
103 // GetFuelTankList returns the list of fuel tanks in this propulsion object
104 const std::unordered_map<std::string, P6DofFuelTank*>& GetFuelTanks() const { return mFuelTankMap; }
105
106 // GetThrustProducerObjectByName returns the engine with the specified name
107 P6DofThrustProducerObject* GetThrustProducerObjectByName(const std::string& aName) const;
108
109 // GetThrustProduceByIndex returns the engine with the specified index
110 P6DofThrustProducerObject* GetThrustProducerByIndex(size_t aIndex) const;
111
112 // GetThrustProduceList returns the list of engines in this propulsion object
113 const std::vector<P6DofThrustProducerObject*>& GetThrustProducerList() const { return mEngineList; }
114
115 // SetThrottleLeverPosition sets the throttles on all engines of this object
116 void SetThrottleLeverPosition(double aThrottleLeverPosition);
117
118 // SetThrustVectoringPitch_deg sets the thrust vectoring in yaw
119 void SetThrustVectoringYaw_deg(double aThrustVectoringAngle_deg);
120
121 // SetThrustVectoringPitch_deg sets the thrust vectoring in pitch
122 void SetThrustVectoringPitch_deg(double aThrustVectoringAngle_deg);
123
124 // EnableThrustVectoring enables/disable thrust vectoring
125 void EnableThrustVectoring(bool aEnableThrustVectoring);
126
127 // SetThrustVectoringPitch_deg sets the thrust vectoring in pitch
128 void SetThrustReserver(double aThrustReserverSetting);
129
130 // EnableThrustReverser enables/disable thrust vectoring
131 void EnableThrustReverser(bool aEnableThrustReverser);
132
133 // Returns true if reverser is enabled
135
136 // Returns true if vectoring is enabled
138
139 // Returns true if an afterburner is present on any engine
140 bool AfterburnerIsPresent() const;
141
142 // GetNumThrustProducers returns the number of engines in this propulsion object
143 size_t GetNumThrustProducers() const;
144
145 // GetNumFuelTanks returns the number of fuel tanks in this propulsion object
146 size_t GetNumFuelTanks() const;
147
148 // Ignite ignites/starts all engines of this object
149 void Ignite(int64_t aIgniteTimeInFrame_nanosec);
150
151 // Shutdown terminates thrust for all engines of this object
152 // aTerminateTime_sec is the time termination occurs
153 void Shutdown(int64_t aTerminateTime_nanosec = 0);
154
155 // RemoveFuelTankByName returns true if the tank was removed
156 bool RemoveFuelTankByName(std::string aName);
157
158 // This requests adding a fuel transfer, but does not "connect it up".
159 // It is typically used during setup (such as ProcessInput) and
160 // returns true if the fuel transfer was added.
161 bool AddFuelTransfer(const std::string& aTransferName,
162 const std::string& aSourceTankName,
163 const std::string& aTargetTankName);
164
165 // This is used to support script-commanded fuel transfers and "connects
166 // it up" within the fuel system. It returns true if the fuel transfer was added.
167 bool AddFuelTransferAndConnect(const std::string& aTransferName,
168 const std::string& aSourceTankName,
169 const std::string& aTargetTankName);
170
171 // RemoveFuelTransfer returns true if the transfer was removed
172 bool RemoveFuelTransfer(const std::string& aTransferName);
173
174 bool ModifyFuelQuantity(const std::string& aTankName, double aQty_lbs);
175
176 bool FuelTransferNameUnique(const std::string& aName) const;
177
178 // This returns true is at least one thrust producer is producing thrust
179 bool IsProducingThrust() const;
180
181 // This specifies the fuel feed (input tank name) for the specified engine.
182 // It returns true if the assignment is successful.
183 bool SetFuelFeed(std::string& aEngineName, std::string aFuelTankName);
184
185 // This specifies the fuel feed (input tank name) for all engines.
186 // It returns true if the assignment is successful.
187 bool SetFuelFeed(std::string aFuelTankName);
188
189 // .....................................................................................................
190
191 void SetControlInputHandles(const P6DofFlightControlSystem* aFlightControlSystem);
192 void SetControlInputValues(const P6DofFlightControlSystem* aFlightControlSystem);
193
194 // .....................................................................................................
195
196 // This returns the maximum internal fuel for the object.
197 // Note that this is quantity of fuel in fuel tanks, and does not include fuel in solid propellant rockets, for example.
198 double GetInternalFuelTankCapacity_lbs() const;
199
200 // This returns the current internal fuel for the object
201 double GetCurrentInternalFuelTankQuantity_lbs() const;
202
203 // This adds fuel in a simplistic manner. It does not use the "fill rate" limit of
204 // tanks -- hence all of the fuel is put into the tank(s) at once. Later, we can
205 // add a "proper" fuel fill that is more realistic and deals with a fill rate
206 // that will require a finite amount of time to transfer. This function will try to
207 // fill all tanks, but if insufficient fuel is being added, it will split the fuel
208 // across tanks, making all tanks the same percent full. The function returns the
209 // amount of fuel added.
210 double AddFuelQuantity_lbs(double aFuelToAdd_lbs);
211
212 // This adds fuel, as needed, to each tank in the system to the specified
213 // percent full level for each tank. If the tank was already at a higher
214 // percent full, fuel will be "drained" to bring it to the specified level.
215 // The function returns the amount of fuel used in filling/draining all tanks.
216 double FillAllTanks(double aPercentFull);
217
218 // This drains all fuel from all of the tanks
219 void EmptyAllTanks();
220
221 // .....................................................................................................
222
223 // This returns a pointer to the mass properties or null, if none exist
225
226 // This calculates the current mass properties, including those
227 // from fuel tanks as well as some thrust producers such as
228 // solid-propellant rockets
229 void CalculateCurrentMassProperties();
230
231 // .....................................................................................................
232
233 // Appearance Parameters. These will determine if any engine has the specified condition.
234 // After using this function, individual engines can be consulted for their conditions.
235
236 // Return true if at least one engine is operating.
237 // If aTestSubobjects (optional) is true, if will test subobjects. Otherwise, it
238 // will only test its own propulsion objects (the default).
239 bool AnEngineIsOperating(bool aTestSubobjects = false) const;
240
241 // Return true if at least one engine is operating
242 // If aTestSubobjects (optional) is true, if will test subobjects. Otherwise, it
243 // will only test its own propulsion objects (the default).
244 bool AnEngineIsSmoking(bool aTestSubobjects = false) const;
245
246 // Return true if at least one engine is operating
247 // If aTestSubobjects (optional) is true, if will test subobjects. Otherwise, it
248 // will only test its own propulsion objects (the default).
249 bool AnEngineHasAfterburnerOn(bool aTestSubobjects = false) const;
250
251 // Return true if at least one engine is contrailing
252 // If aTestSubobjects (optional) is true, if will test subobjects. Otherwise, it
253 // will only test its own propulsion objects (the default).
254 bool AnEngineIsContrailing(bool aTestSubobjects = false) const;
255
256 // Return true if at least one engine has a smoke trailing effect
257 // If aTestSubobjects (optional) is true, if will test subobjects. Otherwise, it
258 // will only test its own propulsion objects (the default).
259 bool AnEngineIsEmittingSmokeTrail(bool aTestSubobjects = false) const;
260
261 // This will make an engine smoke. If an index of zero is used, all engines will smoke.
262 void MakeAnEngineSmoke(int aEngineIndex);
263
264 // .....................................................................................................
265
266protected:
268
269 void PropulsionCalculationsFM(double aDeltaT_sec,
270 double aAlt_ft,
271 double aDynPress_lbsqft,
272 double aStatPress_lbssqft,
273 double aSpeed_fps,
274 double aMach,
275 double aAlpha_rad,
276 double aBeta_rad,
277 P6DofForceAndMomentsObject& aForceAndMoment,
278 double& aFuelBurnRate_pps,
279 double& aFuelBurned_lbs,
280 bool aUpdateData);
281
282 void RemoveInvalidFuelTransfers();
283
289
291 {
293 std::vector<fuelTankData> sourceTankList;
294 };
295
297 {
298 // baseTypeName string identifier for the class (such as "Jet" or "Ramjet"), See P6DofThrustProducerObject::GetClassType()
299 std::string baseTypeName;
300 std::string typeName;
301 std::string instanceName;
302 std::string fuelFeedName;
303 UtVec3dX relPos;
304 double offset_ft;
305 UtVec3dX relYPR;
306 };
307
308 std::vector<P6DofThrustProducerObject*> mEngineList;
309 std::vector<ThrustProducerTypeInfo*> mEngineTypeList;
310 std::unordered_map<std::string, P6DofFuelTank*> mFuelTankMap;
311 std::vector<FuelTransfer*> mFuelTransferList;
312 double mPropulsionSystemThrottleLeverPosition; // Overall throttle lever position
314
315 std::vector<P6DofThrustProducerObject::ThrustControlInputValueData*> mThrustControlInputValueDataList;
316
326
332
334};
335
336#endif
aObjectPtr Update(simTime)
Definition P6DofFlightControlSystem.hpp:42
Definition P6DofForceAndMomentsObject.hpp:24
Definition P6DofFuelTank.hpp:33
Definition P6DofMassProperties.hpp:26
P6DofObject(P6DofScenario *aScenario)
Definition P6DofObject.cpp:17
P6DofObject * Clone() const
Definition P6DofObject.cpp:24
virtual void SetParentVehicle(P6DofVehicle *aParentVehicle)
Definition P6DofObject.hpp:39
Definition P6DofPropulsionSystem.hpp:35
P6DofThrustProducerObject::ThrustControlInputValueData * mThrottleSettingPitch
Definition P6DofPropulsionSystem.hpp:321
std::vector< P6DofThrustProducerObject * > mEngineList
Definition P6DofPropulsionSystem.hpp:308
double mPropulsionSystemThrottleLeverPosition
Definition P6DofPropulsionSystem.hpp:312
const std::vector< P6DofThrustProducerObject * > & GetThrustProducerList() const
Definition P6DofPropulsionSystem.hpp:113
std::vector< ThrustProducerTypeInfo * > mEngineTypeList
Definition P6DofPropulsionSystem.hpp:309
bool mThrustVectorPitchSet
Definition P6DofPropulsionSystem.hpp:325
bool Initialize(int64_t aSimTime_nanosec)
Definition P6DofPropulsionSystem.cpp:177
bool mThrustReverserSet
Definition P6DofPropulsionSystem.hpp:323
std::vector< P6DofThrustProducerObject::ThrustControlInputValueData * > mThrustControlInputValueDataList
Definition P6DofPropulsionSystem.hpp:315
bool mEnableThrustVectoring
Definition P6DofPropulsionSystem.hpp:329
std::vector< FuelTransfer * > mFuelTransferList
Definition P6DofPropulsionSystem.hpp:311
P6DofThrustProducerObject::ThrustControlInputValueData * mThrottleSettingYaw
Definition P6DofPropulsionSystem.hpp:320
bool ProcessInput(UtInput &aInput)
Definition P6DofPropulsionSystem.cpp:309
bool mEnableThrustReverser
Definition P6DofPropulsionSystem.hpp:331
P6DofPropulsionSystem & operator=(const P6DofPropulsionSystem &other)=delete
double mThrustReserverSetting
Definition P6DofPropulsionSystem.hpp:330
const P6DofMassProperties & GetMassProperties() const
Definition P6DofPropulsionSystem.hpp:224
const std::unordered_map< std::string, P6DofFuelTank * > & GetFuelTanks() const
Definition P6DofPropulsionSystem.hpp:104
P6DofThrustProducerObject::ThrustControlInputValueData * mThrottleSettingReverser
Definition P6DofPropulsionSystem.hpp:319
bool ThrustReverserEnabled() const
Definition P6DofPropulsionSystem.hpp:134
double mThrustVectoringAnglePitch_deg
Definition P6DofPropulsionSystem.hpp:328
bool mThrustVectorYawSet
Definition P6DofPropulsionSystem.hpp:324
P6DofThrustProducerObject::ThrustControlInputValueData * mThrottleSettingMIL
Definition P6DofPropulsionSystem.hpp:317
std::unordered_map< std::string, P6DofFuelTank * > mFuelTankMap
Definition P6DofPropulsionSystem.hpp:310
bool ThrustVectoringEnabled() const
Definition P6DofPropulsionSystem.hpp:137
P6DofPropulsionSystem(P6DofScenario *aScenario)
Definition P6DofPropulsionSystem.cpp:32
P6DofMassProperties mMassProperties
Definition P6DofPropulsionSystem.hpp:333
P6DofThrustProducerObject::ThrustControlInputValueData * mThrottleSettingAB
Definition P6DofPropulsionSystem.hpp:318
bool mThrottleLeverPositionSet
Definition P6DofPropulsionSystem.hpp:322
double mThrustVectoringAngleYaw_deg
Definition P6DofPropulsionSystem.hpp:327
int64_t mLastSimTime_nanosec
Definition P6DofPropulsionSystem.hpp:313
void SetLastSimTime(int64_t aLastSimTime_nanosec)
Definition P6DofPropulsionSystem.hpp:65
Definition P6DofScenario.hpp:25
Definition P6DofThrustProducerObject.hpp:34
Definition P6DofVehicle.hpp:53
Definition P6DofPropulsionSystem.hpp:47
std::string sourceTankName
Definition P6DofPropulsionSystem.hpp:49
std::string xferName
Definition P6DofPropulsionSystem.hpp:48
P6DofFuelTank * targetTank
Definition P6DofPropulsionSystem.hpp:52
std::string targetTankName
Definition P6DofPropulsionSystem.hpp:50
P6DofFuelTank * sourceTank
Definition P6DofPropulsionSystem.hpp:51
Definition P6DofPropulsionSystem.hpp:297
std::string instanceName
Definition P6DofPropulsionSystem.hpp:301
UtVec3dX relPos
Definition P6DofPropulsionSystem.hpp:303
UtVec3dX relYPR
Definition P6DofPropulsionSystem.hpp:305
double offset_ft
Definition P6DofPropulsionSystem.hpp:304
std::string fuelFeedName
Definition P6DofPropulsionSystem.hpp:302
std::string typeName
Definition P6DofPropulsionSystem.hpp:300
std::string baseTypeName
Definition P6DofPropulsionSystem.hpp:299
Definition P6DofPropulsionSystem.hpp:285
double fuelActuallyProvided_lbs
Definition P6DofPropulsionSystem.hpp:287
P6DofFuelTank * sourceTank
Definition P6DofPropulsionSystem.hpp:286
Definition P6DofPropulsionSystem.hpp:291
P6DofFuelTank * targetAddTank
Definition P6DofPropulsionSystem.hpp:292
std::vector< fuelTankData > sourceTankList
Definition P6DofPropulsionSystem.hpp:293
Definition P6DofThrustProducerObject.hpp:253
Copyrights Multiple, All Rights Reserved