diff --git a/A320-100-CFM.xml b/A320-100-CFM.xml index e79ddbcd..eeb5ebf1 100644 --- a/A320-100-CFM.xml +++ b/A320-100-CFM.xml @@ -160,7 +160,7 @@ xsi:noNamespaceSchemaLocation="http://jsbsim.sourceforge.net/JSBSim.xsd"> - + diff --git a/A320-200-CFM.xml b/A320-200-CFM.xml index c731d0f4..b0a11a23 100644 --- a/A320-200-CFM.xml +++ b/A320-200-CFM.xml @@ -159,7 +159,7 @@ xsi:noNamespaceSchemaLocation="http://jsbsim.sourceforge.net/JSBSim.xsd"> - + diff --git a/A320-200-IAE.xml b/A320-200-IAE.xml index fd7dac96..872f5b88 100644 --- a/A320-200-IAE.xml +++ b/A320-200-IAE.xml @@ -159,7 +159,7 @@ xsi:noNamespaceSchemaLocation="http://jsbsim.sourceforge.net/JSBSim.xsd"> - + diff --git a/A320-main.xml b/A320-main.xml index 3c855f00..4ecbf14d 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -45,7 +45,7 @@ 0.0 /controls/deice/windowprobeheat 0.5 - + /environment/aircraft-effects/frost-inch Fuselage diff --git a/A320neo-CFM.xml b/A320neo-CFM.xml index 67cb63e2..e19a453e 100644 --- a/A320neo-CFM.xml +++ b/A320neo-CFM.xml @@ -159,7 +159,7 @@ xsi:noNamespaceSchemaLocation="http://jsbsim.sourceforge.net/JSBSim.xsd"> - + diff --git a/A320neo-PW.xml b/A320neo-PW.xml index 78827afc..7d3de32e 100644 --- a/A320neo-PW.xml +++ b/A320neo-PW.xml @@ -159,7 +159,7 @@ xsi:noNamespaceSchemaLocation="http://jsbsim.sourceforge.net/JSBSim.xsd"> - + diff --git a/Models/Fuselages/A320-100/fuselage.xml b/Models/Fuselages/A320-100/fuselage.xml index 4877bde7..3a74a144 100644 --- a/Models/Fuselages/A320-100/fuselage.xml +++ b/Models/Fuselages/A320-100/fuselage.xml @@ -14,7 +14,7 @@ Effects/glass - Windshield + Windsheild Windows glass glass1 diff --git a/Models/Fuselages/A320/fuselage.xml b/Models/Fuselages/A320/fuselage.xml index 4877bde7..3a74a144 100644 --- a/Models/Fuselages/A320/fuselage.xml +++ b/Models/Fuselages/A320/fuselage.xml @@ -14,7 +14,7 @@ Effects/glass - Windshield + Windsheild Windows glass glass1 diff --git a/Models/Fuselages/A320neo/fuselage.xml b/Models/Fuselages/A320neo/fuselage.xml index 4877bde7..3a74a144 100644 --- a/Models/Fuselages/A320neo/fuselage.xml +++ b/Models/Fuselages/A320neo/fuselage.xml @@ -14,7 +14,7 @@ Effects/glass - Windshield + Windsheild Windows glass glass1 diff --git a/Nasal/Systems/icing.nas b/Nasal/Systems/icing.nas index 9ffffad4..35262a8e 100644 --- a/Nasal/Systems/icing.nas +++ b/Nasal/Systems/icing.nas @@ -3,17 +3,100 @@ # Copyright (c) 2019 Joshua Davidson (Octal450) -var dewpoint = 0; -var temperature = 0; -var speed = 0; -var visibility = 0; -var visibLclWx = 0; -var severity = 0; -var factor = 0; + +### Ice sensitive components definition. +var Iceable = { + new: func(node) { + var m = { parents: [Iceable] }; + m.ice_inches = node.getNode("ice-inches", 1); + m.sensitivity = node.getNode("sensitivity", 1); + + var deice_prop = node.getValue("salvage-control"); + m.deice = deice_prop ? props.globals.getNode(deice_prop, 1) : nil; + var output_prop = node.getValue("output-property"); + m.output = output_prop ? props.globals.getNode(output_prop, 1): nil; + + return m; + }, + + update: func(factor, melt) { + var icing = me.ice_inches.getValue(); + if(me.deice != nil and me.deice.getBoolValue()) { + icing += melt; + } else { + icing += factor * me.sensitivity.getValue(); + } + if(icing < 0) icing = 0; + + me.ice_inches.setValue(icing); + if(me.output != nil) me.output.setValue(icing); + }, +}; + + +### Icing parameters computation. +# Environmental parameters of the icing model. +var environment = { + dewpoint: props.globals.getNode("environment/dewpoint-degc"), + temperature: props.globals.getNode("environment/temperature-degc"), + visibility: props.globals.getNode("environment/effective-visibility-m"), + visibLclWx: props.globals.getNode("environment/visibility-m"), +}; + +var effects = { + frost_inch: props.globals.getNode("environment/aircraft-effects/frost-inch", 1), + frost_norm: props.globals.getNode("environment/aircraft-effects/frost-level"), +}; + + +# Icing factor computation. var maxSpread = 0; -var icingCond = 0; + +var severity_factor_table = [ + -0.00000166, + 0.00000277, + 0.00000277, + 0.00000554, + 0.00001108, + 0.00002216, +]; + +var melt_factor = -0.00005; + +var icing_factor = func() { + var temperature = environment.temperature.getValue(); + var dewpoint = environment.dewpoint.getValue(); + var visibility = environment.visibility.getValue(); + var visibLclWx = environment.visibLclWx.getValue(); + + # Do we create ice? + var spread = temperature - dewpoint; + # freezing fog or low temp and below dp or in advanced wx cloud + var icingCond = ((spread < maxSpread or visibility < 1000 or visibLclWx < 5000) + and temperature < 0); + + # todo: turn this into a table or something + var severity = 0; + if (icingCond) { + if (temperature >= -2) { + severity = 1; + } else if (temperature >= -12) { + severity = 3; + } else if (temperature >= -30) { + severity = 5; + } else if (temperature >= -40) { + severity = 3; + } else if (temperature >= -99) { + severity = 1; + } + } + + return severity_factor_table[severity]; +} + + +var speed = 0; var pause = 0; -var melt = 0; var windowprobe = 0; var wingBtn = 0; var wingFault = 0; @@ -31,40 +114,13 @@ var lengAnti = 0; var rengAnti = 0; var WingHasBeenTurnedOff = 0; var GroundModeFinished = 0; -var icing1 = 0; -var sensitive1 = 0; -var v = 0; -var a = 0; -var icing2 = 0; -var sensitive2 = 0; -var u = 0; -var b = 0; -var icing3 = 0; -var sensitive3 = 0; -var t = 0; -var c = 0; -var icing4 = 0; -var sensitive4 = 0; -var s = 0; -var d = 0; -var icing5 = 0; -var sensitive5 = 0; -var r = 0; -var icing6 = 0; -var sensitive6 = 0; -var q = 0; -var e = 0; -var spread = 0; var windowprb = 0; var stateL = 0; var stateR = 0; +var iceables = []; + var icingInit = func { - setprop("systems/icing/severity", "0"); # maximum severity: we will make it random - setprop("systems/icing/factor", 0.0); # the factor is how many inches we add per second - setprop("systems/icing/max-spread-degc", 0.0); - setprop("systems/icing/melt-w-heat-factor", -0.00005000); - setprop("systems/icing/icingcond", 0); setprop("controls/switches/windowprobeheat", 0); setprop("controls/switches/wing", 0); setprop("controls/switches/wingfault", 0); @@ -80,21 +136,18 @@ var icingInit = func { setprop("systems/pitot/failed", 1); setprop("controls/deice/WingHasBeenTurnedOff", 0); setprop("controls/deice/GroundModeFinished", 0); + + iceables = props.globals.getNode("sim/model/icing", 1).getChildren("iceable"); + forindex(var i; iceables) { + iceables[i] = Iceable.new(iceables[i]); + } + icing_timer.start(); } var icingModel = func { - dewpoint = getprop("environment/dewpoint-degc"); - temperature = getprop("environment/temperature-degc"); speed = getprop("velocities/airspeed-kt"); - visibility = getprop("environment/effective-visibility-m"); - visibLclWx = getprop("environment/visibility-m"); - severity = getprop("systems/icing/severity"); - factor = getprop("systems/icing/factor"); - maxSpread = getprop("systems/icing/max-spread-degc"); - icingCond = getprop("systems/icing/icingcond"); pause = getprop("sim/freeze/master"); - melt = getprop("systems/icing/melt-w-heat-factor"); windowprobe = getprop("controls/deice/windowprobeheat"); wingBtn = getprop("controls/switches/wing"); wingFault = getprop("controls/switches/wingfault"); @@ -112,104 +165,19 @@ var icingModel = func { rengAnti = getprop("controls/deice/rengine"); WingHasBeenTurnedOff = getprop("controls/deice/WingHasBeenTurnedOff"); GroundModeFinished = getprop("controls/deice/GroundModeFinished"); - - if (temperature >= 0 or !icingCond) { - setprop("systems/icing/severity", "0"); - } else if (temperature < 0 and temperature >= -2 and icingCond) { - setprop("systems/icing/severity", "1"); - } else if (temperature < -2 and temperature >= -12 and icingCond) { - setprop("systems/icing/severity", "3"); - } else if (temperature < -12 and temperature >= -30 and icingCond) { - setprop("systems/icing/severity", "5"); - } else if (temperature < -30 and temperature >= -40 and icingCond) { - setprop("systems/icing/severity", "3"); - } else if (temperature < -40 and temperature >= -99 and icingCond) { - setprop("systems/icing/severity", "1"); - } - - icing1 = getprop("sim/model/icing/iceable[0]/ice-inches"); - sensitive1 = getprop("sim/model/icing/iceable[0]/sensitivity"); - v = icing1 + (factor * sensitive1); - a = icing1 + melt; - if (icing1 < 0.0 and !pause) { - setprop("sim/model/icing/iceable[0]/ice-inches", 0.0); - } else if (wingAnti) { - setprop("sim/model/icing/iceable[0]/ice-inches", a); - } else if (!pause and !wingAnti) { - setprop("sim/model/icing/iceable[0]/ice-inches", v); - } - - icing2 = getprop("sim/model/icing/iceable[1]/ice-inches"); - sensitive2 = getprop("sim/model/icing/iceable[1]/sensitivity"); - u = icing2 + (factor * sensitive2); - b = icing2 + melt; - if (icing2 < 0.0 and !pause) { - setprop("sim/model/icing/iceable[1]/ice-inches", 0.0); - } else if (lengAnti) { - setprop("sim/model/icing/iceable[1]/ice-inches", b); - } else if (!pause and !lengAnti) { - setprop("sim/model/icing/iceable[1]/ice-inches", u); - } - - icing3 = getprop("sim/model/icing/iceable[2]/ice-inches"); - sensitive3 = getprop("sim/model/icing/iceable[2]/sensitivity"); - t = icing3 + (factor * sensitive3); - c = icing3 + melt; - if (icing3 < 0.0 and !pause) { - setprop("sim/model/icing/iceable[2]/ice-inches", 0.0); - } else if (rengAnti) { - setprop("sim/model/icing/iceable[2]/ice-inches", c); - } else if (!pause and !rengAnti) { - setprop("sim/model/icing/iceable[2]/ice-inches", t); - } - - icing4 = getprop("sim/model/icing/iceable[3]/ice-inches"); - sensitive4 = getprop("sim/model/icing/iceable[3]/sensitivity"); - s = icing4 + (factor * sensitive4); - d = icing4 + melt; - if (icing4 < 0.0 and !pause) { - setprop("sim/model/icing/iceable[3]/ice-inches", 0.0); - } else if (windowprobe) { - setprop("sim/model/icing/iceable[3]/ice-inches", d); - } else if (!pause and !windowprobe) { - setprop("sim/model/icing/iceable[3]/ice-inches", s); - } - - icing5 = getprop("sim/model/icing/iceable[4]/ice-inches"); - sensitive5 = getprop("sim/model/icing/iceable[4]/sensitivity"); - r = icing5 + (factor * sensitive5); - if (icing5 < 0.0 and !pause) { - setprop("sim/model/icing/iceable[4]/ice-inches", 0.0); - } else if (!pause) { - setprop("sim/model/icing/iceable[4]/ice-inches", r); - } - - icing6 = getprop("sim/model/icing/iceable[5]/ice-inches"); - sensitive6 = getprop("sim/model/icing/iceable[5]/sensitivity"); - q = icing6 + (factor * sensitive6); - e = icing6 + melt; - if (icing6 < 0.0 and !pause) { - setprop("sim/model/icing/iceable[5]/ice-inches", 0.0); - } else if (windowprobe) { - setprop("sim/model/icing/iceable[5]/ice-inches", e); - } else if (!pause and !windowprobe) { - setprop("sim/model/icing/iceable[5]/ice-inches", q); - } - - # Do we create ice? - spread = temperature - dewpoint; - # freezing fog or low temp and below dp or in advanced wx cloud - if ((spread < maxSpread and temperature < 0) or (temperature < 0 and visibility < 1000) or (visibLclWx < 5000 and temperature < 0)) { - setprop("systems/icing/icingcond", 1); - } else { - setprop("systems/icing/icingcond", 0); + + var factor = icing_factor(); + foreach(iceable; iceables) { + iceable.update(factor, melt_factor); } + + effects.frost_norm.setDoubleValue(effects.frost_inch.getValue() * 50); if (WingHasBeenTurnedOff and !wowl and !wowr and GroundModeFinished) { setprop("controls/deice/wing", 1); setprop("controls/switches/WingHasBeenTurnedOff", 0); } - + # If we have low pressure we have a fault if (PSI < 10) { setprop("controls/switches/wingfault", 1); @@ -232,7 +200,7 @@ var icingModel = func { setprop("systems/pitot/failed", 0); } } - + # if ((getprop("systems/electrical/bus/dc-1") == 0 or getprop("systems/electrical/bus/dc-2") == 0) and getprop("fdm/jsbsim/position/wow") == 0) { # setprop("controls/switches/leng", 1); # setprop("controls/switches/reng", 1); @@ -364,3 +332,4 @@ var update_Icing = func { } var icing_timer = maketimer(0.2, update_Icing); +icing_timer.simulatedTime = 1; diff --git a/Systems/glass-effect.xml b/Systems/glass-effect.xml new file mode 100644 index 00000000..62accb79 --- /dev/null +++ b/Systems/glass-effect.xml @@ -0,0 +1,56 @@ + + + + + + + + + + velocities/u-aero-fps + + 0 0.01 + 7 0.01 + 8 -0.01 + 25 -0.5 + 50 -1.2 + 120 -2 + +
+
+ /environment/aircraft-effects/splash-vector-x +
+ + + + + velocities/v-aero-fps + + -25 -0.5 + -8 0 + 8 0 + 25 0.5 + +
+
+ /environment/aircraft-effects/splash-vector-y +
+ + + + + velocities/u-aero-fps + + 0 1.2 + 7 1.2 + 8 0.9 + 25 0.9 + 50 -0.2 + 120 -0.5 + +
+
+ /environment/aircraft-effects/splash-vector-z +
+
+
diff --git a/Systems/glass-effect1.xml b/Systems/glass-effect1.xml deleted file mode 100644 index 654426e3..00000000 --- a/Systems/glass-effect1.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - /velocities/airspeed-kt - 40 - - 40 - - - - - - - - - -0.1 - - 2.0 - /fdm/jsbsim/glass-effects/airspeed-clamped-sqrt - - - - /environment/aircraft-effects/splash-vector-x - - - - - 0.0 - - /environment/aircraft-effects/splash-vector-y - - - - - - 1.0 - - 1.35 - /fdm/jsbsim/glass-effects/airspeed-clamped-sqrt - - - - /environment/aircraft-effects/splash-vector-z - - - - - diff --git a/Systems/glass-effect2.xml b/Systems/glass-effect2.xml deleted file mode 100644 index aea5dfbb..00000000 --- a/Systems/glass-effect2.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - splashX - gain - - /fdm/jsbsim/glass-effects/splashx - - - /environment/aircraft-effects/splash-vector-x - - - - - splashY - gain - - 0.0 - - - /environment/aircraft-effects/splash-vector-y - - - - - splashZ - gain - - /fdm/jsbsim/glass-effects/splashz - - - /environment/aircraft-effects/splash-vector-z - - - - diff --git a/Systems/libraries.xml b/Systems/libraries.xml index 06bb51a4..acd2b244 100644 --- a/Systems/libraries.xml +++ b/Systems/libraries.xml @@ -608,27 +608,6 @@ /systems/pressurization/targetvs - - Icing Severity - gain - 1.0 - 0.1 - - - - /systems/icing/severity - 0-0.00000166 - 1 0.00000277 - 2 0.00000277 - 3 0.00000554 - 4 0.00001108 - 5 0.00002216 -
-
- - /systems/icing/factor -
- TAS gain