usnistgov / REFPROP-issues

A repository solely used for reporting issues with NIST REFPROP
26 stars 13 forks source link

Difficulties using Refprop to conserve Enthalpy #542

Open ChemicalDave opened 2 years ago

ChemicalDave commented 2 years ago

If you have an issue to report, please continue and fill out the applicable sections below. The details provided will help to resolve this issue as quickly as possible.

Prerequisites

NOTE: Be aware that all issues are publicly accessible and viewable. Thus please do not post any code or other content that is protected intellectual property or under copyright.

Before posting an issue, please:

You can also use markdown to format your issue: GitHub guide on Markdown. If you have code snippets, please use a code block to ensure that the formatting remains legible in the web interface. For instance, surround your code in triple backticks:

Description

Refprop calculations are not conserving enthalpy when mixing. In other words, the sum of enthalpy of the pure substances is not equivalent to the enthalpy of the mixture stream when no heat/energy is added or removed in the mixing process.

The problem is a little tricky to verify, as refprop uses a different reference point of specific enthalpy than other standards, such as Perry's for example. Modeling with refprop should still work just fine, regardless, and has been verified with CO2 as an example: Refprop(H, CO2, 300K, 1 Bar) = 507 kj/kg, Refprop(H, CO2, 600K, 1 Bar) = 800 kj/kg. delta H = 293 kj/kg. Perry's 5th(H, CO2, 300K, 1 Bar) = 809 kj/kg, Perry's(H, CO2, 600K, 1 Bar) = 1102 kj/kg. delta H = 293 kj/kg.

This is why enthalpy is "specific" - it can only apply for a single homogeneous fluid (can be pure, or mixture). Without a rule to connect multiple fluids to a common basis, the reference point of enthalpy is effectively arbitrary for application. Correct me if I am wrong, but Refprop appears to follow this rule: Enthalpy = 0 at the bubble point of the fluid at 1 atmosphere. This creates problems for conserving enthalpy across any species change to the fluid. Naturally, reactions are a little more complicated, but I can handle the three additional steps (reactant enthalpy from actual temp to Heat of formation temp, Heat of formation values, and product enthalpy from heat of formation temp to actual temp). I need to have confidence that refprop is handling simple mixing appropriately though.

My issue therefore, is how do I conserve enthalpy when creating a mixture, or adding to existing mixtures, with refprop?

Steps to Reproduce

  1. Define two streams that will mix. One is 2 kg/s of Methane (pure) and the other is 2 kg/s of Ethane (pure), both at atmospheric (1 atm, 101325 pascal, etc..) and room temperature (298 Kelvin). Calculate the enthalpy of each stream, and sum them for a net enthalpy flow into the mixer. (in this case, 909 kJ/kg for Methane, and 667.5 kJ/kg for Ethane. Total energy flow would be 3154 kJ/s at given flow rates).

  2. Define the product stream. In this case, it is 4 kg/s of Methane/Ethane at 50:50 mixture by mass (be sure to include that tag in the string: "Methane;Ethane|0.5;0.5 mass"). With no energy having been applied to, or removed from, the mixing process, the enthalpy must remain constant, in this case 3154 kJ/s in this product stream. At 1 atmosphere, calculate the temperature of the mixture stream such that energy is conserved to achieve an enthalpy of 788 kJ/kg.

Expected behavior: [What you expect to happen]

Refprop should correctly identify that the mixture would have an enthalpy of 788 kJ/kg at 298 Kelvin. This is expected because we have mixed two streams of 298 Kelvin each, and no chemical or other energy has been generated, injected, removed, or destroyed in any form. The mixture is very nearly ideal gas, and mass is conserved.

Actual behavior: [What actually happens]

Refprop calculates the temperature to be 262 Kelvin. I.e. - at that temperature (262 K), energy is conserved and energy in = energy out.

Versions

REFPROP Version: [REFPROP version you are using]
10.0

Operating System and Version: [OS you are running REFPROP on]
Windows 10 21H2

Access Method: [How you are accessing REFPROP (i.e. Python, other wrapper)]
Excel

