openrails / test-launchpad-bugs

TEST repository for Launchpad bug migration exploration
0 stars 0 forks source link

[BUG 1989235] steam engine, piston shaft volume #2585

Open twpol opened 2 years ago

twpol commented 2 years ago

Imported from https://bugs.launchpad.net/bugs/1989235

Property Value
Reported by Wesley Johnson (trackcreworts)
Date reported Sat, 10 Sep 2022 03:04:45 GMT

The calculation for the piston shaft volume, is not a volume. There is something missing.

File: MSTSSteamLocomotive.cs Orts code:

Declaration: float CylinderPistonShaftFt3; // Volume taken up by the cylinder piston shaft

Calc:

        // Cylinder Steam Usage = SweptVolumeToTravelRatioFT3pFT x cutoff x {(speed x (SteamDensity (CylPress) - SteamDensity (CylBackPress)) 
        // lbs/s                = ft3/ft                                  x   ft/s  x  lbs/ft3

        // Cylinder piston shaft volume needs to be calculated and deducted from sweptvolume - assume diameter of the cylinder minus one-half of the piston-rod area. Let us assume that the latter is 3 square inches
        CylinderPistonShaftFt3 = Me2.ToFt2(Me2.FromIn2(((float)Math.PI * (CylinderPistonShaftDiaIn / 2.0f) * (CylinderPistonShaftDiaIn / 2.0f)) / 2.0f));
        CylinderPistonAreaFt2 = Me2.ToFt2(MathHelper.Pi * CylinderDiameterM * CylinderDiameterM / 4.0f);

I have yet to determine which is correct, the swept volume for a entire wheel rotation, or only one piston movement (which seems to be what ORTS has attempted).

From my code (which has the fixes and comments):

// Cylinder Steam Usage = SweptVolumeToTravelRatioFT3pFT x cutoff x {(speed x (SteamDensity (CylPress) - SteamDensity (CylBackPress)) // lbs/s = ft3/ft x ft/s x lbs/ft3

swept_cylinder_stroke = num_cylinders cylinder_dia cylinder_dia cylinder_stroke; // PI

// Cylinder piston shaft volume needs to be calculated and deducted from sweptvolume // - assume diameter of the cylinder minus one-half of the piston-rod area. Let us assume that the latter is 3 square inches

if ORTS

// ORTS ERROR: this is not a volume, unless the 1/2 means a 1/2 meter shaft length, or 1/2 the volume of a 1 meter shaft length

// ORTS: CylinderPistonShaftFt3 = Me2.ToFt2(Me2.FromIn2(((float)Math.PI (CylinderPistonShaftDiaIn / 2.0f) (CylinderPistonShaftDiaIn / 2.0f)) / 2.0f));

// Note: unit conversions are result of conversion to SI units // BAD UNITS, name had ft3 but calculation is NOT A VOLUME, it is only an area. piston_shaft_volume = meter3_per_ft3 (1/meter2_per_ft2) ((PI/4) piston_shaft_dia piston_shaft_dia ) / 2.0f; piston_area = (PI/4) cylinder_dia cylinder_dia;

swept_volume = ((piston_area * cylinder_stroke) - piston_shaft_volume);

else

// Area = PI * radius*2 = PI/4 dia*2 piston_shaft_area = (PI/4) piston_shaft_dia piston_shaft_dia; piston_area = (PI/4) cylinder_dia * cylinder_dia;

if 0

// averaged, for one wheel rotation swept_volume = (piston_area * cylinder_stroke)

else

// averaged, for one piston stroke (1/2 wheel rotation) swept_volume = (piston_area - (piston_shaft_area/2)) * cylinder_stroke;

endif

endif

Usage of the swept_volume is itself suspicious, and I suspect, inconsistent. There are several places where it should be used, where only a crude (piston_area cylinder_stroke) is used instead. There are other places where (cylinder_dia cylinder_dia * cylinder_stroke) is used with no correction for piston shaft. The number of cylinders is not used in many places, those places being hard coded for 2 cylinders.