Skip to content

Commit

Permalink
Fixes N2O not decomposing above 100000 Kelvin (ParadiseSS13#26817)
Browse files Browse the repository at this point in the history
* Replaces the N2O decomposition function with one that is slightly above 0 at 1400 Kelvin and approaches 1 as temp increases.

* adds a min check to the calculation of the amount to decompose
  • Loading branch information
Migratingcocofruit authored Oct 2, 2024
1 parent e9ea474 commit 07bd88a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
7 changes: 6 additions & 1 deletion code/__DEFINES/atmospherics_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@
// Reactions
#define N2O_DECOMPOSITION_MIN_ENERGY 1400
#define N2O_DECOMPOSITION_ENERGY_RELEASED 200000

/// The coefficient a for a function of the form: 1 - (a / (x + c)^2) which gives a decomposition rate of 0.5 at 50000 Kelvin
/// And a decomposition close to 0 at 1400 Kelvin
#define N2O_DECOMPOSITION_COEFFICIENT_A 1.376651173e10
/// The coefficient c for a function of the form: 1 - (a / (x + c)^2) which gives a decomposition rate of 0.5 at 50000 Kelvin
/// And a decomposition rate close to 0 at 1400 Kelvin
#define N2O_DECOMPOSITION_COEFFICIENT_C 115930.77913
// From milla/src/model.rs, line 126
#define ATMOS_MODE_SPACE 0 //! Tile is exposed to space and loses air every second
#define ATMOS_MODE_SEALED 1 //! Tile has no special behaviour
Expand Down
22 changes: 10 additions & 12 deletions code/modules/atmospherics/gasmixtures/gas_mixture.dm
Original file line number Diff line number Diff line change
Expand Up @@ -574,21 +574,19 @@ What are the archived variables for?
var/energy_released = 0
var/old_heat_capacity = heat_capacity()
var/burned_fuel = 0
burned_fuel = min((1 - (N2O_DECOMPOSITION_COEFFICIENT_A / ((private_temperature + N2O_DECOMPOSITION_COEFFICIENT_C) ** 2))) * private_sleeping_agent, private_sleeping_agent)
private_sleeping_agent -= burned_fuel

burned_fuel = max(0, 0.00002 * (private_temperature - (0.00001 * (private_temperature ** 2)))) * private_sleeping_agent
if(private_sleeping_agent - burned_fuel > 0)
private_sleeping_agent -= burned_fuel
if(burned_fuel)
energy_released += (N2O_DECOMPOSITION_ENERGY_RELEASED * burned_fuel)

if(burned_fuel)
energy_released += (N2O_DECOMPOSITION_ENERGY_RELEASED * burned_fuel)
private_oxygen += burned_fuel * 0.5
private_nitrogen += burned_fuel

private_oxygen += burned_fuel * 0.5
private_nitrogen += burned_fuel

var/new_heat_capacity = heat_capacity()
if(new_heat_capacity > MINIMUM_HEAT_CAPACITY)
private_temperature = (private_temperature * old_heat_capacity + energy_released) / new_heat_capacity
reacting = TRUE
var/new_heat_capacity = heat_capacity()
if(new_heat_capacity > MINIMUM_HEAT_CAPACITY)
private_temperature = (private_temperature * old_heat_capacity + energy_released) / new_heat_capacity
reacting = TRUE

fuel_burnt = 0
//Handle plasma burning
Expand Down

0 comments on commit 07bd88a

Please sign in to comment.