Skip to content

Commit

Permalink
Merge pull request #8119 from RavingManiac/dev
Browse files Browse the repository at this point in the history
Working TEG Supermatter Engine
  • Loading branch information
comma committed Feb 16, 2015
2 parents be2b0aa + 198bfe9 commit 5c3426f
Show file tree
Hide file tree
Showing 8 changed files with 273 additions and 208 deletions.
5 changes: 5 additions & 0 deletions baystation12.int
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// BEGIN_INTERNALS
/*
MAP_ICON_TYPE: 0
WINDOW: code\ATMOSPHERICS\components\binary_devices\pump.dm;code\ATMOSPHERICS\components\binary_devices\circulator.dm;code\modules\power\generator.dm;code\ATMOSPHERICS\components\unary\heat_exchanger.dm;code\ATMOSPHERICS\components\unary\vent_pump.dm;maps\exodus-1.dmm
LAST_COMPILE_VERSION: 501.1217
DIR: code code\ATMOSPHERICS code\ATMOSPHERICS\components code\ATMOSPHERICS\components\binary_devices code\ATMOSPHERICS\components\unary code\game code\game\machinery\doors code\game\objects code\game\objects\items code\game\objects\items\weapons code\modules code\modules\power maps
FILE: maps\exodus-1.dmm
LAST_COMPILE_TIME: 1424008581
AUTO_FILE_DIR: OFF
*/
// END_INTERNALS
42 changes: 31 additions & 11 deletions code/ATMOSPHERICS/components/binary_devices/circulator.dm
Original file line number Diff line number Diff line change
@@ -1,37 +1,50 @@
//node1, air1, network1 correspond to input
//node2, air2, network2 correspond to output

#define ADIABATIC_EXPONENT 0.667 //Actually adiabatic exponent - 1.

/obj/machinery/atmospherics/binary/circulator
name = "circulator/heat exchanger"
desc = "A gas circulator pump and heat exchanger."
name = "circulator"
desc = "A gas circulator turbine and heat exchanger."
icon = 'icons/obj/pipes.dmi'
icon_state = "circ-off"
anchored = 0

var/kinetic_efficiency = 0.04 //combined kinetic and kinetic-to-electric efficiency
var/volume_ratio = 0.2

var/recent_moles_transferred = 0
var/last_heat_capacity = 0
var/last_temperature = 0
var/last_pressure_delta = 0
var/last_worldtime_transfer = 0
var/last_stored_energy_transferred = 0
var/volume_capacity_used = 0
var/stored_energy = 0

density = 1

/obj/machinery/atmospherics/binary/circulator/New()
..()
desc = initial(desc) + " Its outlet port is to the [dir2text(dir)]."
desc = initial(desc) + " Its outlet port is to the [dir2text(dir)]."
air1.volume = 400

/obj/machinery/atmospherics/binary/circulator/proc/return_transfer_air()
var/datum/gas_mixture/removed
if(anchored && !(stat&BROKEN) )
if(anchored && !(stat&BROKEN) && network1)
var/input_starting_pressure = air1.return_pressure()
var/output_starting_pressure = air2.return_pressure()
last_pressure_delta = max(input_starting_pressure - output_starting_pressure + 10, 0)
last_pressure_delta = max(input_starting_pressure - output_starting_pressure - 5, 0)

//only circulate air if there is a pressure difference (plus 10 kPa to represent friction in the machine)
if(air1.temperature > 0 && last_pressure_delta > 0)
//only circulate air if there is a pressure difference (plus 5kPa kinetic, 10kPa static friction)
if(air1.temperature > 0 && last_pressure_delta > 5)

//Calculate necessary moles to transfer using PV = nRT
recent_moles_transferred = last_pressure_delta*air2.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
recent_moles_transferred = (last_pressure_delta*network1.volume/(air1.temperature * R_IDEAL_GAS_EQUATION))/3 //uses the volume of the whole network, not just itself
volume_capacity_used = min( (last_pressure_delta*network1.volume/3)/(input_starting_pressure*air1.volume) , 1) //how much of the gas in the input air volume is consumed

//Calculate energy generated from kinetic turbine
stored_energy += 1/ADIABATIC_EXPONENT * min(last_pressure_delta * network1.volume , input_starting_pressure*air1.volume) * (1 - volume_ratio**ADIABATIC_EXPONENT) * kinetic_efficiency

//Actually transfer the gas
removed = air1.remove(recent_moles_transferred)
Expand All @@ -40,8 +53,7 @@
last_temperature = removed.temperature

//Update the gas networks.
if(network1)
network1.update = 1
network1.update = 1

last_worldtime_transfer = world.time
else
Expand All @@ -50,6 +62,11 @@
update_icon()
return removed

/obj/machinery/atmospherics/binary/circulator/proc/return_stored_energy()
last_stored_energy_transferred = stored_energy
stored_energy = 0
return last_stored_energy_transferred

/obj/machinery/atmospherics/binary/circulator/process()
..()

Expand All @@ -72,8 +89,11 @@

/obj/machinery/atmospherics/binary/circulator/attackby(obj/item/weapon/W as obj, mob/user as mob)
if(istype(W, /obj/item/weapon/wrench))
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
anchored = !anchored
user << "\blue You [anchored ? "secure" : "unsecure"] the bolts holding [src] to the floor."
user.visible_message("[user.name] [anchored ? "secures" : "unsecures"] the bolts holding [src.name] to the floor.", \
"You [anchored ? "secure" : "unsecure"] the bolts holding [src] to the floor.", \
"You hear a ratchet")

if(anchored)
if(dir & (NORTH|SOUTH))
Expand Down
8 changes: 4 additions & 4 deletions code/ATMOSPHERICS/components/unary/vent_pump.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
/obj/machinery/atmospherics/unary/vent_pump/engine
name = "Engine Core Vent"
power_channel = ENVIRON
power_rating = 15000 //15 kW ~ 20 HP
power_rating = 30000 //15 kW ~ 20 HP

/obj/machinery/atmospherics/unary/vent_pump/engine/New()
..()
Expand Down Expand Up @@ -183,11 +183,11 @@
//JESUS FUCK. THERE ARE LITERALLY 250 OF YOU MOTHERFUCKERS ON ZLEVEL ONE AND YOU DO THIS SHIT EVERY TICK WHEN VERY OFTEN THERE IS NO REASON TO

if(pump_direction && pressure_checks == PRESSURE_CHECK_EXTERNAL && controller_iteration > 10) //99% of all vents
//Fucking hibernate because you ain't doing shit.
//Fucking hibernate because you ain't doing shit.
hibernate = 1
spawn(rand(100,200)) //hibernate for 10 or 20 seconds randomly
hibernate = 0
hibernate = 0


if (power_draw >= 0)
last_power_draw = power_draw
Expand Down

0 comments on commit 5c3426f

Please sign in to comment.