#pragma once #include "FluidSim/Crankcase.hpp" namespace fluidsim::port { // Two-stroke variant of the reciprocating cylinder model. The shared four- // stroke implementation supplies geometry, state balance, and combustion // parameters; cycle events and pumping torque are specialized here. class TwoStrokeCylinder final : public EngineCylinder { public: TwoStrokeCylinder(float bore, float stroke, float connecting_rod_length, float compression_ratio, float transfer_duration_degrees, float exhaust_duration_degrees); float transfer_open() const { return 180.0f - transfer_duration_ * 0.5f; } float transfer_close() const { return 180.0f + transfer_duration_ * 0.5f; } float exhaust_open() const { return 180.0f - exhaust_duration_ * 0.5f; } float exhaust_close() const { return 180.0f + exhaust_duration_ * 0.5f; } void set_crankcase(Crankcase& crankcase) { crankcase_ = &crankcase; } float valve_area(float cycle_degrees, bool inlet) const override; void pre_step(Crankshaft& crank, float dt, float throttle) override; private: float transfer_duration_{}, exhaust_duration_{}; Crankcase* crankcase_{}; static float lift(float angle, float opens, float closes, float peak_lift); void handle_cycle_events(float previous_degrees, float current_degrees); }; } // namespace fluidsim::port