-
Hello, I'm using REFPROP to provide fluid properties for a calculation tool. Due to discrepancies with REFPROP installation location across different machines in my department, I need to allow a user to provide a custom directory for REFPROP. This question may be more of a Python wrapper question, and my difficulties may be because I'm not implementing the wrapper appropriately. I initialize REFPROP in a separate file from where I actually call the wrapper using the following code:
I had some issues with this code structure before, but this seems to work. I've tried to have the REFPROP initialization inside a function where I can provide an optional filename, but this causes issues with all of my other functions due to the "RP" object being called before initialization. From my understanding, REFPROP will be initialized as soon as this module is imported but I would need to apply some sort of condition and pass some information to this module to allow for a custom directory. I'm not sure how to go about solving this. Is initializing REFPROP from a separate file not a good idea due for this case? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 4 replies
-
I don't understand what the problem is. You can point REFPROPFunctionLibrary at a particular shared library, and then call SETPATHdll function with a different location (which could be a shared folder, but this is NOT(!) recommended due to the risk of blocking file reads from multiple users. |
Beta Was this translation helpful? Give feedback.
-
Also, your code you actually run should be inside a if __name__ == '__main__':
.... block, and initialization and calls should happen inside this block. It should work fine, I use this approach all the time with this interface. If not, please provide a runnable(!) example. |
Beta Was this translation helpful? Give feedback.
-
A core comment is that REFPROP is not thread-safe, so you could get surprising behavior in a GUI that uses multiple threads |
Beta Was this translation helpful? Give feedback.
-
I would instantiate the copy in your main thread, and pass that to other threads |
Beta Was this translation helpful? Give feedback.
-
See for instance how I handled that in the code from this paper: https://www.sciencedirect.com/science/article/pii/S0140700719302361 |
Beta Was this translation helpful? Give feedback.
I would instantiate the copy in your main thread, and pass that to other threads