aboutsummaryrefslogtreecommitdiffstats
path: root/test_engine.c
blob: 2ac6e6e5a3ad07a667a77fc08f6d15e126106cdf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include <assert.h>
#include <stdio.h>

#include "test.h"
#include "unit.h"
#include "engine.h"

void
test_comp_outlet_pressure(void) {
	Engine e;
	init_engine(&e);
	e.map = millibar(2000);
	e.intercooler_deltap = psi(0.4);
	test(comp_outlet_pressure(&e), millibar(2027.579029173));
}

void
test_pressure_ratio(void) {
	Engine e = {
		.ambient_pressure = psi(14.3),
		.map = psi(14.3+18),
	};
	test(pressure_ratio(&e), 2.2587413);

}
void
test_pressure_ratio_intercooled(void) {
	Engine e = {
		.ambient_pressure = psi(14.3),
		.map = psi(14.3+18),
		.intercooler_deltap = psi(0.4),
	};
	test(pressure_ratio(&e), 2.2867133);
}

void
test_comp_outlet_temperature_adiabatic(void) {
	Engine e = {
		.ambient_temperature = fahrenheit(70),
		.ambient_pressure = psi(14.7),
		.map = psi(31.7),
		.comp_efficiency = percent(100),
	};
	test(comp_outlet_temperature(&e), kelvin(366.4715514));
}

void
test_comp_outlet_temperature(void) {
	Engine e = {
		.ambient_temperature = fahrenheit(70),
		.ambient_pressure = psi(14.7),
		.map = psi(31.7),
		.comp_efficiency = percent(70),
	};
	test(comp_outlet_temperature(&e), kelvin(397.418883));
}

void
test_manifold_temperature(void) {
	Engine e = {
		.ambient_temperature = fahrenheit(80),
		.ambient_pressure = millibar(1015.9166),
		.map = millibar(2031.8332),
		.comp_efficiency = percent(70),
		.intercooler_efficiency = percent(70),
	};
	test(manifold_temperature(&e), kelvin(327.9429247));
}


void
test_volume_flow_rate(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(volume_flow_rate(&e), cubic_metre_per_sec(0.184086));
}

void
test_mass_flow_rate(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(&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));
}