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

Strange caching bug related to the EquateR function somehow #713

Open
ianhbell opened this issue Dec 17, 2024 · 5 comments
Open

Strange caching bug related to the EquateR function somehow #713

ianhbell opened this issue Dec 17, 2024 · 5 comments
Labels
Milestone

Comments

@ianhbell
Copy link
Contributor

See #710, if the first call to a totally unrelated mixture is made, the error code from the second call differs to when the call is not made

import os 
import ctREFPROP.ctREFPROP as ct 

build_paths = [f for f in os.scandir('RPbuilds') if f.is_dir()]

for f in build_paths:
    if 'f7741' not in f.path: continue
    
    sopath = f.path+'/librefprop.dylib'
    
    if os.path.exists(sopath):
        RP = ct.REFPROPFunctionLibrary(sopath)
        RP.SETPATHdll(f.path)
        res = RP.REFPROPdll("", "FLAGS", "SETREF", 0, 0, 2, 0, 0, [])
        
        r0 = RP.REFPROPdll("R410A.mix", "TD", "DLIQ",RP.MOLAR_SI,0,0,250,10, [])
        SI = RP.GETENUMdll(1, "SI").iEnum
        r = RP.REFPROPdll("hexane;butane|.6;.4 mass", "DE", "P", SI, 0, 0, 600, -120.0, [])
        print(f.path, r.Output[0], r.ierr, r.herr)

yielding

RPbuilds/1734381729_f77418786d9dcca3ebab1b385de41ee94f5efec3 174.8462616496163 -5 [DEFLSH warning -5] One or more inputs are out of range; Temperature above upper limit: T = 597.056 K, Tmax = 589.941 K; Pressure above upper limit: P = 174.846 MPa, Pmax = 149.709 MPa.

but if the R410A line is commented out, you get:

RPbuilds/1734381729_f77418786d9dcca3ebab1b385de41ee94f5efec3 -9999990.0 226 [DEFL2 error 226] 2-phase iteration did not converge.
@ianhbell ianhbell added bug regression-10.0 regression added since 10.0 labels Dec 17, 2024
@ianhbell ianhbell added this to the 10.1 milestone Dec 17, 2024
@ianhbell
Copy link
Contributor Author

ianhbell commented Dec 17, 2024

So this must be some sort of variable that does not get reset properly

ianhbell added a commit to usnistgov/REFPROP-tests that referenced this issue Dec 17, 2024
@ianhbell
Copy link
Contributor Author

Interestingly the failure does not happen on windows

@ianhbell
Copy link
Contributor Author

This was a very(!) tricky one to debug, but the default value for integers in FORTRAN is 1, not 0. Implicit variable initialization is a very bad idea. Not sure why valgrind never flagged this.

See https://github.com/ianhbell/refprop-sandbox/commit/6d6552a407bd726e78b699a5258f73af9dac7d2d

@ianhbell
Copy link
Contributor Author

In the end the variable had to be left uninitialized within the function, relying on the value passed in. Nevertheless, fixed the problem

@ianhbell
Copy link
Contributor Author

Not fixed. Now I am getting uninitialized variable errors with iRcount in the [nearvap] Catch tag on intel on windows. On non-windows, I get no valgrind errors

@ianhbell ianhbell changed the title Strange caching bug Strange caching bug related to the EquateR function somehow Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant