Need help. Coolprop for Matlab.

210 views
Skip to first unread message

Vilde Lund Aarskog

unread,
Feb 22, 2022, 11:00:43 AM2/22/22
to coolprop-users
Hi, im using Matlab for a project, and i want to try out coolprop. Both coolprop and python. is new to me. Ive tried to do some research on how to make it work, but i still dont get it. Only figured out so far that python 3.9 doesnt work, not sure how i can get 3.8. 
Is there any step by step solution to make coolprop work in Matlab for WIndows or OSX? 

Michael LaPresti

unread,
Feb 23, 2022, 3:21:09 PM2/23/22
to coolprop-users
I have worked with CoolProp and Matlab quite a bit over the last few years. 


I am using the Anaconda distribution of Python Version 3.8. 

can...@gmail.com

unread,
Feb 25, 2022, 9:52:58 AM2/25/22
to coolprop-users
I give this document to my students. It works for windows. Hopefully it will work for you. Note that we suggest Python 3.7 and are using Matlab R2021a. Good luck.

1.      In MATLAB type the command pyversion into the command window. If no version of python is shown then complete the following 3 steps. If you do have a version of python then go directly to step 2.

a.       Go to python.org and download a 64 bit version of python. As of the writing of this document a 64 bit version of python is located at https://www.python.org/downloads/release/python-371/. I used the Windows x86-64 web-based installer version (scroll to the bottom to see it), and it worked well.

 

b.      Locate where the python executable (python.exe) was installed on your computer. In my case it was installed at C:\Users\AppData\Local\Programs\Python\Python37\python.exe

Note: I had some trouble with part c below when there were spaces in the directory path.  Make sure you install it in a directory without spaces in any directory names. (e.g., C:\Program Files\Python\Python37\python did not work in part c below because of the space between Program and Files.)

 

c.       The first time you install python you will need to run the following command from the matlab command window. You only need to do this once. Note that you will need to provide the full path to the python executable you determined in step 2 when using the pyversion function.

pyversion 'C:\Users\AppData\Local\Programs\Python\Python37\python.exe'

2. The first time you wish to use CoolProp you will need to do the following

 

[v,e] = pyversion; system([e,' -m pip install --user -U CoolProp'])

 

This command will download and install CoolProp on your computer.

 

3.       For any matlab script that calls CoolProp, after the “clear all; close all; clc;” in your script, add the line

import py.CoolProp.CoolProp.*

 

4.      You can confirm that everything is working correctly by calling Coolprop using

PropsSI('T','P',101325,'Q',0,'Water')

If you have done anything correctly you should get 373.1243.

 

Note that you could do step 3 and 4 from the command window as well.



On Tuesday, February 22, 2022 at 11:00:43 AM UTC-5 vila...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages