1 // vacuum.cxx - a vacuum pump connected to the aircraft engine.
2 // Written by David Megginson, started 2002.
4 // This file is in the Public Domain and comes with no warranty.
11 #include <Main/fg_props.hxx>
14 VacuumSystem::VacuumSystem ( SGPropertyNode *node )
23 for ( i = 0; i < node->nChildren(); ++i ) {
24 SGPropertyNode *child = node->getChild(i);
25 string cname = child->getName();
26 string cval = child->getStringValue();
27 if ( cname == "name" ) {
29 } else if ( cname == "number" ) {
30 num = child->getIntValue();
31 } else if ( cname == "rpm" ) {
33 } else if ( cname == "scale" ) {
34 scale = child->getDoubleValue();
36 SG_LOG( SG_SYSTEMS, SG_WARN, "Error in vacuum config logic" );
37 if ( name.length() ) {
38 SG_LOG( SG_SYSTEMS, SG_WARN, "Section = " << name );
44 VacuumSystem::VacuumSystem( int i )
52 VacuumSystem::~VacuumSystem ()
61 branch = "/systems/" + name;
63 SGPropertyNode *node = fgGetNode(branch.c_str(), num, true );
64 _serviceable_node = node->getChild("serviceable", 0, true);
65 for ( i = 0; i < rpms.size(); i++ ) {
66 SGPropertyNode_ptr _rpm_node = fgGetNode(rpms[i].c_str(), true);
67 _rpm_nodes.push_back( _rpm_node );
69 _pressure_node = fgGetNode("/environment/pressure-inhg", true);
70 _suction_node = node->getChild("suction-inhg", 0, true);
79 VacuumSystem::unbind ()
84 VacuumSystem::update (double dt)
86 // Model taken from steam.cxx
91 if (!_serviceable_node->getBoolValue()) {
94 // select the source with the max rpm
96 for ( i = 0; i < _rpm_nodes.size(); i++ ) {
97 double tmp = _rpm_nodes[i]->getDoubleValue() * scale;
102 double pressure = _pressure_node->getDoubleValue();
103 // This magic formula yields about 4 inhg at 700 rpm
104 suction = pressure * rpm / (rpm + 4875.0);
106 // simple regulator model that clamps smoothly to about 5 inhg
107 // over a normal rpm range
108 double max = (rpm > 0 ? 5.39 - 1.0 / ( rpm * 0.00111 ) : 0);
109 if ( suction < 0.0 ) suction = 0.0;
110 if ( suction > max ) suction = max;
112 _suction_node->setDoubleValue(suction);