Files
FluidSim/Components/Atmosphere.cs

43 lines
1.3 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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
}
}
}