how to calculate diesel fuel consumption?

I am trying to evaluate real-time fuel consumption of diesel engine, and I have learned a post " Fuel economy / consumption for Diesel vehicles in DashCommand ", in this post,the author mentioned that

DashCommand should do fuel economy calculations for all gasoline and Diesel vehicles that comply to the OBD-II spec. ALL OBD-II complient vehicles must support the 5 PIDs that DashCommand needs for fuel economy, SAE.MAP, SAE.IAT, SAE.RPM, SAE.VSS, and SAE.LOAD_PCT. BTW, the last one is only needed for Diesel vehicles

What a useful hint for me to do my work!, however, I do not understand the true method(formulations) to use the 5 PIDs to calcuate the diesel fuel consumption.

Can anyone do me a favor to explain the formulations of the calculating?

That is my understanding, LOAC_PCT is the percentage of maximum flow for the current RPM. I didn't personally write the fuel economy calculations for diesel, but it does just a simple multiplication with LOAD_PCT if I remember.

I don't know a ton about diesels, but just off the top of my head I would try to calculate it like this:
FuelFlow = (MassAirflow / IdealAfr) * (LoadPct / 100)

Not sure what the ideal AFR is for a diesel, but I'd try something like that first. Never owned a diesel, never tried to calculate MPG of one. Just my best guess.

I'm not sure diesel engines even have a stoichiometric AFR. Diesel engines handling fueling in an entirely different way than gasoline engines. The accelerator pedal dumps in more fuel, instead of moving a throttle valve. I don't think that airflow is restricted in a diesel.

I didn't write the fuel consumption formulas for our software, and I'm not entirely sure what all is involved in the calculation for diesels.