wow Leiderman-Khlystov

This commit is contained in:
Andrey 2022-09-05 20:23:40 -04:00
parent 07c08947ba
commit c8cdc50877
3 changed files with 118 additions and 58 deletions

View File

@ -0,0 +1,117 @@
#include "pch.h"
#include "rusefi_lua.h"
#include "lua_lib.h"
// Leiderman-Khlystov Coefficients for Estimating Engine Full Load Characteristics and Performance
TEST(LuaVag, LeidermaKhlystov) {
const char* magic = LUA_POW R"(
currentRpm = 2000
maxPowerHp = 148
maxPowerRpm = 6000
maxTorqueNm = 147
maxTorqueRpm = 3500
maxPowerKw = maxPowerHp * 0.7355
torqAtMaxPower = maxPowerKw * 9549 / maxPowerRpm
print('torqAtMaxPower ' ..torqAtMaxPower)
rpmCoef = maxPowerRpm / maxTorqueRpm
print('rpmCoef ' ..rpmCoef)
torqCoef = maxTorqueNm / torqAtMaxPower
print('torqCoef ' ..torqCoef)
torquePotential =(torqCoef -1) * 100
zz =(100 *(rpmCoef -1) *(rpmCoef -1))
print('torquePotential ' ..torquePotential)
print('zz ' ..zz)
ax = 1 -((torquePotential * rpmCoef *(2 - rpmCoef)) / zz)
bx = 2 *((torquePotential * rpmCoef) / zz)
cx =(torquePotential * rpmCoef * rpmCoef) / zz
print('ax ' ..ax .. ', bx ' ..bx .. ', cx ' ..cx)
rpmRatio = currentRpm / maxPowerRpm
abcMult = ax * rpmRatio + bx * pow(rpmRatio, 2) - cx * pow(rpmRatio, 3)
print ('abcMult ' ..abcMult)
print('rpmRatio ' .. rpmRatio)
LeidermanPower = maxPowerKw * abcMult
print('LeidermanPower ' .. LeidermanPower)
LeidermanTorque = (9550 * LeidermanPower) / currentRpm
print('LeidermanTorque ' .. LeidermanTorque)
function testFunc()
return LeidermanTorque
end
)";
EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(magic).value_or(0), 156.463);
}
TEST(LuaVag, LeidermaKhlystov2) {
const char* magic = LUA_POW R"(
currentRpm = 2000
maxPowerHp = 148
maxPowerRpm = 6000
maxTorqueNm = 147
maxTorqueRpm = 3500
maxPowerKw = maxPowerHp * 0.7355
torqAtMaxPower = maxPowerKw * 9549 / maxPowerRpm
print('torqAtMaxPower ' ..torqAtMaxPower)
rpmCoef = maxPowerRpm / maxTorqueRpm
print('rpmCoef ' ..rpmCoef)
torqCoef = maxTorqueNm / torqAtMaxPower
print('torqCoef ' ..torqCoef)
torquePotential =(torqCoef -1) * 100
print('torquePotential ' ..torquePotential)
ax=2-(25/torquePotential);
bx=(50/torquePotential) - 1;
cx=25/torquePotential;
print('ax ' ..ax .. ', bx ' ..bx .. ', cx ' ..cx)
rpmRatio = currentRpm / maxPowerRpm
abcMult = ax * rpmRatio + bx * pow(rpmRatio, 2) - cx * pow(rpmRatio, 3)
print ('abcMult ' ..abcMult)
print('rpmRatio ' .. rpmRatio)
LeidermanPower = maxPowerKw * abcMult
print('LeidermanPower ' .. LeidermanPower)
LeidermanTorque = (9550 * LeidermanPower) / currentRpm
print('LeidermanTorque ' .. LeidermanTorque)
function testFunc()
return LeidermanTorque
end
)";
EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(magic).value_or(0), 415.858);
}

View File

@ -261,61 +261,3 @@ TEST(LuaVag, ChecksumMotor6) {
EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(realdata).value_or(0), 0x3D);
}
// Leiderman-Khlystov Coefficients for Estimating Engine Full Load Characteristics and Performance
TEST(LuaVag, LeidermaKhlystov) {
const char* magic = LUA_POW VAG_CHECKSUM realMotor6Packet R"(
currentRpm = 2000
maxPowerHp = 148
maxPowerRpm = 6000
maxTorqueNm = 147
maxTorqueRpm = 3500
maxPowerKw = maxPowerHp * 0.7355
torqAtMaxPower = maxPowerKw * 9549 / maxPowerRpm
print('torqAtMaxPower ' ..torqAtMaxPower)
rpmCoef = maxPowerRpm / maxTorqueRpm
print('rpmCoef ' ..rpmCoef)
torqCoef = maxTorqueNm / torqAtMaxPower
print('torqCoef ' ..torqCoef)
torquePotential =(torqCoef -1) * 100
zz =(100 *(rpmCoef -1) *(rpmCoef -1))
print('torquePotential ' ..torquePotential)
print('zz ' ..zz)
ax = 1 -((torquePotential * rpmCoef *(2 - rpmCoef)) / zz)
bx = 2 *((torquePotential * rpmCoef) / zz)
cx =(torquePotential * rpmCoef * rpmCoef) / zz
print('ax ' ..ax .. ', bx ' ..bx .. ', cx ' ..cx)
rpmRatio = currentRpm / maxPowerRpm
abcMult = ax * rpmRatio + bx * pow(rpmRatio, 2) - cx * pow(rpmRatio, 3)
print ('abcMult ' ..abcMult)
print('rpmRatio ' .. rpmRatio)
LeidermanPower = maxPowerKw * abcMult
print('LeidermanPower ' .. LeidermanPower)
LeidermanTorque = (9550 * LeidermanPower) / currentRpm
print('LeidermanTorque ' .. LeidermanTorque)
function testFunc()
return LeidermanTorque
end
)";
EXPECT_NEAR_M3(testLuaReturnsNumberOrNil(magic).value_or(0), 156.463);
}

View File

@ -37,6 +37,7 @@ TESTS_SRC_CPP = \
tests/lua/test_lua_vag.cpp \
tests/lua/test_lua_with_engine.cpp \
tests/lua/test_lua_hooks.cpp \
tests/lua/test_lua_Leiderman_Khlystov.cpp \
tests/lua/test_can_filter.cpp \
tests/sensor/test_cj125.cpp \
tests/test_change_engine_type.cpp \