ibell / coolprop

Deprecated version - go to
https://github.com/CoolProp/CoolProp
MIT License
24 stars 16 forks source link

how to install and use coolprop on ubuntu linux #247

Closed hyhzju closed 9 years ago

hyhzju commented 9 years ago

I am new to linux and has never used python.

I spend many hours on reading instructions provided by the coolprop webpage: http://coolprop.sourceforge.net/HowGetIt.html#how-to-get-it

However, I still have no idea how to use this coolprop. I have installed python 2.7.6, cython, GCC 4.8.2. I also downloaded a few source package and tried "easy_install CoolProp" etc.

and downloaded: CoolProp-4.2.5.zip http://iweb.dl.sourceforge.net/project/coolprop/CoolProp/4.2.5/Python/CoolProp-4.2.5.zip

But what should I do next?

Is there any GUI installed to my system? Can I use "./configure--->make--->make install..." things like that for other program source code?

Why I can not find some real basic and easy-understanding instructions/tutorials for compile, setup, and usage this great software? Step by step.

I believe such a document will be very helpful to anyone who just start to try.

jowr commented 9 years ago

Given that you use Ubuntu, you should install pip. I think sudo apt-get install python-pip does the trick. After that you can get CoolProp from pypi by running sudo pip install coolprop or pip install coolprop --prefix /home/user/where/you/want/it.

ibell commented 9 years ago

@jowr is correct. After installing pip, to install coolprop you just need a

pip install coolprop

at the command prompt.

On 10/23/14, Jorrit Wronski notifications@github.com wrote:

Given that you use Ubuntu, you should install pip. I think sudo apt-get install python-pip does the trick. After that you can get CoolProp from pypi by running sudo pip install coolprop or pip install coolprop --prefix /home/user/where/you/want/it.


Reply to this email directly or view it on GitHub: https://github.com/ibell/coolprop/issues/247#issuecomment-60205386

jjfPCSI1 commented 9 years ago

Hello,

2014-10-23 4:42 GMT+02:00 hyhzju notifications@github.com:

Why I can not find some real basic and easy-understanding instructions/tutorials for compile, setup, and usage this great software? Step by step.

I believe such a document will be very helpful to anyone who just start to try.

Here is a start,

https://github.com/CoolProp/CoolProp/blob/master/Web/coolprop/wrappers/Python/index.rst

JJ Fleck Physique et Informatique PCSI1 Lycée Kléber

hyhzju commented 9 years ago

Thanks so much for the prompt reply!! That's really fast. I followed "start" from your linked webpage. That makes more sense. I realized that a few python packages were not properly installed. Those are: numpy scipy matplotlib matplotlib.pyplot After installed those, I typed the import command: import CoolProp.CoolProp as CP No error message now. However, after I input all those example code. I got nothing. No results printed on the screen.

Then I tried the other commands in python environment, I got

Could you help me on that?

Best regards,

Yonghua Huang Mechanical Engineering School, Shanghai Jiao Tong Univeristy

At 2014-10-23 16:57:41, "Jean-Julien Joseph Fleck" notifications@github.com wrote: Hello,

2014-10-23 4:42 GMT+02:00 hyhzju notifications@github.com:

Why I can not find some real basic and easy-understanding instructions/tutorials for compile, setup, and usage this great software? Step by step.

I believe such a document will be very helpful to anyone who just start to try.

Here is a start,

https://github.com/CoolProp/CoolProp/blob/master/Web/coolprop/wrappers/Python/index.rst

JJ Fleck Physique et Informatique PCSI1 Lycée Kléber

— Reply to this email directly or view it on GitHub.

jjfPCSI1 commented 9 years ago

I fear that image attachment does not work with github messaging system.

It's normal that nothing ended printed on the screen because nothing was sent there. For exemple, the next code

