Adds atmos/supermatter debug messages

This commit is contained in:
mwerezak
2014-09-06 14:44:57 -04:00
parent 36a772903b
commit ce970eacd2
4 changed files with 41 additions and 16 deletions

View File

@@ -11,6 +11,16 @@
/obj/machinery/atmospherics/var/last_flow_rate = 0
/obj/machinery/portable_atmospherics/var/last_flow_rate = 0
/obj/machinery/atmospherics/var/debug = 0
/obj/machinery/atmospherics/verb/toggle_debug()
set name = "Toggle Debug Messages"
set category = "Debug"
set src in view()
debug = !debug
usr << "[src]: Debug messages toggled [debug? "on" : "off"]."
//Generalized gas pumping proc.
//Moves gas from one gas_mixture to another and returns the amount of power needed (assuming 1 second), or -1 if no gas was pumped.
//transfer_moles - Limits the amount of moles to transfer. The actual amount of gas moved may also be limited by available_power, if given.
@@ -36,6 +46,13 @@
if (istype(M, /obj/machinery/atmospherics))
var/obj/machinery/atmospherics/A = M
A.last_flow_rate = (transfer_moles/source.total_moles)*source.volume //group_multiplier gets divided out here
if (A.debug)
A.visible_message("[A]: source entropy: [round(source.specific_entropy(), 0.01)] J/Kmol --> sink entropy: [round(sink.specific_entropy(), 0.01)] J/Kmol")
A.visible_message("[A]: specific entropy change = [round(sink.specific_entropy() - source.specific_entropy(), 0.01)] J/Kmol")
A.visible_message("[A]: specific power = [round(specific_power, 0.1)] W/mol")
A.visible_message("[A]: moles transferred = [transfer_moles] mol")
if (istype(M, /obj/machinery/portable_atmospherics))
var/obj/machinery/portable_atmospherics/P = M
P.last_flow_rate = (transfer_moles/source.total_moles)*source.volume //group_multiplier gets divided out here

View File

@@ -127,7 +127,9 @@
var/cop = air_contents.temperature/heatsink_temperature //heatpump coefficient of performance from thermodynamics -> power used = heat_transfer/cop
heat_transfer = min(heat_transfer, cop * active_power_usage) //limit heat transfer by available power
air_contents.add_thermal_energy(-heat_transfer) //remove the heat
var/removed = -air_contents.add_thermal_energy(-heat_transfer) //remove the heat
if (debug)
visible_message("[src]: Removing [removed] W.")
network.update = 1
else

View File

@@ -128,10 +128,12 @@
. /= total_moles
/*
It's arguable whether this should even be called entropy anymore. It's more "based on" entropy than actually entropy now.
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).
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 should 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.
@@ -140,14 +142,14 @@
if (!(gasid in gas) || gas[gasid] == 0)
return SPECIFIC_ENTROPY_VACUUM //that gas isn't here
//group_multiplier gets divided out in volume/gas[gasid] - also, V/(m*T) = R/(partial pressure)
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] - 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 )
//alternative, simpler equation
//var/partial_pressure = gas[gasid] * R_IDEAL_GAS_EQUATION * temperature / volume
//return R_IDEAL_GAS_EQUATION * ( log (1 + IDEAL_GAS_ENTROPY_CONSTANT/partial_pressure) + 20 )
//Updates the total_moles count and trims any empty gases.
/datum/gas_mixture/proc/update_values()

View File

@@ -76,6 +76,8 @@
var/config_hallucination_power = 0.1
var/obj/item/device/radio/radio
var/debug = 0
shard //Small subtype, less efficient and more sensitive, but less boom.
name = "Supermatter Shard"
@@ -217,18 +219,20 @@
//Also keep in mind we are only adding this temperature to (efficiency)% of the one tile the rock
//is on. An increase of 4*C @ 25% efficiency here results in an increase of 1*C / (#tilesincore) overall.
var/thermal_power = THERMAL_RELEASE_MODIFIER
var/thermal_power = THERMAL_RELEASE_MODIFIER * device_energy
//This shouldn't be necessary. If the number of moles is low, then heat_capacity should be tiny.
//if(removed.total_moles < 35) thermal_power += 750 //If you don't add coolant, you are going to have a bad time.
removed.add_thermal_energy(device_energy * thermal_power)
removed.temperature = max(0, min(removed.temperature, 10000))
//Calculate how much gas to release
//Release reaction gasses
var/heat_capacity = removed.heat_capacity()
removed.adjust_multi("phoron", max(device_energy / PHORON_RELEASE_MODIFIER, 0), \
"oxygen", max((device_energy + removed.temperature - T0C) / OXYGEN_RELEASE_MODIFIER, 0))
if (debug)
var/heat_capacity_new = removed.heat_capacity()
visible_message("[src]: Releasing [round(thermal_power)] W.")
visible_message("[src]: Releasing additional [round((heat_capacity_new - heat_capacity)*removed.temperature)] W with exhaust gasses.")
removed.add_thermal_energy(thermal_power)
removed.temperature = between(0, removed.temperature, 10000)
env.merge(removed)