Additional Information

If possible, please post examples and/or screenshots of the issue. image

In this image, cells like D7 have "=@REFPROP("H",F7,"TP","SI",B7,0.1,0)" where B7 is corresponding temperature and F7 is fluid string. Cells like I7 have "=G7*D7" to simply calculate net enthalpy flow. Cells like K7 describes the phase of the fluid, just to ensure no latent heat is at play. Lastly, the yellow temperature cells (B12) are guessed using excel's solver until energy is conserved (enthalpy in = enthalpy out)

ianhbell commented 2 years ago

Yes, mixture enthalpy is not a straightforward thing. I need to think about this some more, but I believe there is also an enthalpy of mixing to worry about in your enthalpy balance. From a first-law analysis, I don't see where it comes in and your analysis seems sound to me.

More fundamentally, I do not believe that our mixture modeling approach properly handles the enthalpy when mixing two streams together. This has been touched on a number of times in the issues in this and related locations. I believe the problem is that use of a reference state other than absolute zero is the ultimate culprit, but @EricLemmon is needed to chime in on this point.

ChemicalDave commented 2 years ago

@ianhbell (hope I'm using Github correctly) I actually did previously write up on enthalpy of mixing, but nixed it for conciseness. First off, thank you for looking at this, much appreciated. I am using superheated gas that do not react/ionize and minimal molecular interactions (compressibility factor = approx 1) to avoid any enthalpy of mixing. You are correct though, if I were (to use a more obvious example) mixing NaCl in Water, the salt would ionize and actually should change the temperature of the net solution to conserve enthalpy.

For the time being, my current thought if I want to use refprop to mix two streams, is that I can have refprop evaluate Cp (or the Cp function/variables if available) for each stream going in, and use the individual streams heat capacity to exchange energy from the hot stream to the cold stream, until the two streams would be at the same temperature. (Energy taken by lowering the hot stream's temp is put into heating the cold stream's temp). (Be wary of any phase changing!)

^ This process is the one I'm hoping to simplify with simple conservation of enthalpy. Any other simpler suggestions though are welcome. Also looking forward to @EricLemmon thoughts on this, thanks again to both of yall!

Side note, I do recognize that actual reactions need to follow a different mechanism as follows (just for any readers, I don't want this to misguide them if they find their way here somehow). If I wish to do a chemical reaction, I can take the mixture enthalpy at initial temp, evaluate the mixture at heat of formation temp (298 K), calculate heat of reaction, calculate enthalpy of new mixture at heat of formation temp (298). I then take the enthalpy of new mixture at 298 K, add in the heat of reaction, and the delta H of the initial mixture changing temp from Ti to 298 K, which will give me the final enthalpy. I can then simply solve for, with refprop, the temperature of the final mixture that yields the final enthalpy value. (Also - be wary of phase changes, make sure you don't double account for, or completely ignore, them!)

Edit - Just for fun: I have seen a few process simulator programs that account for mixing, and some that even account for reactions. DWSIM (free edition) seems to perfectly conserve enthalpy when mixing. Not reactions though. Some of AVEVA's software will conserve enthalpy over not only mixing, but reactions too. (i.e. enthalpy of stream CH4 + 2O2 at cold temp will be the same as enthalpy of stream CO2 + 2H2O at very hot temp, combustion reaction). A neat tool if you get a chance to play with it!

ianhbell commented 2 years ago

I guess one question I have (aside from the fundamentals of how to model mixtures) is whether it is correct to assume the same pressure at the outlet. Enthalpy balance and mass balance are required, but equality of pressure does not fall out from any of the balances.

ChemicalDave commented 2 years ago

Realistically, the outlet would be using a decreased pressure (to drive flow) but it is not far from realistic to use identical pressure inlet/outlet, and makes the analysis with refprop a little easier.

I looked a little more into any real situations of mixing causing changes in temperature, and there are some cases where you get molecular interactions such as H-bonding that would cause a change in temperature (prime example is Ethanol + Water). However, the degree of temperature change expected by refprop far exceeds what would be reasonable for something like this, and in these specific gas mixtures (namely Methane + Ethane which is a phenomenally ideal gas mixture with barely any such interaction) should not have any reasonable molecularly interaction effect whatsoever on temperature, in reality.

I've done a little more investigating, and it seems like the accuracy of Refprop in conserving enthalpy is correlated to how linearly the boiling point (or, bubble point for mixture) moves from Boiling point A (of 100% component A) to Boiling point B (of 100% component B) along an x-axis of %A (so, from 100% to 0%). - using binary mixtures for simplicity. It's either that, or accuracy is simply only tied to how similar the boiling points of components A and B are, haven't determined yet.

Anyways, it does seem that I may need to use an alternative tool for calculating temperatures of mixing processes unless there's an alternative method in refprop. (If I want to avoid those dreaded hand calculations haha)

ianhbell commented 2 years ago

I think, and we definitely can't correct this any time soon, the problem is that you need to use absolute enthalpies for all substances, with the crystal at 0 K and zero pressure as the reference state. And even with that, I have no idea whether the mixture models would yield the right energy balance.

What happens if you use a different model, like Peng-Robinson? I wonder (although I doubt it) if the problems comes from the EOS itself, rather than the general mixing model behavior.

nist-aharvey commented 2 years ago

As @ianhbell mentioned, this appears to be a problem with reference states, but I think it is not necessary to go to absolute zero reference states (or elemental reference states) to fix it. Those sorts of things would be needed for a reacting mixture, but for a nonreacting mixture it just needs to be the case that the reference state remains the same in the mixture calculation as it was in the pure component calculation. And it appears that REFPROP does not do that by default, at least for some mixtures (possibly that is a GERG thing, or possibly it is a default expected for refrigerant mixtures). It looks like REFPROP by default is making a new reference state for the mixture, based on its normal boiling point or something, which causes a disconnect from the pure-component reference states. You can see this by observing that the specific enthalpy of a mixture that is 99% ethane at that condition is a very different number from what you get with pure ethane.

In the GUI, you can get mixture enthalpies that are consistent with those from the pure component EOS by going to "Options", "Reference State" and choosing to apply reference state to "each pure component" (instead of "currently defined mixture"). I presume/hope there is some way to set that convention for mixture reference states in Excel, but I have no expertise there. Once you do that, I think you will find that mixture enthalpy numbers are consistent with expectations based on pure-component values.

By the way, any mixture, even at low pressure with similar components, will not conserve enthalpy when mixed at constant pressure, because of molecular interactions. Another way of saying this is that the excess enthalpy of mixing may be small, but it won't be zero. Your original change of 37 K is way too much in this case, but I would not be surprised if your mixing of streams at 298 K ended up at something like 298.02 K or 297.98 K to conserve enthalpy.

ChemicalDave commented 2 years ago

@nist-aharvey I think you're spot on with your thoughts and analysis, and I see the option you're talking about in the NIST Refprop GUI. When time allows, I will dive into the excel version of settings (unless that GUI happens to apply to excel also) and explore the effect of this. Worst case scenario is likely that I have a separate process for evaluating mixture/separation conditions using the Refprop GUI outside of excel, and use that to accurately account for this effect within excel. Thank you for showing me that, it may take some time for me to properly explore this avenue but it sounds like it's something that will work. Many appreciations for y'alls insight on this!

ianhbell commented 2 years ago

My colleague provided more context that I had missed the first time around. The key point is that only in very rare circumstances should you expect the temperature to be the same at the end, when the excess enthalpy of the mixture is equal to zero. Otherwise, the temperature should change to compensate for the enthalpy of mixing. The gist is this:

For example, mixing of stream 1 and 2 at same temperature and after mixing stream 3. Energy balance (n being molar flows):

n3 h3 = n1 h1 + n2 h2 -> h3 = x1 h1 + x2 h2

h1 -> Pure component -> h1(T1,p)
h2 -> Pure component -> h2(T1,p)

h3 -> Mixture
h3 = x1 h1(T3,p) + x2 h2(T3,p) + hE

As long as hE is not equal 0, T3 must be different from T1