aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2025-02-28 18:25:43 -0500
committerSam Anthony <sam@samanthony.xyz>2025-02-28 18:25:43 -0500
commitac9ed5d8a5af3cad2f8c70f0bc217ccf97198e5c (patch)
tree28fe5d726438522e5af3026c472dedbd7296b7ce
parentbc1d5a436f81561072d7f4f0f0ecb1fa85718c7f (diff)
downloadvolute-ac9ed5d8a5af3cad2f8c70f0bc217ccf97198e5c.zip
engine volume flow rate
-rw-r--r--engine.c13
-rw-r--r--engine.h1
2 files changed, 14 insertions, 0 deletions
diff --git a/engine.c b/engine.c
index a7fbf11..1817180 100644
--- a/engine.c
+++ b/engine.c
@@ -3,7 +3,20 @@
#include "unit.h"
#include "engine.h"
+
+/* A four-stroke piston engine takes two revolutions per cycle. */
+#define REV_PER_CYCLE 2.0
+
+
void
init_engine(Engine *e) {
memset(e, 0, sizeof(*e));
}
+
+VolumeFlowRate
+volume_flow_rate(const Engine *e) {
+ double n = as_rpm(e->rpm);
+ double d = as_cubic_metre(e->displacement);
+ double ve = e->ve;
+ return cubic_metre_per_min(n * d * ve / REV_PER_CYCLE);
+}
diff --git a/engine.h b/engine.h
index 3ec3dcf..eaa7dc6 100644
--- a/engine.h
+++ b/engine.h
@@ -6,3 +6,4 @@ typedef struct {
} Engine;
void init_engine(Engine *e);
+VolumeFlowRate volume_flow_rate(const Engine *e);