DanWBR / dwsim

DWSIM is a Steady-State and Dynamic Sequential Modular Chemical Process Simulator for Windows, Linux and macOS.
https://dwsim.org
GNU General Public License v3.0
296 stars 95 forks source link

[Bug] wrong Cv calculation; valve has so many problems #672

Closed hsfmailubcca closed 1 month ago

hsfmailubcca commented 2 months ago

IMPORTANT: This section is meant for bug reporting only. For usage issues, please go to the Support Forums.

Describe the bug Overall, the valve cannot take small to medium values of Cv's and produce wrong pressure drops (verified with AFT Arrrow and Aspen HYSYS). For example: Tin=298.15 K, Pin=1,000 bara, Pout=1 bar, flow= 1 kg/s, it gives a Cv of 251.092, which is way far of reality. The Cv is 1.1 calculated by other software and also Swagelok valve Cv calculator.

To Reproduce

PLEASE ATTACH THE ZIPPED FLOWSHEET FILE and/or inform the steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

DanWBR commented 2 months ago

@hsfmailubcca Pin=1,000 bara, Pout=1 bar means critical flow, that the valve model doesn't support. how about the other problems? (you wrote "so many")

hsfmailubcca commented 2 months ago

Hi Daniel,

Thank you for your response and making the software. It is really hard to make a such a comprehensive software.

There are some other. E.g., when I pick the pressure drop instead of Cv, I can go down to very small Cv's with no error but when pick the same Cv, ir does not produce the corresponding pressure drop.

Also some other bugs such as temperature which can be discussed in an online meeting if necessary.

I am also not sure how good the software can handle choked flows.

Best regards, Hamidreza Sadeghifar, PhD, P.Eng.

On Tuesday, September 10, 2024, Daniel Wagner @.***> wrote:

@hsfmailubcca https://github.com/hsfmailubcca Pin=1,000 bara, Pout=1 bar means critical flow, that the valve model doesn't support. how about the other problems? (you wrote "so many")

— Reply to this email directly, view it on GitHub https://github.com/DanWBR/dwsim/issues/672#issuecomment-2341626944, or unsubscribe https://github.com/notifications/unsubscribe-auth/BLF74HUGQ4MFNL6J6RDD7CDZV4XUVAVCNFSM6AAAAABN7IUW3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBRGYZDMOJUGQ . You are receiving this because you were mentioned.Message ID: @.***>

hsfmailubcca commented 2 months ago

Also, choked flow is included in your user guide and the software can handle choked flow to some extent.

On Tuesday, September 10, 2024, Hamidreza Sadeghifar @.***> wrote:

Hi Daniel,

Thank you for your response and making the software. It is really hard to make a such a comprehensive software.

There are some other. E.g., when I pick the pressure drop instead of Cv, I can go down to very small Cv's with no error but when pick the same Cv, ir does not produce the corresponding pressure drop.

Also some other bugs such as temperature which can be discussed in an online meeting if necessary.

I am also not sure how good the software can handle choked flows.

Best regards, Hamidreza Sadeghifar, PhD, P.Eng.

On Tuesday, September 10, 2024, Daniel Wagner @.***> wrote:

@hsfmailubcca https://github.com/hsfmailubcca Pin=1,000 bara, Pout=1 bar means critical flow, that the valve model doesn't support. how about the other problems? (you wrote "so many")

— Reply to this email directly, view it on GitHub https://github.com/DanWBR/dwsim/issues/672#issuecomment-2341626944, or unsubscribe https://github.com/notifications/unsubscribe-auth/BLF74HUGQ4MFNL6J6RDD7CDZV4XUVAVCNFSM6AAAAABN7IUW3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBRGYZDMOJUGQ . You are receiving this because you were mentioned.Message ID: @.***>

DanWBR commented 2 months ago

Maybe @andr1976 can help us here as he is the author of the current Cv code in the valve model, otherwise I'll have to rewrite it from scratch.

andr1976 commented 2 months ago

@hsfmailubcca can you upload a file for us to investigate? Its hard check without

hsfmailubcca commented 2 months ago

I have got results for critical flow but when the pressure difference becomes very high, the software pops up a message saying that the valve is too small. I think there is a limiting condition for the formula used. You can use formula provided in AFT Arrow user guide and just do it as it without putting any limitation.

Overall, DWSIM is a good software; if you can fix this part, then I can validate it for you against other software and then here in our company we can use DWSIM and also provide some donations. DWSIM is a good software and just needs a little bit of work to extend its application to high pressure gases and validate them.

On Tuesday, September 10, 2024, Daniel Wagner @.***> wrote:

Maybe @andr1976 https://github.com/andr1976 can help us here as he is the author of the current Cv code in the valve model, otherwise I'll have to rewrite it from scratch.

