Line | Branch | Decision | Exec | Source |
---|---|---|---|---|
1 | #include "pch.h" | |||
2 | #include "rusefi_lua.h" | |||
3 | #include "lua_lib.h" | |||
4 | ||||
5 | ||||
6 | // Leiderman-Khlystov Coefficients for Estimating Engine Full Load Characteristics and Performance | |||
7 | 4 | TEST(LuaVag, LeidermaKhlystov) { | ||
8 | 1 | const char* magic = LUA_POW R"( | ||
9 | ||||
10 | ||||
11 | currentRpm = 2000 | |||
12 | ||||
13 | maxPowerHp = 148 | |||
14 | maxPowerRpm = 6000 | |||
15 | maxTorqueNm = 147 | |||
16 | maxTorqueRpm = 3500 | |||
17 | ||||
18 | ||||
19 | maxPowerKw = maxPowerHp * 0.7355 | |||
20 | ||||
21 | ||||
22 | torqAtMaxPower = maxPowerKw * 9549 / maxPowerRpm | |||
23 | print('torqAtMaxPower ' ..torqAtMaxPower) | |||
24 | ||||
25 | rpmCoef = maxPowerRpm / maxTorqueRpm | |||
26 | print('rpmCoef ' ..rpmCoef) | |||
27 | ||||
28 | torqCoef = maxTorqueNm / torqAtMaxPower | |||
29 | print('torqCoef ' ..torqCoef) | |||
30 | ||||
31 | torquePotential =(torqCoef -1) * 100 | |||
32 | zz =(100 *(rpmCoef -1) *(rpmCoef -1)) | |||
33 | print('torquePotential ' ..torquePotential) | |||
34 | print('zz ' ..zz) | |||
35 | ||||
36 | ax = 1 -((torquePotential * rpmCoef *(2 - rpmCoef)) / zz) | |||
37 | bx = 2 *((torquePotential * rpmCoef) / zz) | |||
38 | cx =(torquePotential * rpmCoef * rpmCoef) / zz | |||
39 | ||||
40 | print('ax ' ..ax .. ', bx ' ..bx .. ', cx ' ..cx) | |||
41 | ||||
42 | rpmRatio = currentRpm / maxPowerRpm | |||
43 | abcMult = ax * rpmRatio + bx * pow(rpmRatio, 2) - cx * pow(rpmRatio, 3) | |||
44 | print ('abcMult ' ..abcMult) | |||
45 | ||||
46 | print('rpmRatio ' .. rpmRatio) | |||
47 | ||||
48 | LeidermanPower = maxPowerKw * abcMult | |||
49 | print('LeidermanPower ' .. LeidermanPower) | |||
50 | ||||
51 | LeidermanTorque = (9550 * LeidermanPower) / currentRpm | |||
52 | print('LeidermanTorque ' .. LeidermanTorque) | |||
53 | ||||
54 | function testFunc() | |||
55 | return LeidermanTorque | |||
56 | end | |||
57 | ||||
58 | )"; | |||
59 | ||||
60 |
3/7✓ Branch 3 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 time.
✗ Branch 15 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(magic).value_or(0), 156.463); | |
61 | 1 | } | ||
62 | ||||
63 | ||||
64 | 4 | TEST(LuaVag, LeidermaKhlystov2) { | ||
65 | 1 | const char* magic = LUA_POW R"( | ||
66 | ||||
67 | ||||
68 | currentRpm = 2000 | |||
69 | ||||
70 | maxPowerHp = 148 | |||
71 | maxPowerRpm = 6000 | |||
72 | maxTorqueNm = 147 | |||
73 | maxTorqueRpm = 3500 | |||
74 | ||||
75 | ||||
76 | maxPowerKw = maxPowerHp * 0.7355 | |||
77 | ||||
78 | ||||
79 | torqAtMaxPower = maxPowerKw * 9549 / maxPowerRpm | |||
80 | print('torqAtMaxPower ' ..torqAtMaxPower) | |||
81 | ||||
82 | rpmCoef = maxPowerRpm / maxTorqueRpm | |||
83 | print('rpmCoef ' ..rpmCoef) | |||
84 | ||||
85 | torqCoef = maxTorqueNm / torqAtMaxPower | |||
86 | print('torqCoef ' ..torqCoef) | |||
87 | ||||
88 | torquePotential =(torqCoef -1) * 100 | |||
89 | ||||
90 | print('torquePotential ' ..torquePotential) | |||
91 | ||||
92 | ax=2-(25/torquePotential); | |||
93 | bx=(50/torquePotential) - 1; | |||
94 | cx=25/torquePotential; | |||
95 | ||||
96 | print('ax ' ..ax .. ', bx ' ..bx .. ', cx ' ..cx) | |||
97 | ||||
98 | rpmRatio = currentRpm / maxPowerRpm | |||
99 | abcMult = ax * rpmRatio + bx * pow(rpmRatio, 2) - cx * pow(rpmRatio, 3) | |||
100 | print ('abcMult ' ..abcMult) | |||
101 | ||||
102 | print('rpmRatio ' .. rpmRatio) | |||
103 | ||||
104 | LeidermanPower = maxPowerKw * abcMult | |||
105 | print('LeidermanPower ' .. LeidermanPower) | |||
106 | ||||
107 | LeidermanTorque = (9550 * LeidermanPower) / currentRpm | |||
108 | print('LeidermanTorque ' .. LeidermanTorque) | |||
109 | ||||
110 | function testFunc() | |||
111 | return LeidermanTorque | |||
112 | end | |||
113 | ||||
114 | )"; | |||
115 | ||||
116 |
3/7✓ Branch 3 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 time.
✗ Branch 15 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
|
1 | EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(magic).value_or(0), 415.858); | |
117 | 1 | } | ||
118 |