import CoolProp.CoolProp as CP
fluid = 'Water'
pressure_at_critical_point = CP.PropsSI(fluid,'pcrit')
# Massic volume (in m^3/kg) is the inverse of density
# (or volumic mass in kg/m^3). Let's compute the massic volume of liquid
# at 1bar (1e5 Pa) of pressure
vL = 1/CP.PropsSI('D','P',1e5,'Q',0,fluid)
# Same for saturated vapor
vG = 1/CP.PropsSI('D','P',1e5,'Q',1,fluid)
print(vL,vG)

would print the two computed values on the screen because I asked it to via the print statement. Otherwise, values are computed for later use but not printed. If I copy/paste these instruction in the interactive python, I also have to explicitly "ask" for vL and vG variables in order to get the values printed

>>> import CoolProp.CoolProp as CP
>>> fluid = 'Water'
>>> pressure_at_critical_point = CP.PropsSI(fluid,'pcrit')
>>> # Massic volume (in m^3/kg) is the inverse of density
... # (or volumic mass in kg/m^3). Let's compute the massic volume of liquid
... # at 1bar (1e5 Pa) of pressure
... vL = 1/CP.PropsSI('D','P',1e5,'Q',0,fluid)
>>> # Same for saturated vapor
... vG = 1/CP.PropsSI('D','P',1e5,'Q',1,fluid)
>>> vL
0.0010431536977168858
>>> vG
1.6939276653850723
hyhzju commented 9 years ago

@jjfPCSI1 Thanks so much. It works. Cool. I am leaning a lot here and still learning it. I think I am getting more and more familiar with this great code, and 'm going to link it to my Fortran code as well as the Libreoffice Calc.

By the way, is there any GUI available for CoolProp? just like refprop?

ibell commented 9 years ago

Good to hear you got things working. No, I'm afraid we don't have a gui, it would be lots of work, want to write it? On Oct 24, 2014 10:57 AM, "hyhzju" notifications@github.com wrote:

@jjfPCSI1 https://github.com/jjfPCSI1 Thanks so much. It works. Cool. I am leaning a lot here and still learning it. I think I am getting more and more familiar with this great code, and 'm going to link it to my Fortran code as well as the Libreoffice Calc.

By the way, is there any GUI available for CoolProp? just like refprop?

— Reply to this email directly or view it on GitHub https://github.com/ibell/coolprop/issues/247#issuecomment-60398635.

hyhzju commented 9 years ago

I only have experience with VB 6.0 and VB.NET programming for GUI. Python is a completely new thing to me. Currently I am visiting ME school at Purdue University and the schedule is full.

I do wish to be able to call the CoolProp library in LibreOffice Calc at the first step and write an good interface for general calculation.

I noticed a conversation posted on the google group: https://groups.google.com/forum/#!topic/coolprop-users/1l4TxPGZBnI. It suggested to copy the attached coolprop.py to the directory $home/.config/libreoffice/4/. After google "libreoffice + python +macro", I learned that it should be more precisely to $home/.config/libreoffice/4/usr/Scripts/Python/. Or, put the file to /usr/lib/libreoffice/share/Scripts/python/, where I can find some other example python script macro, such as HelloWorld.py.

After loading the Libreoffice Calc I can find "coolprop" in menu Tools/Macros/Organize Macros/Pyhon/Libreoffice Macros/coolprop.

However, when I open the TestLibreOfficePy-3.ods file downloaded from the google group conversation, (Enable macro under security options), I got an error message,


BASIC runtime error. An exception occurred Type: com.sun.star.script.provider.ScriptFrameworkErrorException Message: <class 'pythonscript.com.sun.star.ucb.InteractiveAugmentedIOException'>: an error occurred during file opening /usr/lib/libreoffice/program/pythonscript.py:428 in function getModuleByUrl() [lastRead = self.sfa.getDateTimeModified( url )] /usr/lib/libreoffice/program/pythonscript.py:992 in function getScript() [mod = self.provCtx.getModuleByUrl( fileUri )]

.

The code line "oScript = oMSP.getScript(sURL)" was highlighted in the function invokePyFunc(). It seems the file name passed to that function was not correct/accepted.

What's wrong there? Can anyone help me?

 Good to hear you got things working.  No, I'm afraid we don't have a gui,
 it would be lots of work, want to write it?
ibell commented 9 years ago

Are you on windows? If so, LibreOffice is quite easy to interface with - its just like using Excel. See the docs at http://www.coolprop.dreamhosters.com:8010/sphinx/coolprop/wrappers/LibreOffice/index.html#libreoffice

On Sat, Oct 25, 2014 at 10:28 PM, hyhzju notifications@github.com wrote:

I only have experience with VB 6.0 and VB.NET programming for GUI. Python is a completely new thing to me. Currently I am visiting ME school at Purdue University and the schedule is full.

I do wish to be able to call the CoolProp library in LibreOffice Calc at the first step and write an good interface for general calculation.

I noticed a conversation posted on the google group: https://groups.google.com/forum/#!topic/coolprop-users/1l4TxPGZBnI. It suggested to copy the attached coolprop.py to the directory $home/.config/libreoffice/4/. After google "libreoffice + python +macro", I learned that it should be more precisely to $home/.config/libreoffice/4/usr/Scripts/Python/. Or, put the file to /usr/lib/libreoffice/share/Scripts/python/, where I can find some other example python script macro, such as HelloWorld.py.

After loading the Libreoffice Calc I can find "coolprop" in menu Tools/Macros/Organize Macros/Pyhon/Libreoffice Macros/coolprop.

However, when I open the TestLibreOfficePy-3.ods file downloaded from the google group conversation, (Enable macro under security options), I got an

error message,

BASIC runtime error. An exception occurred Type: com.sun.star.script.provider.ScriptFrameworkErrorException Message: : an error occurred during file opening /usr/lib/libreoffice/program/pythonscript.py:428 in function getModuleByUrl() [lastRead = self.sfa.getDateTimeModified( url )] /usr/lib/libreoffice/program/pythonscript.py:992 in function getScript() [mod = self.provCtx.getModuleByUrl( fileUri )] .

The code line "oScript = oMSP.getScript(sURL)" was highlighted in the function invokePyFunc(). It seems the file name passed to that function was not correct/accepted.

What's wrong there? Can anyone help me?

Good to hear you got things working. No, I'm afraid we don't have a gui, it would be lots of work, want to write it?

— Reply to this email directly or view it on GitHub https://github.com/ibell/coolprop/issues/247#issuecomment-60504370.

ibell commented 9 years ago

Doh I just re-read your subject line again. Linux. Let's see if I can figure out what is going on.

On Sun, Oct 26, 2014 at 8:24 AM, Ian Bell ian.h.bell@gmail.com wrote:

Are you on windows? If so, LibreOffice is quite easy to interface with - its just like using Excel. See the docs at http://www.coolprop.dreamhosters.com:8010/sphinx/coolprop/wrappers/LibreOffice/index.html#libreoffice

On Sat, Oct 25, 2014 at 10:28 PM, hyhzju notifications@github.com wrote:

I only have experience with VB 6.0 and VB.NET programming for GUI. Python is a completely new thing to me. Currently I am visiting ME school at Purdue University and the schedule is full.

I do wish to be able to call the CoolProp library in LibreOffice Calc at the first step and write an good interface for general calculation.

I noticed a conversation posted on the google group: https://groups.google.com/forum/#!topic/coolprop-users/1l4TxPGZBnI. It suggested to copy the attached coolprop.py to the directory $home/.config/libreoffice/4/. After google "libreoffice + python +macro", I learned that it should be more precisely to $home/.config/libreoffice/4/usr/Scripts/Python/. Or, put the file to /usr/lib/libreoffice/share/Scripts/python/, where I can find some other example python script macro, such as HelloWorld.py.

