Installation and Configuration¶
Prerequisites¶
git¶
WINDOWS :
- Install the most recent version for windows from git for windows. Accept all the defaults.
- (optional, but strongly recommended) Install TortoiseGit from TortoiseGit installs (pick the right version for your operating system)
LINUX/OSX :
Your operating system should already come with git. You should not need to do anything extra
Anaconda/Miniconda¶
- Download python using miniconda package: Download link. Download the python 2.7 32-bit version of miniconda - the python 2.7 64-bit version should be fine too, but to compile you will require the professional version of Visual Studio. So just stick with the 32-bit version of miniconda. Do not use a python 3.x version!!
- Run the installer. In the setup, if you are doing a clean install, it is safe to select the option “Add Anaconda to the system PATH environmental variable”. Otherwise, selecting this option will make this the default conda installation on your computer, which may or may not be what you want. If you want Miniconda to live peaceably with an existing miniconda (64-bit?), make sure this option is unselected.
Compiler¶
WINDOWS :
Run the installer for Microsoft Visual C++ Compiler for Python 2.7 (or install Visual Studio 9 2008 professional if you have access to it).
LINUX/OSX :
Your operating system might already come with a compiler. In that case, you should not need to do anything else. On debian-base linux distros, you probably need to do something like:
sudo apt install g++
On OSX, install Xcode, or install gcc via homebrew.
Windows¶
Populate the root conda environment installation the with necessary packages (or see below about using conda environments). At the command prompt, do:
conda install matplotlib numpy scipy h5py cython pip wxpython pyyaml
If you installed Miniconda somewhere else (and/or Miniconda/Scripts is not on the PATH), you might need to give the full path to
conda, which would be something likec:\Miniconda32bit\Scripts\condaon my machineCheck that when you go to a command prompt, you get output something like:
C:\Users\Belli>python Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import scipy >>> scipy.__version__ '0.11.0'
Ok, python has been successfully installed.
Now we are going to collect the source code for PDSim. In Windows Explorer, go to a folder where you want to put the source code for PDSim. Right-click and select “Git Clone…”
Use the URL
https://github.com/ibell/pdsim.To install coolprop, at the command prompt execute:
pip install coolprop
If you want to install the most recent version of coolprop (the above command will install the latest STABLE release), see the instructions here
Install PDSim using:
python setup.py install
If you start a command prompt and run the command
python, you can try to import each of the required python packages using the code below. This will allow you to check whether all the necessary files are included, and where they have been installed to. If none of the following commands give you errors, you are ready to proceed.
In [1]: import CoolProp,matplotlib,Cython,PDSim,wx,numpy,scipy,yaml
ImportErrorTraceback (most recent call last)
<ipython-input-1-36db05d80caf> in <module>()
----> 1 import CoolProp,matplotlib,Cython,PDSim,wx,numpy,scipy,yaml
ImportError: No module named wx
In [2]: CoolProp.__version__, CoolProp.__file__
Out[2]:
(u'6.2.1',
'/home/docs/checkouts/readthedocs.org/user_builds/pdsim/conda/stable/lib/python2.7/site-packages/CoolProp/__init__.pyc')
In [3]: matplotlib.__version__, matplotlib.__file__
Out[3]:
('2.2.3',
'/home/docs/checkouts/readthedocs.org/user_builds/pdsim/conda/stable/lib/python2.7/site-packages/matplotlib/__init__.pyc')
In [4]: Cython.__version__, Cython.__file__
Out[4]:
('0.29.1',
'/home/docs/checkouts/readthedocs.org/user_builds/pdsim/conda/stable/lib/python2.7/site-packages/Cython/__init__.pyc')
In [5]: PDSim.__version__, PDSim.__file__
Out[5]:
('2.11',
'/home/docs/checkouts/readthedocs.org/user_builds/pdsim/conda/stable/lib/python2.7/site-packages/PDSim-2.11-py2.7-linux-x86_64.egg/PDSim/__init__.pyc')
In [6]: wx.version(), wx.__file__
NameErrorTraceback (most recent call last)
<ipython-input-6-2203061925bb> in <module>()
----> 1 wx.version(), wx.__file__
NameError: name 'wx' is not defined
In [7]: numpy.__version__, numpy.__file__
NameErrorTraceback (most recent call last)
<ipython-input-7-0d31ef7bf63e> in <module>()
----> 1 numpy.__version__, numpy.__file__
NameError: name 'numpy' is not defined
In [8]: scipy.__version__, scipy.__file__
NameErrorTraceback (most recent call last)
<ipython-input-8-1efa7b3f9e09> in <module>()
----> 1 scipy.__version__, scipy.__file__
NameError: name 'scipy' is not defined
In [9]: yaml.__version__, yaml.__file__
NameErrorTraceback (most recent call last)
<ipython-input-9-420a25fd9378> in <module>()
----> 1 yaml.__version__, yaml.__file__
NameError: name 'yaml' is not defined
- Now go into the doc folder, start IPython, the below code should yield output something like:
In [10]: %run '../examples/simple_example.py'
Elapsed time for cycle is 0.873997 s
New outlet T: 400.0 K
===========
|| # 000 ||
===========
||....................|..@..........................|| energy balance kW -0.0313473302944 Tlumps: [398.93378939465816] K
||....................|..................@..........|| discharge state -4.445133016720945 h_pump_set: 571.3609880363598 kJ/kg 526.909657869 kJ/kg
||....................|.......@.....................|| cycle-cycle 0.14526734161333166
||..................................|.@.............|| mdot [%] 2.0738573451275055 || in: 0.4973111066552488 g/s || out: 0.5076246295687536 g/s
Elapsed time for cycle is 0.985601 s
New outlet T: 400.0 K
===========
|| # 001 ||
===========
||....................|..@..........................|| energy balance kW -0.0309151247839 Tlumps: [345.54848268055923] K
||....................|..................@..........|| discharge state -5.209644885191392 h_pump_set: 579.0608900936079 kJ/kg 526.964441242 kJ/kg
||....................|..@..........................|| cycle-cycle 0.02401642640722013
||...............................@..|...............|| mdot [%] 0.3275018600415347 || in: 0.49735587418452964 g/s || out: 0.49898472392350984 g/s
Elapsed time for cycle is 0.872112 s
New outlet T: 400.0 K
===========
|| # 002 ||
===========
||....................@.............................|| energy balance kW -0.00927453743518 Tlumps: [329.53289066633016] K
||....................|..................@..........|| discharge state -4.703580968599079 h_pump_set: 576.6602483086508 kJ/kg 529.624438623 kJ/kg
||...................@|.............................|| cycle-cycle 0.007454454994477442
||...........................@......|...............|| mdot [%] -0.10065041022501164 || in: 0.5021491719111097 g/s || out: 0.5016437567096397 g/s
Elapsed time for cycle is 0.912247 s
New outlet T: 400.0 K
===========
|| # 003 ||
===========
||................@...|.............................|| energy balance kW -0.00278236123055 Tlumps: [324.7282130620614] K
||....................|..................@..........|| discharge state -4.473443461354441 h_pump_set: 575.191992096758 kJ/kg 530.457557483 kJ/kg
||.................@..|.............................|| cycle-cycle 0.004531238166263477
||.........................@........|...............|| mdot [%] -0.05978438656979446 || in: 0.5035957100274353 g/s || out: 0.5032946384214035 g/s
Elapsed time for cycle is 0.87058 s
New outlet T: 400.0 K
===========
|| # 004 ||
===========
||............@.......|.............................|| energy balance kW -0.000834708369166 Tlumps: [323.2868097807808] K
||....................|..................@..........|| discharge state -4.391124637829569 h_pump_set: 574.6330356324693 kJ/kg 530.721789254 kJ/kg
||...............@....|.............................|| cycle-cycle 0.0018251560092230896
||.......................@..........|...............|| mdot [%] -0.02664741337610188 || in: 0.5040411678342289 g/s || out: 0.5039068539006504 g/s
Elapsed time for cycle is 0.9831 s
[[526.9096589519077, -4.364331135208409]]
New outlet T: 404.917190845 K
===========
|| # 005 ||
===========
||........@...........|.............................|| energy balance kW -0.00025041251075 Tlumps: [322.8543887963966] K
||....................|..................@..........|| discharge state -4.364331135208409 h_pump_set: 574.4464136613336 kJ/kg 530.803102309 kJ/kg
||...........@........|.............................|| cycle-cycle 0.0005406271159482229
||...............@..................|...............|| mdot [%] -0.0019095634660515337 || in: 0.5041564124868508 g/s || out: 0.5041467853001862 g/s
Elapsed time for cycle is 0.867984 s
[[526.9096589519077, -4.364331135208409], [531.9096589519066, -3.8373060110809547]]
New outlet T: 431.720235877 K
===========
|| # 006 ||
===========
||.....@..............|.............................|| energy balance kW -7.5123753225e-05 Tlumps: [322.72466250108135] K
||....................|.................@...........|| discharge state -3.8373060110809547 h_pump_set: 574.3874234772438 kJ/kg 536.014363366 kJ/kg
||.........@..........|.............................|| cycle-cycle 0.00026161702241045783
||..................@...............|...............|| mdot [%] -0.004667939858549186 || in: 0.5042257909848876 g/s || out: 0.5042022540282131 g/s
Elapsed time for cycle is 0.859643 s
[[526.9096589519077, -4.364331135208409], [531.9096589519066, -3.8373060110809547], [559.2136656923329, -1.0196237198280642]]
New outlet T: 438.979018267 K
===========
|| # 007 ||
===========
||.@..................|.............................|| energy balance kW -2.25371259675e-05 Tlumps: [322.68574461248676] K
||....................|.............@...............|| discharge state -1.0196237198280642 h_pump_set: 574.3692292124606 kJ/kg 564.172992014 kJ/kg
||.....@..............|.............................|| cycle-cycle 7.682871864906581e-05
||..............@...................|...............|| mdot [%] -0.0013486384596861356 || in: 0.5042265651106026 g/s || out: 0.5042197649172215 g/s
Elapsed time for cycle is 0.890985 s
[[526.9096589519077, -4.364331135208409], [531.9096589519066, -3.8373060110809547], [559.2136656923329, -1.0196237198280642], [566.6239616486889, -0.2593093132446597]]
New outlet T: 440.834606764 K
===========
|| # 008 ||
===========
|@....................|.............................|| energy balance kW -6.76113779024e-06 Tlumps: [322.6740692459084] K
||....................|.........@...................|| discharge state -0.2593093132446597 h_pump_set: 574.3637227632476 kJ/kg 571.770629631 kJ/kg
||@...................|.............................|| cycle-cycle 1.5498233605938426e-05
||.....@............................|...............|| mdot [%] -9.373689338065816e-05 || in: 0.5042271856233093 g/s || out: 0.5042267129764099 g/s
Elapsed time for cycle is 0.878147 s
[[526.9096589519077, -4.364331135208409], [531.9096589519066, -3.8373060110809547], [559.2136656923329, -1.0196237198280642], [566.6239616486889, -0.2593093132446597], [568.5194525851463, -0.06506265448406338]]
New outlet T: 441.300677186 K
===========
|| # 009 ||
===========
|@....................|.............................|| energy balance kW -2.02834133708e-06 Tlumps: [322.6705666359349] K
||....................|.....@.......................|| discharge state -0.06506265448406338 h_pump_set: 574.3621033135796 kJ/kg 573.711476769 kJ/kg
||.......@............|.............................|| cycle-cycle 0.00015361370898694807
||................@.................|...............|| mdot [%] -0.002719762684755267 || in: 0.5042289312656476 g/s || out: 0.5042152174353293 g/s
Elapsed time for cycle is 0.945065 s
[[526.9096589519077, -4.364331135208409], [531.9096589519066, -3.8373060110809547], [559.2136656923329, -1.0196237198280642], [566.6239616486889, -0.2593093132446597], [568.5194525851463, -0.06506265448406338], [568.9956216708707, -0.016304678964672803]]
New outlet T: 441.417563008 K
===========
|| # 010 ||
===========
|@....................|.............................|| energy balance kW -6.08502401127e-07 Tlumps: [322.6695158529428] K
||....................|@............................|| discharge state -0.016304678964672803 h_pump_set: 574.3616086491127 kJ/kg 574.198561859 kJ/kg
||.@..................|.............................|| cycle-cycle 2.5972999554938735e-05
||..........@.......................|...............|| mdot [%] -0.00046502234921641517 || in: 0.5042158634679976 g/s || out: 0.5042135187515442 g/s
Elapsed time for cycle is 0.871296 s
[[526.9096589519077, -4.364331135208409], [531.9096589519066, -3.8373060110809547], [559.2136656923329, -1.0196237198280642], [566.6239616486889, -0.2593093132446597], [568.5194525851463, -0.06506265448406338], [568.9956216708707, -0.016304678964672803], [569.1150449651043, -0.0040632736977499915]]
New outlet T: 441.446661032 K
===========
|| # 011 ||
===========
|@....................|.............................|| energy balance kW -1.8255072033e-07 Tlumps: [322.66920061804524] K
||.................@..|.............................|| discharge state -0.0040632736977499915 h_pump_set: 574.3613826080903 kJ/kg 574.320749871 kJ/kg
||........@...........|.............................|| cycle-cycle 0.00018889320515456964
||................@.................|...............|| mdot [%] 0.003302484635447911 || in: 0.5042137373494463 g/s || out: 0.5042303889306521 g/s
Ntheta is 7001
mdot*(h2-h1),P-v,Qamb 0.08294932238542045 0.07491683708054035 -0.0100001825507
Mass flow rate is 0.5042137373494463 g/s
Volumetric efficiency is 88.69409313965578 %
Adiabatic efficiency is 100.597156192 %
time taken 10.82948 s
- Ok good, PDSim is working!
- Go to the GUI folder from the root of the source. Double-click on PDSimGUI.py to start
- Press F5 to run the default scroll compressor
- Wait about 80 seconds for it to finish
Linux and OSX¶
The procedure is nearly identical on linux and OSX, apart from the fact that you do not need to install git or Microsoft Visual Studio. Use the anaconda installer to get python 2.7 64-bit, follow the windows instructions otherwise
Update source code¶
When the code for PDSim is updated, all that you have to do to update the code is to go to the top-level folder where you installed PDSim, right-click and select “TortoiseGit->Pull…” and then OK
If you want to update CoolProp to the most recent code, you can use TortoiseGit. Go to the root folder of the cloned git files, right click and select “TortoiseGit->Submodule update…”. Make sure the following options are selected:
* Initialize submodules(--init)
* Merge
* Remote tracking branch
Press Ok button.
Alternatively, you can do the update from the command line:
git.exe submodule update --init --merge --remote "externals/coolprop"
See also StackOverflow question
Profiling¶
I use a couple of different tools for profiling. One is RunSnakeRun. Install RunSnakeRun using:
easy_install SquareMap RunSnakeRun
and line_profiler, which can be obtained from http://pypi.python.org/pypi/line_profiler . Open the zip file, go to the folder and run:
python setup.py install
Uninstallation¶
To uninstall PDSim, go to the site-packages folder corresponding to the installation of python (probably c:\Python27\Lib\site-packages), delete the folder PDSim. You might want to also delete any files like PDSim-x.x.x-py2.7.egg-info where x are numbers. For a thorough uninstallation, you might also want to remove the build folder in the directory where you cloned the git files
Using conda environments¶
If you have multiple versions of python or PDSim floating around, it can be useful to use conda to create conda environments that encapsulate the desired versions of each of the pieces. This can be easily carried out at the command line. For instance, we might create an environment (named pdsim_stable) with the most up to date version of PDSim and its dependencies. There is a file called RTDenvironment.yml in the root of the repository. This file can be used to create a conda environment with:
conda env create --name pdsim_stable --file RTDenvironment.yml
To activate this new environment on windows, you do:
activate pdsim_stable
If on linux/OSX, you need to do:
source activate pdsim_stable
To remove the environment you created without confirmation (thanks to -y), do:
conda env remove -y -n pdsim_stable
Use PDSim¶
It is recommended to use Eclipse (pick the Eclipse IDE for C/C++ development because it is the smallest) to do the development. Once Eclipse is installed, you will want the Pydev plugin. Once Eclipse is open, go to the menu Help–>Install New Software… Click Add… and add http://pydev.org/updates to the sources. Then go back and you should be able to install pydev. Don’t install mylyn integration.
SciTE is also nice for doing python development. Here are the user options I use and recommend:
tabsize=4
indent.size=4
use.tabs=0
wrap=1
minimize.to.tray=0
open.dialog.in.file.directory=1
buffers=40
statusbar.visible=1
split.vertical=0
title.full.path=1
# one instance of SciTE only
check.if.already.open=1
are.you.sure.on.reload=1
font.base=$(font.monospace)
font.small=$(font.monospace)
font.comment=$(font.monospace)
font.text=$(font.monospace)
font.text.comment=$(font.monospace)
font.embedded.base=$(font.monospace)
font.embedded.comment=$(font.monospace)
font.vbs=$(font.monospace)