mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-22 04:22:39 +01:00
Merge pull request #6171 from mwerezak/gas-entropy
Fixes gas entropy calculation + engine pump/injector flow imbalance issue
This commit is contained in:
@@ -169,7 +169,7 @@
|
||||
var/transfer_moles = pressure_delta*output_volume/(air_temperature * R_IDEAL_GAS_EQUATION)
|
||||
|
||||
//limit flow rate from turfs
|
||||
transfer_moles = min(transfer_moles, environment.total_moles*MAX_SIPHON_FLOWRATE/environment.volume) //group_multiplier gets divided out here
|
||||
transfer_moles = min(transfer_moles, environment.total_moles*air_contents.volume/environment.volume) //group_multiplier gets divided out here
|
||||
|
||||
power_draw = pump_gas(src, environment, air_contents, transfer_moles, active_power_usage)
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -13,6 +13,7 @@ var/global/list/rad_collectors = list()
|
||||
// use_power = 0
|
||||
var/obj/item/weapon/tank/phoron/P = null
|
||||
var/last_power = 0
|
||||
var/last_power_new = 0
|
||||
var/active = 0
|
||||
var/locked = 0
|
||||
var/drainratio = 1
|
||||
@@ -26,6 +27,11 @@ var/global/list/rad_collectors = list()
|
||||
..()
|
||||
|
||||
/obj/machinery/power/rad_collector/process()
|
||||
//so that we don't zero out the meter if the SM is processed first.
|
||||
last_power = last_power_new
|
||||
last_power_new = 0
|
||||
|
||||
|
||||
if(P)
|
||||
if(P.air_contents.gas["phoron"] == 0)
|
||||
investigate_log("<font color='red'>out of fuel</font>.","singulo")
|
||||
@@ -50,10 +56,7 @@ var/global/list/rad_collectors = list()
|
||||
|
||||
|
||||
/obj/machinery/power/rad_collector/attackby(obj/item/W, mob/user)
|
||||
if(istype(W, /obj/item/device/analyzer))
|
||||
user << "\blue The [W.name] detects that [last_power]W were recently produced."
|
||||
return 1
|
||||
else if(istype(W, /obj/item/weapon/tank/phoron))
|
||||
if(istype(W, /obj/item/weapon/tank/phoron))
|
||||
if(!src.anchored)
|
||||
user << "\red The [src] needs to be secured to the floor first."
|
||||
return 1
|
||||
@@ -96,6 +99,11 @@ var/global/list/rad_collectors = list()
|
||||
..()
|
||||
return 1
|
||||
|
||||
/obj/machinery/power/rad_collector/examine()
|
||||
..()
|
||||
if (get_dist(usr, src) <= 3)
|
||||
usr << "The meter indicates that \the [src] is collecting [last_power] W."
|
||||
return 1
|
||||
|
||||
/obj/machinery/power/rad_collector/ex_act(severity)
|
||||
switch(severity)
|
||||
@@ -122,7 +130,7 @@ var/global/list/rad_collectors = list()
|
||||
var/power_produced = 0
|
||||
power_produced = P.air_contents.gas["phoron"]*pulse_strength*20
|
||||
add_avail(power_produced)
|
||||
last_power = power_produced
|
||||
last_power_new = power_produced
|
||||
return
|
||||
return
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#define EMITTER_DAMAGE_POWER_TRANSFER 400 //used to transfer power to containment field generators
|
||||
#define EMITTER_DAMAGE_POWER_TRANSFER 450 //used to transfer power to containment field generators
|
||||
|
||||
/obj/machinery/power/emitter
|
||||
name = "Emitter"
|
||||
|
||||
+2
-2
@@ -837,8 +837,8 @@ var/list/RESTRICTED_CAMERA_NETWORKS = list( //Those networks can only be accesse
|
||||
|
||||
//These balance how easy or hard it is to create huge pressure gradients with pumps and filters. Lower values means it takes longer to create large pressures differences.
|
||||
//Has no effect on pumping gasses from high pressure to low, only from low to high. Must be between 0 and 1.
|
||||
#define ATMOS_PUMP_EFFICIENCY 0.6
|
||||
#define ATMOS_FILTER_EFFICIENCY 0.45
|
||||
#define ATMOS_PUMP_EFFICIENCY 1.0
|
||||
#define ATMOS_FILTER_EFFICIENCY 1.0
|
||||
|
||||
//will not bother pumping or filtering if the gas source as fewer than this amount of moles, to help with performance.
|
||||
#define MINUMUM_MOLES_TO_PUMP 0.01
|
||||
|
||||
Reference in New Issue
Block a user