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.
14 #include <Main/fg_props.hxx>
17 VacuumSystem::VacuumSystem ( SGPropertyNode *node )
19 _name(node->getStringValue("name", "vacuum")),
20 _num(node->getIntValue("number", 0)),
21 _scale(node->getDoubleValue("scale", 1.0))
23 for ( int i = 0; i < node->nChildren(); ++i ) {
24 SGPropertyNode *child = node->getChild(i);
25 if (!strcmp(child->getName(), "rpm"))
26 _rpms.push_back(child->getStringValue());
30 VacuumSystem::~VacuumSystem ()
39 branch = "/systems/" + _name;
41 SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
42 _serviceable_node = node->getChild("serviceable", 0, true);
43 for ( i = 0; i < _rpms.size(); i++ ) {
44 SGPropertyNode_ptr _rpm_node = fgGetNode(_rpms[i].c_str(), true);
45 _rpm_nodes.push_back( _rpm_node );
47 _pressure_node = fgGetNode("/environment/pressure-inhg", true);
48 _suction_node = node->getChild("suction-inhg", 0, true);
57 VacuumSystem::unbind ()
62 VacuumSystem::update (double dt)
64 // Model taken from steam.cxx
69 if (!_serviceable_node->getBoolValue()) {
72 // select the source with the max rpm
74 for ( i = 0; i < _rpm_nodes.size(); i++ ) {
75 double tmp = _rpm_nodes[i]->getDoubleValue() * _scale;
80 double pressure = _pressure_node->getDoubleValue();
81 // This magic formula yields about 4 inhg at 700 rpm
82 suction = pressure * rpm / (rpm + 4875.0);
84 // simple regulator model that clamps smoothly to about 5 inhg
85 // over a normal rpm range
86 double max = (rpm > 0 ? 5.39 - 1.0 / ( rpm * 0.00111 ) : 0);
87 if ( suction < 0.0 ) suction = 0.0;
88 if ( suction > max ) suction = max;
90 _suction_node->setDoubleValue(suction);