mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-03 06:35:21 +01:00
7578f2c3a0
A free end of a rail track marked bufferstop1 / bufferstop2 <kind> in the scenery is a buffer stop (physics/bufferstop.h): rigid, buffered, hydraulic or friction. With physics.collisions new a vehicle running into it meets the stages of the stop in series: the buffers of both, the absorber or the brake elements of a sliding stop, then the frame, whose hit goes through collision::hit() and whose ride-up goes through collision::override_of(), the stop an immovable body. It is held, the frame deforms, it rides up (Enfield 2021), demolishes the stop (Kirkby 2021) or overruns a sliding one. The log tells each hit once, and the memory cells __simulation.bufferstop and <track>:bufferstop and their events tell the scenery. physics.bufferstops marked (the default) takes the marked ends only, auto also the ends with a model of a stop within 3 m, off none. Every other free end keeps the derailment off the end of the track, and so does every end with physics.collisions old; monitor logs what the stop would have done.
225 lines
12 KiB
C++
225 lines
12 KiB
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <limits>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
#include "physics/collision.h"
|
|
#include "physics/couplerphysics.h"
|
|
|
|
// buffer stops (kozioł oporowy, Prellbock) at the free ends of rail tracks (physics.bufferstops in eu07.ini), as plain
|
|
// functions of the stop and the vehicle meeting it. a track end is a stop by the attribute bufferstop1 / bufferstop2 of
|
|
// its track, or with physics.bufferstops auto by a model of a stop placed at it; any other free end keeps the legacy
|
|
// derailment off the end of the track.
|
|
//
|
|
// a stop is three stages in series, met in this order, each optional:
|
|
// - elastic: the spring buffers of the stop (a buffered stop), in series with the buffers of the vehicle;
|
|
// - dissipative: a hydraulic absorber (a steady force over its stroke, recovering when unloaded) or the brake elements
|
|
// of a sliding stop (a steady force over the run-out, staying displaced);
|
|
// - the frame: a crush curve as the ends of the vehicles have (collision.h), demolished past a depth; the hit on it goes
|
|
// through collision::hit() and the ride-up through collision::override_of(), the stop an immovable body.
|
|
// sources:
|
|
// - Ie-1 (PLK, 2025) par. 10 ust. 7: a track ending in a buffer stop shows Z 1 "Stoj" on the stop or ahead of it;
|
|
// Ir-1 par. 38 ust. 9-10: a train is let onto such a track only exceptionally, at 20 km/h at most;
|
|
// - BN-79/9310-06 "Kozly oporowe" (1979): fixed, sliding, destroyed and vehicle-destroying stops; PLK ST-T1-A8 (2021):
|
|
// the stop takes W >= k * 1/2 m v^2, v 10 or 15 km/h, k 1.2 to 2.0 (both after Kowalczyk D., "Urzadzenia
|
|
// zakonczenia torow kolejowych", Problemy Kolejnictwa 202, 2024);
|
|
// - Kowalczyk, FEM of a rail stop of BN-79 (49E1, its beam 960 mm above the rail): 50 t at 3 m/s deform it by about
|
|
// 0.18 m, some 85 % of the energy going into the deformation;
|
|
// - RAIB 13/2022, Enfield Town 2021: a unit of some 140 t at 12 km/h rode up a fixed stop, its leading wheels 800 mm
|
|
// above the rails; RAIB 07/2022, Kirkby 2021: 47 km/h demolished the stop;
|
|
// - Rawie, friction stop 10 EB, the calculation of 21.11.2024: 40 kN for each brake element over the first 5 m of the
|
|
// slide, 36 / 32 / 28 kN past 5 / 8 / 12 m (Ril 800.0113A02, safety factor 1.5);
|
|
// - Oleo, the fixed hydraulic stop: 336 kJ over a recoverable stroke of 600 mm.
|
|
namespace bufferstop {
|
|
|
|
enum class kind : std::uint8_t {
|
|
none, // no stop: the end opts out of the automatic rule
|
|
rigid, // rails bent up or concrete with a beam (BN-79), most of the Polish stops
|
|
buffered, // rigid, with the spring buffers of EN 15551 on its beam
|
|
hydraulic, // a hydraulic absorber over a recoverable stroke
|
|
friction // sliding on brake elements clamped to the rails over a run-out ("samohamowny")
|
|
};
|
|
// the name of the kind in the attribute and the log, e.g. "rigid"
|
|
std::string_view kind_name(kind Kind);
|
|
std::optional<kind> kind_of(std::string_view Name);
|
|
|
|
// what a stop is
|
|
struct definition {
|
|
kind type{kind::rigid};
|
|
double setback{0.0}; // how far its face stands before the rail end, negative past it [m]
|
|
double height{0.96}; // of its beam or buffers above the rail [m]
|
|
double buffer_energy{0.0}; // the energy its spring buffers take in over their stroke, both [J]; 0 none
|
|
double buffer_stroke{0.0}; // [m]
|
|
double absorber_force{0.0}; // hydraulic [N]
|
|
double absorber_stroke{0.0}; // [m]
|
|
int elements{0}; // friction: the brake elements
|
|
double runout{0.0}; // friction: how far it may slide [m]
|
|
double body_mass{0.0}; // friction: the body that slides with the vehicle [kg]
|
|
collision::crush_curve frame; // past the stages above
|
|
double demolish{0.6}; // the crush of the frame past which it's wrecked [m]
|
|
double stiffness{std::numeric_limits<double>::infinity()}; // of its structure in series with the steel of the vehicle [N/m]
|
|
double restitution{0.4}; // of the rebound of the vehicle off it
|
|
};
|
|
// the stop of the kind with the numbers of the sources above
|
|
definition preset(kind Kind);
|
|
// the value of the attribute bufferstop1 / bufferstop2 of a track: <kind>[;<a>[;<b>[;<setback>]]], with a and b
|
|
// buffered: the energy of its buffers [kJ]; hydraulic: the energy [kJ] and the stroke [m]; friction: the elements and
|
|
// the run-out [m]. what's left out (or empty) comes from the preset, the setback of a friction stop is its run-out. none
|
|
// for a value that isn't one: an unknown kind, a value that isn't a number, a negative one where it can't be
|
|
std::optional<definition> read_attribute(std::string_view Value);
|
|
// the spring buffers of the stop, both side by side; a travel of 0 for none
|
|
coupler_physics::spring_curve buffers_of(definition const &Stop);
|
|
// the force the brake elements of a sliding stop hold it with, having slid the distance [m]: each element 40 kN, falling
|
|
// to 36 / 32 / 28 kN past 5 / 8 / 12 m [N]
|
|
double friction_force(definition const &Stop, double Slid);
|
|
|
|
// what the stop went through, kept with the track end: until the scenery loads again
|
|
struct state {
|
|
double absorber{0.0}; // the stroke of the absorber in use now [m], it recovers unloaded
|
|
double slid{0.0}; // [m]
|
|
double crush{0.0}; // of the frame [m]
|
|
bool demolished{false};
|
|
bool overrun{false};
|
|
bool climbed{false}; // a vehicle rode up onto it
|
|
double peak_force{0.0}; // the most it took [N], for the log
|
|
// the contact under way: the energy the buffers took in pressed, and their friction
|
|
double absorbed{0.0};
|
|
coupler_physics::hysteresis elastic;
|
|
bool sliding{false}; // the body of a sliding stop moves with the vehicle
|
|
// the stop gives nothing any more: past it the end is a free one
|
|
bool spent() const { return demolished || overrun; }
|
|
};
|
|
|
|
// how a hit came out. the codes are public: the memory cell __simulation.bufferstop holds them in its value 2
|
|
enum class outcome : std::uint8_t {
|
|
none = 0,
|
|
held = 1, // it stopped the vehicle, nothing crushed worth telling
|
|
damaged = 2, // its frame deformed past collision::crush_mark
|
|
rode_up = 3, // the vehicle climbed onto it and came to rest there
|
|
demolished = 4, // wrecked: the vehicle went on past it
|
|
overrun = 5 // a sliding stop slid to the end of its run-out: the vehicle went on past it
|
|
};
|
|
// the name of the outcome in the memory cell, e.g. "rode_up"
|
|
std::string_view outcome_name(outcome Outcome);
|
|
// the worse of the two, for a hit over many steps
|
|
outcome worse(outcome First, outcome Second);
|
|
|
|
// one end of one vehicle against the stop, in one step
|
|
struct contact_input {
|
|
double closing{0.0}; // the velocity of the vehicle towards the stop [m/s]
|
|
double penetration{0.0}; // its buffer face past the original face of the stop [m]; not more than 0: apart
|
|
double mass{0.0}; // of the vehicle [kg]; the train behind it acts on it through the couplers, as in crush_hit()
|
|
collision::end_state vehicle_end; // its crush curve and the crush it has
|
|
coupler_physics::spring_curve buffers; // the buffers of the end
|
|
double vehicle_capacity{0.0}; // collision::buffer_capacity() of the end; 0 for a central coupler
|
|
double vehicle_height{1.04}; // collision::buffer_height() of the end [m]
|
|
bool anticlimber{false}; // of the end
|
|
double zone{0.0}; // the crush zone of the end (its densify) for override_of() [m]
|
|
double stiffness{1.0e8}; // of the steel of the end [N/m]
|
|
double dt{0.01}; // [s]
|
|
// the energy the crush of the frame may take at most [J]; the buffers of EN 15551 of the end take in their capacity
|
|
// of the hit first either way
|
|
double budget{std::numeric_limits<double>::infinity()};
|
|
};
|
|
struct contact_result {
|
|
bool touched{false}; // the vehicle met the stop in the step
|
|
double impulse{0.0}; // pushing the vehicle back [N s]
|
|
double velocity{0.0}; // its velocity towards the stop after the step [m/s]
|
|
double travel{0.0}; // how far it moved towards the stop over the step [m]
|
|
double force{0.0}; // peak force [N]
|
|
double duration{0.0}; // how long it pressed on the stop over the step [s]
|
|
double vehicle_crush{0.0}; // added to the end of the vehicle [m]
|
|
double work{0.0}; // taken by the crush of the frames [J]
|
|
bool climbed{false}; // the vehicle rode up onto the stop
|
|
double residual{0.0}; // the velocity it keeps after riding up or through the stop [m/s]
|
|
outcome result{outcome::none};
|
|
};
|
|
// the step of the vehicle against the stop: the stages in series, integrated over the step in short slices as
|
|
// collision::hit() is, so the result doesn't depend on the step. the state of the stop changes with it
|
|
contact_result contact(definition const &Stop, state &Stop_state, contact_input const &Input);
|
|
// the vehicle rode up onto the stop: the energy it brings, against what the frame still takes before it's wrecked and
|
|
// the lift of its end over the stop (the 800 mm of Enfield). less: it comes to rest on the stop; more: the stop is
|
|
// demolished, and the vehicle goes on with what's left
|
|
contact_result after_override(definition const &Stop, state &Stop_state, double Mass, double Closing);
|
|
// the lift of the end of a vehicle riding up a stop: the leading wheels of Enfield came to rest 800 mm above the rails [m]
|
|
inline constexpr double ride_up_lift{0.8};
|
|
|
|
// the hit on the frame of the stop past its other stages, the buffers of the pair solid: collision::hit() of the end of
|
|
// the vehicle against the frame, the stop immovable. all that the stop takes of collision.h goes through here
|
|
collision::hit_result frame_hit(definition const &Stop, state const &Stop_state, contact_input const &Input, double Velocity, double Springs, double Dt, double Budget);
|
|
// the stop of no mass to move: as crush_hit() has a wall [kg]
|
|
inline constexpr double immovable{1e12};
|
|
|
|
// ---- what the scenery is told
|
|
|
|
// a vehicle hit a stop: the memory cells __simulation.bufferstop and <track>:bufferstop, and their events
|
|
struct notice {
|
|
std::string vehicle;
|
|
std::string track;
|
|
outcome result{outcome::none};
|
|
double velocity{0.0}; // [km/h] as it hit
|
|
};
|
|
// "<vehicle> <outcome> <track>"
|
|
std::string cell_text(notice const &Notice);
|
|
// "<track>:bufferstop"
|
|
std::string cell_name(std::string_view Track);
|
|
|
|
// ---- the automatic rule: a model of a stop at a free track end (physics.bufferstops auto)
|
|
|
|
// a pattern of the file name of a model (without the folders and the extension, lower case; * matches anything), what
|
|
// kind of stop it is, and where the face of the stop lies from the origin of the model towards the track [m]. an
|
|
// excluded pattern is never a stop, whatever comes after it
|
|
struct model_rule {
|
|
std::string pattern;
|
|
kind type{kind::rigid};
|
|
double face{0.0};
|
|
bool excluded{false};
|
|
};
|
|
// the models of the stops of the bundled data
|
|
std::vector<model_rule> default_rules();
|
|
// rules of a text, one to a line: <pattern> <kind> <face>, or !<pattern> for one excluded; // starts a comment
|
|
std::vector<model_rule> read_rules(std::string_view Text);
|
|
bool wildcard(std::string_view Pattern, std::string_view Text);
|
|
// the rule the model file is a stop by, none for a model that isn't one
|
|
std::optional<model_rule> match(std::string_view ModelFile, std::vector<model_rule> const &Rules);
|
|
|
|
// a model counts for a free end within this distance of it, across and along [m]
|
|
inline constexpr double model_reach{3.0};
|
|
// the setback a model gives is kept within this [m]
|
|
inline constexpr double model_setback_limit{1.0};
|
|
// where a model stands at a free track end, on the ground (x, z)
|
|
struct placement {
|
|
double distance{0.0}; // from the end [m]
|
|
double along{0.0}; // past the end along the track, negative inside it [m]
|
|
};
|
|
placement place(double EndX, double EndZ, double OutwardX, double OutwardZ, double ModelX, double ModelZ);
|
|
// whether a model there stands at the end
|
|
bool at_end(placement const &Placement);
|
|
// the setback of the stop a model gives there
|
|
double model_setback(placement const &Placement, model_rule const &Rule);
|
|
|
|
// ---- the stop at a track end
|
|
|
|
struct installation {
|
|
definition stop;
|
|
state now;
|
|
std::string track; // the name of the track
|
|
int end{1}; // 0 at its point 1, 1 at its point 2
|
|
std::string source; // what made it a stop: the attribute or the model
|
|
};
|
|
|
|
} // namespace bufferstop
|