Add machine workshop, typed logic, mechanics and sensor-driven ECUs
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
#include "FluidSim/Constants.hpp"
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
#include <random>
|
||||
#include <vector>
|
||||
|
||||
@@ -25,6 +27,8 @@ public:
|
||||
float average_power{}, average_torque{};
|
||||
|
||||
void add_torque(float torque);
|
||||
float take_torque(); // Consume gas torque when an external shaft integrator owns motion.
|
||||
void record_output(float torque,float power);
|
||||
void step(float dt);
|
||||
private:
|
||||
float external_torque_{};
|
||||
@@ -51,6 +55,7 @@ public:
|
||||
float rev_limit_rpm{7500.0f}, rev_limit_cut_time{0.05f}, rev_limit_hysteresis{200.0f};
|
||||
float air_mass{}, exhaust_mass{}, energy{}, volume{}, pressure{101325.0f};
|
||||
float fuel_mass{}, burn_fraction{};
|
||||
float fuel_equivalent_mass{}; // passive fuel-origin tracer, unaffected by combustion
|
||||
bool combustion_active{}, fuel_injected{}, rev_limit_active{};
|
||||
Port intake{}, exhaust{};
|
||||
|
||||
@@ -84,6 +89,14 @@ protected:
|
||||
|
||||
class FourStrokeCylinder final : public EngineCylinder {
|
||||
public:
|
||||
struct IgnitionCommand {bool fire{},cut{true};};
|
||||
// Present selects external timing exclusively. A fire pulse is consumed
|
||||
// once; missing subsequent commands cannot recreate internal timed sparks.
|
||||
// Requires physically transported fuel, including carburetor operation.
|
||||
std::optional<IgnitionCommand> ignition_command;
|
||||
// Once per cycle, before ignition consumes fuel. Independent of spark cut.
|
||||
float charge_afr{std::numeric_limits<float>::quiet_NaN()};
|
||||
bool charge_sampled{};
|
||||
struct CamPoint { float angle_degrees{}, lift_metres{}; };
|
||||
struct ValveDynamics {
|
||||
float mass_kg{0.035f};
|
||||
@@ -106,6 +119,8 @@ public:
|
||||
static float cam_lift_at(const CamProfile& profile,float degrees) { return sample_cam(profile,degrees).lift_metres; }
|
||||
|
||||
private:
|
||||
float external_burn_angle_{};
|
||||
bool external_charge_ready_{};
|
||||
struct ValveState { float lift{},velocity{};bool floating{}; };
|
||||
const CamProfile* intake_cam_{};
|
||||
const CamProfile* exhaust_cam_{};
|
||||
|
||||
Reference in New Issue
Block a user