This commit is contained in:
2026-10-23 03:00:20 +02:00
parent 589d22aa5e
commit 7a5c77c1c8
31 changed files with 1196 additions and 44 deletions

View File

@@ -17,6 +17,7 @@ int main(int argc, char** argv) {
std::string scenario_name = "twin";
TwoStrokeConfig two_stroke_config;
bool turbo_enabled = false;
std::string turbo_name;
for (int i = 1; i + 1 < argc; ++i) {
const std::string option = argv[i];
if (option == "--seconds") duration_seconds = std::max(0.0f, std::strtof(argv[++i], nullptr));
@@ -24,8 +25,9 @@ int main(int argc, char** argv) {
else if (option == "--scenario") scenario_name = argv[++i];
else if (option == "--turbo") {
const std::string value = argv[++i];
if (value != "none" && value != "vz21") { std::cerr << "Choose none or vz21 turbo\n"; return 2; }
turbo_enabled = value == "vz21";
if (value != "none" && value != "vz21" && value != "gt17") { std::cerr << "Choose none, vz21 or gt17 turbo\n"; return 2; }
turbo_name = value;
turbo_enabled = value != "none";
}
else if (option == "--exhaust") {
const std::string value = argv[++i];
@@ -35,14 +37,19 @@ int main(int argc, char** argv) {
}
}
if (turbo_enabled && scenario_name != "twin") { std::cerr << "The turbo test preset uses --scenario twin\n"; return 2; }
if (turbo_name.empty() && scenario_name == "b205") turbo_enabled = true;
if ((!turbo_name.empty() && turbo_name != "none" &&
!((turbo_name == "gt17" && scenario_name == "b205") || (turbo_name == "vz21" && scenario_name == "twin"))) ||
(turbo_enabled && scenario_name != "twin" && scenario_name != "b205")) {
std::cerr << "Use gt17 with b205 or vz21 with twin\n"; return 2;
}
constexpr int sample_rate = 44100;
const auto total_samples = static_cast<std::uint64_t>(duration_seconds * sample_rate);
const auto report_interval = static_cast<std::uint64_t>(sample_rate / 10);
if (scenario_name == "twin" || scenario_name == "b205") {
FourStrokeScenario scenario(sample_rate, scenario_name == "b205" ? FourStrokePreset::SaabB205 : FourStrokePreset::Twin, turbo_enabled);
scenario.throttle = throttle;
std::cout << (scenario_name == "b205" ? "FluidSimCpp | Saab B205 / 9-5 wagon (no turbo) | throttle " : "FluidSimCpp | 600 cc parallel twin | throttle ") << std::fixed << std::setprecision(0)
std::cout << (scenario_name == "b205" ? "FluidSimCpp | Saab B205 / 9-5 wagon | throttle " : "FluidSimCpp | 600 cc parallel twin | throttle ") << std::fixed << std::setprecision(0)
<< throttle * 100.0f << "%\n";
for (std::uint64_t i = 0; i < total_samples; ++i) {
scenario.process();