mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-03 00:45:29 +01:00
feat(physics): the damage flags of a track make the ride rougher, a derailed vehicle once stopped stays put
Found running line 107 with every train driven by the AI: - a 401Ka wagon of a freight train overturned into a 282 m curve with a cant of 179 mm at 28 km/h: line 107 has damage 31 on every track, which scaled the whole lateral acceleration by 2.1, the cant too. The sceneries set the flags for the jolts of a worn track (thousands of tracks with 2, 31, 4 or 16), so they now scale only the sway of the body and the short waves of the uneven track, and no longer take load off the wheels; the cross level of the uneven track still does - the overturned wagon crept and stopped in turn in every step (the friction of the ballast against the pull of its train), which kept the physics of the whole train awake: the run went at half the speed after it. The friction now holds a stopped derailed vehicle until the forces on it are larger - a vehicle without a mass got Y/Q 1e9 (no wheel load), now none - the log of a derailment tells the mass, the centre of gravity, the forces of the couplings, the damage flags and the cross level as well
This commit is contained in:
+1
-1
@@ -2438,7 +2438,7 @@ class TMoverParameters
|
||||
// physics.derailment new: the criteria of derailment.h over the step, which travelled the Distance [m]
|
||||
void check_derailment(TTrackShape const &Shape, TTrackParam const &Track, double Distance);
|
||||
// the vehicle leaves the rails, as the criteria of derailment.h found
|
||||
void derail(derailment::verdict const &Verdict, TTrackShape const &Shape);
|
||||
void derail(derailment::verdict const &Verdict, derailment::vehicle_state const &Vehicle, derailment::track_state const &Track);
|
||||
// height of the centre of gravity above the rail with the load [m]
|
||||
double centre_of_gravity() const;
|
||||
// how the vehicle left the rails by the criteria of derailment.h: upright, or on its side. none for any other
|
||||
|
||||
+19
-6
@@ -1550,11 +1550,11 @@ void TMoverParameters::check_derailment(TTrackShape const &Shape, TTrackParam co
|
||||
auto const verdict{derailment_monitor.update(vehicle, track, V, Distance)};
|
||||
if (verdict.result != derailment::outcome::none)
|
||||
{
|
||||
derail(verdict, Shape);
|
||||
derail(verdict, vehicle, track);
|
||||
}
|
||||
}
|
||||
|
||||
void TMoverParameters::derail(derailment::verdict const &Verdict, TTrackShape const &Shape)
|
||||
void TMoverParameters::derail(derailment::verdict const &Verdict, derailment::vehicle_state const &Vehicle, derailment::track_state const &Track)
|
||||
{
|
||||
if (false == SetFlag(DamageFlag, dtrain_out))
|
||||
{
|
||||
@@ -1568,10 +1568,12 @@ void TMoverParameters::derail(derailment::verdict const &Verdict, TTrackShape co
|
||||
{
|
||||
AlarmChainFlag = true;
|
||||
}
|
||||
auto const cant{1000.0 * derailment::contact_spacing(TrackW) * std::sin(std::abs(Shape.dHrail))};
|
||||
ErrorLog(std::format("Bad driving: {} {} at {:.0f} km/h, curve radius {:.0f} m, cant {:.0f} mm: lateral acceleration {:.2f} m/s2, wheel unloading {:.2f}, Y/Q {:.2f}", Name,
|
||||
Derailed == derailment::outcome::overturned ? "overturned" : "derailed, the flange climbed the rail", std::abs(V) * 3.6, std::abs(Shape.R), cant, Verdict.acceleration,
|
||||
Verdict.unloading, Verdict.flange_ratio));
|
||||
auto const cant{1000.0 * derailment::contact_spacing(Track.gauge) * std::sin(std::abs(Track.cant))};
|
||||
ErrorLog(std::format("Bad driving: {} {} at {:.0f} km/h, curve radius {:.0f} m, cant {:.0f} mm: lateral acceleration {:.2f} m/s2, wheel unloading {:.2f}, Y/Q {:.2f}"
|
||||
" (mass {:.1f} t, centre of gravity {:.2f} m, couplings pushing {:.0f} / {:.0f} kN, track damage {}, cross level {:.0f} mm)",
|
||||
Name, Derailed == derailment::outcome::overturned ? "overturned" : "derailed, the flange climbed the rail", std::abs(V) * 3.6, std::abs(Track.radius), cant,
|
||||
Verdict.acceleration, Verdict.unloading, Verdict.flange_ratio, Vehicle.mass / 1000.0, Vehicle.centre_of_gravity, Vehicle.ends[end::front].compression / 1000.0,
|
||||
Vehicle.ends[end::rear].compression / 1000.0, Track.damage, Track.uneven_cross));
|
||||
}
|
||||
|
||||
void TMoverParameters::Derail(DerailReason const Reason)
|
||||
@@ -1652,6 +1654,10 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
|
||||
// a vehicle derailed by the physical criteria slides on with the friction of ComputeTotalForce()
|
||||
if (TestFlag(DamageFlag, dtrain_out) && Derailed == derailment::outcome::none)
|
||||
AccS = -Sign(V) * g * 1; // random(0.0, 0.1)
|
||||
// stuck in the ballast: the friction holds a derailed vehicle once it stopped, until the forces on it are larger
|
||||
auto const stuck{Derailed != derailment::outcome::none && V == 0.0 && std::abs(FTrain) <= std::abs(FStand)};
|
||||
if (stuck)
|
||||
AccS = 0.0;
|
||||
|
||||
// przyspieszenie normalne
|
||||
if (abs(Shape.R) > 0.01)
|
||||
@@ -1662,6 +1668,8 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
|
||||
// velocity change
|
||||
auto const Vprev{V};
|
||||
V += (3.0 * AccS - AccSprev) * dt / 2.0; // przyrost predkosci
|
||||
if (stuck)
|
||||
V = 0.0;
|
||||
if (V * Vprev <= 0 && std::abs(FStand) > std::abs(FTrain))
|
||||
{
|
||||
// tlumienie predkosci przy hamowaniu
|
||||
@@ -1757,12 +1765,17 @@ double TMoverParameters::FastComputeMovement(double dt, const TTrackShape & /*Sh
|
||||
|
||||
if (TestFlag(DamageFlag, dtrain_out) && Derailed == derailment::outcome::none)
|
||||
AccS = -Sign(V) * g * 1; // * random(0.0, 0.1)
|
||||
auto const stuck{Derailed != derailment::outcome::none && V == 0.0 && std::abs(FTrain) <= std::abs(FStand)};
|
||||
if (stuck)
|
||||
AccS = 0.0;
|
||||
|
||||
// simple mode skips calculation of normal acceleration
|
||||
|
||||
// velocity change
|
||||
auto const Vprev{V};
|
||||
V += (3.0 * AccS - AccSprev) * dt / 2.0; // przyrost predkosci
|
||||
if (stuck)
|
||||
V = 0.0;
|
||||
if (V * Vprev <= 0 && std::abs(FStand) > std::abs(FTrain))
|
||||
{
|
||||
// tlumienie predkosci przy hamowaniu
|
||||
|
||||
@@ -128,12 +128,14 @@ double nadal_limit(double const FlangeAngle, double const Friction) {
|
||||
|
||||
track_condition condition_of(track_state const &Track) {
|
||||
track_condition condition;
|
||||
// as the legacy criterion had it, a loose rail sways the vehicles 1.4 times as much
|
||||
// the flags make the ride rougher: the sway of the vehicles and the short waves of the track grow, the curve and
|
||||
// the cant stay what they are. sceneries set them for the jolts of a worn track (damage 31 on all of line 107),
|
||||
// not for broken rails. a loose rail sways the vehicles 1.4 times as much, as the legacy criterion had it
|
||||
condition.lateral = 1.0 + 0.4 * has(Track.damage, track_damage::freerail) + 0.5 * has(Track.damage, track_damage::railbend) + 0.1 * has(Track.damage, track_damage::railwear) +
|
||||
0.1 * has(Track.damage, track_damage::thinrail);
|
||||
// the twist of the track lifts a wheel: 1 % of its load for each mm of cross level, up to the 0.6 the twist test
|
||||
// of EN 14363 lets the load drop by
|
||||
condition.unloading = std::min(0.6, 0.01 * std::max(0.0, Track.uneven_cross) + 0.1 * has(Track.damage, track_damage::freerail) + 0.1 * has(Track.damage, track_damage::railbend));
|
||||
condition.unloading = std::min(0.6, 0.01 * std::max(0.0, Track.uneven_cross));
|
||||
return condition;
|
||||
}
|
||||
|
||||
@@ -160,8 +162,8 @@ wheel_forces flange_forces(vehicle_state const &Vehicle, track_state const &Trac
|
||||
auto const quasistatic{inertia + couplings};
|
||||
// the sway and the uneven track push the worst way: towards the rail the vehicle already leans on
|
||||
auto const direction{quasistatic >= 0.0 ? 1.0 : -1.0};
|
||||
auto const dynamic{Vehicle.mass * dynamic_acceleration(Track, Velocity)};
|
||||
result.lateral = direction * (std::abs(quasistatic) + dynamic) * condition.lateral;
|
||||
auto const dynamic{Vehicle.mass * dynamic_acceleration(Track, Velocity) * condition.lateral};
|
||||
result.lateral = direction * (std::abs(quasistatic) + dynamic);
|
||||
|
||||
// the leading axle meets the rail at an angle in a curve, the creep force of its inner wheel at most the friction
|
||||
auto guiding{0.0};
|
||||
@@ -172,7 +174,7 @@ wheel_forces flange_forces(vehicle_state const &Vehicle, track_state const &Trac
|
||||
result.y = std::abs(result.lateral) / axles + guiding;
|
||||
|
||||
// the lateral forces at their heights move the load onto the wheels they push towards
|
||||
auto const moment{(direction * (inertia * height + couplings * buffer_height) + dynamic * height) * condition.lateral};
|
||||
auto const moment{direction * (inertia * height + couplings * buffer_height) + dynamic * height};
|
||||
auto const shift{moment / (spacing * axles)};
|
||||
result.q = std::max(0.0, (staticload + shift) * (1.0 - condition.unloading));
|
||||
return result;
|
||||
@@ -185,7 +187,7 @@ double body_acceleration(vehicle_state const &Vehicle, track_state const &Track,
|
||||
auto const height{leaning_height(Vehicle.centre_of_gravity, suspension{})};
|
||||
// the couplings pull at the height of the buffers: as much of a lean as their moment gives
|
||||
auto const moment{Vehicle.mass * unbalanced_acceleration(Velocity, Track.radius, Track.cant) * height + coupling_force(Vehicle, Track) * buffer_height};
|
||||
return (std::abs(moment) / (Vehicle.mass * height) + dynamic_acceleration(Track, Velocity)) * condition_of(Track).lateral;
|
||||
return std::abs(moment) / (Vehicle.mass * height) + dynamic_acceleration(Track, Velocity) * condition_of(Track).lateral;
|
||||
}
|
||||
|
||||
bool stretch::update(bool const Holds, double const Distance, double const Window) {
|
||||
|
||||
@@ -129,8 +129,8 @@ struct track_state {
|
||||
|
||||
// what the state of the track does to the lateral forces and the wheel loads
|
||||
struct track_condition {
|
||||
double lateral{1.0}; // multiplier of the lateral acceleration
|
||||
double unloading{0.0}; // share of the wheel load the twist of the track takes off
|
||||
double lateral{1.0}; // multiplier of the sway of the vehicle and of the short waves of an uneven track
|
||||
double unloading{0.0}; // share of the wheel load the twist of the track (its cross level) takes off
|
||||
};
|
||||
track_condition condition_of(track_state const &Track);
|
||||
// share of the vehicle that follows the short waves of an uneven track: the wheelsets and the bogies, the body not
|
||||
@@ -144,7 +144,8 @@ struct wheel_forces {
|
||||
double lateral{0.0}; // the lateral force on the vehicle, positive out of the curve [N]
|
||||
double y{0.0}; // lateral force of the flanging wheel [N]
|
||||
double q{0.0}; // its vertical force [N]
|
||||
double ratio() const { return q > 0.0 ? y / q : 1e9; }
|
||||
// a wheel lifted off the rail with a force on it is past any limit; no force at all (a vehicle without a mass) none
|
||||
double ratio() const { return q > 0.0 ? y / q : (y > 0.0 ? 1e9 : 0.0); }
|
||||
};
|
||||
// the forces of the flanging wheel of the leading axle, at the speed [m/s]
|
||||
wheel_forces flange_forces(vehicle_state const &Vehicle, track_state const &Track, double Velocity);
|
||||
|
||||
@@ -155,6 +155,19 @@ TEST_CASE("derailment: a peak shorter than the window doesn't derail") {
|
||||
CHECK(stretch.distance() == doctest::Approx(2.0));
|
||||
}
|
||||
|
||||
TEST_CASE("derailment: a vehicle without a mass never derails") {
|
||||
// a definition without M (or with all of it in the rotating masses) gives no forces, not a lifted wheel
|
||||
dr::vehicle_state massless;
|
||||
massless.mass = 0.0;
|
||||
dr::track_state track;
|
||||
track.radius = 150.0;
|
||||
CHECK(dr::flange_forces(massless, track, 30.0).ratio() == 0.0);
|
||||
dr::monitor monitor;
|
||||
for (int step = 0; step < 10; ++step) {
|
||||
CHECK(monitor.update(massless, track, 30.0, 1.0).result == dr::outcome::none);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("derailment: pushing a light wagon between heavy vehicles in a curve") {
|
||||
// the empty 3WL (10.5 t, 2 axles 6 m apart, 9.87 m long) between two EU07 in a 150 m curve: the more the train
|
||||
// pushes, the more the couplings push the wagon out of the curve, the higher its Y/Q
|
||||
@@ -209,9 +222,9 @@ TEST_CASE("derailment: pushing a light wagon between heavy vehicles in a curve")
|
||||
return result > flat;
|
||||
}()};
|
||||
CHECK(twisted);
|
||||
// on a bent rail, with a twist of 40 mm, the wagon pushed with 300 kN climbs the rail over 2 m, without falling over
|
||||
// on a bent rail, with a twist of 50 mm, the wagon pushed with 300 kN climbs the rail over 2 m, without falling over
|
||||
track.damage = dr::track_damage::railbend;
|
||||
track.uneven_cross = 40.0;
|
||||
track.uneven_cross = 50.0;
|
||||
dr::monitor monitor;
|
||||
auto pushed{wagon};
|
||||
for (auto &end : pushed.ends) {
|
||||
@@ -225,3 +238,43 @@ TEST_CASE("derailment: pushing a light wagon between heavy vehicles in a curve")
|
||||
CHECK(verdict.unloading < 1.0);
|
||||
CHECK(verdict.result == dr::outcome::off_rails);
|
||||
}
|
||||
|
||||
TEST_CASE("derailment: the damage flags of the track make the ride rougher, not the curve sharper") {
|
||||
// line 107 has damage 31 on every track, for the jolts. a 401Ka wagon creeping at 28 km/h through a 282 m curve
|
||||
// with a cant of 179 mm, pulled by a freight train, stays on: in the 2026-11-15 run with the flags scaling the
|
||||
// whole lateral acceleration it overturned into the curve
|
||||
dr::vehicle_state wagon;
|
||||
wagon.mass = 23000.0;
|
||||
wagon.axles = 4;
|
||||
wagon.length = 14.7;
|
||||
wagon.axle_base = 1.8;
|
||||
wagon.centre_of_gravity = dr::default_centre_of_gravity(4.2, dr::vehicle_class::unpowered);
|
||||
for (auto &end : wagon.ends) {
|
||||
end.compression = -200e3;
|
||||
end.other_length = 14.7;
|
||||
}
|
||||
dr::track_state track;
|
||||
track.radius = 282.0;
|
||||
track.cant = std::asin(0.179 / 1.5);
|
||||
auto const speed{28.0 * kmh};
|
||||
auto const smooth{dr::body_acceleration(wagon, track, speed)};
|
||||
track.damage = 31;
|
||||
auto const rough{dr::body_acceleration(wagon, track, speed)};
|
||||
// the sway grows, by what a rough track adds to the sway at that speed
|
||||
CHECK(rough > smooth);
|
||||
CHECK(rough - smooth == doctest::Approx(1.1 * dr::body_vibration(speed)));
|
||||
CHECK(dr::unloading_ratio(rough, wagon.centre_of_gravity, 1.5) < 0.5);
|
||||
CHECK(dr::flange_forces(wagon, track, speed).ratio() < 0.8);
|
||||
// at speed the rough track still lowers the overturning speed some, as the legacy criterion's factor did
|
||||
{
|
||||
dr::vehicle_state eu07vehicle;
|
||||
eu07vehicle.mass = 80000.0;
|
||||
eu07vehicle.centre_of_gravity = eu07;
|
||||
dr::track_state good;
|
||||
good.radius = 300.0;
|
||||
auto worn{good};
|
||||
worn.damage = 31;
|
||||
CHECK(dr::body_acceleration(eu07vehicle, worn, 30.0) > dr::body_acceleration(eu07vehicle, good, 30.0));
|
||||
CHECK(dr::body_acceleration(eu07vehicle, worn, 30.0) - dr::body_acceleration(eu07vehicle, good, 30.0) == doctest::Approx(1.1 * dr::vibration));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,3 +140,24 @@ TEST_CASE("derailment: the brake hoses tear") {
|
||||
REQUIRE(eu07vehicle->Derailed == dr::outcome::overturned);
|
||||
CHECK(eu07vehicle->AlarmChainFlag);
|
||||
}
|
||||
|
||||
TEST_CASE("derailment: a stopped derailed vehicle stays put on a gradient") {
|
||||
// the friction of the ballast holds it, rather than the vehicle creeping and stopping in turn in every step, which
|
||||
// kept the physics of its whole train awake (the run of line 107 went at half the speed after a derailment)
|
||||
model_setting const physical{global_settings::derailment_model::physical};
|
||||
test::track curve;
|
||||
curve.radius = 300.0;
|
||||
curve.gradient = 0.01;
|
||||
vehicle eu07vehicle{definition::fiz("4e_v1/4e"), 150.0};
|
||||
for (int step = 0; step < 2000; ++step) {
|
||||
eu07vehicle.step(curve);
|
||||
}
|
||||
REQUIRE(eu07vehicle->Derailed == dr::outcome::overturned);
|
||||
REQUIRE(eu07vehicle->V == 0.0);
|
||||
auto still{true};
|
||||
for (int step = 0; step < 500; ++step) {
|
||||
eu07vehicle.step(curve);
|
||||
still = still && eu07vehicle->V == 0.0 && eu07vehicle->AccS == 0.0;
|
||||
}
|
||||
CHECK(still);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user