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.
7 #include <Main/fg_props.hxx>
10 VacuumSystem::VacuumSystem ( SGPropertyNode *node )
19 for ( i = 0; i < node->nChildren(); ++i ) {
20 SGPropertyNode *child = node->getChild(i);
21 string cname = child->getName();
22 string cval = child->getStringValue();
23 if ( cname == "name" ) {
25 } else if ( cname == "number" ) {
26 num = child->getIntValue();
27 } else if ( cname == "rpm" ) {
29 } else if ( cname == "scale" ) {
30 scale = child->getDoubleValue();
32 SG_LOG( SG_SYSTEMS, SG_WARN, "Error in vacuum config logic" );
33 if ( name.length() ) {
34 SG_LOG( SG_SYSTEMS, SG_WARN, "Section = " << name );
40 VacuumSystem::VacuumSystem( int i )
48 VacuumSystem::~VacuumSystem ()
57 branch = "/systems/" + name;
59 SGPropertyNode *node = fgGetNode(branch.c_str(), num, true );
60 _serviceable_node = node->getChild("serviceable", 0, true);
61 for ( i = 0; i < rpms.size(); i++ ) {
62 SGPropertyNode_ptr _rpm_node = fgGetNode(rpms[i].c_str(), true);
63 _rpm_nodes.push_back( _rpm_node );
65 _pressure_node = fgGetNode("/environment/pressure-inhg", true);
66 _suction_node = node->getChild("suction-inhg", 0, true);
75 VacuumSystem::unbind ()
80 VacuumSystem::update (double dt)
82 // Model taken from steam.cxx
87 if (!_serviceable_node->getBoolValue()) {
90 // select the source with the max rpm
92 for ( i = 0; i < _rpm_nodes.size(); i++ ) {
93 double tmp = _rpm_nodes[i]->getDoubleValue() * scale;
98 double pressure = _pressure_node->getDoubleValue();
99 // This magic formula yields about 4 inhg at 700 rpm
100 suction = pressure * rpm / (rpm + 4875.0);
102 // simple regulator model that clamps smoothly to about 5 inhg
103 // over a normal rpm range
104 double max = (rpm > 0 ? 5.39 - 1.0 / ( rpm * 0.00111 ) : 0);
105 if ( suction < 0.0 ) suction = 0.0;
106 if ( suction > max ) suction = max;
108 _suction_node->setDoubleValue(suction);