3. Installation on Linux systems

This section describes a procedure for compiling JModelica.org from sources on Linux. The instructions have been verified to work on Ubuntu Linux release 12.04, 64bit.

3.1. Prerequisites

3.1.1. Installing pre-compiled packages

It is convenient to use a package management system, if available, of the Linux distribution to install the prerequisites. On Ubuntu systems, the apt-get command line program may be used:

sudo apt-get -y install g++
sudo apt-get -y install subversion
sudo apt-get -y install gfortran
sudo apt-get -y install ipython
sudo apt-get -y install cmake
sudo apt-get -y install swig
sudo apt-get -y install ant
sudo apt-get -y install openjdk-6-jdk
sudo apt-get -y install python-dev
sudo apt-get -y install python-numpy
sudo apt-get -y install python-scipy
sudo apt-get -y install python-matplotlib
sudo apt-get -y install cython
sudo apt-get -y install python-lxml
sudo apt-get -y install python-nose
sudo apt-get -y install python-jpype
sudo apt-get -y install zlib1g-dev
sudo apt-get -y install libboost-dev

On Ubuntu 12.04, the bundled jcc version is too old. A new enough version can be installed using pip:

sudo apt-get -y install python-pip
sudo pip install jcc

The following versions of each package have been tested and verified to work. Please note that in some cases, a minimum version is required.

Table 2.1. Package versions for Ubuntu

Package Version Note
g++ 4.6.3 Tested version
subversion 1.6.17 Tested version
gfortran 4.6.3 Tested version
ipython 0.12.1 Tested version
cmake 2.8.6 Minimum version
swig 2.0.4 Tested version
ant 1.8.2 Tested version
python-dev 2.7.3 Tested version
python-numpy 1.6.1 Tested version
python-scipy 0.9.0 Tested version
python-matplotlib 1.1.1 Tested version
cython 0.15 Minimum version
python-lxml 2.3.2 Tested version
python-nose 1.1.2 Tested version
python-jpype Tested version
zlib1g-dev 1: Tested version
libboost-dev Tested version
jcc 2.16 Minimum version

3.1.2. Compiling Ipopt

While Ipopt is available as a pre-compiled package for Ubuntu, it is recommended to build Ipopt from sources. The Ipopt packages provided for Ubuntu have had flaws (including the version provided for Ubuntu 12.04) that prevented usage with JModelica.org. Also, compiling Ipopt from sources is required when using the linear solvers MA27 or MA57 from the HSL library, since these are not available as open source software.

First, download the Ipopt sources from https://projects.coin-or.org/Ipopt and unpack the content:

tar xvf Ipopt-3.10.2.tgz

Then, retrieve the third party dependencies:

cd Ipopt-3.10.2/ThirdParty/Blas
cd ../Lapack
cd ../Mumps
cd ../Metis
cd ../../

If you have access to the HSL codes MA57 or MA27, copy their sources into the directory ThirdParty/HSL. In the next step, configure and compile Ipopt:

mkdir build
cd build
../configure --prefix=/home/<user_name>/<ipopt_installation_location>
make install

where <user_name> and <ipopt_installation_location> are replaced by the user directory and the installation directory of choice for Ipopt.

3.2. Compiling

Make sure that all prerequisites are installed before compiling the JModelica.org platform. First, check out the JModelica.org sources:

svn co https://svn.jmodelica.org/trunk JModelica.org

Then configure and build JModelica.org:

cd JModelica.org
mkdir build
cd build
../configure --prefix=/home/<user_name>/<jmodelica_install_location> \
make install
make casadi_interface

where <user_name> and <jmodelica_installation_location> are replaced by the user directory and the installation directory of choice for JModelica.org.

3.3. Testing JModelica.org

In order to verify that JModelica.org has been installed correctly, start an IPython shell using the command /home/<user_name>/<jmodelica_install_location>/bin/jm_ipython and run a few examples:

# Import and run the VDP_sim example and plot results
from pyjmi.examples import VDP_sim

# Import and run the CSTR example and plot results
from pyjmi.examples import cstr

# Import and run the CSTR example using CasADi and plot results
from pyjmi.examples import cstr_casadi