mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 22:07:55 +01:00
096e60ff38
With physics.derailment new, a verdict the curve and the cant alone give
(the criterion holds for the vehicle without its coupler forces, on the
track without a buckle, damage flags or unevenness) is held back while
the vehicle runs under the trusted speed of the track: its speed limit
times 1.1 plus 5 km/h. The log names the track once as a defect of the
scenery ("derailment monitor: data: ..."). Over the trusted speed, on a
track without a limit, and for whatever the couplings, a buckle or the
damage of the track bring about, the verdict goes as before.
physics.derailment.trustlimits yes|no, default yes; no is the behaviour
before. The decision is a set of pure functions in McZapkie/derailment
(trusted_speed, from_track_alone, limited_verdict, held_back_report);
check_derailment only calls them.
The 144 tracks physics.trackcheck finds with limits their curves don't
take (backlog L4) no longer derail trains that keep to them, so the
default of physics.derailment can be decided apart from the data fixes.
Tests: unit tests of the decision and of a vehicle on a curve with a bad
limit; scenario cases eu07_td_overspeed_bad_limit (140 km/h, held on),
_fast (175 km/h, overturns) and _untrusted (trustlimits no, overturns).
502 lines
22 KiB
C++
502 lines
22 KiB
C++
#include "stdafx.h"
|
|
#include "doctest.h"
|
|
#include "McZapkie/derailment.h"
|
|
|
|
#include <cmath>
|
|
#include <optional>
|
|
|
|
// the criteria of derailment (McZapkie/derailment.h): overturning by the lateral acceleration the cant doesn't
|
|
// balance, the flange climbing the rail by Nadal's Y/Q, either held over 2 m
|
|
|
|
namespace dr = derailment;
|
|
|
|
namespace {
|
|
|
|
constexpr double kmh{1.0 / 3.6};
|
|
|
|
// the cant [rad] of the height of the outer rail [mm] on the standard gauge
|
|
double cant(double const Millimetres) {
|
|
return std::asin(Millimetres / 1000.0 / dr::contact_spacing(1.435));
|
|
}
|
|
|
|
// the centres of gravity the vehicles of data/fiz get without a CoGH of their own
|
|
// EU07 (4E): 80 t, a body 4.348 m high
|
|
double const eu07{dr::default_centre_of_gravity(4.348, dr::vehicle_class::powered)};
|
|
// the 430W coal wagon: 20.5 t, a body 3.235 m high, 59.5 t of coal
|
|
double const coal_wagon{dr::default_centre_of_gravity(3.235, dr::vehicle_class::unpowered)};
|
|
double const coal_wagon_loaded{dr::loaded_centre_of_gravity(coal_wagon, 20500.0, 59500.0, 1.0, 0.0, 3.235)};
|
|
|
|
} // namespace
|
|
|
|
TEST_CASE("derailment: Nadal's limit of Y/Q") {
|
|
// 70 degrees of the flange: 1.34 with a friction of 0.3, 1.2 with 0.36, the limit the criterion takes
|
|
CHECK(dr::nadal_limit(dr::flange_angle, 0.3) == doctest::Approx(1.342).epsilon(0.001));
|
|
CHECK(dr::nadal_limit(dr::flange_angle, 0.36) == doctest::Approx(dr::climbing_limit).epsilon(0.01));
|
|
// a steeper flange holds more, a higher friction less
|
|
CHECK(dr::nadal_limit(dr::flange_angle + 0.05, 0.3) > dr::nadal_limit(dr::flange_angle, 0.3));
|
|
CHECK(dr::nadal_limit(dr::flange_angle, 0.5) < dr::nadal_limit(dr::flange_angle, 0.3));
|
|
}
|
|
|
|
TEST_CASE("derailment: the centre of gravity") {
|
|
CHECK(eu07 == doctest::Approx(1.65).epsilon(0.01));
|
|
CHECK(coal_wagon == doctest::Approx(1.13).epsilon(0.01));
|
|
// the load raises it: a full coal wagon is near 2 m, the limit of the railways for a loaded wagon is 2 to 2.5 m
|
|
CHECK(coal_wagon_loaded == doctest::Approx(1.94).epsilon(0.01));
|
|
CHECK(dr::loaded_centre_of_gravity(coal_wagon, 20500.0, 30000.0, 0.5, 0.0, 3.235) > coal_wagon);
|
|
CHECK(dr::loaded_centre_of_gravity(coal_wagon, 20500.0, 30000.0, 0.5, 0.0, 3.235) < coal_wagon_loaded);
|
|
CHECK(dr::loaded_centre_of_gravity(coal_wagon, 20500.0, 0.0, 0.0, 0.0, 3.235) == coal_wagon);
|
|
// a body height of 2 m or less is the floor, the older meaning of the key: a 4 m high body then
|
|
CHECK(dr::default_centre_of_gravity(1.2, dr::vehicle_class::unpowered) == doctest::Approx(1.4));
|
|
}
|
|
|
|
TEST_CASE("derailment: the overturning speed by the radius and the cant") {
|
|
struct expected {
|
|
char const *vehicle;
|
|
double centre;
|
|
double radius;
|
|
double cant; // mm
|
|
double speed; // km/h
|
|
};
|
|
// EU07 overturns at 108 km/h in a 300 m curve without cant, as the legacy criterion had it near 112 km/h; at
|
|
// 119 km/h with a cant of 100 mm. a full coal wagon at 98 km/h, an empty one at 137 km/h
|
|
for (auto const &[name, centre, radius, height, speed] : {
|
|
expected{"EU07", eu07, 150.0, 0.0, 77.6},
|
|
expected{"EU07", eu07, 300.0, 0.0, 107.8},
|
|
expected{"EU07", eu07, 300.0, 100.0, 119.0},
|
|
expected{"EU07", eu07, 600.0, 150.0, 175.8},
|
|
expected{"430W empty", coal_wagon, 300.0, 0.0, 136.9},
|
|
expected{"430W empty", coal_wagon, 300.0, 100.0, 145.9},
|
|
expected{"430W loaded", coal_wagon_loaded, 300.0, 0.0, 97.5},
|
|
expected{"430W loaded", coal_wagon_loaded, 300.0, 100.0, 109.6},
|
|
expected{"430W loaded", coal_wagon_loaded, 1200.0, 150.0, 230.5},
|
|
}) {
|
|
CAPTURE(name);
|
|
CAPTURE(radius);
|
|
CAPTURE(height);
|
|
CHECK(dr::overturning_speed(radius, cant(height), centre, 1.435) / kmh == doctest::Approx(speed).epsilon(0.002));
|
|
}
|
|
// on the faster side of 100 km/h, where the vibration is all there: v^2 / R - g sin(cant) + 0.05 g = g s / 2 h'
|
|
auto const leaning{eu07 + 0.4 * (eu07 - 0.5)};
|
|
auto const limit{dr::gravity * 1.5 / (2.0 * leaning)};
|
|
CHECK(dr::overturning_acceleration(eu07, 1.5) == doctest::Approx(limit));
|
|
auto const speed{std::sqrt((limit - dr::vibration + dr::gravity * std::sin(cant(100.0))) * 300.0)};
|
|
CHECK(dr::overturning_speed(300.0, cant(100.0), eu07, 1.435) == doctest::Approx(speed).epsilon(0.001));
|
|
// the legacy criterion, the lateral acceleration over g times the gauge to the height of the vehicle, without cant
|
|
auto const legacy{std::sqrt(dr::gravity * 1.435 / 4.348 * 300.0)};
|
|
CHECK(dr::overturning_speed(300.0, 0.0, eu07, 1.435) == doctest::Approx(legacy).epsilon(0.05));
|
|
// faster on a wider curve, as its square root
|
|
CHECK(dr::overturning_speed(1200.0, 0.0, eu07, 1.435) / dr::overturning_speed(300.0, 0.0, eu07, 1.435) == doctest::Approx(2.0).epsilon(0.001));
|
|
// the cant only helps
|
|
CHECK(dr::overturning_speed(300.0, cant(150.0), eu07, 1.435) > dr::overturning_speed(300.0, cant(60.0), eu07, 1.435));
|
|
// no overturning on a straight track
|
|
CHECK(dr::overturning_speed(0.0, 0.0, eu07, 1.435) == 0.0);
|
|
}
|
|
|
|
TEST_CASE("derailment: below the balancing speed the cant leans the vehicle into the curve") {
|
|
// 100 mm on the 1.5 m between the contact points of the wheels
|
|
CHECK(dr::unbalanced_acceleration(0.0, 300.0, cant(100.0)) == doctest::Approx(-dr::gravity * 0.1 / 1.5));
|
|
// at the balancing speed nothing's left
|
|
auto const balanced{std::sqrt(dr::gravity * 0.1 / 1.5 * 300.0)};
|
|
CHECK(dr::unbalanced_acceleration(balanced, 300.0, cant(100.0)) == doctest::Approx(0.0).epsilon(1e-9));
|
|
// the sign of the radius and of the cant doesn't matter
|
|
CHECK(dr::unbalanced_acceleration(30.0, -300.0, -cant(100.0)) == doctest::Approx(dr::unbalanced_acceleration(30.0, 300.0, cant(100.0))));
|
|
}
|
|
|
|
TEST_CASE("derailment: the decision and the place don't depend on the step") {
|
|
// EU07 runs at a steady speed into a 300 m curve without cant 100 m ahead, the track checked at the end of each step
|
|
dr::vehicle_state eu07vehicle;
|
|
eu07vehicle.mass = 80000.0;
|
|
eu07vehicle.axles = 4;
|
|
eu07vehicle.length = 15.915;
|
|
eu07vehicle.axle_base = 3.05;
|
|
eu07vehicle.centre_of_gravity = eu07;
|
|
auto const critical{dr::overturning_speed(300.0, 0.0, eu07, 1.435)};
|
|
constexpr double curve{100.0};
|
|
|
|
// where the vehicle overturns, if it does within 400 m
|
|
auto const run = [&](double const Speed, double const Step) -> std::optional<double> {
|
|
dr::monitor monitor;
|
|
dr::track_state track;
|
|
auto distance{0.0};
|
|
while (distance < 400.0) {
|
|
auto const travelled{Speed * Step};
|
|
distance += travelled;
|
|
track.radius = distance >= curve ? 300.0 : 0.0;
|
|
if (monitor.update(eu07vehicle, track, Speed, travelled).result == dr::outcome::overturned) {
|
|
return distance;
|
|
}
|
|
}
|
|
return std::nullopt;
|
|
};
|
|
|
|
for (auto const step : {0.01, 0.05, 0.5}) {
|
|
CAPTURE(step);
|
|
// 5 % too fast: overturns 2 m into the curve, give or take the step it got there in
|
|
auto const fast{run(1.05 * critical, step)};
|
|
REQUIRE(fast.has_value());
|
|
CHECK(*fast >= curve + dr::window - 1.05 * critical * step - 1e-6);
|
|
CHECK(*fast <= curve + dr::window + 1.05 * critical * step + 1e-6);
|
|
// 5 % below it: never
|
|
CHECK_FALSE(run(0.95 * critical, step).has_value());
|
|
}
|
|
auto const fine{run(1.05 * critical, 0.01)};
|
|
auto const coarse{run(1.05 * critical, 0.5)};
|
|
REQUIRE(fine.has_value());
|
|
REQUIRE(coarse.has_value());
|
|
CHECK(std::abs(coarse.value() - fine.value()) <= 1.05 * critical * 0.5);
|
|
}
|
|
|
|
TEST_CASE("derailment: a peak shorter than the window doesn't derail") {
|
|
dr::stretch stretch;
|
|
CHECK_FALSE(stretch.update(true, 1.5));
|
|
CHECK_FALSE(stretch.update(false, 0.5));
|
|
CHECK_FALSE(stretch.update(true, 1.5));
|
|
CHECK(stretch.update(true, 0.5));
|
|
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
|
|
dr::vehicle_state wagon;
|
|
wagon.mass = 10500.0;
|
|
wagon.axles = 2;
|
|
wagon.length = 9.87;
|
|
wagon.axle_base = 6.0;
|
|
wagon.centre_of_gravity = dr::default_centre_of_gravity(3.0, dr::vehicle_class::unpowered);
|
|
dr::track_state track;
|
|
track.radius = 150.0;
|
|
auto const speed{20.0 * kmh};
|
|
|
|
auto const ratio = [&](dr::vehicle_state Vehicle, double const Compression) {
|
|
for (auto &end : Vehicle.ends) {
|
|
end.compression = Compression;
|
|
end.other_length = 15.915;
|
|
}
|
|
return dr::flange_forces(Vehicle, track, speed).ratio();
|
|
};
|
|
auto previous{ratio(wagon, 0.0)};
|
|
// the leading axle guides the wagon with the friction of its inner wheel: over 0.3 even unpushed
|
|
CHECK(previous > dr::tread_friction);
|
|
CHECK(previous < 0.4);
|
|
for (auto const compression : {100e3, 300e3, 600e3, 1000e3}) {
|
|
CAPTURE(compression);
|
|
auto const pushed{ratio(wagon, compression)};
|
|
CHECK(pushed > previous);
|
|
previous = pushed;
|
|
}
|
|
// a loaded 430W in its place is pushed out less
|
|
dr::vehicle_state loaded;
|
|
loaded.mass = 80000.0;
|
|
loaded.axles = 4;
|
|
loaded.length = 14.028;
|
|
loaded.axle_base = 2.0;
|
|
loaded.centre_of_gravity = coal_wagon_loaded;
|
|
CHECK(ratio(loaded, 600e3) < ratio(wagon, 600e3));
|
|
// pulled, the couplings draw the wagon into the curve: the flange of the inner wheel then
|
|
auto pulled{wagon};
|
|
for (auto &end : pulled.ends) {
|
|
end.compression = -600e3;
|
|
end.other_length = 15.915;
|
|
}
|
|
CHECK(dr::flange_forces(pulled, track, speed).lateral < 0.0);
|
|
// on a twisted track the wheel is lighter, so the same push comes nearer the limit
|
|
auto const twisted{[&] {
|
|
auto const flat{ratio(wagon, 600e3)};
|
|
track.uneven_cross = 30.0;
|
|
auto const result{ratio(wagon, 600e3)};
|
|
track.uneven_cross = 0.0;
|
|
return result > flat;
|
|
}()};
|
|
CHECK(twisted);
|
|
// 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 = 50.0;
|
|
dr::monitor monitor;
|
|
auto pushed{wagon};
|
|
for (auto &end : pushed.ends) {
|
|
end.compression = 300e3;
|
|
end.other_length = 15.915;
|
|
}
|
|
CHECK(monitor.update(pushed, track, speed, 1.0).result == dr::outcome::none);
|
|
auto const verdict{monitor.update(pushed, track, speed, 1.0)};
|
|
CAPTURE(verdict.flange_ratio);
|
|
CAPTURE(verdict.unloading);
|
|
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));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("derailment: the speed the flange climbs the rail at") {
|
|
dr::vehicle_state vehicle;
|
|
vehicle.mass = 80000.0;
|
|
vehicle.axles = 4;
|
|
vehicle.length = 16.0;
|
|
vehicle.axle_base = 3.0;
|
|
vehicle.centre_of_gravity = 1.65;
|
|
dr::track_state track;
|
|
track.radius = 300.0;
|
|
SUBCASE("a lone vehicle on a good track overturns first: its Y/Q stays under the limit") {
|
|
CHECK_FALSE(dr::climbing_speed(vehicle, track).has_value());
|
|
}
|
|
SUBCASE("on a twisted track it climbs, at the speed Y/Q reaches the limit") {
|
|
// 50 mm of cross level takes half the load off the wheel
|
|
track.uneven_cross = 50.0;
|
|
auto const speed{dr::climbing_speed(vehicle, track)};
|
|
REQUIRE(speed.has_value());
|
|
CHECK(*speed > 0.0);
|
|
CHECK(dr::flange_forces(vehicle, track, *speed).ratio() >= dr::climbing_limit);
|
|
CHECK(dr::flange_forces(vehicle, track, *speed - 0.01).ratio() < dr::climbing_limit);
|
|
SUBCASE("the cant moves it up") {
|
|
track.cant = std::asin(0.1 / 1.5);
|
|
auto const canted{dr::climbing_speed(vehicle, track)};
|
|
REQUIRE(canted.has_value());
|
|
CHECK(*canted > *speed);
|
|
}
|
|
}
|
|
SUBCASE("pushed hard enough it climbs at a standstill: from the speed the cant balances") {
|
|
// an empty 3WL between heavy vehicles pushing 1 MN in a curve of 150 m, on 40 mm of cross level
|
|
vehicle.mass = 10500.0;
|
|
vehicle.axles = 2;
|
|
vehicle.length = 9.0;
|
|
vehicle.axle_base = 5.0;
|
|
vehicle.centre_of_gravity = 1.1;
|
|
vehicle.ends[0] = {1000000.0, 16.0};
|
|
vehicle.ends[1] = {1000000.0, 16.0};
|
|
track.radius = 150.0;
|
|
track.uneven_cross = 40.0;
|
|
auto const speed{dr::climbing_speed(vehicle, track)};
|
|
REQUIRE(speed.has_value());
|
|
CHECK(*speed == 0.0);
|
|
}
|
|
}
|
|
|
|
TEST_CASE("derailment: the report of the log") {
|
|
dr::verdict verdict;
|
|
verdict.result = dr::outcome::overturned;
|
|
verdict.acceleration = 3.31;
|
|
verdict.unloading = 1.02;
|
|
verdict.flange_ratio = 0.55;
|
|
dr::vehicle_state vehicle;
|
|
vehicle.mass = 80000.0;
|
|
vehicle.centre_of_gravity = 1.65;
|
|
vehicle.ends[1].compression = 50000.0;
|
|
dr::track_state track;
|
|
track.radius = -300.0;
|
|
track.damage = 31;
|
|
auto const text{dr::report(verdict, vehicle, track, 113.0 / 3.6, "track_7")};
|
|
CHECK(text ==
|
|
"overturned at 113 km/h on track track_7, curve radius 300 m, cant 0 mm: lateral acceleration 3.31 m/s2, wheel unloading 1.02, Y/Q 0.55 (mass 80.0 t, centre of gravity 1.65 m,"
|
|
" couplings pushing 0 / 50 kN, track damage 31, cross level 0 mm)");
|
|
verdict.result = dr::outcome::off_rails;
|
|
CHECK(dr::report(verdict, vehicle, track, 20.0, "").starts_with("derailed, the flange climbed the rail at 72 km/h on track (none),"));
|
|
}
|
|
|
|
// physics.derailment.trustlimits: the speed limit of a track trusted, a verdict of the curve alone under it held back
|
|
|
|
namespace {
|
|
|
|
// EU07 alone, as the criteria see it
|
|
dr::vehicle_state eu07_alone() {
|
|
dr::vehicle_state vehicle;
|
|
vehicle.mass = 80000.0;
|
|
vehicle.axles = 4;
|
|
vehicle.length = 15.915;
|
|
vehicle.axle_base = 3.05;
|
|
vehicle.centre_of_gravity = eu07;
|
|
return vehicle;
|
|
}
|
|
|
|
// the empty 3WL (10.5 t, 2 axles 6 m apart, 9.87 m long) between two EU07, pushed with the force [N]
|
|
dr::vehicle_state pushed_wagon(double const Compression) {
|
|
dr::vehicle_state wagon;
|
|
wagon.mass = 10500.0;
|
|
wagon.axles = 2;
|
|
wagon.length = 9.87;
|
|
wagon.axle_base = 6.0;
|
|
wagon.centre_of_gravity = dr::default_centre_of_gravity(3.0, dr::vehicle_class::unpowered);
|
|
for (auto &end : wagon.ends) {
|
|
end.compression = Compression;
|
|
end.other_length = 15.915;
|
|
}
|
|
return wagon;
|
|
}
|
|
|
|
// the verdict of the monitor at the steady speed [km/h] once the vehicle ran 3 m on the track
|
|
dr::verdict verdict_at(dr::vehicle_state const &Vehicle, dr::track_state const &Track, double const Speed) {
|
|
dr::monitor monitor;
|
|
dr::verdict verdict;
|
|
for (int step = 0; step < 3; ++step) {
|
|
verdict = monitor.update(Vehicle, Track, Speed * kmh, 1.0);
|
|
}
|
|
return verdict;
|
|
}
|
|
|
|
// what goes of that verdict on a track with the limit [km/h]
|
|
dr::outcome limited(dr::vehicle_state const &Vehicle, dr::track_state const &Track, double const Speed, double const Limit) {
|
|
auto const verdict{verdict_at(Vehicle, Track, Speed)};
|
|
return dr::limited_verdict(verdict, dr::from_track_alone(verdict, Vehicle, Track, Speed * kmh), Speed * kmh, Limit).result;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
TEST_CASE("derailment: the trusted speed of a speed limit") {
|
|
CHECK(dr::trusted_speed(140.0) == doctest::Approx(140.0 * dr::trusted_limit_factor + dr::trusted_limit_margin));
|
|
CHECK(dr::trusted_speed(140.0) == doctest::Approx(159.0));
|
|
CHECK(dr::trusted_speed(40.0) == doctest::Approx(49.0));
|
|
// a closed track (0) is trusted to a crawl, one without a limit not at all
|
|
CHECK(dr::trusted_speed(0.0) == doctest::Approx(dr::trusted_limit_margin));
|
|
CHECK_FALSE(dr::trusted_speed(-1.0).has_value());
|
|
}
|
|
|
|
TEST_CASE("derailment: a speed limit too high for the curve is trusted up to its trusted speed") {
|
|
// a 300 m curve without cant with a limit of 140 km/h, where EU07 overturns at 108 km/h: the data is wrong
|
|
auto const vehicle{eu07_alone()};
|
|
dr::track_state track;
|
|
track.radius = 300.0;
|
|
REQUIRE(dr::overturning_speed(300.0, 0.0, eu07, 1.435) / kmh < 120.0);
|
|
|
|
SUBCASE("at 130 km/h, under the limit, it stays on the rails") {
|
|
auto const verdict{verdict_at(vehicle, track, 130.0)};
|
|
REQUIRE(verdict.result == dr::outcome::overturned);
|
|
CHECK(dr::from_track_alone(verdict, vehicle, track, 130.0 * kmh));
|
|
auto const held{dr::limited_verdict(verdict, true, 130.0 * kmh, 140.0)};
|
|
CHECK(held.result == dr::outcome::none);
|
|
// with the values of the verdict, for the log
|
|
CHECK(held.unloading == verdict.unloading);
|
|
// and so just under the trusted speed of 159 km/h
|
|
CHECK(limited(vehicle, track, 158.5, 140.0) == dr::outcome::none);
|
|
}
|
|
SUBCASE("at 160 km/h, over the trusted speed, it overturns") {
|
|
CHECK(limited(vehicle, track, 160.0, 140.0) == dr::outcome::overturned);
|
|
CHECK(limited(vehicle, track, 190.0, 140.0) == dr::outcome::overturned);
|
|
}
|
|
SUBCASE("a track without a limit isn't trusted") {
|
|
CHECK(limited(vehicle, track, 130.0, -1.0) == dr::outcome::overturned);
|
|
}
|
|
SUBCASE("over a limit the curve takes the verdict goes as it was") {
|
|
// 100 km/h: trusted up to 115 km/h
|
|
CHECK(limited(vehicle, track, 130.0, 100.0) == dr::outcome::overturned);
|
|
CHECK(verdict_at(vehicle, track, 100.0).result == dr::outcome::none);
|
|
CHECK(limited(vehicle, track, 100.0, 100.0) == dr::outcome::none);
|
|
}
|
|
SUBCASE("no verdict stays none") {
|
|
dr::verdict none;
|
|
CHECK(dr::limited_verdict(none, true, 100.0 * kmh, 140.0).result == dr::outcome::none);
|
|
CHECK_FALSE(dr::from_track_alone(none, vehicle, track, 100.0 * kmh));
|
|
}
|
|
SUBCASE("the damage flags of line 107 don't take the trust from a curve the speed alone overturns in") {
|
|
track.damage = 31;
|
|
CHECK(limited(vehicle, track, 130.0, 140.0) == dr::outcome::none);
|
|
}
|
|
SUBCASE("the log names the track as a defect of the scenery") {
|
|
auto const verdict{verdict_at(vehicle, track, 130.0)};
|
|
auto const text{dr::held_back_report(verdict, vehicle, track, 130.0 * kmh, 140.0, "curve_7")};
|
|
CHECK(text.starts_with("held on the rails on track curve_7 under its trusted speed of 159 km/h (speed limit 140 km/h, too high for the curve: a defect of the scenery): "
|
|
"overturned at 130 km/h on track curve_7, curve radius 300 m,"));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("derailment: what the couplings, a buckle or the damage of the track bring about goes under any limit") {
|
|
SUBCASE("a light wagon pushed hard in a 190 m curve at 60 km/h, with a limit of 60 km/h") {
|
|
// pushed with 1 MN the couplings throw it out of the curve, at a speed the curve alone takes
|
|
auto const wagon{pushed_wagon(1000e3)};
|
|
dr::track_state track;
|
|
track.radius = 190.0;
|
|
auto const verdict{verdict_at(wagon, track, 60.0)};
|
|
REQUIRE(verdict.result != dr::outcome::none);
|
|
CHECK_FALSE(dr::from_track_alone(verdict, wagon, track, 60.0 * kmh));
|
|
CHECK(limited(wagon, track, 60.0, 60.0) == verdict.result);
|
|
// not pushed it runs on
|
|
CHECK(verdict_at(pushed_wagon(0.0), track, 60.0).result == dr::outcome::none);
|
|
}
|
|
SUBCASE("a pushed wagon climbing a bent, twisted rail") {
|
|
// as in the case of the pushed light wagon: 300 kN in a 150 m curve at 20 km/h, the rail bent, a twist of 50 mm
|
|
auto const wagon{pushed_wagon(300e3)};
|
|
dr::track_state track;
|
|
track.radius = 150.0;
|
|
track.damage = dr::track_damage::railbend;
|
|
track.uneven_cross = 50.0;
|
|
auto const verdict{verdict_at(wagon, track, 20.0)};
|
|
REQUIRE(verdict.result == dr::outcome::off_rails);
|
|
CHECK_FALSE(dr::from_track_alone(verdict, wagon, track, 20.0 * kmh));
|
|
CHECK(limited(wagon, track, 20.0, 40.0) == dr::outcome::off_rails);
|
|
}
|
|
SUBCASE("a buckle of a straight track") {
|
|
// EU07 at 80 km/h over a buckle bending a straight track with a limit of 100 km/h by 1/150 m
|
|
auto const vehicle{eu07_alone()};
|
|
dr::track_state track;
|
|
track.buckle_curvature = 1.0 / 150.0;
|
|
auto const verdict{verdict_at(vehicle, track, 80.0)};
|
|
REQUIRE(verdict.result == dr::outcome::overturned);
|
|
CHECK_FALSE(dr::from_track_alone(verdict, vehicle, track, 80.0 * kmh));
|
|
CHECK(limited(vehicle, track, 80.0, 100.0) == dr::outcome::overturned);
|
|
}
|
|
SUBCASE("a worn track tipping over a vehicle the curve alone doesn't overturn") {
|
|
// 3 km/h under the overturning speed of EU07 on a good track the damage flags of line 107 make the sway
|
|
// overturn it: a limit over that speed doesn't hold it on the rails
|
|
auto const vehicle{eu07_alone()};
|
|
dr::track_state track;
|
|
track.radius = 300.0;
|
|
auto const speed{dr::overturning_speed(300.0, 0.0, eu07, 1.435) / kmh - 3.0};
|
|
REQUIRE(verdict_at(vehicle, track, speed).result == dr::outcome::none);
|
|
track.damage = 31;
|
|
auto const verdict{verdict_at(vehicle, track, speed)};
|
|
REQUIRE(verdict.result == dr::outcome::overturned);
|
|
CHECK_FALSE(dr::from_track_alone(verdict, vehicle, track, speed * kmh));
|
|
CHECK(limited(vehicle, track, speed, 140.0) == dr::outcome::overturned);
|
|
}
|
|
}
|