added valves display

This commit is contained in:
maxwes08
2026-05-06 14:05:37 +02:00
parent d6b1d214f5
commit bc4e077924
4 changed files with 103 additions and 29 deletions

View File

@@ -17,17 +17,19 @@ namespace FluidSim.Core
// ---- Exhaust valve ----
private double exhMaxOrificeArea;
private double exhValveOpenStart = 120.0 * Math.PI / 180.0; // 120° (EVO)
private double exhValveOpenEnd = 480.0 * Math.PI / 180.0; // 480° (EVC)
private double exhValveOpenStart = 130.0 * Math.PI / 180.0;
private double exhValveOpenEnd = 390.0 * Math.PI / 180.0;
private double exhValveRampWidth = 30.0 * Math.PI / 180.0;
public double ExhaustOrificeArea => ExhaustValveLift() * exhMaxOrificeArea;
public double ExhaustValveLiftCurrent => ExhaustValveLift();
// ---- Intake valve ----
private double intMaxOrificeArea;
private double intValveOpenStart = 380.0 * Math.PI / 180.0; // 380° (IVO)
private double intValveOpenEnd = 560.0 * Math.PI / 180.0; // 560° (IVC)
private double intValveOpenStart = 340.0 * Math.PI / 180.0;
private double intValveOpenEnd = 600.0 * Math.PI / 180.0;
private double intValveRampWidth = 30.0 * Math.PI / 180.0;
public double IntakeOrificeArea => IntakeValveLift() * intMaxOrificeArea;
public double IntakeValveLiftCurrent => IntakeValveLift();
// ---- Combustion ----
public double TargetPeakPressure { get; set; } = 50.0 * 101325.0;
@@ -70,8 +72,8 @@ namespace FluidSim.Core
this.stroke = stroke;
conRodLength = 2.0 * stroke;
this.compressionRatio = compressionRatio;
exhMaxOrificeArea = exhPipeArea;
intMaxOrificeArea = intPipeArea;
exhMaxOrificeArea = exhPipeArea * 0.5;
intMaxOrificeArea = intPipeArea * 0.5;
pistonArea = Math.PI / 4.0 * bore * bore;
V_disp = pistonArea * stroke;

46
Components/Nozzleflow.cs Normal file
View File

@@ -0,0 +1,46 @@
using System;
namespace FluidSim.Components
{
public static class NozzleFlow
{
/// <summary>
/// Computes the nozzleexit primitive state and mass flow rate from a
/// volume to a pipe, using isentropic relations. Follows ensim4's flow() logic.
/// </summary>
public static void Compute(double Pt_high, double Tt_high,
double P_low, double gamma, double R, double area,
out double rhoExit, out double uExit,
out double pExit, out double mdot)
{
double gm1 = gamma - 1.0;
double Pt_over_Ps = Pt_high / P_low;
// Mach number (subsonic, clamped to 1)
double M = Math.Sqrt(Math.Max(0.0,
(2.0 / gm1) * (Math.Pow(Pt_over_Ps, gm1 / gamma) - 1.0)));
if (M > 1.0) M = 1.0;
double T_star = Tt_high / (1.0 + 0.5 * gm1 * M * M);
double a_star = Math.Sqrt(gamma * R * T_star);
double u_star = M * a_star;
pExit = Pt_high * Math.Pow(1.0 + 0.5 * gm1 * M * M, -gamma / gm1);
rhoExit = pExit / (R * T_star);
uExit = u_star; // positive away from highpressure side
mdot = rhoExit * uExit * area;
}
/// <summary>
/// Ambient cell for nonreflecting open end (ensim4 calc_ambient_cell).
/// </summary>
public static void ComputeAmbientCell(double rhoInt, double uInt, double pInt,
double pAmbient, double gamma,
out double rhoAmb, out double uAmb,
out double pAmb)
{
pAmb = pAmbient;
uAmb = uInt;
rhoAmb = rhoInt * Math.Pow(pAmb / pInt, 1.0 / gamma);
}
}
}