usnistgov / REFPROP-wrappers

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

embed the REFPROP Version 10 in Excel 2016 #83

Closed yangmengnist closed 5 years ago

yangmengnist commented 5 years ago

Description

I want embed the software REFPROP Version 10 into excel2016, so that I can obtain the results after I entered the command such as =Density("water","TP","SI",300,1) in the Excel’s cell, and I tried the method linked "https://github.com/usnistgov/REFPROP-wrappers/tree/master/wrappers/Excel", but I didn't get the result I wanted. you can see the detailed description in the attachment.

Steps to Reproduce

I want embed the software REFPROP Version 10 into excel2016, so that I can obtain the results after I entered the command such as =Density("water","TP","SI",300,1) in the Excel’s cell, and I tried the method linked "https://github.com/usnistgov/REFPROP-wrappers/tree/master/wrappers/Excel", but I didn't get the result I wanted. Below is the detailed description for what I did according to the link: https://github.com/usnistgov/REFPROP-wrappers/tree/master/wrappers/Excel.

For step 1. I opened REFPROP.xls and saved it as an add-in, REFPROP.xlam, in the main REFPROP folder, C:\Program Files\REFPROP. But it could not save in this folder directly. So I saved the REFPROP.xlam in another file, and the copied it into the main REFPROP folder, C:\Program Files\REFPROP. The figure below is the warning window.

image

The figure that I copied REFPROP.xlam into the main folder.

image Step 2 to 5 is ok. image image image

For step 6, I didn’t know if I did it correctly. I can’t find Edit Links and the button. Can you show me the operation process? When I typed in a Refprop command [such as “=Density("water","TP","SI",300,1)], the result showed in the picture below. image

Versions

REFPROP Version: Version 10 Operating System and Version: window 10, 64 bit

ianhbell commented 5 years ago

I converted your docx to properly formatted issue

yangmengnist commented 5 years ago

thank you. and how can i do next?

ianhbell commented 5 years ago

How about this: image

yangmengnist commented 5 years ago

it is my excel image

ianhbell commented 5 years ago

You want the same icon in the one to the right:

image

yangmengnist commented 5 years ago

the button Edit Links is grey. So i can't try as step 6. i want to embed the REFPROP to Excel 2016.

ianhbell commented 5 years ago

I'm afraid I don't use Excel personally, but @EricLemmon does. Maybe he knows? Have you googled this problem?

yangmengnist commented 5 years ago

yes, I googled this, but it didn't work. So can you help me embed REFPROP Version 10 in excel2016? Actually, if the software was embeded in Excel successfully, when the command I entered is incomplete,it wil happen like the picture shows below. image

NickAtNight2017 commented 5 years ago

I don’t think you need to make it an .xlam file.

You already have a ‘refprop.xla’ file in that folder.

And you have the ‘refprop_Ribbon.xlam’ in that folder.

I think these are the only two files you need.

Get Outlook for iOShttps://aka.ms/o0ukef


From: yangmengnist notifications@github.com Sent: Tuesday, December 11, 2018 6:48 AM To: usnistgov/REFPROP-wrappers Cc: Subscribed Subject: Re: [usnistgov/REFPROP-wrappers] embed the REFPROP Version 10 in Excel 2016 (#83)

Attention: This is an EXTERNAL SENDER

yes, I googled this, but it didn't work. So can you help me embed REFPROP Version 10 in excel2016? Actually, if the software was embeded in Excel successfully, when the command I entered is incomplete,it wil happen like the picture shows below. [image]https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F45703839%2F49801752-ffddbe00-fd85-11e8-8d42-2100abb7f986.png&data=02%7C01%7CNicholas.james%40mexichem.com%7Ca26532869d3747e9bece08d65f66e37a%7Cfad75a54a3234cd08e516a8d57035aa8%7C1%7C0%7C636801292840704420&sdata=Gj%2F5lwZ7B3xQY%2Fw1LMrRh40o30P5IcuL3%2BRfkw%2BCuKM%3D&reserved=0

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fusnistgov%2FREFPROP-wrappers%2Fissues%2F83%23issuecomment-446190626&data=02%7C01%7CNicholas.james%40mexichem.com%7Ca26532869d3747e9bece08d65f66e37a%7Cfad75a54a3234cd08e516a8d57035aa8%7C1%7C0%7C636801292840704420&sdata=Hva1R7iBgIGNJhflsCi3ZF4dZqaYavewrMZRi3cp8Z4%3D&reserved=0, or mute the threadhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAeAdeOjl1e3oNMt0CIU4Uftq4cJFY7rZks5u36mBgaJpZM4ZJp6E&data=02%7C01%7CNicholas.james%40mexichem.com%7Ca26532869d3747e9bece08d65f66e37a%7Cfad75a54a3234cd08e516a8d57035aa8%7C1%7C0%7C636801292840704420&sdata=ucqGSHJZIffoUSJH33lGNy8QPhCmLcdMBDRGwg%2BfaeQ%3D&reserved=0.

The information contained in this email may be confidential and/or legally privileged. It has been sent for the sole use of the intended recipient(s). If the reader of this message is not an intended recipient, you are hereby notified that any unauthorized review, use, disclosure, dissemination, distribution, or copying of this communication, or any of its contents, is strictly prohibited and may be illegal. If you have received this communication in error, please reply to the sender and destroy all copies of the message.

yangmengnist commented 5 years ago

thank you. I tried as you commented. but it didn't work. Have you embeded REFPROP Version 10 in excel 2016?

NickAtNight2017 commented 5 years ago

Absolutely.

The new refprop installed and startedup just fine on my machine... :) But then I did help develop the new update. So perhaps that was not a fair test.