— Reply to this email directly, view it on GitHub https://github.com/DanWBR/dwsim/issues/672#issuecomment-2342090790, or unsubscribe https://github.com/notifications/unsubscribe-auth/BLF74HTHNTJHFNFIP2C4W3DZV5UK5AVCNFSM6AAAAABN7IUW3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBSGA4TANZZGA . You are receiving this because you were mentioned.Message ID: @.***>

hsfmailubcca commented 2 months ago

Sure. I will. I have it on my laptop and send it to you in a few hours.

On Tuesday, September 10, 2024, Anders Andreasen @.***> wrote:

@hsfmailubcca https://github.com/hsfmailubcca can you upload a file for us to investigate? Its hard check without

— Reply to this email directly, view it on GitHub https://github.com/DanWBR/dwsim/issues/672#issuecomment-2342306154, or unsubscribe https://github.com/notifications/unsubscribe-auth/BLF74HTEL4F3EHQUQJKUTETZV52VXAVCNFSM6AAAAABN7IUW3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBSGMYDMMJVGQ . You are receiving this because you were mentioned.Message ID: @.***>

hsfmailubcca commented 1 month ago

Please find the file attached

On Tue, Sep 10, 2024 at 6:27 PM Hamidreza Sadeghifar @.***> wrote:

Sure. I will. I have it on my laptop and send it to you in a few hours.

On Tuesday, September 10, 2024, Anders Andreasen @.***> wrote:

@hsfmailubcca https://github.com/hsfmailubcca can you upload a file for us to investigate? Its hard check without

— Reply to this email directly, view it on GitHub https://github.com/DanWBR/dwsim/issues/672#issuecomment-2342306154, or unsubscribe https://github.com/notifications/unsubscribe-auth/BLF74HTEL4F3EHQUQJKUTETZV52VXAVCNFSM6AAAAABN7IUW3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBSGMYDMMJVGQ . You are receiving this because you were mentioned.Message ID: @.***>

andr1976 commented 1 month ago

Did you attach the file? I can't see it anywhere

hsfmailubcca commented 1 month ago

Yes, I did. Please scroll all the way to the bottom thread.

On Wed, Sep 11, 2024 at 11:18 AM Anders Andreasen @.***> wrote:

Did you attach the file? I can't see it anywhere

— Reply to this email directly, view it on GitHub https://github.com/DanWBR/dwsim/issues/672#issuecomment-2344371526, or unsubscribe https://github.com/notifications/unsubscribe-auth/BLF74HU46QA3VH3IZ6RICMLZWCCQFAVCNFSM6AAAAABN7IUW3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBUGM3TCNJSGY . You are receiving this because you were mentioned.Message ID: @.***>

andr1976 commented 1 month ago

What is the fluid? and the temperature?

hsfmailubcca commented 1 month ago

H2 gas; temperature can be set at 25 C or 10 C.

I check the same example with HYSYS with no error. HYSYS still does not allow very low Cv's but its temperatures are very reasonable. For example, Hysys provide a temperature increase from 10 to 38 degrees but DWSIM from 10 to 1807 K (~1500 C) which is not reasonable. Interestingly, AFT Arrow provides the choked warning but still gives the pressure drop and the pressure of the outlet. I have attached the DWSIM of this example that provides an unreasonable outlet T of 1807 K. I suggest you use the formulae used in AFT Arrow; you can find via google.

On Wed, Sep 11, 2024 at 11:44 AM Anders Andreasen @.***> wrote:

What is the fluid? and the temperature?

— Reply to this email directly, view it on GitHub https://github.com/DanWBR/dwsim/issues/672#issuecomment-2344418445, or unsubscribe https://github.com/notifications/unsubscribe-auth/BLF74HTIO2LB6BSO6CLSEETZWCFPFAVCNFSM6AAAAABN7IUW3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBUGQYTQNBUGU . You are receiving this because you were mentioned.Message ID: @.***>

andr1976 commented 1 month ago

@hsfmailubcca Please do the following:

1) zip the simulation file and drop it in a comment field here in a browser (not via mail). The file has not been uploaded 2) Inform DWSIM version used 3) Which mode: Dynamic or steady-state?

Assuming steady-state for now Then some things seems completely off. The heating due to reverse J-T effect is well produced in DWSIM, take e.g. the CoolProp property package which has the fundamental equation of state for hydrogen. Please make sure the same fluid package is applied both upstream, for the valve and downstream, since the enthalpy basis may be different from fluid package to fluid package messing up the temperature calculation for the PH flash. You will get something between 25-60 C depending on the initial temperature. Then I would bet your strangely high Cv is due to something like this, When I do the calc in DWSIM from 1000 to 1 bar, I get a Cv of 1.01, in our in-house control valve calculation methods also based on IEC/ANSI/ISA (as in DWSIM) I get the same result.

