2010-08-04 22:22:38 +00:00
|
|
|
#########
|
|
|
|
# contrail calculator. Based on an approxmation to the "Appleman Chart"
|
|
|
|
# y = -0.077x2 + 2.7188x - 64.36
|
|
|
|
#
|
|
|
|
########
|
|
|
|
|
|
|
|
updateContrail = func{
|
|
|
|
var pressure_Node = props.globals.getNode("environment/pressure-inhg");
|
|
|
|
var temperature_Node = props.globals.getNode("environment/temperature-degc");
|
|
|
|
var contrail_Node = props.globals.getNode("environment/contrail");
|
|
|
|
var contrail_temp_Node = props.globals.getNode("environment/contrail-temperature-degc");
|
|
|
|
|
|
|
|
var x = pressure_Node.getValue();
|
|
|
|
var y = temperature_Node.getValue();
|
|
|
|
var con_temp = -0.077 * x * x + 2.7188 * x - 64.36;
|
|
|
|
contrail_temp_Node.setValue(con_temp);
|
|
|
|
|
|
|
|
if (y < con_temp and y < -40){
|
2013-10-20 03:34:56 +00:00
|
|
|
contrail_Node.setValue(1);
|
|
|
|
} else {
|
|
|
|
contrail_Node.setValue(0);
|
|
|
|
}
|
2010-08-04 22:22:38 +00:00
|
|
|
|
2013-10-20 03:34:56 +00:00
|
|
|
settimer(updateContrail,30)
|
2010-08-04 22:22:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
### Contrail
|
|
|
|
|
|
|
|
_setlistener("/sim/signals/nasal-dir-initialized", func {
|
2010-10-13 18:46:31 +00:00
|
|
|
printlog ("debug", "init contrail");
|
2010-08-04 22:22:38 +00:00
|
|
|
props.globals.initNode("environment/pressure-inhg", 1, "DOUBLE");
|
|
|
|
props.globals.initNode("environment/temperature-degc", 1, "DOUBLE");
|
|
|
|
props.globals.initNode("environment/contrail", 1, "BOOL");
|
|
|
|
props.globals.initNode("environment/contrail-temperature-degc", 1, "DOUBLE");
|
|
|
|
var static_contrail_node = props.globals.getNode("sim/ai/aircraft/contrail", 1);
|
|
|
|
var time_node = props.globals.getNode("sim/time/elapsed-sec", 1);
|
|
|
|
|
|
|
|
updateContrail();
|
|
|
|
});
|