Improve physical geometry, fluid solvers, audio, and profiling
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <random>
|
||||
#include <vector>
|
||||
|
||||
namespace fluidsim::port {
|
||||
|
||||
@@ -33,11 +34,9 @@ private:
|
||||
};
|
||||
|
||||
struct CylinderConfig {
|
||||
float intake_open{340}, intake_close{590}, exhaust_open{130}, exhaust_close{390};
|
||||
float bore{0.075f}, stroke{0.068f}, rod{0.112f}, compression{11.5f};
|
||||
float intake_valve_diameter{0.030f}, exhaust_valve_diameter{0.028f};
|
||||
int intake_valve_count{1}, exhaust_valve_count{1};
|
||||
float intake_valve_lift{0.005f}, exhaust_valve_lift{0.005f};
|
||||
float spark_advance{20.0f}, wiebe_a{5.0f}, wiebe_m{2.0f}, burn_duration{60.0f}, burn_start{5.0f};
|
||||
float afr{14.7f}, fuel_lhv{44.0e6f}, energy_variation{0.05f}, misfire_probability{};
|
||||
float wall_area{0.02f}, heat_transfer{100.0f}, ambient_temperature{300.0f};
|
||||
@@ -79,14 +78,44 @@ protected:
|
||||
static bool crossed_angle(float previous, float current, float event) {
|
||||
return current >= previous ? previous < event && current >= event : event > previous || event <= current;
|
||||
}
|
||||
static bool crossed_window_close(float previous, float current, float open, float close);
|
||||
void update_rev_limiter(float rpm, float dt);
|
||||
void sync_ports();
|
||||
};
|
||||
|
||||
class FourStrokeCylinder final : public EngineCylinder {
|
||||
public:
|
||||
struct CamPoint { float angle_degrees{}, lift_metres{}; };
|
||||
struct ValveDynamics {
|
||||
float mass_kg{0.035f};
|
||||
float spring_rate_n_per_m{30000.f};
|
||||
float damping_n_s_per_m{24.f};
|
||||
float seat_force_n{100.f};
|
||||
float maximum_lift_m{0.015f};
|
||||
float seat_restitution{0.005f}, cam_restitution{0.01f}, stop_restitution{0.01f};
|
||||
};
|
||||
struct CamProfile { std::vector<CamPoint> points; };
|
||||
|
||||
void set_valve_profiles(const CamProfile& intake_cam, const ValveDynamics& intake_valve,
|
||||
const CamProfile& exhaust_cam, const ValveDynamics& exhaust_valve);
|
||||
float valve_area(float cycle_degrees, bool inlet) const override;
|
||||
void pre_step(Crankshaft& crank, float dt, float throttle) override;
|
||||
float take_contact_impulse() { const float value=contact_impulse_;contact_impulse_=0;return value; }
|
||||
bool valve_floating() const { return intake_floating_ || exhaust_floating_; }
|
||||
float intake_lift() const { return intake_lift_; }
|
||||
float exhaust_lift() const { return exhaust_lift_; }
|
||||
static float cam_lift_at(const CamProfile& profile,float degrees) { return sample_cam(profile,degrees).lift_metres; }
|
||||
|
||||
private:
|
||||
struct ValveState { float lift{},velocity{};bool floating{}; };
|
||||
const CamProfile* intake_cam_{};
|
||||
const CamProfile* exhaust_cam_{};
|
||||
ValveDynamics intake_dynamics_{},exhaust_dynamics_{};
|
||||
ValveState intake_state_{},exhaust_state_{};
|
||||
float intake_lift_{},exhaust_lift_{},contact_impulse_{};
|
||||
bool intake_floating_{},exhaust_floating_{};
|
||||
|
||||
static CamPoint sample_cam(const CamProfile& profile,float degrees);
|
||||
float advance_valve(ValveState& state,const CamProfile& cam,const ValveDynamics& dynamics,
|
||||
bool inlet,const Crankshaft& crank,float dt);
|
||||
};
|
||||
} // namespace fluidsim::port
|
||||
|
||||
Reference in New Issue
Block a user