Please forgive me because it has been a while since I installed it. I have to refresh my memory.

When working correctly, you need the two excel add-ins installed. They should already be located in the refprop folder. So you just need to link to them.

NickAtNight2017 commented 5 years ago

There may be a 'trusted file' issue. Check to see if you need to make that refprop folder location a 'trusted file' source.

NickAtNight2017 commented 5 years ago

Um, you are using the old formula style. The new formulas should look like this: =refprop("D","Water","TP","SI",300,1,0)

NickAtNight2017 commented 5 years ago

I do not seem to be able to embed an image. I shall try to describe it with text only.

NickAtNight2017 commented 5 years ago

The first add-in is the 'refprop.xla' file. It should already be located in the 'C:\Program Files (x86)\REFPROP' folder.

On the Developer tab. Select 'Excel Add-ins'. Browse for a new tab. Go to the folder: C:\Program Files (x86)\REFPROP Select 'refprop.xla' file.

Notice that this is an '.xla' file. It is not a '.xlam' file.

xlam files are a newer EXCEL file format. To increase the use of refprop with the older versions of Excel, the bulk of the code was left in the old excel format.

NickAtNight2017 commented 5 years ago

Hmmm, and I can't edit my comment either. Oh well.

This file should now show up as 'REFPROP Addins' in the Excel Add-ins list. There should be a check box by it.

yangmengnist commented 5 years ago

thank you. I tried the new formulas =refprop("D","Water","TP","SI",300,1,0), it's ok. where can i find the rule of new formulars? image

yangmengnist commented 5 years ago

image

NickAtNight2017 commented 5 years ago

The second Excel Add-in you need is the REFPROP Ribbon.

This addin will make the new New Refprop much easier to use.

Repeat the above steps.
.. Excell Add-ins / Browse/ Navigate to C:\Program Files (x86)\REFPROP / Select the REFPROPR_Ribbon.xlam file

This should now show as 'REFPROP Ribbon' on the Add-ins menu.

With this addin installed, you should now have a "REFPROP" tab added to the Excel menu along the top. It should be at the far right after all the other menu items.

There are not many items on the menu at present. Just 5.

  1. Insert function
  2. Wizard
  3. About
  4. Help PDF
  5. Help

The command you should use most frequently will be the 'WIZARD'.

Clicking on Wizard will open a userform. Complete the form and select one of the 3 options.

You enter the following information from drop down menus:

  1. Fluid (pure or mixed)
  2. Units (SI, etc.)
  3. First input property (Temperature) and value (300 K)
  4. Second input property (Pressure) and value (1 MPa)
  5. You can select Saturated Liquid or Saturated vapor
  6. Then select you calculated property (Density) The results will appear on the screen to the right (996.960 kg/m3)

The excel string you need is shown below in the form. You can copy and paste it in. =refprop("D","Water","TP","SI",300,1,0)

However, just press the Calculate button. Well first, navigate to the spot on the Excel spreadsheet where you want the equation. Then press Calculate. The string will be entered into the spot.

The weakness of the Calculate button is that you will just get the value '(996.960). So you have to remember the Units and the property.

You may prefer the 'Compose' button. This will place the property name (Density) to the left of your value. And it will place the units (kg/m3) to the right of your value.

If you are... rigourous… try the 'Compose All' button. ;) But make sure you have plenty of space. Because this will give you ALL of the properties for the fluid !

As in: Temperature 300 K Pressure 1 MPa Density 996.9600227 kg/m^3 Quality (mass) #State is single phase, quality not calculated - Quality (molar) #State is single phase, quality not calculated - Phase Subcooled liquid PHASE Molar mass 18.015268 g/mol Volume 0.001003049 m^3/kg Internal energy 112.4789982 kJ/kg Enthalpy 113.4820475 kJ/kg Entropy 0.392813903 (kJ/kg)/K Isochoric heat capacity 4.127217305 (kJ/kg)/K Isobaric heat capacity 4.178103606 (kJ/kg)/K Cp/Cv 1.012329445 - Speed of sound 1503.035984 m/s Compressibility factor 0.007244565 - Isenthalpic Joule-Thomson coefficient -0.220216673 K/MPa Gibbs energy -4.362123376 kJ/kg Viscosity 853.662323 uPa-s Thermal conductivity 610.0033311 mW/(m-K) Prandtl number 5.84700025 - Thermal diffusivity 0.001464452 cm^2/s Kinematic Viscosity 0.008562654 cm^2/s Surface tension 71.68596253 mN/m Dielectric constant 77.78127435 - Isothermal compressibility 0.000449475 1/MPa Volume expansivity 0.000275697 1/K Isentropic expansion coefficient 2252.249504 - Isothermal expansion coefficient 2224.818723 - Adiabatic compressibility 0.000444001 1/MPa Adiabatic bulk modulus 2252.249504 MPa Isothermal bulk modulus 2224.818723 MPa Isothermal throttling coefficient 0.000920088 m^3/kg Critical flow factor #[CSTAR error 151] Iteration failed to converge. - Throat mass flux #[CSTAR error 151] Iteration failed to converge. kg/(m^2s) dP/dD at constant T 2.231602744 MPa(m^3/kg) dP/dT at constant D 0.613374899 MPa/K dD/dP at constant T 0.448108429 (kg/m^3)/MPa dD/dT at constant P -0.274858462 (kg/m^3)/K dT/dP at constant D 1.630324295 K/MPa dT/dD at constant P -3.638236172 K(m^3/kg) d^2P/dD^2 at constant T 0.010544166 MPa(m^3/kg)^2 d^2P/dT^2 at constant D 0.024266917 MPa/K^2 d^2P/dTdD 0.00843383 MPa(m^3/kg)/K d^2D/dP^2 at constant T -0.000948771 (kg/m^3)/MPa^2 d^2D/dT^2 at constant P -0.009153636 (kg/m^3)/K^2 d^2D/dPdT -0.00111157 (kg/m^3)/[MPaK] d^2T/dP^2 at constant D -0.105156615 K/MPa^2 d^2T/dD^2 at constant P -0.440825088 K(m^3/kg)^2 d^2T/dPdD 0.21225103 K(m^3/kg)/MPa dH/dT at constant D 4.742462536 (kJ/kg)/K dH/dT at constant P 4.178103606 (kJ/kg)/K dH/dD at constant P 2.053271073 (kJ/kg)(m^3/kg) dH/dD at constant T -15.20092767 (kJ/kg)(m^3/kg) dH/dP at constant T 0.920088075 (kJ/kg)/MPa dH/dP at constant D 7.731751891 (kJ/kg)/MPa dS/dT at constant D 0.013757391 (kJ/kg)/K^2 dS/dT at constant P 0.013927012 (kJ/kg)/K^2 dS/dD at constant T -0.000617121 (kJ/kg)(m^3/kg)/K dS/dD at constant P -0.050669759 (kJ/kg)(m^3/kg)/K dS/dP at constant T -0.000276537 (kJ/kg)/[MPaK] dS/dP at constant D 0.022429009 (kJ/kg)/[MPaK] Ideal gas pressure 138.0345137 MPa Ideal gas internal energy 2412.975655 kJ/kg Ideal gas enthalpy 2551.43107 kJ/kg Ideal gas entropy 3.642663073 (kJ/kg)/K Ideal gas isochoric heat capacity 1.403323543 (kJ/kg)/K Ideal gas isobaric heat capacity 1.864841593 (kJ/kg)/K Ideal gas speed of sound 428.9404872 m/s Ideal gas Helmholtz energy 1320.176733 kJ/kg Ideal gas Gibbs energy 1458.632148 kJ/kg Pressure minus ideal gas pressure -137.0345137 MPa Negative reciprocal temperature (-1/T) -0.003333333 1/K Fpv (supercompressibility factor) 0.324523621 - Gruneisen parameter 0.149070229 - Phase identification parameter -6.997512777 - (Z-1)/D -0.000995783 m^3/kg (Z-1)/P -0.992755435 1/MPa PV 0.001003049 MPa(m^3/kg) SD 391.6197575 (kJ/kg)(kg/m^3)/K Second virial coefficient -0.066682288 m^3/kg Third virial coefficient -0.012953916 (m^3/kg)^2 Fourth virial coefficient -2.464314981 (m^3/kg)^3 1st derivative of B with respect to T 0.001159532 (m^3/kg)/K 2nd derivative of B with respect to T -2.95183E-05 (m^3/kg)/K^2 1st derivative of C with respect to T 0.000442316 (m^3/kg)^2/K 2nd derivative of C with respect to T -1.65496E-05 (m^3/kg)^2/K^2 Second acoustic virial coefficient -0.120787638 m^3/kg Third acoustic virial coefficient 0.01294989 (m^3/kg)^2 Density at liquid spinodal 892.619298 kg/m^3 Density at vapor spinodal 0.365246572 kg/m^3 Specific heat input 15154.71719 kJ/kg Saturated heat capacity 4.180895103 (kJ/kg)/K dP/dT along the saturation line 0.000207903 MPa/K dH/dZ along the saturation line 8.635607949 kJ/kg Isochoric two-phase heat capacity 4.180876635 (kJ/kg)/K Heat of vaporization (for a pure fluid) 2437.289241 kJ/kg Heat of vap. (for a mixture at constant P) -677840253.7 kJ/kg Heat of vap. (for a mixture at constant T) 2437.289241 kJ/kg Heat of formation #[HEATFRM error 662] Heating values are not available for all species in the mixture. kJ/kg Heat of combustion 2443.260905 kJ/kg Gross (or superior) heating value 2438.975045 kJ/kg Net (or inferior) heating value 0.127953507 kJ/kg Gross heating value (Liquid) 0.108835192 kJ/kg Net heating value (Liquid) -2438.738256 kJ/kg Gross HV (Ideal gas volume basis) 17.61559882 MJ/m^3 Net HV (Ideal gas volume basis) 0.00092415 MJ/m^3 Critical temperature 647.096 K Critical pressure 22.064 MPa Critical density 322 kg/m^3 Temperature at cricondentherm 647.096 K Pressure at cricondentherm 22.064 MPa Density at cricondentherm 322 kg/m^3 Temperature at cricondenbar 647.096 K Pressure at cricondenbar 22.064 MPa Density at cricondenbar 322 kg/m^3 B12 0 m^3/kg Fugacity (first component) 0.003556305 MPa Fugacity coefficient (first component) 0.003556305 - Gas constant 0.46151805 (kJ/kg)/K Number of components in mixture 1 - Global warming potential (first component) -1 - Ozone depletion potential -1 - Dipole moment (first component) 1.855 debye Acentric Factor (first component) 0.3443 - Mole composition (first component) 1 - Mass composition (first component) 1 - Liquid phase fluid string Water|1.000000000 LIQUIDFLUIDSTRING Vapor phase fluid string Water|1.000000000 VAPORFLUIDSTRING Fluid name (first component) Water NAME Full name (first component) Water LONGNAME Fluid file name (first component) Water.FLD FLDNAME Fluid file directory C:/Program Files (x86)/REFPROP/fluids/Water.FLD FDIR Short chemical formula H2O CHEMFORM Long chemical formula H2O FULLCHEMFORM CAS number (first component) 7732-18-5 CAS# Hash identifier (first component) b43a7600 HASH Standard InChI String (first component) 1S/H2O/h1H2 INCHI Standard InChI Key (first component) XLYOFNOQVPJJNP-UHFFFAOYSA-N INCHIKEY Reference State (first component) OTH REFSTATE Synonym (first component) R-718 SYNONYM UN number (first component) Not available UNNUMBER

