mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-24 13:09:16 +01:00
* fix(ai): an uphill start keeps the power on until the train brake is off The uphill start of #265 ended as soon as the power held the train (or the head of the train moved back 0.5 km/h). From then on the brake still on in the wagons made Ready false, the power went off, the train rolled back, was braked again and the start began anew; only the cylinders falling below 0.8 bar let the train get away. - Once the power holds the train, the start goes on while the train brake is released: Ready holds, the power stays on, bounded to 1.5 x the grade force. It ends when the consist is released (the same test as Ready, without the hold) or after 60 s. - A start is given up for rolling back on the mass-weighted speed of the consist, not on the speed of the locomotive, which runs back into the slack of the train held by its brake. - A train slipping back uphill is not released by the rule for a train to go on. * fix(ai): an uphill start begins only with the whole train at a stand * fix(ai): an uphill start applies the train brake further while it doesn't hold the train without the locomotive brake * fix(ai): the speed and the tractive force of an uphill start in the direction of travel also from cab 2 * fix(ai): an uphill start tops up the train brake a full application time a step, at most to full service, and keeps the power between 1.1 and 1.5 times the grade force while the brake releases * fix(ai): an uphill start no longer takes a notch back in the release phase: the notch below doesn't hold the train * refactor(ai): the train brake top-up of an uphill start in uphill_start::brake_top_up(), with unit tests
104 lines
4.2 KiB
C++
104 lines
4.2 KiB
C++
#include "stdafx.h"
|
|
#include "doctest.h"
|
|
|
|
#include "vehicle/uphillstart.h"
|
|
|
|
// starting uphill, the train brake is applied further, a step at a time, until the brake of the unpowered vehicles
|
|
// holds the train without the locomotive brake (eu07/maszyna#396). the numbers are those of an ST43 with 37 empty
|
|
// wagons on 12.5 per mille: 1040 t, 128.6 kN of grade force, the wagons on G with about 22 s to apply
|
|
|
|
using uphill_start::brake_top_up;
|
|
using uphill_start::top_up;
|
|
using uphill_start::top_up_action;
|
|
|
|
namespace {
|
|
|
|
double const grade{128600.0}; // [N]
|
|
double const application{22.0}; // [s]
|
|
|
|
// the train standing with the brake handle at Position, held there long enough for the cylinders to fill, while
|
|
// each step adds Gain of brake force (as a multiple of the grade force) to the Start it had. runs the top-up until it
|
|
// lets the locomotive brake off, and returns the handle position it stopped at and the number of steps
|
|
struct outcome {
|
|
double position;
|
|
int steps;
|
|
};
|
|
outcome run_top_up(double Start, double Gain, double Position = 1.25) {
|
|
top_up state;
|
|
auto force{Start * grade};
|
|
auto steps{0};
|
|
for (auto guard{0}; guard < 100; ++guard) {
|
|
auto const action{brake_top_up(state, force, grade, Position, application, application)};
|
|
if (action == top_up_action::none) {
|
|
break;
|
|
}
|
|
REQUIRE(action == top_up_action::step);
|
|
Position += 0.25;
|
|
force += Gain * grade;
|
|
++steps;
|
|
}
|
|
return {Position, steps};
|
|
}
|
|
|
|
} // namespace
|
|
|
|
TEST_CASE("uphill start: a brake that holds the train isn't applied further") {
|
|
top_up state;
|
|
CHECK(brake_top_up(state, 1.1 * grade, grade, 1.25, application, application) == top_up_action::none);
|
|
CHECK(state.last_force < 0.0);
|
|
}
|
|
|
|
TEST_CASE("uphill start: each step waits the full application time of the brake") {
|
|
top_up state;
|
|
CHECK(brake_top_up(state, 0.9 * grade, grade, 1.25, 0.5 * application, application) == top_up_action::wait);
|
|
CHECK(brake_top_up(state, 0.9 * grade, grade, 1.25, application, application) == top_up_action::step);
|
|
// the handle has just moved
|
|
CHECK(brake_top_up(state, 0.95 * grade, grade, 1.5, 0.0, application) == top_up_action::wait);
|
|
CHECK(brake_top_up(state, 0.95 * grade, grade, 1.5, application - 0.1, application) == top_up_action::wait);
|
|
}
|
|
|
|
TEST_CASE("uphill start: a light application is topped up until the brake holds the train") {
|
|
// before Nowy Zagorz on linia_107_objazdy: 0.64 bar in the wagons, 128 kN against 129 kN
|
|
auto const result{run_top_up(0.995, 0.15)};
|
|
CHECK(result.steps == 1);
|
|
CHECK(result.position == doctest::Approx(1.5));
|
|
}
|
|
|
|
TEST_CASE("uphill start: a brake that doesn't get stronger ends the top-up after one more step") {
|
|
// all the wagon brakes cut out: no step adds anything
|
|
auto const result{run_top_up(0.0, 0.0)};
|
|
CHECK(result.steps == 1);
|
|
CHECK(result.position < uphill_start::top_up_position);
|
|
}
|
|
|
|
TEST_CASE("uphill start: a brake that gets stronger by too little ends the top-up") {
|
|
// a step adds 1% of the grade force, below the 2% that counts
|
|
auto const result{run_top_up(0.3, 0.01)};
|
|
CHECK(result.steps == 1);
|
|
SUBCASE("and one that gets stronger by enough goes on") {
|
|
auto const going{run_top_up(0.3, 0.05)};
|
|
CHECK(going.steps > 1);
|
|
}
|
|
}
|
|
|
|
TEST_CASE("uphill start: the top-up goes no further than full service") {
|
|
// every step adds enough to go on, but never enough to hold the train
|
|
auto const result{run_top_up(0.0, 0.03)};
|
|
CHECK(result.position == doctest::Approx(uphill_start::top_up_position));
|
|
CHECK(result.steps == 11);
|
|
top_up state;
|
|
CHECK(brake_top_up(state, 0.0, grade, uphill_start::top_up_position, application, application) == top_up_action::none);
|
|
}
|
|
|
|
TEST_CASE("uphill start: once ended, the top-up stays ended for the start") {
|
|
top_up state;
|
|
REQUIRE(brake_top_up(state, 0.2 * grade, grade, 1.25, application, application) == top_up_action::step);
|
|
REQUIRE(brake_top_up(state, 0.2 * grade, grade, 1.5, application, application) == top_up_action::none);
|
|
CHECK(state.done);
|
|
// the brake gets stronger later all the same: the start has gone on without the top-up
|
|
CHECK(brake_top_up(state, 0.5 * grade, grade, 1.5, application, application) == top_up_action::none);
|
|
// a new start begins with a new top-up
|
|
state = {};
|
|
CHECK(brake_top_up(state, 0.5 * grade, grade, 1.5, application, application) == top_up_action::step);
|
|
}
|