Add turbocharged twin scenario and cross-platform test harness
This commit is contained in:
@@ -3,9 +3,14 @@
|
||||
#include "FluidSim/AudioProcessing.hpp"
|
||||
#include "FluidSim/Crankcase.hpp"
|
||||
#include "FluidSim/Fluid.hpp"
|
||||
#include "FluidSim/OutdoorExhaustReverb.hpp"
|
||||
#include "FluidSim/OutdoorAudio.hpp"
|
||||
#include "FluidSim/Atmosphere.hpp"
|
||||
#include "FluidSim/Ecu.hpp"
|
||||
#include "FluidSim/ReedValve.hpp"
|
||||
#include "FluidSim/MotorcycleTest.hpp"
|
||||
#include "FluidSim/Solver.hpp"
|
||||
#include "FluidSim/TwoStrokeCylinder.hpp"
|
||||
#include "FluidSim/TwoStrokeConfig.hpp"
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
@@ -14,19 +19,34 @@ namespace fluidsim::port {
|
||||
struct TwoStrokeSnapshot {
|
||||
float rpm{}, cylinder_pressure{}, crankcase_pressure{}, intake_pressure{};
|
||||
float throttle{}, transfer_area{}, exhaust_area{};
|
||||
bool reed_open{};
|
||||
bool reed_open{}, fuel_cut{};
|
||||
float pedal{};
|
||||
OutdoorScene audio_scene{OutdoorScene::Wall};
|
||||
};
|
||||
|
||||
// Port of the C# 125 cc crankcase-scavenged two-stroke scenario. It retains
|
||||
// the plenum / reed / crankcase / transfer / cylinder / exhaust topology.
|
||||
class TwoStrokeScenario {
|
||||
class TwoStrokeScenario : public MotorcycleTest {
|
||||
public:
|
||||
explicit TwoStrokeScenario(int sample_rate = 44100);
|
||||
explicit TwoStrokeScenario(int sample_rate = 44100, TwoStrokeConfig config = {});
|
||||
AudioFrame process();
|
||||
void set_throttle(float value);
|
||||
void set_controls(float pedal, float load_value, float clutch_value);
|
||||
void shift_up() { vehicle.shift_up(); }
|
||||
void shift_down() { vehicle.shift_down(); }
|
||||
void set_neutral() { vehicle.set_neutral(); }
|
||||
void set_audio_scene(OutdoorScene scene) { audio_.set_scene(scene); }
|
||||
void set_monitor_filter(bool enabled) { audio_.set_monitor_filter(enabled); }
|
||||
AudioFrame dry_audio() const { return audio_.dry_frame(); }
|
||||
AudioFrame unfiltered_audio() const { return audio_.unfiltered_frame(); }
|
||||
TwoStrokeSnapshot snapshot() const;
|
||||
|
||||
float throttle{};
|
||||
const TwoStrokeConfig configuration;
|
||||
Ecu ecu{};
|
||||
ReedValve reed{};
|
||||
Atmosphere intake_atmosphere{};
|
||||
float intake_flow{}, exhaust_flow{};
|
||||
Crankshaft crankshaft{};
|
||||
TwoStrokeCylinder cylinder;
|
||||
Crankcase crankcase;
|
||||
@@ -34,7 +54,7 @@ public:
|
||||
std::vector<Pipe1D> pipes;
|
||||
|
||||
private:
|
||||
float dt_{}, max_throttle_area_{};
|
||||
float dt_{}, max_throttle_area_{}, intake_boundary_area_{};
|
||||
float reed_in_area_{}, reed_out_area_{}, transfer_pipe_area_{}, transfer_valve_area_{}, exhaust_valve_area_{};
|
||||
bool reed_open_{};
|
||||
std::uint64_t step_count_{};
|
||||
@@ -42,12 +62,10 @@ private:
|
||||
Port* plenum_outlet_{};
|
||||
BoundarySystem boundaries_;
|
||||
Solver solver_;
|
||||
SoundProcessor intake_sound_;
|
||||
SoundProcessor exhaust_sound_;
|
||||
OutdoorExhaustReverb reverb_;
|
||||
OutdoorAudio audio_;
|
||||
|
||||
static float area_for_diameter(float diameter);
|
||||
static std::vector<Pipe1D> create_pipes();
|
||||
static std::vector<Pipe1D> create_pipes(const TwoStrokeConfig& config);
|
||||
};
|
||||
|
||||
} // namespace fluidsim::port
|
||||
|
||||
Reference in New Issue
Block a user