The caveat comes if you supply the Cv and calculate the pressure drop. Since the flow is choked, there is no explicit way of going below the critical pressure, since it has no effect any longer - remember the flow is specified upstream, so is pressure. With the given Cv the required outlet pressure to give you this will be the critical pressure. So although you sized for a dP of 999 bar, this is not what you will get in the reverse calculations due to the critical conditions.

Hydrogen at 1000 bar is tricky. Not all fluid packages in DWSIM will manage e.g. SRK and GERG in DWSIM. Peng-Robinson will, but I would not trust it for pure hydrogen at 1000 bar. DWSIM has limitations since it does not allow you to calculate flow based on pressure drop, nor doing backwards calculations propagating downstream to upstream (unless using Pro I assume), thus the things you can do with a valve in steady state will be limited to some extent

hsfmailubcca commented 1 month ago

ValveCv_1.zip

hsfmailubcca commented 1 month ago

Steady State; the last (most recent ) version of DWSIM I just dropped the file; I had sent it via my email and that's why you could not see it.

andr1976 commented 1 month ago

The error is here you scale the Cv to 0.4% at full opening. Remove the scaling and all is good image

andr1976 commented 1 month ago

For Peng-Robinson the compressibility starts being off at 10 C and 1000 bar, at 25 bar t is reasoanable. I would use CoolProp for pure hydrogen at these extreme values

hsfmailubcca commented 1 month ago

Thanks Anders.
CoolProp gives much more reasonable temperatures.
Still it can solve for Cv's above 1.1 for this example. For Cv's less than 1.1, it cannot solve. I was able to solve a similar example for any Cv's using AFT Arrow. I am not saying your results are incorrect but it does not cover any Cv's.

HYSYS also does something similar to DWSIM and only solves for some Cvs if ISA method is selected. HYSYS can do for lower Cv's if its other methods is elected.

With CoolProp, DWSIM and HYSYS results are very close and almost the same since both use the ANSI/ISA method.

That 0.4 was not coming to play in my simulation since the section box had not be checked.

hsfmailubcca commented 1 month ago

With CoolProp, the results are correct; the only issue remains unsolved is that both HYSYS and DWSIM cannot do for low Cv's of valves (if ANSI/ISA method selected in HYSYS) but AFT Arrow can do. For the file attached, the lowest CV is 1.1 but my valve Cv is 0.8 and i need results for my real application.

andr1976 commented 1 month ago

The problem is the fixed mass flow and the critical conditions, which is not possible with a lower Cv. Only solution is to lower mass flow accordingly.

ons. 11. sep. 2024 kl. 23.36 skrev hsfmailubcca @.***>:

With CoolProp, the results are correct; the only issue remains unsolved is that both HYSYS and DWSIM cannot do for low Cv's of valves (if ANSI/ISA method selected in HYSYS).

— Reply to this email directly, view it on GitHub https://github.com/DanWBR/dwsim/issues/672#issuecomment-2344745886, or unsubscribe https://github.com/notifications/unsubscribe-auth/AN6EID2AVAFW4MCUUGGDAL3ZWCZW3AVCNFSM6AAAAABN7IUW3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBUG42DKOBYGY . You are receiving this because you were mentioned.Message ID: @.***>

hsfmailubcca commented 1 month ago

Ok, I will double check it against AFT Arrow and see how accurate AFT Arrow is for low Cv's; I will try yo make apples-to-apples comparisons between HYSYS, DWSIM and AFT Arrow for such extreme conditions.

I think you are right Anders; even AFT Arrow cannot do it for low CV's; I do not have access to AFT but in the past, I was doing the reverse; giving all the Cv's and resistances to AFT and AFT was giving me the flow. The way I see it now is that AFT gives the min available flow that it can solve.

andr1976 commented 1 month ago

@DanWBR I think you can close this one and @hsfmailubcca can still add comments/updates on the AFT results

hsfmailubcca commented 1 month ago

Having done two cases, I found DWSIM produces results very similar to HYSYS even though there are still some minor differences. E.g., DWSIM only has Cv but HYSYS and AFT have Cv and Xt parameters.
1- Does DWSIM have PSV sizing as well? 2- Does DWSIM have something like an "Adjust" function that we can change one variable to reach a target value for another variable? E.g., I want to change flow to reach a specific/target value for the outlet temperature? 3- I see that DWSIM also has Dynamic. How can I model a transient flow from a 100-bar tank to a 5-bar tank connected via a valve with a Cv of 1? I need this transient flow as a function of time.