PDSim Tutorial

This tutorial will walk a windows user step-by-step through the use of PDSim on a windows platform machine

Pre-Requisites

Requirements:

  • TortoiseGit Download an installer and install. If you get errors about not having MSYS git, you can download MSYSGIT from msysgit
  • Python(x,y) (Version 2.7.2.3 used here). Download and install the full installation. When you go to install, you need to ensure that under Packages, you have cython, wxpython, matplotlib, nose, scipy, numpy checked, and under Other, you want SciTE, WinMerge, MinGW and SWIG.
  • CoolProp - see installation instructions in CoolProp installation. The easiest solution is just to download and run the nightly build from http://sourceforge.net/projects/coolprop/files/CoolProp/Nightly/
  • A C++ compiler. If you installed MinGW from Python(x,y), you are are all set. Otherwise you can get a copy of Microsoft Visual Studio 2008 C++ Express for free and it works great
  • Eclipse + pydev (pick the Eclipse IDE for C/C++ development because it is the smallest) - An integrated design environment for writing Python code. 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.

Getting the necessary files

Somewhere on your computer, right-click on a folder as below and select Git Clone...

../_images/page002.png

then set the path to the repository and the folder on your computer where the files will be saved. Doesn’t matter what folder you select, though in general if it better to use a path without spaces. Click the OK button, and the files will be downloaded into that folder.

../_images/page003.png

Saving the files is successful

../_images/page004.png

You will then need to install the PDSim module files. The easiest solution is just to download a nightly build from http://sourceforge.net/projects/pdsim/files/Nightly/ (select the newest file), download and install it.

If you want to install PDSim from source, open a command line prompt (Start button -> type cmd into the search box). Change the directory to the directory where you installed the files. If you have installed MinGW as recommended above, you can install PDSim by running:

python setup.py build --compiler=mingw32 install

Otherwise if you have Microsoft Visual Studio installed, you can just run:

python setup.py install
../_images/page017.png

which should ultimately yield something like

../_images/page018.png

Make sure that the last line says something like Writing C:\Python27\Lib\site-packages\PDSim-0.0.1-py2.7.egg-info. This means the files have been installed properly.

Checking installed files

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

In [2]: print CoolProp.__file__; print CoolProp.__version__
C:\Miniconda\lib\site-packages\coolprop-5.0.0-py2.7-win-amd64.egg\CoolProp\__init__.pyc
5.0.0

In [3]: print matplotlib.__file__; print matplotlib.__version__
C:\Miniconda\lib\site-packages\matplotlib\__init__.pyc
1.3.1

In [4]: print Cython.__file__; print Cython.__version__
C:\Miniconda\lib\site-packages\Cython\__init__.pyc
0.20.2

In [5]: print PDSim.__file__; print PDSim.__version__
c:\users\belli\documents\code\pdsim-git\PDSim\__init__.pyc
2.8

In [6]: print wx.__file__; print wx.version()
C:\Miniconda\lib\site-packages\wx-3.0-msw\wx\__init__.pyc
3.0.0.0 msw (classic)

In [7]: print numpy.__file__; print numpy.__version__
C:\Miniconda\lib\site-packages\numpy\__init__.pyc
1.8.2

In [8]: print scipy.__file__; print scipy.__version__
C:\Miniconda\lib\site-packages\scipy\__init__.pyc
0.14.0

Running the sample files

You have python on your computer because you installed Python(x,y). Assuming the installation went as expected, you should be able to just browse to the folder you installed the source files, go into the examples sub-folder and double click on the file PURecip.py and you should get a window that looks something like this:

../_images/page005.png

When the run finshes you will get a window that opens with a few possible plots.

../_images/page006.png

Click on a button to generate a plot. In this case, clicking on the pressure v. volume button gives

../_images/page007.png

You can also zoom in on the plot by clicking the magnifying button and selecting a range with the mouse.

../_images/page008.png

Doing this a few times allows you to see that at the end of the rotation there is a bit of oscillation due to the relatively high flow rate for the relatively small volume

../_images/page009.png

Code Development in Eclipse

Setup

The first time you start up Eclipse you may have to do a bit of configuration. For your information, eclipse installs some files in HOME/.eclipse where HOME is the path to your home folder (c:\Users\username on Windows 7)

Eclipse may ask you for a default workspace folder, just select the default and tell it to remember your choice. This is simply where it will default to create a new project, but it’s not that important and I almost never make projects in the default folder anyway.

Eclipse might not find your python installation by default, but is relatively straightforward to set up a new interpreter. To check and/or set your python interpreter, go to Window->Preferences in the top menu. Then expand pydev by clicking the arrow left to pydev and select Interpreter - Python. If you see your python interpreter there, you are all set and go to the next section.

../_images/page009a.png

If you do not see your interpreter listed, you can try to click the Auto Config button and it will try to find python automatically and set up the paths. Click the ok and give it a while to parse all your packages installed.

Using Eclipse

Now you will need to set up a project. So let’s go ahead and do that. First open Eclipse - you probably won’t see any projects on the left side. If you right click in the Pydev package explorer, you can go to New... –> Project...

../_images/page011.png

Then select Pydev project

../_images/page012.png

You can call the project whatever you like. Deselect the default workspace and select the folder where your PDSim source tree is (c:\pdsim in the example above)

../_images/page013.png

Don’t check any of the other projects

../_images/page014.png

You can browse to the examples folder then double-click PURecip.py to open it in the editor.

../_images/page015.png

Once you have opened PURecip.py, you need to configure pydev to run the file. Left-click the little down-arrow next to the run button, Run As... –> Python Run.

../_images/page016.png

Which should run the example file. You can also run the sample recip and scroll compressors in the same folder by the same method.