usnistgov / REFPROP-wrappers

Wrappers around NIST REFPROP for languages such as Python, MATLAB, etc.
193 stars 127 forks source link

use refprop in mathematica #581

Closed Happiness-in-Danger closed 8 months ago

Happiness-in-Danger commented 8 months ago

In MMA14,there are some problems.The version of NIST REFPROP is 10.0. I'm so sorry to pull request there0fae0e1aeb3976031cb7fe497eac6711a6bea59c3241345ac9089541098b54f5.0.PNG

henningjp commented 8 months ago

@Happiness-in-Danger The RefProp function is only available in 10.0.0.0 or higher. The code checks to make sure that's what you have.

  1. Please open the REFPROP GUI. When the splash screen come up. Give me the exact version of REFPROP. Screen grab if you can and post that. image

  2. Open a Mathematica notebook and just execute the Needs["RefpropLink`"] line by itself in Mathematica. You should see the following (or a similar version): image

    Post the output here.

  3. After the Needs statement above, execute getversion[] and post the result.

  4. Finally, please execute setup[{"nitrogen"}, -1,"DEF"] and post the output of that as well.

There may be a problem with version 10.0 as I think the code is expecting 10.0.0.0 or similar format. The above output should help me figure it out. I have 10.0.0.02 and so can't see the problem you are having. I have an idea what's going on, though, and can probably patch it quickly.

A patch update from NIST would fix this, but I'd rather fix the wrapper code.

Happiness-in-Danger commented 8 months ago

image image My refprop is in A:\REFPROP use setdll to set location of refprop.dll?

henningjp commented 8 months ago

Yes. That's the problem. RefpropLink is looking in the default location (C:\Program Files\REFPROP\REFPRP64.DLL) for the NIST REFPROP installation.

You can use:

   SetDLL[]

You'll get a pop-up to browse to and select your REFPRP64.DLL file and temporarily set it's location. In your case it will be A:\REFPROP\REFPRP64.DLL.

Using a parameter of 1 will set this permanently in your profile so that to don't have to do this every time you start Mathematica.

   SetDLL[1]

See the Wolfram Help page on SetDLL for more information.

Let me know how it turns out and close this issue if it's working.

henningjp commented 8 months ago

@ianhbell - Does the RPprefix environment variable always get set when REFPROP is installed? This Mathematica wrapper should probably check for that if it does.

Happiness-in-Danger commented 8 months ago

@ianhbell - Does the RPprefix environment variable always get set when REFPROP is installed? This Mathematica wrapper should probably check for that if it does. yes,I set the RPprefix environment in installing and other question is that how to set resoult unit is "SI"

Happiness-in-Danger commented 8 months ago

Yes. That's the problem. RefpropLink is looking in the default location (C:\Program Files\REFPROP\REFPRP64.DLL) for the NIST REFPROP installation.

You can use:

SetDLL[]

You'll get a pop-up to browse to and select your REFPRP64.DLL file and temporarily set it's location. In your case it will be A:\REFPROP\REFPRP64.DLL.

Using a parameter of 1 will set this permanently in your profile so that to don't have to do this every time you start Mathematica.

SetDLL[1]

See the Wolfram Help page on SetDLL for more information.

Let me know how it turns out and close this issue if it's working.

I use the SetDLL[1] ,but it doesn't seem to work

henningjp commented 8 months ago

You'll have to provide more information than that. What is the result from SetDLL? Does the function do anything? Do you get the pop-up to select the REFPROP location? Screen shots would be helpful.

Per your previous question, the wrapper is set to use REFPROP's "DEFAULT" set of units (modified SI units with pressure in kPa, instead of Pa). However,

  1. RefpropLink handles Quantity values for all inputs/outputs. Mathematica can easily convert these values to any units you want, so no attempt has been made to work with any of the other unit systems.
  2. You can use the iUnits option on most function calls to set the units system to other than DEFAULT, but this will break RefpropLink's unit handling and is not recommended.

There is extensive help available on this embedded in the Refpropink help pages.

Happiness-in-Danger commented 8 months ago

You'll have to provide more information than that. What is the result from SetDLL? Does the function do anything? Do you get the pop-up to select the REFPROP location? Screen shots would be helpful.

Per your previous question, the wrapper is set to use REFPROP's "DEFAULT" set of units (modified SI units with pressure in kPa, instead of Pa). However,

  1. RefpropLink handles Quantity values for all inputs/outputs. Mathematica can easily convert these values to any units you want, so no attempt has been made to work with any of the other unit systems.
  2. You can use the iUnits option on most function calls to set the units system to other than DEFAULT, but this will break RefpropLink's unit handling and is not recommended.

There is extensive help available on this embedded in the Refpropink help pages.

I use SetDll[1],but I reopen the new netbook I still set dll. some unite is not to convert ,like density

henningjp commented 8 months ago

Not sure about the SetDLL[1] option. I'll look into it. It works on my machine if I move REFPROP to a new location. Best option, however, is to let REFPROP install in its expected default location on C:\Program Files(x86)\REFPROP.

On units, it all seems to work as advertised. Using your example above for CO2, the units are as expected. Note that by default everything is on a molar-basis; one must multiply/divide by the molecular weight to get the mass-basis values.

image

If you have an example where the units are not as expected, please provide an example.

Happiness-in-Danger commented 8 months ago

Not sure about the SetDLL[1] option. I'll look into it. It works on my machine if I move REFPROP to a new location. Best option, however, is to let REFPROP install in its expected default location on C:\Program Files(x86)\REFPROP.

On units, it all seems to work as advertised. Using your example above for CO2, the units are as expected. Note that by default everything is on a molar-basis; one must multiply/divide by the molecular weight to get the mass-basis values.

image

If you have an example where the units are not as expected, please provide an example.

OK,i understand how to convert unit. Can you give me your environment about the REFPROP.I want to make sure my REFPROP environment.Thanks

ianhbell commented 8 months ago

@henningjp Yes, the windows installer sets the RPPREFIX variable.

henningjp commented 8 months ago

@Happiness-in-Danger - I do not understand your last question about the environment. Can you be more specific?

Happiness-in-Danger commented 8 months ago

@Happiness-in-Danger - I do not understand your last question about the environment. Can you be more specific?

I reopen the new netbook I still set dll.However you don't set.I understand the problem is the RPPREFIX variable.I don't know my RPPREFIX variable is right or not?let me take a look at your settings about RPPREFIX variable

henningjp commented 8 months ago

The code is not looking for RPPREFIX and it should. I'll have to update the code to make use of this.

For now, look at: C:\Users\<user>\AppData\Roaming\Mathematica\Paclets\Repository\RefpropLink-1.1.0\TextREsources\Filepaths.txt

This is where SetDLL[1] stores the path you pick. Open this file in notepad and let me know what is written there.

Thanks.

henningjp commented 8 months ago

@Happiness-in-Danger - Ignore the above request. This functionality is broken. It looks like Wolfram changed their paclet resource structure; not sure when as I haven't tested non-default REFPROP locations it in a while. I can fix this and add the check for RPprefix as well, but it will take a couple of weeks as I have other commitments.

Meanwhile, you'll need to run SetDLL to set the non-standard REFPROP location each time (or install REFROP in its default location on C: drive)

Happiness-in-Danger commented 8 months ago

@Happiness-in-Danger - Ignore the above request. This functionality is broken. It looks like Wolfram changed their paclet resource structure; not sure when as I haven't tested non-default REFPROP locations it in a while. I can fix this and add the check for RPprefix as well, but it will take a couple of weeks as I have other commitments.

Meanwhile, you'll need to run SetDLL to set the non-standard REFPROP location each time (or install REFROP in its default location on C: drive)

ok,I will wait you fix this problem.Thanks

henningjp commented 8 months ago

@Happiness-in-Danger Download and try this new version. It should fix your problem. Make sure the environment variable RPprefix is set to your REFPROP location before your run it.

Happiness-in-Danger commented 4 months ago

@Happiness-in-Danger Download and try this new version. It should fix your problem. Make sure the environment variable RPprefix is set to your REFPROP location before your run it.

Sorry, I forget to reply this messages. Thanks, it's worked. Can I add chinese help documentation?

henningjp commented 4 months ago

Absolutely! Documentation on creating and building other language paclet documentation looks like it's supported, but documentation on how to do this is sketchy. It may take a bit of research. If you can figure it out, go for it.