NickAtNight2017 commented 5 years ago

Great news ! It is working.

The new rules... Well, all equations start with 'refprop'. :(

The best way is to just use the Wizard. It will help you complete the equations.

Then you need no memory.

yangmengnist commented 5 years ago

thank you very much. Just as you commented, With this addin installed, the "REFPROP" tab has added to the Excel menu along the top like the pictures show below. image image thank you again.

NickAtNight2017 commented 5 years ago

However, there is another new feature.

If you press the 'Insert Function' button. It is just to the left of the equation. A1 (X) (Check) (Insert Function) =refprop(…)

Or, from the REFPROP menu, it is the first button.

There is now a Category. Use the dropdown menu to 'select a category'. There is a 'REFPROP' spot.

There should be two items in the list. FluidString10 REFPROP

This was going to be more useful with the old function scheme. When each function had an equation... density, pressure, etc.

But now we just have 2 equations.

Select your function, the help appears at the bottom of the screen.

For example: Fluidstring10(FluidNames, Compositions, MassMole, AllFluids) Create the code for a user defined mixture that can then be used in the call to the REFPORP function. First, specify the fluid names, then the fluid compositions, and then the mass or molar basis. Example-FluidString10(A1:A3,B1:B3,"Mass").

The "Help on this function" below that should load more help.

And Selecting OK will load the second help screen.

You can now enter information for each parameter. And the extra help information for each parameter will be displayed.

Fluidnames "Select the cells with he fluid names"

Compositions "Select the cells with the associated compositions"

MassMole "Enter "Mass" to specify that the input valves are on a mass basis for the compositions. Leave blank for molar compositions.

For REFPROP it says

REFPROP(OutputCode, FluidName, InpCode, Units, Prop1, Prop2, Prop3) To find the density of air with inputs of temperature at 273 K and pressure at 1 MPa with the output in SI units, use: Example=REFPROP("D","Air","TP","SI",273,1)

When completing the second page, the function will show you the result. So you know if you got it correct.

NickAtNight2017 commented 5 years ago

You are most welcome. ENJOY !!!

Oh, by the way.

Try selecting the 'Calculated Property' box (currently Density).

Then use the Up and Down arrows.

You can very quickly scroll through all of the different property results for those two input conditions !

NickAtNight2017 commented 5 years ago

My contact information is at the bottom of the ‘About’ button if you have any suggestions for improvements.

Let’s see if this trick works to post an image.

image

yangmengnist commented 5 years ago

thank you very much. i can see your image, and I posted images by copy the screenshot saved images. I use the WeChat client to take a screenshot,you can try it:https://weixin.qq.com/. thank you again.

yangmengnist commented 5 years ago

this is the interface of WeChat client. I hope to bring you convenience. image

NickAtNight2017 commented 5 years ago

I will give it a try.

Get Outlook for iOShttps://aka.ms/o0ukef


From: yangmengnist notifications@github.com Sent: Tuesday, December 11, 2018 9:05 AM To: usnistgov/REFPROP-wrappers Cc: Nicholas James; Comment Subject: Re: [usnistgov/REFPROP-wrappers] embed the REFPROP Version 10 in Excel 2016 (#83)

Attention: This is an EXTERNAL SENDER

this is the interface of WeChat client. I hope to bring you convenience. [image]https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F45703839%2F49809173-2fe28c80-fd99-11e8-8631-64cd93466c09.png&data=02%7C01%7CNicholas.james%40mexichem.com%7C642b0dc6d5a2484d78f908d65f7a0b4a%7Cfad75a54a3234cd08e516a8d57035aa8%7C1%7C0%7C636801375112810621&sdata=Ys%2FJt6b7uNceR4MEaus5OGBwl4Bvb3iSM9uHKRkCn1U%3D&reserved=0

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fusnistgov%2FREFPROP-wrappers%2Fissues%2F83%23issuecomment-446234456&data=02%7C01%7CNicholas.james%40mexichem.com%7C642b0dc6d5a2484d78f908d65f7a0b4a%7Cfad75a54a3234cd08e516a8d57035aa8%7C1%7C0%7C636801375112820625&sdata=BgGAitKDVNn3gZhWwCiauV%2F%2FHLve8o3MgirLElctk5I%3D&reserved=0, or mute the threadhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAeAdeKEfOEjUGg9iphuzAR-pl8dSHvDuks5u38mkgaJpZM4ZJp6E&data=02%7C01%7CNicholas.james%40mexichem.com%7C642b0dc6d5a2484d78f908d65f7a0b4a%7Cfad75a54a3234cd08e516a8d57035aa8%7C1%7C0%7C636801375112830634&sdata=2o9dRgKr%2Bz985OZJpOBM7kr5QBJgPOJYkTv9TjaJQQQ%3D&reserved=0.

The information contained in this email may be confidential and/or legally privileged. It has been sent for the sole use of the intended recipient(s). If the reader of this message is not an intended recipient, you are hereby notified that any unauthorized review, use, disclosure, dissemination, distribution, or copying of this communication, or any of its contents, is strictly prohibited and may be illegal. If you have received this communication in error, please reply to the sender and destroy all copies of the message.

NickAtNight2017 commented 5 years ago

Well, it seems the issue was with my browser.

I switched from Internet explorer to Edge and the pictures now load. Go figure.

test

yangmengnist commented 5 years ago

🆗

EricLemmon commented 5 years ago

Has this issue been resolved and can we close this now?

yangmengnist commented 5 years ago

yes, the issue was resolved.