From d02cd9ca383cabe7a9ff26162b14be7fe2fc8224 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Fri, 9 Sep 2022 13:16:12 +0200 Subject: [PATCH] [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> --- .../components/electrolyzer/electrolyzer_reactions.dm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/code/modules/atmospherics/machinery/components/electrolyzer/electrolyzer_reactions.dm b/code/modules/atmospherics/machinery/components/electrolyzer/electrolyzer_reactions.dm index ad31d80aa54..c393436d5a7 100644 --- a/code/modules/atmospherics/machinery/components/electrolyzer/electrolyzer_reactions.dm +++ b/code/modules/atmospherics/machinery/components/electrolyzer/electrolyzer_reactions.dm @@ -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"