After loading the Libreoffice Calc I can find "coolprop" in menu Tools/Macros/Organize Macros/Pyhon/Libreoffice Macros/coolprop.

However, when I open the TestLibreOfficePy-3.ods file downloaded from the google group conversation, (Enable macro under security options), I got an

error message,

BASIC runtime error. An exception occurred Type: com.sun.star.script.provider.ScriptFrameworkErrorException Message: : an error occurred during file opening /usr/lib/libreoffice/program/pythonscript.py:428 in function getModuleByUrl() [lastRead = self.sfa.getDateTimeModified( url )] /usr/lib/libreoffice/program/pythonscript.py:992 in function getScript() [mod = self.provCtx.getModuleByUrl( fileUri )] .

The code line "oScript = oMSP.getScript(sURL)" was highlighted in the function invokePyFunc(). It seems the file name passed to that function was not correct/accepted.

What's wrong there? Can anyone help me?

Good to hear you got things working. No, I'm afraid we don't have a gui, it would be lots of work, want to write it?

— Reply to this email directly or view it on GitHub https://github.com/ibell/coolprop/issues/247#issuecomment-60504370.

ibell commented 9 years ago

Ok, I got it working. Here's a recipe:

Make a folder for the script to reside in

mkdir -p ~/.config/libreoffice/4/user/Scripts/python/

Copy the dowloaded .py file to the folder you made (adjust download path

as necessary) cp ~/Downloads/coolprop.py ~/.config/libreoffice/4/user/Scripts/python/

Install python script provider (uses python 3)

sudo apt-get install libreoffice-script-provider-python

pyton scripting in LibreOffice uses python3, make sure we populate the

right python site-packages folder sudo apt-get install python3-pip sudo pip3 install Cython

Compile CoolProp v5+ manually

you need to have numpy and matplotlib already - you can do sudo apt-get

install python3-matplotlib git clone http://github.com/CoolProp/CoolProp --recursive cd CoolProp/wrappers/Python sudo python3 setup.py install

Open example in LibreOffice

On Sun, Oct 26, 2014 at 8:46 AM, Ian Bell ian.h.bell@gmail.com wrote:

Doh I just re-read your subject line again. Linux. Let's see if I can figure out what is going on.

On Sun, Oct 26, 2014 at 8:24 AM, Ian Bell ian.h.bell@gmail.com wrote:

Are you on windows? If so, LibreOffice is quite easy to interface with - its just like using Excel. See the docs at http://www.coolprop.dreamhosters.com:8010/sphinx/coolprop/wrappers/LibreOffice/index.html#libreoffice

On Sat, Oct 25, 2014 at 10:28 PM, hyhzju notifications@github.com wrote:

I only have experience with VB 6.0 and VB.NET programming for GUI. Python is a completely new thing to me. Currently I am visiting ME school at Purdue University and the schedule is full.

I do wish to be able to call the CoolProp library in LibreOffice Calc at the first step and write an good interface for general calculation.

I noticed a conversation posted on the google group: https://groups.google.com/forum/#!topic/coolprop-users/1l4TxPGZBnI. It suggested to copy the attached coolprop.py to the directory $home/.config/libreoffice/4/. After google "libreoffice + python +macro", I learned that it should be more precisely to $home/.config/libreoffice/4/usr/Scripts/Python/. Or, put the file to /usr/lib/libreoffice/share/Scripts/python/, where I can find some other example python script macro, such as HelloWorld.py.

After loading the Libreoffice Calc I can find "coolprop" in menu Tools/Macros/Organize Macros/Pyhon/Libreoffice Macros/coolprop.

However, when I open the TestLibreOfficePy-3.ods file downloaded from the google group conversation, (Enable macro under security options), I got

an error message,

