Fixes entropy calculation

Fixed the entropy calculation so that it is easier to remove gas from a
hot gas mix, not harder. Added comments explaining the entropy
calculation. Also returns pump and filter efficiency to previous values.
This commit is contained in:
mwerezak
2014-08-25 15:49:39 -04:00
parent 5fa876d9f5
commit 82a862e07e
2 changed files with 17 additions and 5 deletions

View File

@@ -128,15 +128,27 @@
. += ratio * specific_entropy_gas(g)
. /= total_moles
//Returns the ideal gas specific entropy of a specific gas in the mix. This is the entropy due to that gas per mole of /that/ gas in the mixture, not the entropy due to that gas per mole of gas mixture.
/*
Returns the ideal gas specific entropy of a specific gas in the mix. This is the entropy due to that gas per mole of /that/ gas in the mixture, not the entropy due to that gas per mole of gas mixture.
For the purposes of SS13, the specific entropy is just a number that tells you how hard it is to move gas. You can replace this with whatever you want.
Just remember that returning a SMALL number == adding gas to this gas mix is HARD, taking gas away is EASY, and that returning a LARGE number means the opposite (so a vacuum would approach infinity).
So returning a constant/(partial pressure) would probably do what most players expect. Although the version I have implemented below is a bit more nuanced than simply 1/P in that it scales in a way
which is bit more realistic (natural log), and returns a fairly accurate entropy around room temperatures and pressures.
*/
/datum/gas_mixture/proc/specific_entropy_gas(var/gasid)
if (!(gasid in gas) || gas[gasid] == 0)
return SPECIFIC_ENTROPY_VACUUM //that gas isn't here
var/molar_mass = gas_data.molar_mass[gasid]
var/specific_heat = gas_data.specific_heat[gasid]
//group_multiplier gets divided out in volume/gas[gasid]
return R_IDEAL_GAS_EQUATION * ( log( (IDEAL_GAS_ENTROPY_CONSTANT*volume/gas[gasid]) * sqrt((molar_mass*specific_heat*temperature)**3) + 1 ) + 5/2 )
//group_multiplier gets divided out in volume/gas[gasid] - also, V/(m*T) = R/(partial pressure)
//This equation is not accurate at all, but should work well enough for a game.
//Based on the form of Sackur-Tetrode + some curve fitting to specific entropy tables for N2 gas + some adjustments to make it work down to 0 K
//(the real S-T equation does not work at low temperatures, you need quantum mechanics to do it, but screw that) and with the specific power atmos machinery calculations.
return R_IDEAL_GAS_EQUATION * ( log( (IDEAL_GAS_ENTROPY_CONSTANT*volume/(gas[gasid] * temperature)) * (molar_mass*specific_heat*temperature)**(2/3) + 1 ) + 15 )
//Updates the total_moles count and trims any empty gases.
/datum/gas_mixture/proc/update_values()