From 8b541bb1e966596bd00d2c2ba6be6dbafb309173 Mon Sep 17 00:00:00 2001 From: Markolie Date: Thu, 13 Oct 2016 19:40:16 +0200 Subject: [PATCH] Hopefully final TEG fixes --- .../components/binary_devices/circulator.dm | 10 +++--- code/game/machinery/pipe/construction.dm | 4 +++ code/modules/power/generator.dm | 34 +++++++++++-------- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/code/ATMOSPHERICS/components/binary_devices/circulator.dm b/code/ATMOSPHERICS/components/binary_devices/circulator.dm index 287988ff05d..b6c5d55e5a9 100644 --- a/code/ATMOSPHERICS/components/binary_devices/circulator.dm +++ b/code/ATMOSPHERICS/components/binary_devices/circulator.dm @@ -2,7 +2,7 @@ //node2, air2, network2 correspond to output /obj/machinery/atmospherics/binary/circulator name = "circulator/heat exchanger" - desc = "A gas circulator pump and heat exchanger." + desc = "A gas circulator pump and heat exchanger. Its input port is on the south side, and its output port is on the north side." icon = 'icons/obj/atmospherics/circulator.dmi' icon_state = "circ1-off" @@ -41,20 +41,20 @@ var/output_starting_pressure = air1.return_pressure() var/input_starting_pressure = air2.return_pressure() - if(output_starting_pressure >= input_starting_pressure-10) + if(output_starting_pressure >= input_starting_pressure - 10) //Need at least 10 KPa difference to overcome friction in the mechanism last_pressure_delta = 0 return null //Calculate necessary moles to transfer using PV = nRT - if(air2.temperature>0) - var/pressure_delta = (input_starting_pressure - output_starting_pressure)/2 + if(air2.temperature > 0) + var/pressure_delta = (input_starting_pressure - output_starting_pressure) / 2 var/transfer_moles = pressure_delta * air1.volume/(air2.temperature * R_IDEAL_GAS_EQUATION) last_pressure_delta = pressure_delta - //world << "pressure_delta = [pressure_delta]; transfer_moles = [transfer_moles];" + //log_debug("pressure_delta = [pressure_delta]; transfer_moles = [transfer_moles];") //Actually transfer the gas var/datum/gas_mixture/removed = air2.remove(transfer_moles) diff --git a/code/game/machinery/pipe/construction.dm b/code/game/machinery/pipe/construction.dm index b7a88ae8b83..bf2eedeaf23 100644 --- a/code/game/machinery/pipe/construction.dm +++ b/code/game/machinery/pipe/construction.dm @@ -292,6 +292,10 @@ if( usr.stat || usr.restrained() ) return + + if(pipe_type == PIPE_CIRCULATOR) + flip() + return src.dir = turn(src.dir, -90) diff --git a/code/modules/power/generator.dm b/code/modules/power/generator.dm index 55afcafe65e..0ff6289ea66 100644 --- a/code/modules/power/generator.dm +++ b/code/modules/power/generator.dm @@ -36,6 +36,10 @@ disconnect_from_network() /obj/machinery/power/generator/initialize() + ..() + connect() + +/obj/machinery/power/generator/proc/connect() connect_to_network() var/obj/machinery/atmospherics/binary/circulator/circpath = /obj/machinery/atmospherics/binary/circulator @@ -86,49 +90,49 @@ if(powernet) - //world << "cold_circ and hot_circ pass" + //log_debug("cold_circ and hot_circ pass") var/datum/gas_mixture/cold_air = cold_circ.return_transfer_air() var/datum/gas_mixture/hot_air = hot_circ.return_transfer_air() - //world << "hot_air = [hot_air]; cold_air = [cold_air];" + //log_debug("hot_air = [hot_air]; cold_air = [cold_air];") if(cold_air && hot_air) - //world << "hot_air = [hot_air] temperature = [hot_air.temperature]; cold_air = [cold_air] temperature = [hot_air.temperature];" + //log_debug("hot_air = [hot_air] temperature = [hot_air.temperature]; cold_air = [cold_air] temperature = [hot_air.temperature];") - //world << "coldair and hotair pass" + //log_debug("coldair and hotair pass") var/cold_air_heat_capacity = cold_air.heat_capacity() var/hot_air_heat_capacity = hot_air.heat_capacity() var/delta_temperature = hot_air.temperature - cold_air.temperature - //world << "delta_temperature = [delta_temperature]; cold_air_heat_capacity = [cold_air_heat_capacity]; hot_air_heat_capacity = [hot_air_heat_capacity]" + //log_debug("delta_temperature = [delta_temperature]; cold_air_heat_capacity = [cold_air_heat_capacity]; hot_air_heat_capacity = [hot_air_heat_capacity]") if(delta_temperature > 0 && cold_air_heat_capacity > 0 && hot_air_heat_capacity > 0) var/efficiency = 0.65 - var/energy_transfer = delta_temperature*hot_air_heat_capacity*cold_air_heat_capacity/(hot_air_heat_capacity + cold_air_heat_capacity) + var/energy_transfer = delta_temperature * hot_air_heat_capacity * cold_air_heat_capacity / (hot_air_heat_capacity + cold_air_heat_capacity) - var/heat = energy_transfer*(1-efficiency) - lastgen = energy_transfer*efficiency + var/heat = energy_transfer * (1 - efficiency) + lastgen = energy_transfer * efficiency - //world << "lastgen = [lastgen]; heat = [heat]; delta_temperature = [delta_temperature]; hot_air_heat_capacity = [hot_air_heat_capacity]; cold_air_heat_capacity = [cold_air_heat_capacity];" + //log_debug("lastgen = [lastgen]; heat = [heat]; delta_temperature = [delta_temperature]; hot_air_heat_capacity = [hot_air_heat_capacity]; cold_air_heat_capacity = [cold_air_heat_capacity];") hot_air.temperature = hot_air.temperature - energy_transfer / hot_air_heat_capacity cold_air.temperature = cold_air.temperature + heat / cold_air_heat_capacity - //world << "POWER: [lastgen] W generated at [efficiency*100]% efficiency and sinks sizes [cold_air_heat_capacity], [hot_air_heat_capacity]" + //log_debug("POWER: [lastgen] W generated at [efficiency * 100]% efficiency and sinks sizes [cold_air_heat_capacity], [hot_air_heat_capacity]") add_avail(lastgen) // update icon overlays only if displayed level has changed if(hot_air) - var/datum/gas_mixture/hot_circ_air1 = hot_circ.return_transfer_air() + var/datum/gas_mixture/hot_circ_air1 = hot_circ.air1 hot_circ_air1.merge(hot_air) if(cold_air) - var/datum/gas_mixture/cold_circ_air1 = cold_circ.return_transfer_air() + var/datum/gas_mixture/cold_circ_air1 = cold_circ.air1 cold_circ_air1.merge(cold_air) var/genlev = max(0, min( round(11 * lastgen / 100000), 11)) @@ -161,7 +165,7 @@ disconnect() power_change() else - initialize() + connect() playsound(loc, 'sound/items/Ratchet.ogg', 50, 1) to_chat(user, "You [anchored ? "secure" : "unsecure"] the bolts holding [src] to the floor.") else if(istype(W, /obj/item/device/multitool)) @@ -171,7 +175,7 @@ else cold_dir = WEST hot_dir = EAST - initialize() + connect() to_chat(user, "You reverse the generator's circulator settings. The cold circulator is now on the [dir2text(cold_dir)] side, and the heat circulator is now on the [dir2text(hot_dir)] side.") update_desc() else @@ -229,7 +233,7 @@ return 0 if( href_list["check"] ) if(!powernet || !cold_circ || !hot_circ) - initialize() + connect() return 1 /obj/machinery/power/generator/power_change()