Jump to content

Natural gas generator not producing output at the correct temperature


psusi
  • Branch: Live Branch Version: Linux Pending

The CO2 coming out of the output pipe of the natural gas generator is supposed to be 110 C or HIGHER if the machine temperature is higher, but it is only around 27 degrees if that is the temperature of the machine.  The pWater coming out is also less than the 40 degree minimum it is supposed to have.


Steps to Reproduce

Build a natural gas generator.




User Feedback


I ran across something while digging through code while looking at modding something semi-related, and I noticed that when the natural gas generator (and other generators that produce piped/ducted outputs) generate an output, they seem to use (from EnergyGenerator.cs):

 

 if (output.store)
    {
      if (elementByHash.IsGas)
        this.storage.AddGasChunk(output.element, num1, root_pe.Temperature, byte.MaxValue, 0, true);
      else if (elementByHash.IsLiquid)
        this.storage.AddLiquid(output.element, num1, root_pe.Temperature, byte.MaxValue, 0, true);

root_pe.Temperature appears to be the temperature of the building.

 

Shouldn't root_pe.Temperature be replaced with something that clamps it to at least 110C?

When outputting liquid pwater, it at least uses

      float temperature = Mathf.Max(root_pe.Temperature, output.minTemperature);
....
          FallingWater.instance.AddParticle(num2, elementIndex, num1, temperature, byte.MaxValue, 0, true);

which appears that it should be coming out at a minimum of the specified temperature.

 

Edited by ashridah

Share this comment


Link to comment
Share on other sites

On 1/13/2024 at 12:11 PM, ashridah said:

I ran across something while digging through code while looking at modding something semi-related, and I noticed that when the natural gas generator (and other generators that produce piped/ducted outputs) generate an output, they seem to use (from EnergyGenerator.cs):

This is exactly what's causing the bug. In EnergyGenerator.Emit() the branch of the code that places the element in the building's storage for emission into output pipe isn't clamping the temperature to be the max of the building's PrimaryElement and the OutputItem's minTemperature. It is correctly doing that clamping for the branch that emits to the environment. The fix is easy.

 

private void Emit(EnergyGenerator.OutputItem output, float dt, PrimaryElement root_pe)
{
	Element element = ElementLoader.FindElementByHash(output.element);
	float num = output.creationRate * dt;
	float temperature = Mathf.Max(root_pe.Temperature, output.minTemperature); // This line moved from inside environment-emission branch
	if (output.store)
	{
		if (element.IsGas)
		{
			this.storage.AddGasChunk(output.element, num, temperature, byte.MaxValue, 0, true, true); // Change root_pe.Temperature to temperature variable
			return;
		}
		if (element.IsLiquid)
		{
			this.storage.AddLiquid(output.element, num, temperature, byte.MaxValue, 0, true, true); // Change root_pe.Temperature to temperature variable
			return;
		}
		GameObject go = element.substance.SpawnResource(base.transform.GetPosition(), temperature, byte.MaxValue, 0, false, false, false); // Change root_pe.Temperature to temperature variable
		this.storage.Store(go, true, false, true, false);
		return;
	}
	else
	{
		int num2 = Grid.OffsetCell(Grid.PosToCell(base.transform.GetPosition()), output.emitOffset);
// 		float temperature = Mathf.Max(root_pe.Temperature, output.minTemperature);	// Moved to above
		if (element.IsGas)	// Code continues unchanged from here

 

This only generator this seems to affect (that currently exists in game) is the Natural Gas Generator; all others emit to their environment, so are clamping temperature correctly.

Edited by Vertel
  • Thanks 1
  • Big Ups 1

Share this comment


Link to comment
Share on other sites

Example natural gas generator at -30 C. Consumes natural gas at 26.9 C. Outputs CO2 at -30 C.

This problem has existed for a while.

image-75.png

Share this comment


Link to comment
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...