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

CO2 rich mixture with N2 fails with segmentation fault #2333

Open
Pablo-Salinas opened this issue Dec 7, 2023 · 2 comments
Open

CO2 rich mixture with N2 fails with segmentation fault #2333

Pablo-Salinas opened this issue Dec 7, 2023 · 2 comments

Comments

@Pablo-Salinas
Copy link

Description

Trying to obtain the properties of 0.97CO2+0.03N2 using a C++ codeto call Coolprop I get segmentation faults depending on the input P and T. I checked with gdb and debuging the library and it seems internal to Coolprop as it is allocating a vector:
std::vector<double, std::allocator >::operator[]
The code below reproduce the problem. If instead of 264.65 K one uses, say 263.15, things are fine. By they way, I coudln't find a way to provide a guessed density, is that possible or one can only help the solver by providing the expected phase? Thank you.

Steps to Reproduce

#include "CoolProp.h"
#include
#include <stdlib.h>
using namespace CoolProp;
int main() {

std::vector<std::string> fluids = {"CarbonDioxide", "Nitrogen"};
std::vector<double> z = {0.97,0.03};
double temp = 264.65; // 263.15 is fine
double pres = 6.51e6;
std::vector<std::string> outputs = {"DMASS", "H", "Z", "PHASE", "VISCOSITY"};

std::vector<double> T(1, temp), p(1, pres);
std::vector<std::vector<double>> coolsol =PropsSImulti(outputs, "T", T, "P", p, "HEOS", fluids, z);
for(int i=0;i<size(outputs);i++)
{
    std::cout << outputs[i] <<" "<< coolsol[0][i] << std::endl;
}
// All done return
return EXIT_SUCCESS;

}

Versions

v6.6.0 and also tested 6.4.2

@jowr
Copy link
Member

jowr commented Dec 7, 2023

Hi - thanks for reporting the issue.

The Halley solver used in solver_dpdrho0_Tp seems to overshoot and tries to calculate with a negative molar density which then fails ungracefully.

This may take some time to debug :/

@ibell
Copy link
Contributor

ibell commented Dec 7, 2023

Some comments here:

  1. Definitely the failure mode should be an exception not a crash (this is not good)
  2. Definitely the pure fluid EOS are not helping since nitrogen EOS doesn't have a spinodal sometimes
  3. REFPROP is recommended for mixtures in general
    3a) Help improving the mixture routines is welcomed(!)
  4. The mixture viscosity model in CoolProp should not be trusted, don't use it except for as a very rule-of-thumb model

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

3 participants