#a script that calculates the energy of combustion
#obs! this script runs once and automatically ignites the furnace
#the 5 J added by ignite is not accounted for
#E = s(Ta-Tb)/f + Ta*172.615
#s = specific heat of the gas mix = sum(specificHeat * gasRatio)
#Ta = temp before ignition
#Tb = temp after ignition
#f = fuel = min(RatioOxygen, RatioVolatiles / 2)
alias furnace d0
alias consoleOne d1 #small LED display
alias consoleTwo d2 #small LED display
alias ratioOx r5
alias ratioVol r6
alias specificHeat r12
alias fuel r13
alias tempBefore r14
alias tempAfter r15
#calculate the specific heat of the gas mix
l r5 furnace RatioOxygen
l r6 furnace RatioVolatiles
l r7 furnace RatioCarbonDioxide
l r8 furnace RatioPollutant
l r9 furnace RatioNitrogen
l r10 furnace RatioNitrousOxide
l r11 furnace RatioWater
mul r0 r5 21.1
mul r1 r6 20.4
add r0 r0 r1
mul r1 r7 28.2
add r0 r0 r1
mul r1 r8 24.8
add r0 r0 r1
mul r1 r9 20.6
add r0 r0 r1
mul r1 r10 23
add r0 r0 r1
mul r1 r11 72
add specificHeat r0 r1
#calculate the fuel amount
div ratioVol ratioVol 2
min fuel ratioOx ratioVol
#save temperature before
l tempBefore furnace Temperature
#ignite and wait a little
s furnace Activate 1
sleep 2
#save temperature after
l tempAfter furnace Temperature
#check mol amount after combustion
#l r4 furnace TotalMoles
#calculate released energy
mul r0 172.615 tempAfter
sub r2 tempAfter tempBefore
mul r1 specificHeat r2
div r1 r1 fuel
add r0 r0 r1
#display released energy from chemical reaction (95%)
s consoleOne Setting r0
#display the 100% released energy value
div r0 r0 0.95
s consoleTwo Setting r0
### End Script ###