1 // pitot.cxx - the pitot air system.
2 // Written by David Megginson, started 2002.
4 // Last modified by Eric van den Berg, 01 Nov 2013
5 // This file is in the Public Domain and comes with no warranty.
11 #include <simgear/constants.h>
13 #include <Main/fg_props.hxx>
14 #include <Main/util.hxx>
19 PitotSystem::PitotSystem ( SGPropertyNode *node )
21 _name(node->getStringValue("name", "pitot")),
22 _num(node->getIntValue("number", 0)),
23 _stall_factor(cos(node->getDoubleValue("stall-deg", 60.0) * SGD_DEGREES_TO_RADIANS ))
24 // this is the projection factor for the stall angle.
28 PitotSystem::~PitotSystem ()
36 branch = "/systems/" + _name;
38 SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
39 _serviceable_node = node->getChild("serviceable", 0, true);
40 _pressure_node = fgGetNode("/environment/pressure-inhg", true);
41 _mach_node = fgGetNode("/velocities/mach", true);
42 _alpha_deg_node = fgGetNode("/orientation/alpha-deg", true);
43 _beta_deg_node = fgGetNode("/orientation/side-slip-deg", true);
44 _total_pressure_node = node->getChild("total-pressure-inhg", 0, true);
45 _measured_total_pressure_node = node->getChild("measured-total-pressure-inhg", 0, true);
46 if ( _stall_factor < 0 ) { // |stall angle| > 90°
47 _stall_factor = cos(60 * SGD_DEGREES_TO_RADIANS);
57 PitotSystem::unbind ()
62 PitotSystem::update (double dt)
64 if (_serviceable_node->getBoolValue()) {
65 double p = _pressure_node->getDoubleValue();
66 double mach = _mach_node->getDoubleValue();
67 double alpha = _alpha_deg_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
68 double beta = _beta_deg_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
69 double x_proj_factor = cos(alpha) * fabs(cos(beta)); // the factor to project the total speed vector on the longitudinal body axis
71 double p_t = p; // pitot tube stalled: total pressure = static pressure
74 if ( x_proj_factor > _stall_factor ) { // NOTE: alpha: -180 - 180, beta: -90 - 90, pitot probe is stalled at more than 60 deg
75 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
79 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)
83 _total_pressure_node->setDoubleValue(p_t);
84 _measured_total_pressure_node->setDoubleValue(p_t_meas);