JSBSim Flight Dynamics Model 1.3.0 (09 Apr 2026)
An Open Source Flight Dynamics and Control Software Library in C++
Loading...
Searching...
No Matches
FGNozzle.cpp
1/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Module: FGNozzle.cpp
4 Author: Jon S. Berndt
5 Date started: 08/24/00
6 Purpose: Encapsulates the nozzle object
7
8 ------------- Copyright (C) 2000 Jon S. Berndt (jon@jsbsim.org) -------------
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
27FUNCTIONAL DESCRIPTION
28--------------------------------------------------------------------------------
29
30HISTORY
31--------------------------------------------------------------------------------
3208/24/00 JSB Created
33
34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35INCLUDES
36%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
37
38#include "FGNozzle.h"
39#include "FGFDMExec.h"
40#include "input_output/FGXMLElement.h"
41#include "input_output/FGLog.h"
42
43using namespace std;
44
45namespace JSBSim {
46
47/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48CLASS IMPLEMENTATION
49%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
50
51
52FGNozzle::FGNozzle(FGFDMExec* FDMExec, Element* nozzle_element, int num)
53 : FGThruster(FDMExec, nozzle_element, num)
54{
55 if (nozzle_element->FindElement("area"))
56 Area = nozzle_element->FindElementValueAsNumberConvertTo("area", "FT2");
57 else {
58 XMLLogException err(nozzle_element);
59 err << "Fatal Error: Nozzle exit area must be given in nozzle config file.\n";
60 throw err;
61 }
62
63 Thrust = 0;
64 Type = ttNozzle;
65
66 Debug(0);
67}
68
69//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70
72{
73 Debug(1);
74}
75
76//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77
78double FGNozzle::Calculate(double vacThrust)
79{
80 Thrust = max((double)0.0, vacThrust - in.Pressure*Area);
81
82 vFn(1) = Thrust * cos(ReverserAngle);
83
84 return Thrust;
85}
86
87//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
88
89string FGNozzle::GetThrusterLabels(int id, const string& delimeter)
90{
91 std::ostringstream buf;
92
93 buf << Name << " Thrust (engine " << id << " in lbs)";
94
95 return buf.str();
96}
97
98//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
99
100string FGNozzle::GetThrusterValues(int id, const string& delimeter)
101{
102 std::ostringstream buf;
103
104 buf << Thrust;
105
106 return buf.str();
107}
108
109//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
110// The bitmasked value choices are as follows:
111// unset: In this case (the default) JSBSim would only print
112// out the normally expected messages, essentially echoing
113// the config files as they are read. If the environment
114// variable is not set, debug_lvl is set to 1 internally
115// 0: This requests JSBSim not to output any messages
116// whatsoever.
117// 1: This value explicity requests the normal JSBSim
118// startup messages
119// 2: This value asks for a message to be printed out when
120// a class is instantiated
121// 4: When this value is set, a message is displayed when a
122// FGModel object executes its Run() method
123// 8: When this value is set, various runtime state variables
124// are printed out periodically
125// 16: When set various parameters are sanity checked and
126// a message is printed out when they go out of bounds
127
128void FGNozzle::Debug(int from)
129{
130 if (debug_lvl <= 0) return;
131
132 if (debug_lvl & 1) { // Standard console startup message output
133 if (from == 0) { // Constructor
134 FGLogging log(LogLevel::DEBUG);
135 log << " Nozzle Name: " << Name << "\n";
136 log << " Nozzle Exit Area = " << Area << "\n";
137 }
138 }
139 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
140 FGLogging log(LogLevel::DEBUG);
141 if (from == 0) log << "Instantiated: FGNozzle\n";
142 if (from == 1) log << "Destroyed: FGNozzle\n";
143 }
144 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
145 }
146 if (debug_lvl & 8 ) { // Runtime state variables
147 }
148 if (debug_lvl & 16) { // Sanity checking
149 }
150 if (debug_lvl & 64) {
151 if (from == 0) { // Constructor
152 }
153 }
154}
155}
Element * FindElement(const std::string &el="")
Searches for a specified element.
double FindElementValueAsNumberConvertTo(const std::string &el, const std::string &target_units)
Searches for the named element and converts and returns the data belonging to it.
Encapsulates the JSBSim simulation executive.
Definition FGFDMExec.h:185
~FGNozzle()
Destructor.
Definition FGNozzle.cpp:71
FGNozzle(FGFDMExec *exec, Element *el, int num=0)
Constructor.
Definition FGNozzle.cpp:52
Base class for specific thrusting devices such as propellers, nozzles, etc.
Definition FGThruster.h:77
Main namespace for the JSBSim Flight Dynamics Model.
Definition FGFDMExec.cpp:71