2002-09-24 14:51:37 +00:00
|
|
|
// vacuum.cxx - a vacuum pump connected to the aircraft engine.
|
|
|
|
// Written by David Megginson, started 2002.
|
|
|
|
//
|
|
|
|
// This file is in the Public Domain and comes with no warranty.
|
|
|
|
|
2006-06-16 10:17:06 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2002-09-24 14:51:37 +00:00
|
|
|
#include "vacuum.hxx"
|
|
|
|
#include <Main/fg_props.hxx>
|
|
|
|
|
|
|
|
|
2004-10-16 12:37:39 +00:00
|
|
|
VacuumSystem::VacuumSystem ( SGPropertyNode *node )
|
|
|
|
:
|
2006-12-06 22:11:43 +00:00
|
|
|
_name(node->getStringValue("name", "vacuum")),
|
|
|
|
_num(node->getIntValue("number", 0)),
|
|
|
|
_scale(node->getDoubleValue("scale", 1.0))
|
2004-10-16 12:37:39 +00:00
|
|
|
{
|
2006-12-06 22:11:43 +00:00
|
|
|
_rpms.clear();
|
2004-10-16 12:37:39 +00:00
|
|
|
int i;
|
|
|
|
for ( i = 0; i < node->nChildren(); ++i ) {
|
|
|
|
SGPropertyNode *child = node->getChild(i);
|
|
|
|
string cname = child->getName();
|
|
|
|
string cval = child->getStringValue();
|
2006-12-06 22:11:43 +00:00
|
|
|
if ( cname == "rpm" ) {
|
|
|
|
_rpms.push_back(cval);
|
2004-10-16 12:37:39 +00:00
|
|
|
} else {
|
2004-10-24 11:05:14 +00:00
|
|
|
SG_LOG( SG_SYSTEMS, SG_WARN, "Error in vacuum config logic" );
|
2006-12-06 22:11:43 +00:00
|
|
|
if ( _name.length() ) {
|
|
|
|
SG_LOG( SG_SYSTEMS, SG_WARN, "Section = " << _name );
|
2004-10-16 12:37:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-24 14:51:37 +00:00
|
|
|
VacuumSystem::~VacuumSystem ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-05-27 19:25:27 +00:00
|
|
|
VacuumSystem::init()
|
2002-09-24 14:51:37 +00:00
|
|
|
{
|
2005-10-15 20:03:17 +00:00
|
|
|
unsigned int i;
|
2004-10-16 12:37:39 +00:00
|
|
|
string branch;
|
2006-12-06 22:11:43 +00:00
|
|
|
branch = "/systems/" + _name;
|
2004-10-16 12:37:39 +00:00
|
|
|
|
2006-12-06 22:11:43 +00:00
|
|
|
SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true );
|
2003-05-27 19:25:27 +00:00
|
|
|
_serviceable_node = node->getChild("serviceable", 0, true);
|
2006-12-06 22:11:43 +00:00
|
|
|
for ( i = 0; i < _rpms.size(); i++ ) {
|
|
|
|
SGPropertyNode_ptr _rpm_node = fgGetNode(_rpms[i].c_str(), true);
|
2005-10-15 20:03:17 +00:00
|
|
|
_rpm_nodes.push_back( _rpm_node );
|
|
|
|
}
|
2002-09-24 14:51:37 +00:00
|
|
|
_pressure_node = fgGetNode("/environment/pressure-inhg", true);
|
2003-05-27 19:25:27 +00:00
|
|
|
_suction_node = node->getChild("suction-inhg", 0, true);
|
2002-09-24 14:51:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VacuumSystem::bind ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VacuumSystem::unbind ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VacuumSystem::update (double dt)
|
|
|
|
{
|
|
|
|
// Model taken from steam.cxx
|
|
|
|
|
|
|
|
double suction;
|
2005-10-15 20:03:17 +00:00
|
|
|
unsigned int i;
|
2002-09-24 14:51:37 +00:00
|
|
|
|
|
|
|
if (!_serviceable_node->getBoolValue()) {
|
|
|
|
suction = 0.0;
|
|
|
|
} else {
|
2005-10-15 20:03:17 +00:00
|
|
|
// select the source with the max rpm
|
|
|
|
double rpm = 0.0;
|
|
|
|
for ( i = 0; i < _rpm_nodes.size(); i++ ) {
|
2006-12-06 22:11:43 +00:00
|
|
|
double tmp = _rpm_nodes[i]->getDoubleValue() * _scale;
|
2005-10-15 20:03:17 +00:00
|
|
|
if ( tmp > rpm ) {
|
|
|
|
rpm = tmp;
|
|
|
|
}
|
|
|
|
}
|
2002-09-24 14:51:37 +00:00
|
|
|
double pressure = _pressure_node->getDoubleValue();
|
2003-05-28 18:48:00 +00:00
|
|
|
// This magic formula yields about 4 inhg at 700 rpm
|
|
|
|
suction = pressure * rpm / (rpm + 4875.0);
|
|
|
|
|
|
|
|
// simple regulator model that clamps smoothly to about 5 inhg
|
|
|
|
// over a normal rpm range
|
2003-07-22 02:05:50 +00:00
|
|
|
double max = (rpm > 0 ? 5.39 - 1.0 / ( rpm * 0.00111 ) : 0);
|
2003-05-27 19:25:27 +00:00
|
|
|
if ( suction < 0.0 ) suction = 0.0;
|
2003-05-28 18:48:00 +00:00
|
|
|
if ( suction > max ) suction = max;
|
2002-09-24 14:51:37 +00:00
|
|
|
}
|
|
|
|
_suction_node->setDoubleValue(suction);
|
|
|
|
}
|
|
|
|
|
|
|
|
// end of vacuum.cxx
|