Adding initial Project to git
This commit is contained in:
71
BWR.core/Ports/FluidPort.cs
Normal file
71
BWR.core/Ports/FluidPort.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
68
BWR.core/Ports/ThermalPort.cs
Normal file
68
BWR.core/Ports/ThermalPort.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
// MyBWRSimulator.Core/Ports/ThermalPort.cs
|
||||
namespace MyBWRSimulator.Core.Ports
|
||||
{
|
||||
using MyBWRSimulator.Core.Components.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an Thermal connection point on a component.
|
||||
/// </summary>
|
||||
public class ThermalPort : Port
|
||||
{
|
||||
/// <summary>
|
||||
/// Current voltage at this port (e.g., Volts).
|
||||
/// </summary>
|
||||
public double Voltage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Current amperage at this port (e.g., Amperes).
|
||||
/// </summary>
|
||||
public double Amperage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// True if this port is actively supplying power.
|
||||
/// </summary>
|
||||
public bool IsSupplyingPower { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for an ThermalPort.
|
||||
/// </summary>
|
||||
/// <param name="id">Unique identifier for the port.</param>
|
||||
public ThermalPort(string id) : base(id)
|
||||
{
|
||||
Voltage = 0.0;
|
||||
Amperage = 0.0;
|
||||
IsSupplyingPower = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Connects this Thermal port to another Thermal port.
|
||||
/// Includes basic type checking.
|
||||
/// </summary>
|
||||
/// <param name="otherPort">The port to connect to.</param>
|
||||
public override void Connect(Port otherPort)
|
||||
{
|
||||
if (otherPort is ThermalPort)
|
||||
{
|
||||
base.Connect(otherPort);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Error: Cannot connect ThermalPort {ID} to non-ThermalPort {otherPort.ID}.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mirrors Thermal 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 ThermalPort connectedThermalPort)
|
||||
{
|
||||
connectedThermalPort.Voltage = this.Voltage;
|
||||
connectedThermalPort.Amperage = this.Amperage;
|
||||
connectedThermalPort.IsSupplyingPower = this.IsSupplyingPower;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user