refactoring (broken right now)
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
namespace FluidSim.Interfaces
|
||||
{
|
||||
/// <summary>Pure data link between two ports, with orifice parameters.</summary>
|
||||
public class Connection
|
||||
{
|
||||
public Port PortA { get; }
|
||||
public Port PortB { get; }
|
||||
|
||||
public double Area { get; set; } = 1e-5; // effective orifice area (m²)
|
||||
public double DischargeCoefficient { get; set; } = 0.62;
|
||||
public double Gamma { get; set; } = 1.4;
|
||||
|
||||
public Connection(Port a, Port b) => (PortA, PortB) = (a, b);
|
||||
}
|
||||
}
|
||||
19
Interfaces/IComponent.cs
Normal file
19
Interfaces/IComponent.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FluidSim.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Minimal interface for all simulation components that have ports.
|
||||
/// </summary>
|
||||
public interface IComponent
|
||||
{
|
||||
/// <summary>All ports exposed by this component.</summary>
|
||||
IReadOnlyList<Port> Ports { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Called once per global time step to update the component's internal state
|
||||
/// using the port flow data accumulated during sub‑steps.
|
||||
/// </summary>
|
||||
void UpdateState(double dt);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,28 @@
|
||||
namespace FluidSim.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// A fluid port that belongs to a component. The solver writes mass flow,
|
||||
/// enthalpy, etc. here, and reads pressure, density, etc.
|
||||
/// </summary>
|
||||
public class Port
|
||||
{
|
||||
// Set by the solver during coupling resolution
|
||||
public double MassFlowRate; // kg/s, positive INTO the component that owns this port
|
||||
public double SpecificEnthalpy; // J/kg, enthalpy of the fluid crossing the port (inflow direction)
|
||||
|
||||
// Set by the owning component after integration to reflect its current state
|
||||
public double Pressure; // Pa
|
||||
public double MassFlowRate; // kg/s, positive INTO the component
|
||||
public double SpecificEnthalpy; // J/kg, enthalpy of fluid entering this port
|
||||
public double Density; // kg/m³
|
||||
public double Temperature; // K
|
||||
|
||||
// Link back to owner (optional, but handy for debugging)
|
||||
public object? Owner { get; set; }
|
||||
|
||||
public Port()
|
||||
{
|
||||
Pressure = 101325.0;
|
||||
MassFlowRate = 0.0;
|
||||
SpecificEnthalpy = 0.0;
|
||||
Pressure = 101325.0;
|
||||
Density = 1.225;
|
||||
Temperature = 300.0;
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
namespace FluidSim.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// A Connection that also produces an audio sample from the pressure drop across it.
|
||||
/// </summary>
|
||||
public class SoundConnection : Connection
|
||||
{
|
||||
/// <summary>Gain applied to the normalised pressure difference.</summary>
|
||||
public float Gain { get; set; } = 1.0f;
|
||||
|
||||
/// <summary>Reference pressure used for normalisation (Pa). Default: 1 atm.</summary>
|
||||
public double ReferencePressure { get; set; } = 101325.0;
|
||||
|
||||
public SoundConnection(Port a, Port b) : base(a, b) { }
|
||||
|
||||
/// <summary>
|
||||
/// Returns a normalised audio sample proportional to the pressure difference.
|
||||
/// </summary>
|
||||
public float GetAudioSample()
|
||||
{
|
||||
double dp = PortA.Pressure - PortB.Pressure;
|
||||
return (float)(dp / ReferencePressure) * Gain;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user