BASIC runtime error. An exception occurred Type: com.sun.star.script.provider.ScriptFrameworkErrorException Message: : an error occurred during file opening /usr/lib/libreoffice/program/pythonscript.py:428 in function getModuleByUrl() [lastRead = self.sfa.getDateTimeModified( url )] /usr/lib/libreoffice/program/pythonscript.py:992 in function getScript() [mod = self.provCtx.getModuleByUrl( fileUri )] .

The code line "oScript = oMSP.getScript(sURL)" was highlighted in the function invokePyFunc(). It seems the file name passed to that function was not correct/accepted.

What's wrong there? Can anyone help me?

Good to hear you got things working. No, I'm afraid we don't have a gui, it would be lots of work, want to write it?

— Reply to this email directly or view it on GitHub https://github.com/ibell/coolprop/issues/247#issuecomment-60504370.

ibell commented 9 years ago

I think that error is because it wants it in the ~/.config/... location. See my recipe below

On Sat, Oct 25, 2014 at 10:28 PM, hyhzju notifications@github.com wrote:

I only have experience with VB 6.0 and VB.NET programming for GUI. Python is a completely new thing to me. Currently I am visiting ME school at Purdue University and the schedule is full.

I do wish to be able to call the CoolProp library in LibreOffice Calc at the first step and write an good interface for general calculation.

I noticed a conversation posted on the google group: https://groups.google.com/forum/#!topic/coolprop-users/1l4TxPGZBnI. It suggested to copy the attached coolprop.py to the directory $home/.config/libreoffice/4/. After google "libreoffice + python +macro", I learned that it should be more precisely to $home/.config/libreoffice/4/usr/Scripts/Python/. Or, put the file to /usr/lib/libreoffice/share/Scripts/python/, where I can find some other example python script macro, such as HelloWorld.py.

After loading the Libreoffice Calc I can find "coolprop" in menu Tools/Macros/Organize Macros/Pyhon/Libreoffice Macros/coolprop.

However, when I open the TestLibreOfficePy-3.ods file downloaded from the google group conversation, (Enable macro under security options), I got an

error message,

BASIC runtime error. An exception occurred Type: com.sun.star.script.provider.ScriptFrameworkErrorException Message: : an error occurred during file opening /usr/lib/libreoffice/program/pythonscript.py:428 in function getModuleByUrl() [lastRead = self.sfa.getDateTimeModified( url )] /usr/lib/libreoffice/program/pythonscript.py:992 in function getScript() [mod = self.provCtx.getModuleByUrl( fileUri )] .

The code line "oScript = oMSP.getScript(sURL)" was highlighted in the function invokePyFunc(). It seems the file name passed to that function was not correct/accepted.

What's wrong there? Can anyone help me?

Good to hear you got things working. No, I'm afraid we don't have a gui, it would be lots of work, want to write it?

— Reply to this email directly or view it on GitHub https://github.com/ibell/coolprop/issues/247#issuecomment-60504370.

hyhzju commented 9 years ago

I followed your recipe and It works perfectly! Thanks. I want to mention that previously, 1) I created a fold "Python" instead of "python" in the ~/.config/libreoffice/4/user/Scripts directory 2) I was using Python 2.7.6 instead of 3.x

  1. I was using CoolProp 4.2.6 I don't know if they matter. but anyway, the problem is solved now.
ibell commented 9 years ago

Excellent news. LO support for python is pretty rough and badly documented. Glad to hear it works now! On Oct 27, 2014 3:24 PM, "hyhzju" notifications@github.com wrote:

I followed the your recipe and It works perfectly! Thanks. I want to mention that previously, 1) I created a fold "Python" instead of "python" in the ~/.config/libreoffice/4/user/Scripts directory 2) I was using Python 2.7.6 instead of 3.x

  1. I was using CoolProp 4.2.6 I don't know if they matter. but anyway, the problem is solved now.

— Reply to this email directly or view it on GitHub https://github.com/ibell/coolprop/issues/247#issuecomment-60653692.