Add American V8 preset, carb fuel transport, and adaptive desktop audio
This commit is contained in:
@@ -159,8 +159,10 @@ int main(int argc, char **argv) {
|
||||
capture<SaabB205Scenario>(prefix, frames, pedal, selected, config);
|
||||
else if (scenario == "two-stroke")
|
||||
capture<TwoStrokeScenario>(prefix, frames, pedal, selected, config);
|
||||
else if (scenario == "v8")
|
||||
capture<AmericanV8Scenario>(prefix, frames, pedal, selected, config);
|
||||
else
|
||||
throw std::runtime_error("choose twin, two-stroke or b205");
|
||||
throw std::runtime_error("choose twin, two-stroke, b205 or v8");
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << e.what() << '\n';
|
||||
return 1;
|
||||
|
||||
@@ -4,18 +4,26 @@
|
||||
#include "FluidSim/PulseTestScenario.hpp"
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
using namespace fluidsim::port;
|
||||
template<class S, class Control> void run(const char* name, S& s, int seconds, Control control) {
|
||||
double checksum = 0;
|
||||
std::uint64_t previous_iterations = 0;
|
||||
std::uint64_t previous_substeps = 0;
|
||||
for (int second = 0; second < seconds; ++second) {
|
||||
float peak = 0;
|
||||
const auto begin = std::chrono::steady_clock::now();
|
||||
for (int i = 0; i < 44100; ++i) {
|
||||
control(second);
|
||||
auto value = s.process();
|
||||
if constexpr (requires { value.left; }) checksum += value.left;
|
||||
if constexpr (requires { value.left; }) {
|
||||
if (!std::isfinite(value.left) || !std::isfinite(value.right))
|
||||
throw std::runtime_error("Nonfinite benchmark audio");
|
||||
checksum += value.left;
|
||||
peak = std::max({peak, std::abs(value.left), std::abs(value.right)});
|
||||
}
|
||||
else checksum += value;
|
||||
}
|
||||
const double elapsed = std::chrono::duration<double>(std::chrono::steady_clock::now()-begin).count();
|
||||
@@ -32,6 +40,19 @@ template<class S, class Control> void run(const char* name, S& s, int seconds, C
|
||||
const auto state = s.snapshot();
|
||||
std::cerr << name << " iterations_per_frame="
|
||||
<< (state.boundary_iterations-previous_iterations)/44100.0 << '\n';
|
||||
std::size_t limiting_pipe = 0;
|
||||
float stable_dt = std::numeric_limits<float>::max();
|
||||
for (std::size_t p = 0; p < s.pipes.size(); ++p) {
|
||||
const float candidate = s.pipes[p].stable_timestep();
|
||||
if (candidate < stable_dt) { stable_dt = candidate; limiting_pipe = p; }
|
||||
}
|
||||
std::cerr << name << " substeps_per_frame=" << (state.solver_substeps-previous_substeps)/44100.0
|
||||
<< " limiting_pipe=" << limiting_pipe << " cfl_us=" << stable_dt*1e6f << '\n';
|
||||
previous_substeps = state.solver_substeps;
|
||||
unsigned long long repairs = 0;
|
||||
for (const auto& pipe : s.pipes) repairs += pipe.positivity_repairs;
|
||||
std::cerr << name << " rpm=" << state.rpm << " power_kW=" << state.average_power/1000
|
||||
<< " peak=" << peak << " pipe_repairs=" << repairs << '\n';
|
||||
previous_iterations = state.boundary_iterations;
|
||||
}
|
||||
}
|
||||
@@ -41,18 +62,19 @@ int main(int argc, char** argv) {
|
||||
const std::string mode = argc > 2 ? argv[2] : "pedal";
|
||||
const std::string only = argc > 3 ? argv[3] : "all";
|
||||
auto pedal = [&](int second) {
|
||||
return mode == "idle" ? 0.0f : mode == "transient" && (second == 0 || second >= seconds-2) ? 0.0f : .7f;
|
||||
return mode == "idle" ? 0.0f : mode == "coast" ? (second >= 1 && second < 5 ? .7f : 0.f) :
|
||||
mode == "transient" && (second == 0 || second >= seconds-2) ? 0.0f : .7f;
|
||||
};
|
||||
std::cout << "scenario,second,wall_seconds,checksum\n";
|
||||
for (auto name : {"twin", "turbo", "b205", "b205-gt17"}) {
|
||||
for (auto name : {"twin", "turbo", "b205", "b205-gt17", "v8"}) {
|
||||
if (only != "all" && only != name) continue;
|
||||
auto s = std::make_unique<FourStrokeScenario>(44100,
|
||||
std::string(name).starts_with("b205") ? FourStrokePreset::SaabB205 : FourStrokePreset::Twin,
|
||||
std::string(name)=="v8" ? FourStrokePreset::AmericanV8 : std::string(name).starts_with("b205") ? FourStrokePreset::SaabB205 : FourStrokePreset::Twin,
|
||||
std::string(name)=="turbo" || std::string(name)=="b205-gt17");
|
||||
s->throttle = .7f;
|
||||
run(name, *s, seconds, [&](int second) {
|
||||
s->throttle = pedal(second);
|
||||
if (mode == "loaded") s->crankshaft.omega = (std::string(name)=="b205-gt17" ? 5500 : 7000) * 2*pi/60;
|
||||
if (mode == "loaded") s->crankshaft.omega = (std::string(name)=="v8" ? 4500 : std::string(name)=="b205-gt17" ? 5500 : 7000) * 2*pi/60;
|
||||
});
|
||||
}
|
||||
for (bool racing : {true, false}) {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#include "FluidSim/TwoStrokeScenario.hpp"
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
|
||||
using namespace fluidsim::port;
|
||||
int main() {
|
||||
std::cout << "exhaust,rpm,shaft_kW,shaft_Nm,firings_per_revolution,repairs,wall_seconds\n";
|
||||
std::cout << "exhaust,rpm,shaft_kW,shaft_Nm,firings_per_revolution,carb_afr,crankcase_afr,repairs,wall_seconds\n";
|
||||
for (auto exhaust : {TwoStrokeExhaust::Straight, TwoStrokeExhaust::Racing}) {
|
||||
for (float rpm : {6000.f, 8000.f, 10000.f, 12000.f, 14000.f, 17000.f}) {
|
||||
TwoStrokeConfig config;
|
||||
@@ -31,6 +32,9 @@ int main() {
|
||||
std::cout << (exhaust == TwoStrokeExhaust::Racing ? "racing" : "straight") << ',' << rpm
|
||||
<< ',' << power << ',' << torque << ','
|
||||
<< (s.cylinder.combustion_count()-initial_firings) / (rpm / 120)
|
||||
<< ',' << s.carburetor.indicated_afr()
|
||||
<< ',' << s.crankcase.mass() * s.crankcase.air_fraction() /
|
||||
std::max(s.crankcase.fuel_mass(), 1e-12f)
|
||||
<< ',' << repairs << ',' << wall << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user