Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R513A #15

Open
AndreaVIC opened this issue Mar 25, 2021 · 9 comments
Open

R513A #15

AndreaVIC opened this issue Mar 25, 2021 · 9 comments

Comments

@AndreaVIC
Copy link

Hello,
I am trying to use the NuGet pack and I am interested in some R513A properties. Following my code:

  •         MediaType MediaFluid = new MediaType("HEOS", "R513A.MIX");
    
  •         Fluid my_fluid = new Fluid(MediaFluid);
    
  •         my_fluid.UpdatePX(Pressure.FromBars(9), 0.0);
    

Is it the right way to initialize R513A? Is R513A in the FluidList?

From the call my_fluid.UpdatePX(Pressure.FromBars(9), 0.0) I don’t obtain any exceptions however all the properties are equal to zero. I am particular interested to obtain the saturation temperature at a given pressure. Are there any ways to obtain this value?

Thanks in advanced.

Andrea

@MadsFoged
Copy link
Collaborator

MadsFoged commented Mar 25, 2021

Hi AndreaVIC,

R513A is not yet in SharpFluids's official List however it is in CoolProp's list, thats why it kinda works for you.
For some reason coolprop cant return R513A's Critical Pressure which is used inside 'UpdatePX' -thats way it doesnt work for you.

I have created a new release that should work for you.
Can you try to download the newest NuGet and test it out?

@MadsFoged MadsFoged reopened this Mar 25, 2021
@AndreaVIC
Copy link
Author

Thank you MadsFoged! It works perfectly!

Andrea

@AndreaVIC
Copy link
Author

Probably there is the same problem also here:

my_fluid.UpdatePS(Pressure.FromBars(9), UnitsNet.Entropy.FromJoulesPerKelvin(1699.7));

Could you fix the issue? Thanks again

Andrea

@MadsFoged
Copy link
Collaborator

Coolprop gives me this error when I try:
phase envelope must be built to carry out HSU_P_flash for mixture

It looks like it is a CoolProp problem:
CoolProp/CoolProp#2000

ibell commented on 14 Feb
For mixtures, you will probably need REFPROP. The mixture routines in CoolProp are not very stable, and those of REFPROP are much better.

This is the reason I haven't yet been supporting mixtures, it is simply not stable enough.

@MadsFoged
Copy link
Collaborator

However if you want you could build a binary search to search for the entropy you need.

If you use my_fluid.UpdatePT(Pressure.FromBars(10), Temperature.FromDegreesCelsius(x));
You can read out the entropy and guess the next temperature to lookup

Does that make sense?

@AndreaVIC
Copy link
Author

Thanks for the suggestion. It is probably more time-consuming procedure but it could work. Before moving to Refprop I am going to follow this approach and if you are interested I can share the algorithm.

Thanks again

Andrea

@MadsFoged
Copy link
Collaborator

MadsFoged commented Mar 26, 2021

It could be as simple as this:

            MediaType MediaFluid = new MediaType("HEOS", "R513A.MIX");
            Fluid my_fluid = new Fluid(MediaFluid);

            //This is want we are aiming for
            Entropy Aim = Entropy.FromJoulesPerKelvin(1699.7);


            Temperature Max = my_fluid.LimitTemperatureMax;
            Temperature Min = my_fluid.LimitTemperatureMin;
            Temperature Mid = Temperature.Zero;   

            
            for (int i = 0; i < 20; i++)
            {

                Mid = Temperature.FromKelvins((Max.Kelvins + Min.Kelvins) / 2);

                my_fluid.UpdatePT(Pressure.FromBars(10), Mid);


                if (my_fluid.Entropy > Aim) 
                    Max = Mid;
                else
                    Min = Mid;

            }

@MadsFoged
Copy link
Collaborator

With the neweste verion you can get the fluid using:

Fluid my_fluid = new Fluid(FluidList.R513A_mix);

@AndreaVIC
Copy link
Author

Thanks, the new string for R513A works for me. Following my custom UpdatePS function:

private void My_UpdatePS(ref Fluid my_fluid,double my_Entropy, double ref_Pressure)
{

    // my_Entropy:   J/(kg*K)
    // ref_Pressure: Pa

    double error = my_Entropy;                  // Function error
    double stop_error = my_Entropy * 1e-3/100;  // Stop error

    //This is want we are aiming for:
    Entropy Aim = Entropy.FromJoulesPerKelvin(my_Entropy);

    //Interval:
    Temperature Max = my_fluid.LimitTemperatureMax;
    Temperature Min = my_fluid.LimitTemperatureMin;
    Temperature Mid = Temperature.Zero;

    int iter = 0;
    while(error > stop_error & iter < 20)
    {

        Mid = Temperature.FromKelvins((Max.Kelvins + Min.Kelvins) / 2);

        my_fluid.UpdatePT(Pressure.FromPascals(ref_Pressure), Mid);

        if (my_fluid.Entropy > Aim)
            Max = Mid;
        else
            Min = Mid;

        iter++;
        error = Math.Abs(my_fluid.Entropy.JoulesPerDegreeCelsius - Aim.JoulesPerDegreeCelsius);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants