[MIRROR] Water vapour electrolysis and hypernoblium electrolysis now respects heat capacity changes. [MDB IGNORE] (#16114)

* Water vapour electrolysis and hypernoblium electrolysis now respects heat capacity changes. (#69396)

Electrolyzer heat capacity respect.

The electrolyzer did not respect heat capacity changes for the h2o_conversion reaction and the nob_conversion reaction, destroying energy.

This changes that by storing the old heat capacity at the start of the reactions, then getting the new heat capacity at the end of the reaction, then adjusting temperature based on the heat capacity changes.

* Water vapour electrolysis and hypernoblium electrolysis now respects heat capacity changes.

Co-authored-by: Pickle-Coding <58013024+Pickle-Coding@users.noreply.github.com>
This commit is contained in:
SkyratBot
2022-09-09 12:16:12 +01:00
committed by GitHub
co-authored by Pickle-Coding
parent 91cc55bd68
commit d02cd9ca38
@@ -50,11 +50,15 @@ GLOBAL_LIST_INIT(electrolyzer_reactions, electrolyzer_reactions_list())
/datum/electrolyzer_reaction/h2o_conversion/react(turf/location, datum/gas_mixture/air_mixture, working_power)
var/old_heat_capacity = air_mixture.heat_capacity()
air_mixture.assert_gases(/datum/gas/water_vapor, /datum/gas/oxygen, /datum/gas/hydrogen)
var/proportion = min(air_mixture.gases[/datum/gas/water_vapor][MOLES] * INVERSE(2), (2.5 * (working_power ** 2)))
air_mixture.gases[/datum/gas/water_vapor][MOLES] -= proportion * 2
air_mixture.gases[/datum/gas/oxygen][MOLES] += proportion
air_mixture.gases[/datum/gas/hydrogen][MOLES] += proportion * 2
var/new_heat_capacity = air_mixture.heat_capacity()
if(new_heat_capacity > MINIMUM_HEAT_CAPACITY)
air_mixture.temperature = max(air_mixture.temperature * old_heat_capacity / new_heat_capacity, TCMB)
/datum/electrolyzer_reaction/nob_conversion
name = "Hypernob conversion"
@@ -73,10 +77,14 @@ GLOBAL_LIST_INIT(electrolyzer_reactions, electrolyzer_reactions_list())
/datum/electrolyzer_reaction/nob_conversion/react(turf/location, datum/gas_mixture/air_mixture, working_power)
var/old_heat_capacity = air_mixture.heat_capacity()
air_mixture.assert_gases(/datum/gas/hypernoblium, /datum/gas/antinoblium)
var/proportion = min(air_mixture.gases[/datum/gas/hypernoblium][MOLES], (1.5 * (working_power ** 2)))
air_mixture.gases[/datum/gas/hypernoblium][MOLES] -= proportion
air_mixture.gases[/datum/gas/antinoblium][MOLES] += proportion * 0.5
var/new_heat_capacity = air_mixture.heat_capacity()
if(new_heat_capacity > MINIMUM_HEAT_CAPACITY)
air_mixture.temperature = max(air_mixture.temperature * old_heat_capacity / new_heat_capacity, TCMB)
/datum/electrolyzer_reaction/halon_generation
name = "Halon generation"