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

30 lines
795 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 "pch.h"
2020-07-22 13:11:07 -07:00
#include "speed_density_base.h"
/**
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
2021-12-26 09:33:32 -08:00
mass_t 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
}
2021-12-26 10:41:10 -08:00
/*static*/ mass_t SpeedDensityBase::getAirmassImpl(float ve, float manifoldPressure, float temperature) {
2023-03-27 00:58:18 -07:00
mass_t cycleAir = ve * idealGasLaw(engineConfiguration->displacement, manifoldPressure, temperature);
return cycleAir / engineConfiguration->cylindersCount;
2020-07-22 13:11:07 -07:00
}