43 lines
1.3 KiB
C#
43 lines
1.3 KiB
C#
using FluidSim.Interfaces;
|
||
|
||
namespace FluidSim.Components
|
||
{
|
||
/// <summary>
|
||
/// Represents the ambient atmosphere – constant pressure/temperature reservoir.
|
||
/// </summary>
|
||
public class Atmosphere : IComponent
|
||
{
|
||
public double Pressure { get; set; } = 101325.0;
|
||
public double Temperature { get; set; } = 300.0;
|
||
public double GasConstant { get; set; } = 287.0;
|
||
public double Gamma => 1.4;
|
||
|
||
public double Density => Pressure / (GasConstant * Temperature);
|
||
public double SpecificEnthalpy => Gamma / (Gamma - 1.0) * Pressure / Density;
|
||
|
||
public Port Port { get; }
|
||
|
||
public Atmosphere()
|
||
{
|
||
Port = new Port { Owner = this };
|
||
UpdatePort();
|
||
}
|
||
|
||
public IReadOnlyList<Port> Ports => new[] { Port };
|
||
|
||
public void UpdateState(double dt)
|
||
{
|
||
// Atmosphere is static – just ensure the port reflects current values
|
||
UpdatePort();
|
||
}
|
||
|
||
private void UpdatePort()
|
||
{
|
||
Port.Pressure = Pressure;
|
||
Port.Density = Density;
|
||
Port.Temperature = Temperature;
|
||
Port.SpecificEnthalpy = SpecificEnthalpy;
|
||
// MassFlowRate is set by the solver connector
|
||
}
|
||
}
|
||
} |