71 lines
2.4 KiB
C#
71 lines
2.4 KiB
C#
// MyBWRSimulator.Core/Ports/FluidPort.cs
|
|
namespace MyBWRSimulator.Core.Ports
|
|
{
|
|
//using MyBWRSimulator.Core.Components.Enums;
|
|
using MyBWRSimulator.Core.Components.Abstract;
|
|
|
|
/// <summary>
|
|
/// Represents a fluid connection point on a component.
|
|
/// </summary>
|
|
public class FluidPort : Port
|
|
{
|
|
/// <summary>
|
|
/// Current fluid flow rate through this port (e.g., kg/s).
|
|
/// </summary>
|
|
public double FlowRate { get; set; }
|
|
|
|
/// <summary>
|
|
/// Current fluid pressure at this port (e.g., Pa).
|
|
/// </summary>
|
|
public double Pressure { get; set; }
|
|
|
|
/// <summary>
|
|
/// Current fluid temperature at this port (e.g., K or C).
|
|
/// </summary>
|
|
public double Temperature { get; set; }
|
|
|
|
/// <summary>
|
|
/// Current volume of fluid within the port itself (optional, for more detailed modeling).
|
|
/// </summary>
|
|
public double CurrentVolume { get; set; }
|
|
|
|
/// <summary>
|
|
/// Constructor for a FluidPort.
|
|
/// </summary>
|
|
/// <param name="id">Unique identifier for the port.</param>
|
|
/// <param name="type">The type of fluid port (Inlet or Outlet).</param>
|
|
public FluidPort(string id) : base(id)
|
|
{
|
|
FlowRate = 0.0;
|
|
Pressure = 0.0;
|
|
Temperature = 0.0;
|
|
CurrentVolume = 0.0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Connects this fluid port to another fluid port.
|
|
/// Includes basic type checking.
|
|
/// </summary>
|
|
/// <param name="otherPort">The port to connect to.</param>
|
|
public override void Connect(Port otherPort)
|
|
{
|
|
base.Connect(otherPort);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Mirrors fluid properties from this port to its connected port.
|
|
/// This is for the direct property assignment data flow model.
|
|
/// </summary>
|
|
public void MirrorToConnectedPort()
|
|
{
|
|
if (ConnectedPort is FluidPort connectedFluidPort)
|
|
{
|
|
connectedFluidPort.FlowRate = this.FlowRate;
|
|
connectedFluidPort.Pressure = this.Pressure;
|
|
connectedFluidPort.Temperature = this.Temperature;
|
|
// Optionally, mirror CurrentVolume if applicable
|
|
// connectedFluidPort.CurrentVolume = this.CurrentVolume;
|
|
}
|
|
}
|
|
}
|
|
} |