From 640d079ba6256121c45522e9a5fc0eef8725ff8c Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Sun, 2 Mar 2025 14:40:09 -0500 Subject: calculate mass flow rate at standard conditions --- engine.c | 13 +++++++++++++ engine.h | 1 + test.c | 1 + test.h | 1 + test_engine.c | 19 +++++++++++++++++++ unit.h | 4 ++++ 6 files changed, 39 insertions(+) diff --git a/engine.c b/engine.c index d0a1b38..3e0a792 100644 --- a/engine.c +++ b/engine.c @@ -116,3 +116,16 @@ mass_flow_rate(const Engine *e) { t = e->ambient_temperature; return (p * v) / (R_AIR * t); } + +/* Mass flow rate through the engine (corrected to standard conditions). */ +MassFlowRate +mass_flow_rate_corrected(const Engine *e) { + Pressure p; + Temperature t; + VolumeFlowRate v; + + p = STANDARD_PRESSURE; + t = STANDARD_TEMPERATURE; + v = volume_flow_rate(e); + return (p * v) / (R_AIR * t); +} diff --git a/engine.h b/engine.h index 92b8b68..8fb816a 100644 --- a/engine.h +++ b/engine.h @@ -17,3 +17,4 @@ Temperature comp_outlet_temperature(const Engine *e); Temperature manifold_temperature(const Engine *e); VolumeFlowRate volume_flow_rate(const Engine *e); MassFlowRate mass_flow_rate(const Engine *e); +MassFlowRate mass_flow_rate_corrected(const Engine *e); diff --git a/test.c b/test.c index 460c320..11348c2 100644 --- a/test.c +++ b/test.c @@ -63,4 +63,5 @@ main(void) { test_manifold_temperature(); test_volume_flow_rate(); test_mass_flow_rate(); + test_mass_flow_rate_corrected(); } diff --git a/test.h b/test.h index 9e127f6..1e34ece 100644 --- a/test.h +++ b/test.h @@ -69,3 +69,4 @@ void test_comp_outlet_temperature(void); void test_manifold_temperature(void); void test_volume_flow_rate(void); void test_mass_flow_rate(void); +void test_mass_flow_rate_corrected(void); diff --git a/test_engine.c b/test_engine.c index 4acfa17..2ac6e6e 100644 --- a/test_engine.c +++ b/test_engine.c @@ -105,3 +105,22 @@ test_mass_flow_rate(void) { }; test(mass_flow_rate(&e), kilo_per_sec(0.2214056)); } + +void +test_mass_flow_rate_corrected(void) { + Pressure p_ambient, p_boost, map; + + p_ambient = inch_mercury(30); + p_boost = psi(10); + map = p_ambient + p_boost; + Engine e = { + .displacement = cubic_inch(250), + .rpm = rpm(5000), + .map = map, + .ambient_temperature = fahrenheit(70), + .ambient_pressure = p_ambient, + .ve = percent(80), + .comp_efficiency = percent(65), + }; + test(mass_flow_rate_corrected(&e), kilo_per_sec(0.2216067)); +} diff --git a/unit.h b/unit.h index b189ff1..d25aff9 100644 --- a/unit.h +++ b/unit.h @@ -1,3 +1,7 @@ +#define STANDARD_PRESSURE millibar(1013) +#define STANDARD_TEMPERATURE celsius(20) + + typedef double AngularSpeed; typedef AngularSpeed (*AngularSpeedMaker)(double); typedef double (*AngularSpeedReader)(AngularSpeed); -- cgit v1.2.3