Gas math stripping

Removed update_values(). RIP, shine on you CPU diamond.
Removed get_moles_by_id and get_archived_moles_by_id, all moles are now accessed directly to reduce call cost.
Added set_temperature and set_volume procs which recalc pressure when temperature or pressure change.
Heat_capacity is now a var updated when gases update.
Modified adjust_gas to use set_gas, modified set_gas to alter heat_capacity, total_moles, and pressure as needed.
This commit is contained in:
ComicIronic
2015-05-06 20:50:27 +01:00
parent 9d5911b404
commit c1a58dc3c3
95 changed files with 509 additions and 618 deletions

View File

@@ -26,26 +26,26 @@
//Get processable air sample and thermal info from environment
var/transfer_moles = 0.25 * environment.total_moles()
var/transfer_moles = 0.25 * environment.total_moles
var/datum/gas_mixture/external_removed = environment.remove(transfer_moles)
if (!external_removed)
return radiate()
if (external_removed.total_moles() < 10)
if (external_removed.total_moles < 10)
return radiate()
//Get same info from connected gas
var/internal_transfer_moles = 0.25 * air_contents.total_moles()
var/internal_transfer_moles = 0.25 * air_contents.total_moles
var/datum/gas_mixture/internal_removed = air_contents.remove(internal_transfer_moles)
if (!internal_removed)
environment.merge(external_removed)
return
var/combined_heat_capacity = internal_removed.heat_capacity() + external_removed.heat_capacity()
var/combined_energy = internal_removed.temperature * internal_removed.heat_capacity() + external_removed.heat_capacity() * external_removed.temperature
var/combined_heat_capacity = internal_removed.heat_capacity + external_removed.heat_capacity
var/combined_energy = internal_removed.temperature * internal_removed.heat_capacity + external_removed.heat_capacity * external_removed.temperature
if(!combined_heat_capacity) combined_heat_capacity = 1
var/final_temperature = combined_energy / combined_heat_capacity
@@ -73,14 +73,14 @@
air_contents.copy_from(network.radiate) //We can cut down on processing time by only calculating radiate() once and then applying the result
return
var/internal_transfer_moles = 0.25 * air_contents.total_moles()
var/internal_transfer_moles = 0.25 * air_contents.total_moles
var/datum/gas_mixture/internal_removed = air_contents.remove(internal_transfer_moles)
if (!internal_removed)
return
var/combined_heat_capacity = internal_removed.heat_capacity() + RADIATION_CAPACITY
var/combined_energy = internal_removed.temperature * internal_removed.heat_capacity() + (RADIATION_CAPACITY * 6.4)
var/combined_heat_capacity = internal_removed.heat_capacity + RADIATION_CAPACITY
var/combined_energy = internal_removed.temperature * internal_removed.heat_capacity + (RADIATION_CAPACITY * 6.4)
var/final_temperature = combined_energy / combined_heat_capacity