mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 02:16:05 +00:00
Reagent heating fixes (#34281)
* Take thermal masses into account when equalizing temperature of mixed reagents. * Convert from U to CC. * .
This commit is contained in:
@@ -80,3 +80,4 @@
|
||||
#define CC_PER_SHEET_MOLITZ CC_PER_SHEET_METAL
|
||||
#define CC_PER_SHEET_GINGERBREAD CC_PER_SHEET_METAL
|
||||
|
||||
#define CC_PER_U 10 //How many cc per 1 u of reagent in eg. a glass of water or a human's bloodstream.
|
||||
|
||||
@@ -522,7 +522,7 @@
|
||||
#define TEMPERATURE_WELDER 3480
|
||||
#define TEMPERATURE_PLASMA 4500
|
||||
#define TEMPERATURE_ETHANOL (T0C+1560)
|
||||
#define HEAT_TRANSFER_MULTIPLIER 7 //Multiplies the numbers above when heating a reagent container. A truly magical number.
|
||||
#define HEAT_TRANSFER_MULTIPLIER 7 //Multiplies the numbers above when heating a reagent container. A truly magical number. Not currently used anywhere due to a bug with reagent heating being fixed.
|
||||
|
||||
// By defining the effect multiplier this way, it'll exactly adjust
|
||||
// all effects according to how they originally were with the 0.4 metabolism
|
||||
|
||||
@@ -606,6 +606,16 @@ trans_to_atmos(var/datum/gas_mixture/target, var/amount=1, var/multiplier=1, var
|
||||
for(var/datum/reagent/R in reagent_list)
|
||||
R.reaction_dropper_obj(A, R.volume+volume_modifier)
|
||||
|
||||
/datum/reagents/proc/get_equalized_temperature(temperature_A, thermalmass_A, temperature_B, thermalmass_B)
|
||||
//Gets the equalized temperature of two thermal masses
|
||||
if(temperature_A == temperature_B)
|
||||
return temperature_A
|
||||
if(thermalmass_A + thermalmass_B)
|
||||
return ((temperature_A * thermalmass_A) + (temperature_B * thermalmass_B)) / (thermalmass_A + thermalmass_B)
|
||||
else
|
||||
warning("[usr] tried to equalize the temperature of a thermally-massless mixture.")
|
||||
return T0C+20 //Sanity but this shouldn't happen.
|
||||
|
||||
/datum/reagents/proc/add_reagent(var/reagent, var/amount, var/list/data=null, var/reagtemp = T0C+20)
|
||||
if(!my_atom)
|
||||
return 0
|
||||
@@ -616,9 +626,12 @@ trans_to_atmos(var/datum/gas_mixture/target, var/amount=1, var/multiplier=1, var
|
||||
update_total()
|
||||
if(total_volume + amount > maximum_volume)
|
||||
amount = (maximum_volume - total_volume) //Doesnt fit in. Make it disappear. Shouldn't happen. Will happen.
|
||||
chem_temp = round(((amount * reagtemp) + (total_volume * chem_temp)) / (total_volume + amount)) //equalize with new chems
|
||||
for (var/datum/reagent/R in reagent_list)
|
||||
if (R.id == reagent)
|
||||
|
||||
//Equalize temperatures
|
||||
chem_temp = get_equalized_temperature(chem_temp, get_thermal_mass(), reagtemp, amount * R.density * R.specheatcap * CC_PER_U)
|
||||
|
||||
R.volume += amount
|
||||
update_total()
|
||||
my_atom.on_reagent_change()
|
||||
@@ -641,6 +654,10 @@ trans_to_atmos(var/datum/gas_mixture/target, var/amount=1, var/multiplier=1, var
|
||||
if(D)
|
||||
|
||||
var/datum/reagent/R = new D.type()
|
||||
|
||||
//Equalize temperatures
|
||||
chem_temp = get_equalized_temperature(chem_temp, get_thermal_mass(), reagtemp, amount * R.density * R.specheatcap * CC_PER_U)
|
||||
|
||||
reagent_list += R
|
||||
R.holder = src
|
||||
R.volume = amount
|
||||
@@ -901,25 +918,18 @@ trans_to_atmos(var/datum/gas_mixture/target, var/amount=1, var/multiplier=1, var
|
||||
/datum/reagents/proc/is_full()
|
||||
return total_volume >= maximum_volume
|
||||
|
||||
/datum/reagents/proc/get_heatcapacity()
|
||||
var/heat_capacity = 0
|
||||
|
||||
if(reagent_list.len)
|
||||
for(var/datum/reagent/R in reagent_list)
|
||||
heat_capacity += R.volume*R.specheatcap
|
||||
|
||||
return heat_capacity
|
||||
|
||||
/datum/reagents/proc/get_overall_mass()
|
||||
/datum/reagents/proc/get_overall_mass() //currently unused
|
||||
//M = DV
|
||||
|
||||
var/overall_mass = 0
|
||||
for(var/datum/reagent/R in reagent_list)
|
||||
overall_mass += R.density * R.volume
|
||||
return overall_mass * CC_PER_U
|
||||
|
||||
if(reagent_list.len)
|
||||
for(var/datum/reagent/R in reagent_list)
|
||||
overall_mass += R.density*R.volume
|
||||
|
||||
return overall_mass
|
||||
/datum/reagents/proc/get_thermal_mass()
|
||||
var/total_thermal_mass = 0
|
||||
for(var/datum/reagent/R in reagent_list)
|
||||
total_thermal_mass += R.volume * R.density * R.specheatcap
|
||||
return total_thermal_mass * CC_PER_U
|
||||
|
||||
/datum/reagents/proc/heating(var/power_transfer, var/received_temperature)
|
||||
/*
|
||||
@@ -931,10 +941,8 @@ trans_to_atmos(var/datum/gas_mixture/target, var/amount=1, var/multiplier=1, var
|
||||
*/
|
||||
if(received_temperature == chem_temp || !total_volume || !reagent_list.len)
|
||||
return
|
||||
var/heat_capacity = get_heatcapacity()
|
||||
var/energy = power_transfer
|
||||
var/mass = get_overall_mass()
|
||||
var/temp_change = (energy / (mass * heat_capacity))* HEAT_TRANSFER_MULTIPLIER
|
||||
var/temp_change = (energy / (get_thermal_mass()))
|
||||
if(power_transfer > 0)
|
||||
chem_temp = min(chem_temp + temp_change, received_temperature)
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user