Solving the Enthalpy Equation in C++

  • Thread starter ZachGriffin
  • Start date
In summary, the speaker is seeking help with implementing the enthalpy equation in C++, specifically with the order of operations for the given equation. They provide both the enthalpy equation and a macro equation for reference, as well as their own implementation. They also mention the possibility of fractional powers and request the values of A1 to A6 being used.
  • #1
ZachGriffin
20
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
  • #2
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.
 
  • #3


Hi there, it looks like you're on the right track with your implementation of the enthalpy equation in C++. However, it's difficult to pinpoint the exact issue without seeing the data you are using and the specific problem you are having with the results. Generally, it's important to make sure that you are using the correct units and that your variables are defined properly. As for the order of operations, it looks like you have correctly followed the formula provided in the macro equation. Just make sure to double check your calculations and units to ensure accuracy. If you are still having trouble, it may be helpful to consult with a colleague or seek assistance from a programming expert. Good luck with your project!
 

Related to Solving the Enthalpy Equation in C++

1. What is Enthalpy and why is it important in chemistry?

Enthalpy is a measure of the total energy of a thermodynamic system. In chemistry, it is important because it helps us understand the heat transfer that occurs during chemical reactions, and can also be used to calculate the energy required to make or break chemical bonds.

2. How do you calculate Enthalpy using C++?

To calculate Enthalpy in C++, you will need to use the enthalpy equation, which is H = U + PV. This equation takes into account the internal energy (U), pressure (P), and volume (V) of the system. You can use this equation in your C++ program by declaring and initializing variables for each of these components and then using the appropriate mathematical operators to perform the calculation.

3. Can you provide an example code for solving the Enthalpy equation in C++?

Yes, here is a simple example code for solving the Enthalpy equation in C++:

double U = 150.0; // internal energy of the system in Joulesdouble P = 2.5; // pressure in atmospheresdouble V = 0.05; // volume in cubic metersdouble H = U + (P * V); // calculating enthalpycout << "The enthalpy of the system is: " << H << " Joules." << endl; // outputting the result

4. Is there a built-in function in C++ for calculating Enthalpy?

No, there is not a specific built-in function in C++ for calculating Enthalpy. However, there are mathematical functions and operators that can be used to perform the necessary calculations, as shown in the example code above.

5. How can solving the Enthalpy equation in C++ help in practical applications?

Solving the Enthalpy equation in C++ can be useful in many practical applications, such as in chemical engineering, materials science, and thermodynamics. It can help in the design and optimization of chemical processes, understanding energy transfer in materials, and predicting the behavior of thermodynamic systems.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
7
Views
938
  • Advanced Physics Homework Help
Replies
6
Views
2K
  • Advanced Physics Homework Help
Replies
6
Views
491
Replies
7
Views
754
  • Calculus and Beyond Homework Help
Replies
3
Views
623
  • Special and General Relativity
Replies
11
Views
360
Replies
1
Views
789
  • Differential Equations
Replies
2
Views
2K
  • Differential Equations
Replies
1
Views
760
  • Thermodynamics
Replies
5
Views
1K
Back
Top