SilverShaded
Well-known member
- Joined
- Mar 7, 2020
- Messages
- 110
- Programming Experience
- 10+
is there any possible way to speed up the following method?
baset is 298.15K, baset2 is baset*baset etc
I tried converting the divides to multipliers which made no difference.
baset is 298.15K, baset2 is baset*baset etc
I tried converting the divides to multipliers which made no difference.
C#:
private static double IdealGasMolarEnthalpy(Temperature Tk, BaseComp sc)
{
double VE = 0;
double Tk1 = Tk;
double Tk2 = Tk1 * Tk1; // slightly faster
double[] cp = sc.IdealVapCP;
if (cp != null)
{
VE = cp[0] * (Tk1 - baset1)
+ cp[1] * (Tk2 - baset2) / 2
+ cp[2] * (Tk2 * Tk1 - baset3) / 3
+ cp[3] * (Tk2 * Tk2 - baset4) / 4
+ cp[4] * (Tk1 * Tk2 * Tk2 - baset5) / 5;
}
return VE * sc.MW;
}