Solving the Enthalpy Equation in C++

  • Context: Undergrad 
  • Thread starter Thread starter ZachGriffin
  • Start date Start date
Click For Summary
SUMMARY

The discussion focuses on implementing the enthalpy equation in C++ by converting an Excel macro. The enthalpy equation is expressed as H/(R*T) = A1 + A2*T/2 + A3*T^2/3 + A4*T^3/4 + A5*T^4/5 + A6/T, while the macro version is H = H + W * r * t * (a1 + t * a2 / 2 + t ^ 2 * a3 / 3 + t ^ 3 * a4 / 4 + t ^ 4 * a5 / 5 + a6 / t). The user, Mike, seeks assistance with the correct order of operations and the values for coefficients A1 to A6 to ensure accurate calculations in his C++ implementation.

PREREQUISITES
  • Understanding of C++ programming language
  • Familiarity with mathematical operations and order of operations
  • Knowledge of thermodynamics concepts, specifically enthalpy
  • Experience with Excel macros and their conversion to programming languages
NEXT STEPS
  • Research C++ operator precedence and how it affects calculations
  • Learn about the Math::Pow function in C++ for exponentiation
  • Investigate thermodynamic properties and how to derive coefficients A1 to A6
  • Explore debugging techniques in C++ to verify calculations
USEFUL FOR

C++ developers, thermodynamics engineers, and anyone involved in converting mathematical models from Excel to programming languages.

ZachGriffin
Messages
20
Reaction score
0
Hi guys,

I'm trying to implement the enthalpy equation in C++ converting it from an excel macro I found on this forum. I'm having a problem with the results which I think is as a result of having the incorrect order of operations. Can somebody help with the order of operations for this with brackets? Any help is much appreciated.

The enthalpy equation:
Code:
H/(R*T) = A1 + A2*T/2 + A3*T^2/3 + A4*T^3/4 + A5*T^4/5 + A6/T

The macro equation:
Code:
H = H + W * r * t * (a1 + t * a2 / 2 + t ^ 2 * a3 / 3 + t ^ 3 * a4 / 4 + t ^ 4 * a5 / 5 + a6 / t)

My Implementation:
Code:
ocpcOxidantEnthalpy += w * universalGasConstant * ocpcOxidantTemperature * (fuelContainer.a1 + ocpcOxidantTemperature * fuelContainer.a2 / 2 + Math::Pow(ocpcOxidantTemperature,2) * fuelContainer.a3 / 3 + Math::Pow(ocpcOxidantTemperature,3) * fuelContainer.a4 / 4 + Math::Pow(ocpcOxidantTemperature,4) * fuelContainer.a5 / 5 + fuelContainer.a6 / ocpcOxidantTemperature);
 
Science news on Phys.org
I think that power is fractional 2/3, 3/4, 4/5.
Could you please provide the values of A1 to A6 you are using?
Regards,
Mike.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 27 ·
Replies
27
Views
7K
  • · Replies 67 ·
3
Replies
67
Views
7K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K