250cc mx engine, and dyno

This commit is contained in:
max
2026-06-09 20:20:56 +02:00
parent aba9b76530
commit ac2eab6f83
5 changed files with 385 additions and 82 deletions

View File

@@ -107,13 +107,11 @@ namespace FluidSim.Components
if (closes < opens)
{
// Wraparound case (e.g., exhaust: opens near 480°, closes near 30°)
effectiveClose += 720f;
}
duration = effectiveClose - effectiveOpen;
if (duration <= 0f) return 0f;
// Map the angle into the [opens, opens+duration] window
float mapped = deg;
if (mapped < opens) mapped += 720f;
if (mapped < opens || mapped > effectiveClose) return 0f;
@@ -153,6 +151,10 @@ namespace FluidSim.Components
public void PreStep(float dt)
{
// Speeddependent spark advance (simple linear)
float rpm = Crankshaft.AngularVelocity * 60f / (2f * MathF.PI);
SparkAdvance = Math.Clamp(10f + rpm * 0.002f, 5f, 40f); // 10° at idle, ~30° at 10k rpm
float prevVolume = cylinderVolume;
float crankAngleRad = Crankshaft.CrankAngle + PhaseOffset;
cylinderVolume = ComputeVolume(crankAngleRad);
@@ -170,7 +172,7 @@ namespace FluidSim.Components
float prevDeg = (Crankshaft.PreviousAngle + PhaseOffset) * 180f / MathF.PI % 720f;
float currDeg = crankAngleRad * 180f / MathF.PI % 720f;
// Intake closing
// Intake closing triggers fuel injection
if (prevDeg >= IVO && prevDeg < IVC && currDeg >= IVC)
{
trappedAirMass = _airMass;