fome-fw/firmware/controllers/algo/airmass/speed_density_base.cpp

32 lines
818 B
C++
Raw Normal View History

2020-07-22 18:24:20 -07:00
/**
* @file speed_density_base.cpp
*
* Base for speed density (ie, ideal gas law) math shared by multiple fueling modes.
*
* @date July 22, 2020
* @author Matthew Kennedy, (C) 2020
*/
2020-07-22 13:11:07 -07:00
#include "global.h"
#include "speed_density_base.h"
EXTERN_ENGINE;
/**
2020-07-22 18:24:20 -07:00
* Derived via:
* (8.31 J K mol^-1) <- ideal gas constant R
* /
* (28.97g mol^-1) <- molar mass of air
* = 0.28705 J*K/g
2020-07-22 13:11:07 -07:00
*/
2020-07-22 18:24:20 -07:00
#define AIR_R 0.28705f
2020-07-22 13:11:07 -07:00
float idealGasLaw(float volume, float pressure, float temperature) {
2020-07-22 18:24:20 -07:00
return volume * pressure / (AIR_R * temperature);
2020-07-22 13:11:07 -07:00
}
float SpeedDensityBase::getAirmassImpl(float ve, float manifoldPressure, float temperature DECLARE_ENGINE_PARAMETER_SUFFIX) {
float cycleAir = ve * idealGasLaw(CONFIG(specs.displacement), manifoldPressure, temperature);
return cycleAir / CONFIG(specs.cylindersCount);
}