mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 09:36:48 +01:00
db5a171ccd
Stage E1 of editor-tracks-domain.md (§3, §6): the norms stand on their own in editor/norms, with no scene, no tracks and no user interface, so they are tested whole in tests/unit. Nothing of the editor uses them yet but the report of the next commit; alignment::limits stays as the laying tools use it. - The profiles are tables of rows (normsTables.cpp). A row holds the limits of PREFER / WARN / BLOCK of one parameter where its conditions hold (a band of the speed, of the radius or of the load, main or side track, the traffic, a switch and its frog, a crossing, an expansion device, a platform, a station track, ballastless track, crest or sag), with the table or the paragraph of its document. Where several rows hold the strictest limit of each tier counts. A cell can be unconfirmed: it warns, never blocks. - PLK, ST-T1-A6 v1.0: P0 PREFER, P1 WARN, P2 BLOCK; tab. 8.1, 9.1, 9.2, 9.6 - 9.8, 9.10, 9.12 - 9.16, 10.1, 10.2, formula 9.8. - TSI only, Reg. 1299/2014 consolidated 28.9.2023: BLOCK; 4.2.3.3 - 4.2.3.5, 4.2.4.2 - 4.2.4.4. - EN 13803-1:2010 5.2.1 - 5.2.5: normal WARN, exceptional BLOCK. - CH, AB-EBV AB 17 (Normalspur, 1.7.2024): Grenzwert im Normalfall WARN, maximaler Grenzwert BLOCK. - In every profile the global hard limits of §6.3: the TSI rows and the cant gradient of 2.5 mm/m (EN 13803-1 5.2.5, the twist). - The line class: Vmax, Vmin of the slow trains (by tab. 8.1 when not given), passenger / mixed / freight, main or side track, the load, and what holds along the line (platform, station, ballastless, suburban, tilting). - One engine (normsEngine.cpp) over a line of elements (straights, transitions, arcs, the curvature changing evenly along each), its cant (points, a step being two at one chainage) and its grade line: I at Vmax and E at Vmin; dI/dt along the transitions and the ramps; ΔI at every jump of the curvature or of the cant, the jumps closer than the intermediate length of the profile (tab. 9.16) taken together while the deficiency keeps changing one way (9.11 pkt 8 - 13); dD/ds and dD/dt along the ramps, a step of the cant as its twist on the 5 m base; the lengths of the straights, arcs and transitions and the shift of the arc; R; D with (R - 50) / 1.5 and the least cant; Rv and the breaks of the grade over 2 per mille; the held grades. A finding names the parameter, the value, the limit, the tier, the profile, the source, confirmed or not, hard or not, and the chainage. The module makes no text, its users write the messages. - Areas (§6.4): the default profile of the scenery, areas outlined in the plan, lines by name (a line's own wins). An element with its ends under two profiles is checked against both, the worse kept (the stricter one); an arc across a boundary is a warning. - describe() reads a line from samples along it (the curvature, the cant and the grade simplified by Douglas and Peucker), with a precision of 0.2 % for the values measured on it. - The formulas of ST-T1-A6 9.1 - 9.10: Deq, Dreg, I, E, Dmin, Dmax, Rmin, V. The sources, and what they gave: - The cells of ST-T1-A6 spanning two or three columns (tab. 9.1, 9.6, 9.7, 9.13 - 9.15, 10.1, 10.2; §6.5 pkt 4) were read on the pages of the PDF. Tab. 9.15 has for the connections of tracks P0 = P1 = 80 mm at 100 < V <= 160 and 60 mm at 160 < V <= 200, P2 160 - 0.35 V; the table of §6.2 has P1 = 160 - 0.35 V there. Tab. 9.1 has P1 = P0 (one cell), not "-". - TSI tab. 8 (§6.5 pkt 3): the 153 mm spans both columns up to 300 km/h, 100 mm only above 300 km/h. - Unconfirmed, warning only: tab. 9.8, 5 < q <= 10, P0 95 mm, and tab. 9.7, movable frog 230 < V <= 250, P2 110 mm (as printed, out of line with the rows around them); EN 13803-2:2006+A1:2009 7.1.3, ΔI of the plain line 50 / 40 / 30 mm, read from a garbled preview. - Not there: ST-T1-A6 tab. 9.4 (a picture); EN 13803-1 dD/dt, dI/dt, ΔI in S&C, element lengths, Rv and grades (beyond the part of the standard published as its preview); AB-EBV a limit of the grade of a line, the least cant, the table of the buffer locking of 5.4.2; the TSI has no dD/ds, dD/dt nor dI/dt. DB (Ril 800.0110) is left out: it isn't published, its values are known from secondary sources only. - Simplified: the (R - 50) / 1.5 of the TSI holds for every R < 305 m of mixed and freight traffic, leaving out its condition of a ramp steeper than 1 mm/m; the intermediate element of tab. 9.16 between transitions is the one of tab. 9.1 at P2 (tab. 9.10 at P2 would do there); a switch has a fixed frog unless the track says it moves; the track is ballasted unless the class says not. Tests: test_norms_tables.cpp, every value of the PLK tables and of the TSI with its table in the name of the test, the edges of the bands (a speed on the boundary, R 300, 250 and 200 m), some of EN and AB-EBV; test_norms_engine.cpp, the examples of ST-T1-A6 (Z1-1, Z1-2, załącznik 2, the ramps of Z3-2 and Z3-3), I at Vmax and E at Vmin, ΔI of arcs turning alike and the other way, taken together over a short straight or not, dD/ds, dD/dt, a step of the cant, dI/dt, the lengths, the vertical curves, the areas and the boundary, describe().
227 lines
6.6 KiB
C++
227 lines
6.6 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/.
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
#include "editor/norms/norms.hpp"
|
|
#include "editor/norms/normsTables.hpp"
|
|
|
|
#include <algorithm>
|
|
#include <array>
|
|
#include <cmath>
|
|
|
|
// the limits of the profiles from their tables, the tier of a value against them, the formulas of the cant
|
|
namespace norms
|
|
{
|
|
|
|
namespace
|
|
{
|
|
|
|
double constexpr kC{11.8}; // mm m h^2 / km^2: the cant balancing a curve, 11.8 V^2 / R (ST-T1-A6 9.7, EN 13803-1 5.2.1)
|
|
|
|
// the strictest of the limits of one tier where several rows hold: the lowest of the greatest values, the highest of the least
|
|
// ones; at the same value a confirmed one
|
|
void stricter(std::optional<bound> &Kept, bound const &Candidate, bool const Minimum)
|
|
{
|
|
if (false == Kept.has_value())
|
|
{
|
|
Kept = Candidate;
|
|
return;
|
|
}
|
|
auto const better{Minimum ? Candidate.value > Kept->value : Candidate.value < Kept->value};
|
|
if (better || (Candidate.value == Kept->value && Candidate.confirmed && false == Kept->confirmed))
|
|
Kept = Candidate;
|
|
}
|
|
|
|
thresholds gathered(std::span<tables::row const> const Rows, std::string_view const Document, parameter const What, query const &Where)
|
|
{
|
|
thresholds result;
|
|
auto const least{minimum(What)};
|
|
for (auto const &row : Rows)
|
|
{
|
|
if (row.what != What || false == tables::applies(row, Where))
|
|
continue;
|
|
source const from{row.document.empty() ? Document : row.document, row.place};
|
|
auto const take = [&Where, &from, least](tables::cell const &Cell, std::optional<bound> &Kept) {
|
|
if (Cell.present)
|
|
stricter(Kept, {tables::value(Cell.limit, Where.speed, Where.radius), from, Cell.confirmed}, least);
|
|
};
|
|
take(row.prefer, result.prefer);
|
|
take(row.warn, result.warn);
|
|
take(row.block, result.block);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
bool beyond(parameter const What, double const Value, bound const &Bound, double const Precision)
|
|
{
|
|
auto const margin{std::max(1e-9 * std::max(1.0, std::abs(Bound.value)), Precision * std::abs(Bound.value))};
|
|
return minimum(What) ? Value < Bound.value - margin : Value > Bound.value + margin;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
bool minimum(parameter const What)
|
|
{
|
|
switch (What)
|
|
{
|
|
case parameter::element_length:
|
|
case parameter::transition_length:
|
|
case parameter::transition_shift:
|
|
case parameter::radius:
|
|
case parameter::cant_min:
|
|
case parameter::vertical_radius:
|
|
case parameter::intermediate_length: return true;
|
|
default: return false;
|
|
}
|
|
}
|
|
|
|
profile const &profile_of(profile_id const Id)
|
|
{
|
|
static std::array<profile, static_cast<std::size_t>(profile_id::count)> const profiles{{
|
|
{profile_id::plk, "PLK ST-T1-A6", "PLK", "ST-T1-A6"},
|
|
{profile_id::tsi, "TSI INF", "TSI INF", "TSI INF"},
|
|
{profile_id::en13803, "EN 13803", "EN 13803", "EN 13803-1"},
|
|
{profile_id::ch, "CH AB-EBV", "AB-EBV", "AB-EBV"},
|
|
}};
|
|
return profiles[std::min(static_cast<std::size_t>(Id), profiles.size() - 1)];
|
|
}
|
|
|
|
double slow_speed(traffic const Kind, double const Vmax)
|
|
{
|
|
struct line_type
|
|
{
|
|
traffic kind;
|
|
double vmax;
|
|
double vmin;
|
|
};
|
|
// ST-T1-A6 tab. 8.1: P250 P200 M200 P160 M160 P120 M120 T120 P80 M80 T80 T40
|
|
static std::array<line_type, 12> constexpr types{{
|
|
{traffic::passenger, 80, 60},
|
|
{traffic::passenger, 120, 80},
|
|
{traffic::passenger, 160, 120},
|
|
{traffic::passenger, 200, 120},
|
|
{traffic::passenger, 250, 120},
|
|
{traffic::mixed, 80, 40},
|
|
{traffic::mixed, 120, 60},
|
|
{traffic::mixed, 160, 80},
|
|
{traffic::mixed, 200, 80},
|
|
{traffic::freight, 40, 40},
|
|
{traffic::freight, 80, 40},
|
|
{traffic::freight, 120, 60},
|
|
}};
|
|
double result{-1.0};
|
|
double fastest{-1.0};
|
|
for (auto const &type : types)
|
|
{
|
|
if (type.kind != Kind)
|
|
continue;
|
|
if (type.vmax >= Vmax - 1e-9)
|
|
{
|
|
result = type.vmin;
|
|
break;
|
|
}
|
|
fastest = type.vmin;
|
|
}
|
|
if (result < 0.0)
|
|
result = fastest;
|
|
return std::min(result, Vmax);
|
|
}
|
|
|
|
thresholds limits(profile_id const Profile, parameter const What, query const &Where)
|
|
{
|
|
return gathered(tables::rows(Profile), profile_of(Profile).document, What, Where);
|
|
}
|
|
|
|
thresholds hard_limits(parameter const What, query const &Where)
|
|
{
|
|
return gathered(tables::hard_rows(), profile_of(profile_id::tsi).document, What, Where);
|
|
}
|
|
|
|
assessment assess(parameter const What, double const Value, thresholds const &Profile, thresholds const &Hard, double const Precision)
|
|
{
|
|
assessment result;
|
|
auto const passed = [What, Value, Precision](std::optional<bound> const &Bound) { return Bound.has_value() && beyond(What, Value, *Bound, Precision); };
|
|
// the extended limit of the profile when confirmed, the hard one in any case
|
|
auto const profile_block{passed(Profile.block) && Profile.block->confirmed};
|
|
auto const hard_block{passed(Hard.block)};
|
|
if (profile_block || hard_block)
|
|
{
|
|
result.level = tier::block;
|
|
result.passed = profile_block ? *Profile.block : *Hard.block;
|
|
result.hard = hard_block && false == profile_block;
|
|
return result;
|
|
}
|
|
// an extended limit not confirmed only warns
|
|
if (passed(Profile.block))
|
|
{
|
|
result.level = tier::warn;
|
|
result.passed = *Profile.block;
|
|
return result;
|
|
}
|
|
if (passed(Profile.warn))
|
|
{
|
|
result.level = tier::warn;
|
|
result.passed = *Profile.warn;
|
|
return result;
|
|
}
|
|
if (passed(Profile.prefer))
|
|
{
|
|
result.level = tier::prefer;
|
|
result.passed = *Profile.prefer;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
double equilibrium_cant(double const Speed, double const Radius)
|
|
{
|
|
return Radius > 0.0 ? kC * Speed * Speed / Radius : 0.0;
|
|
}
|
|
|
|
double regular_cant(double const Speed, double const Radius)
|
|
{
|
|
return Radius > 0.0 ? 6.5 * Speed * Speed / Radius : 0.0;
|
|
}
|
|
|
|
double cant_deficiency(double const Speed, double const Radius, double const Cant)
|
|
{
|
|
return equilibrium_cant(Speed, Radius) - Cant;
|
|
}
|
|
|
|
double cant_excess(double const Speed, double const Radius, double const Cant)
|
|
{
|
|
return Cant - equilibrium_cant(Speed, Radius);
|
|
}
|
|
|
|
double least_cant(double const Speed, double const Radius, double const Deficiency)
|
|
{
|
|
return equilibrium_cant(Speed, Radius) - Deficiency;
|
|
}
|
|
|
|
double greatest_cant(double const Speed, double const Radius, double const Excess)
|
|
{
|
|
return equilibrium_cant(Speed, Radius) + Excess;
|
|
}
|
|
|
|
double least_radius(double const Speed, double const Cant, double const Deficiency)
|
|
{
|
|
return Cant + Deficiency > 0.0 ? kC * Speed * Speed / (Cant + Deficiency) : 0.0;
|
|
}
|
|
|
|
double greatest_speed(double const Radius, double const Cant, double const Deficiency)
|
|
{
|
|
return std::sqrt(std::max(0.0, (Cant + Deficiency) * Radius / kC));
|
|
}
|
|
|
|
double speed_for_deficiencies(double const Radius, double const Fast, double const Slow, double const Vmin)
|
|
{
|
|
return std::sqrt(std::max(0.0, (Fast - Slow) * Radius / kC + Vmin * Vmin));
|
|
}
|
|
|
|
} // namespace norms
|