added two stroke scenario with vehicle
This commit is contained in:
@@ -13,12 +13,16 @@ namespace FluidSim.Tests
|
||||
protected const float AmbientTemperature = 300f;
|
||||
public float Throttle { get; set; }
|
||||
public float Load { get; set; }
|
||||
public float Clutch { get; set; } // 0 = engaged, 1 = fully disengaged (manual lever)
|
||||
public Font? Font { get; set; }
|
||||
|
||||
public abstract void Initialize(int sampleRate);
|
||||
public abstract float Process();
|
||||
public abstract void Draw(RenderWindow target);
|
||||
|
||||
public virtual void ShiftUp() { }
|
||||
public virtual void ShiftDown() { }
|
||||
|
||||
// ---- Dyno curve graph ----
|
||||
private const float RpmBinSize = 50f;
|
||||
private readonly List<(float powerKw, float torqueNm)> _dynoBins = new();
|
||||
@@ -259,7 +263,7 @@ namespace FluidSim.Tests
|
||||
target.Draw(border);
|
||||
}
|
||||
|
||||
protected void DrawCylinder(RenderWindow target, Cylinder cylinder,
|
||||
protected void DrawCylinder(RenderWindow target, EngineCylinder cylinder,
|
||||
float centerX, float topY, float width, float maxHeight)
|
||||
{
|
||||
float fraction = cylinder.PistonFraction;
|
||||
@@ -298,7 +302,8 @@ namespace FluidSim.Tests
|
||||
}
|
||||
|
||||
protected void DrawPipe(RenderWindow target, PipeSystem pipeSystem, int pipeIndex,
|
||||
float pipeCenterY, float pipeStartX, float pipeEndX)
|
||||
float pipeCenterY, float pipeStartX, float pipeEndX,
|
||||
float areaScale = 0f)
|
||||
{
|
||||
int start = pipeSystem.GetPipeStart(pipeIndex);
|
||||
int end = pipeSystem.GetPipeEnd(pipeIndex);
|
||||
@@ -307,20 +312,34 @@ namespace FluidSim.Tests
|
||||
|
||||
float pipeLen = pipeEndX - pipeStartX;
|
||||
float dx = pipeLen / (n - 1);
|
||||
float baseRadius = 25f;
|
||||
|
||||
var centers = new float[n];
|
||||
var radii = new float[n];
|
||||
var temps = new float[n];
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
int cell = start + i;
|
||||
float p = pipeSystem.GetCellPressure(cell);
|
||||
float rho = pipeSystem.GetCellDensity(cell);
|
||||
temps[i] = p / MathF.Max(rho * 287f, 1e-12f);
|
||||
float dev = MathF.Tanh((p - AmbientPressure) / AmbientPressure * 0.5f);
|
||||
radii[i] = baseRadius * (1f + dev * 2f);
|
||||
if (radii[i] < 2f) radii[i] = 2f;
|
||||
|
||||
if (areaScale > 0f)
|
||||
{
|
||||
// Use actual cell area to determine visual radius
|
||||
float area = pipeSystem.GetCellArea(cell);
|
||||
radii[i] = MathF.Sqrt(area / MathF.PI) * areaScale;
|
||||
if (radii[i] < 1f) radii[i] = 1f;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Original pressure‑based radius
|
||||
float dev = MathF.Tanh((p - AmbientPressure) / AmbientPressure * 0.5f);
|
||||
float baseRadius = 25f; // default visual radius for constant‑area pipes
|
||||
radii[i] = baseRadius * (1f + dev * 2f);
|
||||
if (radii[i] < 2f) radii[i] = 2f;
|
||||
}
|
||||
|
||||
centers[i] = pipeStartX + i * dx;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user