#pragma once #include #include namespace fluidsim::port { // Lumped carburetor shared by two-stroke and four-stroke scenarios. The // jets use liquid-orifice flow from a float bowl into the measured venturi // depression. Delivered fuel is injected into the downstream fluid volume and // is then transported as a conserved species; this class never doses a cylinder. struct CarburetorConfig { float fuel_density{740.0f}; float pilot_jet_diameter{0.00040f}, main_jet_diameter{0.00150f}; float needle_jet_diameter{0.00190f}; // Needle annulus area corrections at configured slide positions; jets meter // liquid fuel from measured pressure, without AFR feedback. float needle_low_scale{1.f}, needle_mid_scale{1.f}; float needle_off_idle_scale{1.f}, needle_transition_scale{1.f}, needle_tip_scale{1.f}; float needle_quarter_scale{1.f}, needle_upper_scale{1.f}; float pilot_transition_scale{1.f}, pilot_tip_scale{1.f}; float pilot_discharge_coefficient{0.62f}, main_discharge_coefficient{0.72f}; float bowl_head_pressure{}; float film_fraction{0.28f}, film_time_constant{0.11f}; float bowl_capacity{0.008f}, bowl_refill_rate{0.0025f}; // kg, kg/s float overrun_rpm{4200.0f}, overrun_exit_rpm{3300.0f}; }; class Carburetor : public CarburetorConfig { public: explicit Carburetor(float throat_diameter = 0.0381f); // air_mass_flow is positive from atmosphere toward the engine. void step(float dt, float pedal, float slide, float rpm, float air_mass_flow, float air_density, float upstream_pressure, float downstream_pressure); float indicated_afr() const { return indicated_afr_; } float fuel_flow() const { return delivered_fuel_flow_; } float film_mass() const { return film_mass_; } float bowl_level() const { return bowl_mass_ / bowl_capacity; } bool overrun_active() const { return overrun_; } bool fault() const { return fault_; } float venturi_depression() const { return venturi_depression_; } private: float bowl_mass_{}, film_mass_{}; float throat_area_{}, venturi_depression_{}; float filtered_air_flow_{}, filtered_fuel_flow_{}, delivered_fuel_flow_{}; float indicated_afr_{13.5f}; float previous_pedal_{}, lift_enrichment_{}; bool initialized_{}, overrun_{}, fault_{}; }; } // namespace fluidsim::port