mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-03 06:35:21 +01:00
da69df97b8
Two vehicles on the rails beside each other at a switch, up to its fouling point, now meet by their bodies (physics.collisions new, the default; physics.collisions.flank no turns it off). Before, they passed through each other there, or, on the switch itself, the vehicle on the other way was taken for the one ahead and gave a phantom end-on hit. The neighbour search follows the ways of a switch: the way of the searcher's own axle, on the next switch the way joined to the track it comes from. A vehicle on the other way is skipped unless the two are in line end to end, their facing ends less than 2.2 m apart across so that a pair of buffers meets (flank::EndsMeet()). The flank contacts: the fouling zones of all rail switches are made once (the tracks along each way up to the fouling point, 3.50 m between the axes as found by fouling::find(), and 30 m past it); only a moving vehicle with an axle in a zone is checked against the vehicles on the other way of that switch. The footprints collide as for the vehicles off the track; the side of a body crushes at 250 kN, past 0.5 m and at an end at 2 MN, never more than stops the closing within the step. The force slows both along their rails and loads their wheels across: a vehicle with its end in the contact climbs at Nadal's limit held over the 2 m window of EN 14363, a body hit along its side only at three times the limit at once. It leaves the rails with the new derailment cause flank_collision (14). Pairs in line end to end stay with the collision of the ends. Tests: tests/unit/test_flank_contact.cpp (the neighbours on a 1:9 switch, the crush forces, Skierniewice 2023, a graze at 5 km/h, steps of 0.01 to 0.05 s); scenario cases eu07_td_switch_flank_foul, _foul_buffers and _clear on td.scn. The coach of eu07_td_crew_refused stood 0.6 m into the way of track 1 and is moved clear of the fouling point.
261 lines
9.7 KiB
C++
261 lines
9.7 KiB
C++
#include "stdafx.h"
|
|
#include "doctest.h"
|
|
#include "vehicle/flankcontact.h"
|
|
#include "vehicle/derailmotion.h"
|
|
#include "physics/derailment.h"
|
|
|
|
#include <algorithm>
|
|
#include <cmath>
|
|
#include <format>
|
|
#include <optional>
|
|
|
|
// two vehicles on the rails running into each other from the side at a switch, short of its fouling point (physics.collisions
|
|
// new): vehicle/flankcontact.h
|
|
|
|
namespace dm = derail_motion;
|
|
namespace dr = derailment;
|
|
|
|
namespace {
|
|
|
|
constexpr double kmh{1.0 / 3.6};
|
|
|
|
// to the left of the way along, level
|
|
glm::dvec3 leftOf(glm::dvec3 const &Front) {
|
|
return glm::dvec3{Front.z, 0.0, -Front.x};
|
|
}
|
|
|
|
// a vehicle on a straight track: where its middle is and the way it runs, its speed and how it brakes
|
|
struct runner {
|
|
glm::dvec3 start{0.0};
|
|
glm::dvec3 way{0.0, 0.0, 1.0};
|
|
double travelled{0.0}; // [m] along the way from the start
|
|
double speed{0.0}; // [m/s]
|
|
double braking{0.0}; // [m/s2], from the first contact on
|
|
double length{20.0};
|
|
double width{2.9};
|
|
double height{4.0};
|
|
flank::Body body;
|
|
flank::Climb climb;
|
|
bool derailed{false};
|
|
|
|
glm::dvec3 position() const { return start + way * travelled; }
|
|
dm::footprint print() const {
|
|
dm::pose pose;
|
|
pose.position = position();
|
|
pose.front = way;
|
|
pose.left = leftOf(way);
|
|
pose.up = glm::dvec3{0.0, 1.0, 0.0};
|
|
return dm::footprint_of(pose, length, width, height);
|
|
}
|
|
flank::Body now() const {
|
|
auto result{body};
|
|
result.print = print();
|
|
result.guide = way;
|
|
result.speed = speed;
|
|
return result;
|
|
}
|
|
};
|
|
|
|
// the striking locomotive of Skierniewice: a unit of an ET41 (83.5 t, 12 t of it rotating), pushed on by its train of 1007 t
|
|
runner et41() {
|
|
runner result;
|
|
result.length = 15.93;
|
|
result.width = 2.9;
|
|
result.height = 4.34;
|
|
result.body.mass = 83.5e3 + 1007e3;
|
|
result.body.wheelMass = 83.5e3 - 12e3;
|
|
result.body.axles = 4;
|
|
result.body.pivots = 8.55;
|
|
return result;
|
|
}
|
|
|
|
// a motor car of an EMU (57 t, 8 t of it rotating) in its train of some 125 t
|
|
runner emu() {
|
|
runner result;
|
|
result.length = 21.85;
|
|
result.width = 2.96;
|
|
result.height = 4.0;
|
|
result.body.mass = 125e3;
|
|
result.body.wheelMass = 57e3 - 8e3;
|
|
result.body.axles = 4;
|
|
result.body.pivots = 15.0;
|
|
return result;
|
|
}
|
|
|
|
// a turnout of 1:9: the branch runs into the main track (along z, x 0) at the frog, z 0, from the left
|
|
glm::dvec3 const branch{glm::normalize(glm::dvec3{1.0, 0.0, 9.0})};
|
|
|
|
struct outcome {
|
|
bool contact{false};
|
|
bool striker{false}; // derailed
|
|
bool struck{false};
|
|
double depth{0.0}; // the most they overlapped by [m]
|
|
double where{0.0}; // [m] the striker travelled when it derailed
|
|
double ratio{0.0}; // the most Y / Q of the struck one
|
|
};
|
|
|
|
// the striker on the branch, its front Before [m] short of the frog, and the struck one on the main track passing it, both
|
|
// running towards z: stepped by Dt until 6 s, or the striker derails (from then on the motion off the track has them)
|
|
outcome run(runner Striker, runner Struck, double const Dt) {
|
|
outcome result;
|
|
auto braking{false};
|
|
for (auto time{0.0}; time < 6.0 && false == result.striker; time += Dt) {
|
|
for (auto *vehicle : {&Striker, &Struck}) {
|
|
vehicle->travelled += vehicle->speed * Dt;
|
|
if (braking) {
|
|
vehicle->speed = std::max(0.0, vehicle->speed - vehicle->braking * Dt);
|
|
}
|
|
}
|
|
auto const hit{dm::collide(Striker.print(), Struck.print())};
|
|
if (false == hit.has_value()) {
|
|
Striker.climb.Reset();
|
|
Struck.climb.Reset();
|
|
continue;
|
|
}
|
|
auto const striker{Striker.now()};
|
|
auto const struck{Struck.now()};
|
|
auto const response{flank::Respond(*hit, striker, struck, Dt)};
|
|
if (response.force > 0.0) {
|
|
result.contact = true;
|
|
braking = true;
|
|
}
|
|
result.depth = std::max(result.depth, hit->depth);
|
|
result.ratio = std::max(result.ratio, response.second.ratio);
|
|
Striker.speed += response.first.along * Dt / striker.mass;
|
|
Struck.speed += response.second.along * Dt / struck.mass;
|
|
if (Striker.climb.Update(response.first, std::abs(Striker.speed) * Dt)) {
|
|
result.striker = true;
|
|
result.where = Striker.travelled;
|
|
}
|
|
result.struck = result.struck || Struck.climb.Update(response.second, std::abs(Struck.speed) * Dt);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
// Skierniewice: the striker at 25 km/h on the branch, its front 32 m short of the frog; the struck one at 53 km/h with its
|
|
// middle 43 m behind the frog, so that the corner of the striker meets it in its front half
|
|
outcome skierniewice(double const Dt) {
|
|
auto striker{et41()};
|
|
striker.way = branch;
|
|
striker.start = -branch * (32.0 + 0.5 * striker.length);
|
|
striker.speed = 25.0 * kmh;
|
|
auto struck{emu()};
|
|
struck.start = glm::dvec3{0.0, 0.0, -43.0};
|
|
struck.speed = 53.0 * kmh;
|
|
return run(striker, struck, Dt);
|
|
}
|
|
|
|
} // namespace
|
|
|
|
TEST_CASE("flank contacts: on a switch the vehicles on its two ways beside each other aren't neighbours") {
|
|
// a turnout of 1:9 with a curve of 190 m: one vehicle on the straight way, the other on the curved one 15 m further on
|
|
auto const curved = [](double const Along) {
|
|
auto const angle{Along / 190.0};
|
|
return std::pair{glm::dvec3{190.0 * (1.0 - std::cos(angle)), 0.0, 190.0 * std::sin(angle)}, glm::dvec3{std::sin(angle), 0.0, std::cos(angle)}};
|
|
};
|
|
flank::Placed straight{glm::dvec3{0.0, 0.0, 10.0}, glm::dvec3{0.0, 0.0, 1.0}, 20.0, 2.9};
|
|
auto const [beside, besidefront]{curved(25.0)};
|
|
flank::Placed other{beside, besidefront, 20.0, 2.9};
|
|
SUBCASE("on the two ways side by side they pass each other") {
|
|
CHECK_FALSE(flank::EndsMeet(straight, other));
|
|
CHECK(flank::PassesBy(0, 1, straight, other));
|
|
CHECK(flank::PassesBy(1, 0, other, straight));
|
|
}
|
|
SUBCASE("on the same way they are in line, one ahead of the other") {
|
|
CHECK_FALSE(flank::PassesBy(0, 0, straight, other));
|
|
CHECK_FALSE(flank::PassesBy(1, 1, other, straight));
|
|
}
|
|
SUBCASE("a way not known: as before, ahead") {
|
|
CHECK_FALSE(flank::PassesBy(-1, 1, straight, other));
|
|
CHECK_FALSE(flank::PassesBy(0, -1, straight, other));
|
|
}
|
|
SUBCASE("near the points the two ways run together: a vehicle on each, end to end, still meet by their ends") {
|
|
auto const [ahead, aheadfront]{curved(31.0)};
|
|
flank::Placed next{ahead, aheadfront, 20.0, 2.9};
|
|
CHECK(flank::EndsMeet(straight, next));
|
|
CHECK_FALSE(flank::PassesBy(0, 1, straight, next));
|
|
}
|
|
SUBCASE("ends 1.8 m apart across still meet by a pair of buffers, 2.5 m apart only by their corners") {
|
|
flank::Placed const buffers{glm::dvec3{1.8, 0.0, 30.5}, glm::dvec3{0.0, 0.0, 1.0}, 20.0, 2.9};
|
|
flank::Placed const corners{glm::dvec3{2.5, 0.0, 30.5}, glm::dvec3{0.0, 0.0, -1.0}, 20.0, 2.9};
|
|
CHECK(flank::EndsMeet(straight, buffers));
|
|
CHECK(flank::EndsMeet(buffers, straight));
|
|
CHECK_FALSE(flank::EndsMeet(straight, corners));
|
|
CHECK_FALSE(flank::EndsMeet(corners, straight));
|
|
}
|
|
}
|
|
|
|
TEST_CASE("flank contacts: the side of a body gives way before its end does, and a graze pushes little") {
|
|
runner first{et41()};
|
|
first.start = glm::dvec3{0.0};
|
|
runner second{emu()};
|
|
second.start = glm::dvec3{2.0, 0.0, 5.0};
|
|
dm::contact hit;
|
|
hit.point = glm::dvec3{1.0, 0.0, 5.0};
|
|
// across the second one: its side
|
|
hit.normal = glm::dvec3{1.0, 0.0, 0.0};
|
|
hit.depth = 0.2;
|
|
CHECK(flank::CrushForce(hit, first.now(), second.now()) == doctest::Approx(flank::sideCrush));
|
|
hit.depth = 0.02;
|
|
CHECK(flank::CrushForce(hit, first.now(), second.now()) == doctest::Approx(0.2 * flank::sideCrush));
|
|
// past the side wall the floor takes more
|
|
hit.depth = 0.75;
|
|
CHECK(flank::CrushForce(hit, first.now(), second.now()) == doctest::Approx(0.5 * (flank::sideCrush + flank::endCrush)));
|
|
// along both: their ends
|
|
hit.normal = glm::dvec3{0.0, 0.0, 1.0};
|
|
hit.depth = 0.2;
|
|
CHECK(flank::CrushForce(hit, first.now(), second.now()) == doctest::Approx(flank::endCrush));
|
|
SUBCASE("two side by side on tracks too close together, neither closing in: no force") {
|
|
hit.normal = glm::dvec3{1.0, 0.0, 0.0};
|
|
auto a{first.now()};
|
|
auto b{second.now()};
|
|
a.speed = 10.0;
|
|
b.speed = 20.0;
|
|
auto const response{flank::Respond(hit, a, b, 0.01)};
|
|
CHECK(response.force == 0.0);
|
|
CHECK(response.first.ratio == 0.0);
|
|
}
|
|
}
|
|
|
|
TEST_CASE("flank contacts: the corner that strikes derails, the train struck along its side stays on the rails (Skierniewice 2023)") {
|
|
auto const result{skierniewice(0.01)};
|
|
MESSAGE(std::format("the striker derailed {:.2f} m on, the bodies overlapped by {:.2f} m, the struck one at Y/Q {:.2f} at most", result.where, result.depth, result.ratio));
|
|
CHECK(result.contact);
|
|
CHECK(result.striker);
|
|
CHECK_FALSE(result.struck);
|
|
// at Nadal's limit held over the window, not at once, and before the side wall gave way to the floor
|
|
CHECK(result.ratio < 3.0 * dr::climbing_limit);
|
|
CHECK(result.depth < flank::sideDepth);
|
|
}
|
|
|
|
TEST_CASE("flank contacts: a graze at 5 km/h, the driver braking, derails neither") {
|
|
auto striker{et41()};
|
|
striker.way = branch;
|
|
striker.start = -branch * (32.0 + 0.5 * striker.length);
|
|
striker.speed = 5.0 * kmh;
|
|
striker.braking = 1.0;
|
|
auto struck{emu()};
|
|
// standing foul with its middle at the corner of the striker as it comes
|
|
struck.start = glm::dvec3{0.0, 0.0, -29.0};
|
|
auto const result{run(striker, struck, 0.01)};
|
|
MESSAGE(std::format("overlapped by {:.2f} m, the struck one at Y/Q {:.2f} at most", result.depth, result.ratio));
|
|
CHECK(result.contact);
|
|
CHECK_FALSE(result.striker);
|
|
CHECK_FALSE(result.struck);
|
|
}
|
|
|
|
TEST_CASE("flank contacts: the same with a step of 0.01, 0.03 and 0.05 s") {
|
|
auto const reference{skierniewice(0.01)};
|
|
for (auto const dt : {0.03, 0.05}) {
|
|
CAPTURE(dt);
|
|
auto const result{skierniewice(dt)};
|
|
CHECK(result.striker == reference.striker);
|
|
CHECK(result.struck == reference.struck);
|
|
// where it derails: within two steps of the striker (the step the contact is found in, the step the window is full
|
|
// in), and the overlap by as much as it closes in over them at 1:9
|
|
auto const within{2.0 * 25.0 * kmh * dt + 0.05};
|
|
CHECK(std::abs(result.where - reference.where) < within);
|
|
CHECK(std::abs(result.depth - reference.depth) < within / 9.0 + 0.01);
|
|
}
|
|
}
|