Python Numpy Spicy and Odespy

HPC clusters: Vilje and Kongull

Scipy and Numpy are part of the Python module on Vilje and Kongull. Odespy is not impemented yet. How to load the Python module:

Available modules: 
$ module avail
 
Default versions: Vilje 2.7.2, Kongull 2.7.1
$ module load python

Vilje -----------------------------: 
Python v.2.7.3:
$ module load intelcomp/13.0.1
$ module load mpt/2.06
$ module load python/2.7.3
 
Python v.2.7.6:
$ module load intelcomp/14.0.1
$ module load mpt/2.09
$ module load python/2.7.6

Kongull ---------------------------:
Python 2.7.3
$ module load python/2.7.3
 
Python 2.7.6
$ module load intelcomp/13.0.1
$ module load openmpi/1.6.5
$ module load python/2.7.6-intel

CalcFarm

Scipy, Numpy and Odespy are implemented in Python on the CalcFarm.

1.Start Remote Desktop Connection on your Laptop/PC/Smartphone/Tablet.

a. Windows: Remote Desktop Connection

b. Android App: "RD Client"

c. iPhone/iPad App: "Microsoft Remote Desktop"

d. Linux: eg. "Remmina Remote Desktop Client"

2. Login: Computer: calcfarm.ntnu.no, Username: win-ntnu-no\my-ntnu-username and Ntnu-password. For Linux: Domene: win-ntnu-no, Username: my-ntnu-username.

3. Click on Connect.

4. Click on "Startmeny" in the CalcFarm desktop.

5. Use one of the Python Apps: IPython (Qt), IPython (sh) or Python interpreter

Scipy/Numpy

NumPy is the fundamental package for scientific computing with Python (http://www.numpy.org/)

SciPy (pronounced “Sigh Pie”) is a Python-based ecosystem of open-source software for mathematics, science, and engineering (http://scipy.org/).

How to install Scipy/Numpy on a Laptop or PC

Linux.

You need Python installed (Python is normaly installed on every linux distro).

Installation of Scipy/Numpy see: http://scipy.org/install.html

(Note that you can install linux on Windows PC with VMWare player. See http://www.vmware.com/)

Windows

Install python for Windows (32bit), the recommended version is 2.7.6 because of numpy: See http://www.python.org/download/releases/2.7.6/ and Windows x86 MSI Installer (2.7.6).

Install numpy for Windows (32bit), the recommended version is "numpy-1.8.0-win32-superpack-python2.7.exe". See http://sourceforge.net/projects/numpy/files/NumPy/1.7.2/

Install scipy for Windows (32bit), the recommended version is "scipy-0.13.2-win32-superpack-python2.7.exe". See http://sourceforge.net/projects/scipy/files/scipy/0.13.2/

The installation is on path c:\python2.7\ (by default)

Set the path to python in System Properties -> Advanced Tab -> Enviroment Varilables; Add the directory to python under "System variables" and "path".

To install matplotlib

https://github.com/matplotlib/matplotlib/downloads and download "matplotlib-1.2.0.win32-py2.7.exe".

Mac

Install python: sudo port install python27

Install numpy and scipy; see http://www.scipy.org/install.html

Test the installation

Start python (Windows: Start->Programs->Python 2.7):

>>>import numpy

>>>import scipy

>>>

OK, if none error messages.

Example codes

See reference: http://docs.scipy.org/doc/scipy/reference/linalg.html

See also http://wiki.scipy.org/Numpy_Example_List

Sample code (numpy and scipy is equal for the examples below. Use import numpy instead of import scipy):

import scipy
from scipy import linalg
n=100;
a=scipy.random.rand(n,n);
b=scipy.ones((n,n));
c=scipy.zeros((n,n));
A=scipy.mat((a));
B=scipy.mat((b));
C=scipy.mat((c));
# Matrix multiplication with operator
C = A * B;
# Matrix determinant
d = scipy.linalg.det(A);
# Inv matrix
B2 = A.I * C;
# FFT (only scipy)
F = scipy.fft(A);

Odespy

Odespy (ODE Software in Python) offers a unified interface to a a large collection of software for solving systems of ordinary differential equations (ODEs). There is also some support for Differential Algebraic Equations (DAEs)

(see http://hplgit.github.io/odespy/doc/web/index.html and https://github.com/hplgit/odespy).

Note! Odespy is not installed on our HPC clusters Vilje and Kongull.

How to install Odespy

For linux

Download and install odespy: (See git://github.com/hplgit/odespy)

$ git clone git://github.com/hplgit/odespy

$ cd odespy

$ python setup.py install

(If you don't have git installed then install git with "sudo yum install git" or "sudo apt-get install git".)

(Note that you can install linux on Windows PC with VMWare player. See http://www.vmware.com/)

For Windows and Mac

Download zip file file (hplgit-odespy-1081789.zip) from http://hplgit.github.io/odespy/doc/web/index.html and Download.

Unzip the file and in the command prompt:

python setup.py install --no-fortran

(If you have a fortran compiler installed; you can write: python setup.py install)

Windows: Copy the odespy folder to c:\pythonxx\LIb\site-packages\. Ex: ..\hplgit-odespy-1081789\odespy to c:\python27\LIb\site-packages\

Test the installation

Start python:

>>>import odespy

>>>

OK, If none error messages.

Example

 def f(u, t):
        """2x2 system for a van der Pool oscillator."""
        return [u[1], 3.*(1. - u[0]*u[0])*u[1] - u[0]]

import odespy, numpy
solver = odespy.Vode(f, rtol=0.0, atol=1e-6,
                         adams_or_bdf='adams', order=10)
solver.set_initial_condition([2.0, 0.0])
t_points = numpy.linspace(0, 30, 150)
u, t = solver.solve(t_points)

u0 = u[:,0]
from matplotlib.pyplot import *
plot(t, u0)
show()

See https://github.com/hplgit/odespy

Scroll to Top