]> git.mxchange.org Git - flightgear.git/blob - src/Systems/vacuum.cxx
Update the suction model as per Alex Perry's recommendations.
[flightgear.git] / src / Systems / vacuum.cxx
1 // vacuum.cxx - a vacuum pump connected to the aircraft engine.
2 // Written by David Megginson, started 2002.
3 //
4 // This file is in the Public Domain and comes with no warranty.
5
6 #include "vacuum.hxx"
7 #include <Main/fg_props.hxx>
8
9
10 VacuumSystem::VacuumSystem( int i )
11 {
12     num = i;
13 }
14
15 VacuumSystem::~VacuumSystem ()
16 {
17 }
18
19 void
20 VacuumSystem::init()
21 {
22                                 // TODO: allow index of engine to be
23                                 // configured.
24     SGPropertyNode *node = fgGetNode("/systems/vacuum", num, true );
25     _serviceable_node = node->getChild("serviceable", 0, true);
26     _rpm_node = fgGetNode("/engines/engine[0]/rpm", true);
27     _pressure_node = fgGetNode("/environment/pressure-inhg", true);
28     _suction_node = node->getChild("suction-inhg", 0, true);
29 }
30
31 void
32 VacuumSystem::bind ()
33 {
34 }
35
36 void
37 VacuumSystem::unbind ()
38 {
39 }
40
41 void
42 VacuumSystem::update (double dt)
43 {
44     // Model taken from steam.cxx
45
46     double suction;
47
48     if (!_serviceable_node->getBoolValue()) {
49         suction = 0.0;
50     } else {
51         double rpm = _rpm_node->getDoubleValue();
52         double pressure = _pressure_node->getDoubleValue();
53         // This magic formula yields about 4 inhg at 700 rpm
54         suction = pressure * rpm / (rpm + 4875.0);
55
56         // simple regulator model that clamps smoothly to about 5 inhg
57         // over a normal rpm range
58         double max = 5.39 - 1.0 / ( rpm * 0.00111 );
59         if ( suction < 0.0 ) suction = 0.0;
60         if ( suction > max ) suction = max;
61     }
62     _suction_node->setDoubleValue(suction);
63 }
64
65 // end of vacuum.cxx