all of the changes
This commit is contained in:
27
src/main.cpp
27
src/main.cpp
@@ -16,18 +16,15 @@ int main(int argc, char** argv) {
|
||||
float throttle = 0.35f;
|
||||
std::string scenario_name = "twin";
|
||||
TwoStrokeConfig two_stroke_config;
|
||||
bool turbo_enabled = false;
|
||||
std::string turbo_name;
|
||||
PipeSolver pipe_solver=PipeSolver::Rusanov;
|
||||
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));
|
||||
else if (option == "--throttle") throttle = std::clamp(std::strtof(argv[++i], nullptr), 0.0f, 1.0f);
|
||||
else if (option == "--scenario") scenario_name = argv[++i];
|
||||
else if (option == "--turbo") {
|
||||
const std::string value = argv[++i];
|
||||
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 == "--solver") {
|
||||
try { pipe_solver=parse_pipe_solver(argv[++i]); }
|
||||
catch(const std::exception& e) { std::cerr<<e.what()<<"\n"; return 2; }
|
||||
}
|
||||
else if (option == "--exhaust") {
|
||||
const std::string value = argv[++i];
|
||||
@@ -37,17 +34,12 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
}
|
||||
|
||||
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" || scenario_name == "v8") {
|
||||
FourStrokeScenario scenario(sample_rate, scenario_name == "v8" ? FourStrokePreset::AmericanV8 : scenario_name == "b205" ? FourStrokePreset::SaabB205 : FourStrokePreset::Twin, turbo_enabled);
|
||||
FourStrokeScenario scenario(sample_rate, scenario_name == "v8" ? FourStrokePreset::AmericanV8 : scenario_name == "b205" ? FourStrokePreset::SaabB205 : FourStrokePreset::Twin);
|
||||
scenario.set_pipe_solver(pipe_solver);
|
||||
scenario.throttle = throttle;
|
||||
std::cout << (scenario_name == "v8" ? "FluidSimCpp | American 5.0 V8 | throttle " : 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";
|
||||
@@ -63,17 +55,12 @@ int main(int argc, char** argv) {
|
||||
<< scenario.cylinder2.pressure / 1000.0f << " kPa"
|
||||
<< " intake=" << scenario.intake_plenum.pressure() / 1000.0f << " kPa"
|
||||
<< " exhaust=" << scenario.exhaust_collector.pressure() / 1000.0f << " kPa";
|
||||
if (scenario.turbo) {
|
||||
const auto turbo = scenario.turbo->snapshot();
|
||||
std::cout << " turbo_rpm=" << turbo.rpm << " CPR=" << turbo.compressor_pressure_ratio
|
||||
<< " turbine_in=" << turbo.turbine_inlet_pressure/1000 << " kPa"
|
||||
<< " charge_T=" << turbo.charge_temperature << " K";
|
||||
}
|
||||
std::cout << '\n';
|
||||
}
|
||||
}
|
||||
} else if (scenario_name == "two-stroke") {
|
||||
TwoStrokeScenario scenario(sample_rate, two_stroke_config);
|
||||
scenario.set_pipe_solver(pipe_solver);
|
||||
scenario.set_throttle(throttle);
|
||||
std::cout << "FluidSimCpp | 125 cc crankcase-scavenged two-stroke | throttle "
|
||||
<< std::fixed << std::setprecision(0) << throttle * 100.0f << "%\n";
|
||||
|
||||
Reference in New Issue
Block a user