FlightGear next
pitot.cxx
Go to the documentation of this file.
1/*
2 * SPDX-FileName: pitot.cxx
3 * SPDX-FileComment: the pitot air system
4 * SPDX-FileCopyrightText: Written by David Megginson, started 2002.
5 * SPDX-FileContributor: modified by Eric van den Berg, 01 Nov 2013
6 * SPDX-License-Identifier: This file is in the Public Domain and comes with no warranty.
7 */
8
9#ifdef HAVE_CONFIG_H
10# include <config.h>
11#endif
12
13#include <simgear/constants.h>
14
15#include <Main/fg_props.hxx>
16#include <Main/util.hxx>
17
18#include "pitot.hxx"
19
20
21PitotSystem::PitotSystem ( SGPropertyNode *node )
22 :
23 _name(node->getStringValue("name", "pitot")),
24 _num(node->getIntValue("number", 0)),
25 _stall_factor(cos(node->getDoubleValue("stall-deg", 60.0) * SGD_DEGREES_TO_RADIANS ))
26 // this is the projection factor for the stall angle.
27{
28}
29
33
34void
36{
37 std::string branch;
38 branch = "/systems/" + _name;
39
40 SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
41 _serviceable_node = node->getChild("serviceable", 0, true);
42 _pressure_node = fgGetNode("/environment/pressure-inhg", true);
43 _mach_node = fgGetNode("/velocities/mach", true);
44 _alpha_deg_node = fgGetNode("/orientation/alpha-deg", true);
45 _beta_deg_node = fgGetNode("/orientation/side-slip-deg", true);
46 _total_pressure_node = node->getChild("total-pressure-inhg", 0, true);
47 _measured_total_pressure_node = node->getChild("measured-total-pressure-inhg", 0, true);
48 if ( _stall_factor < 0 ) { // |stall angle| > 90°
49 _stall_factor = cos(60 * SGD_DEGREES_TO_RADIANS);
50 }
51}
52
53void
57
58void
62
63void
65{
66 if (_serviceable_node->getBoolValue()) {
67 double p = _pressure_node->getDoubleValue();
68 double mach = _mach_node->getDoubleValue();
69 double alpha = _alpha_deg_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
70 double beta = _beta_deg_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
71 double x_proj_factor = cos(alpha) * fabs(cos(beta)); // the factor to project the total speed vector on the longitudinal body axis
72
73 double p_t = p; // pitot tube stalled: total pressure = static pressure
74 double p_t_meas = p;
75
76 if ( x_proj_factor > _stall_factor ) { // NOTE: alpha: -180 - 180, beta: -90 - 90, pitot probe is stalled at more than 60 deg
77 p_t = p * pow(1 + 0.2 * mach*mach*x_proj_factor*x_proj_factor, 3.5 ); // total pressure in the pitot tube if not stalled
78 p_t_meas = p_t;
79
80 if (mach > 1) {
81 p_t_meas = p * pow( 1.2 * mach*mach, 3.5 ) * pow( 2.8/2.4*mach*mach - 0.4 / 2.4 , -2.5 ); // measured total pressure by pitot tube (Rayleigh formula, at Mach>1, normal shockwave in front of pitot tube)
82 }
83 }
84
85 _total_pressure_node->setDoubleValue(p_t);
86 _measured_total_pressure_node->setDoubleValue(p_t_meas);
87 }
88}
89
90
91// Register the subsystem.
92#if 0
93SGSubsystemMgr::Registrant<PitotSystem> registrantPitotSystem(
94 SGSubsystemMgr::POST_FDM,
95 {{"static", SGSubsystemMgr::Dependency::SOFT},
96 {"vacuum", SGSubsystemMgr::Dependency::SOFT}});
97#endif
98
99// end of pitot.cxx
#define p(x)
void init() override
Definition pitot.cxx:35
virtual ~PitotSystem()
Definition pitot.cxx:30
PitotSystem(SGPropertyNode *node)
Definition pitot.cxx:21
void update(double dt) override
Definition pitot.cxx:64
void unbind() override
Definition pitot.cxx:59
void bind() override
Definition pitot.cxx:54
SGPropertyNode * fgGetNode(const char *path, bool create)
Get a property node.
Definition proptest.cpp:27