Skip to content

Instantly share code, notes, and snippets.

@samtx
Last active March 6, 2018 01:26
Show Gist options
  • Save samtx/4cbd90afabd0fc801ed6721324b2e317 to your computer and use it in GitHub Desktop.
Save samtx/4cbd90afabd0fc801ed6721324b2e317 to your computer and use it in GitHub Desktop.
Setup for Matlab, Python, OpenMDAO, and OpenAeroStruct on TAMU HPC cluster

Setup instructions

TAMU HPRC Python virtual environment setup: https://hprc.tamu.edu/wiki/SW:Python

Summary

On the Ada cluster, run these commands one after the other. They probably also work on the Terra and Curie clusters.

module load Python/2.7.12-foss-2017A myPython/2.7.12-foss-2017A

$MYCREATEVIRTENV

$MYACTIVATE

pip install openmdao==1.7.3

git clone https://github.com/samtx/OpenAeroStruct.git

cd OpenAeroStruct && make

python run_aerostruct.py 0

To work on the program after you've already completed the steps above, reload the python and mypython modules and activate the virtual environment.

module load Python/2.7.12-foss-2017A myPython/2.7.12-foss-2017A && $MYACTIVATE
module load Matlab/R2017a

To pull in updates to the master branch shown at www.github.com/samtx/OpenAeroStruct, type:

git pull

This assumes that you don't change any of the python or matlab files that are in the repository.

Step-by-Step Instructions

1. Load Python 2.7 toolchain and the MyPython virtual environment tool

Run: module load Python/2.7.12-foss-2017A myPython/2.7.12-foss-2017A

Example:

[samfriedman@ada8 ~]$ module load Python/2.7.12-foss-2017A myPython/2.7.12-foss-2017A

2. Create virtual environment by running $MYCREATEVIRTENV.

This creates a scratch directory where you can install custom python modules. You only have to do this once.

Run: $MYCREATEVIRTENV

Example:

[samfriedman@ada8 ~]$ $MYCREATEVIRTENV
New python executable in /scratch/user/samfriedman/myPython/2.7.12-foss-2017A/bin/python
Installing setuptools, pip, wheel...done.
[samfriedman@ada8 ~]$

3. Activate virtual environment with $MYACTIVATE.

You have to do this each time you use the virtual environment. The name of the virtural environment should appear in parantheses before the ''bang'' of the command line once you activate it. You need to activate the virtual environment when you add modules or run programs using those modules.

Run: $MYACTIVATE

Example:

[samfriedman@ada8 ~]$ $MYACTIVATE
(2.7.12-foss-2017A) [samfriedman@ada8 ~]$
  1. Install OpenMDAO 1.7.3 in virtual environment with pip install openmdao==1.7.3. Since it is not the latest version available, we have to explicity specify the verison number. Installing using pip should also install any other dependent modules not already installed.

Run: pip install openmdao==1.7.3

Example:

(2.7.12-foss-2017A) [samfriedman@ada8 ~]$ pip install openmdao==1.7.3
Collecting openmdao==1.7.3
  Downloading openmdao-1.7.3.tar.gz (471kB)
    100% |████████████████████████████████| 481kB 1.9MB/s
Collecting six (from openmdao==1.7.3)
  Downloading six-1.11.0-py2.py3-none-any.whl
Collecting numpydoc (from openmdao==1.7.3)
  Downloading numpydoc-0.7.0.tar.gz

... more stuff happens here ...

Successfully installed Jinja2-2.10 MarkupSafe-1.0 Pygments-2.2.0 alabaster-0.7.10 babel-2.5.3 certifi-2018.1.18 chardet-3.0.4 decorator-4.2.1 docutils-0.14 idna-2.6 imagesize-1.0.0 networkx-1.11 numpy-1.14.1 numpydoc-0.7.0 openmdao-1.7.3 packaging-17.1 pyparsing-2.2.0 pytz-2018.3 requests-2.18.4 scipy-1.0.0 six-1.11.0 snowballstemmer-1.2.1 sphinx-1.7.1 sphinxcontrib-websupport-1.0.1 sqlitedict-1.5.0 typing-3.6.4 urllib3-1.22
(2.7.12-foss-2017A) [samfriedman@ada8 ~]$
  1. Download the OpenAeroStruct package from Github. It is easy using git. Git is already loaded, so you can immediately run git clone https://github.com/samtx/OpenAeroStruct.git. This downloads the most recent production copy of the OpenAeroStruct code into a folder in the current directory named OpenAeroStruct. You don't need an account on Github to do this.

Run: git clone https://github.com/samtx/OpenAeroStruct.git

Example:

(2.7.12-foss-2017A) [samfriedman@ada8 ~]$ git clone https://github.com/samtx/OpenAeroStruct.git
Initialized empty Git repository in /general/home/samfriedman/OpenAeroStruct/.git/
remote: Counting objects: 5246, done.
remote: Total 5246 (delta 0), reused 0 (delta 0), pack-reused 5246
Receiving objects: 100% (5246/5246), 4.59 MiB | 2.11 MiB/s, done.
Resolving deltas: 100% (3761/3761), done.
(2.7.12-foss-2017A) [samfriedman@ada8 ~]$
  1. We should also compile the associated Fortran files so that the OpenAeroStruct computations are much faster. To do that we need to load a Fortran compiler. The GNU C and Fortran compilers are already loaded, so we use the OpenAeroStruct default options to compile the libraries. We need to move into the OpenAeroStruct directory and run make.

Run: cd OpenAeroStruct then make.

Example:

(2.7.12-foss-2017A) [samfriedman@ada8 ~]$ cd OpenAeroStruct
(2.7.12-foss-2017A) [samfriedman@ada8 OpenAeroStruct]$ make
make[1]: Entering directory `/general/home/samfriedman/OpenAeroStruct'
mkdir -p obj
mkdir -p mod
ln -sf config/config.mk config.mk
making module in src/adjoint

make[2]: Entering directory `/general/home/samfriedman/OpenAeroStruct/src/adjoint'
            Making in OpenAeroStruct Derivatives...
make  adBuffer.o adStack.o outputReverse/oas_main_b.o outputForward/oas_main_d.o
make[3]: Entering directory `/general/home/samfriedman/OpenAeroStruct/src/adjoint'
gfortran -I../../mod -fdefault-real-8 -O2 -fPIC -c adBuffer.f -o ../../obj/adBuffer.o

... more stuff here ...

Testing if module OpenAeroStruct can be imported...
Module OpenAeroStruct was successfully imported.
cp OAS_API.so ../../..
rm *.o
rm *.c
rm .f2py_f2cmap
make[2]: Leaving directory `/general/home/samfriedman/OpenAeroStruct/src/python/f2py'
make[1]: Leaving directory `/general/home/samfriedman/OpenAeroStruct'
(2.7.12-foss-2017A) [samfriedman@ada8 OpenAeroStruct]$
  1. Run the OpenAeroStruct example problem to make sure everything is installed correctly.

Run: python run_aerostruct.py 0

Example:

(2.7.12-foss-2017A) [samfriedman@ada8 OpenAeroStruct]$ python run_aerostruct.py 0
Fortran = True
##############################################
Setup: Checking root problem for potential issues...

The following parameters have no associated unknowns:
total_perf.wing_nodes
Group 'coupled' has the following cycles: [['wing', 'aero_states', 'wing_loads']]

The following params are connected to unknowns that are updated out of order, so their initial values may contain uninitialized unknown values: ['coupled.wing.struct_states.create_rhs.loads']

Setup: Check of root problem complete.
##############################################


Fuelburn: 73943.4429374
Time elapsed: 0.0408811569214 secs
(2.7.12-foss-2017A) [samfriedman@ada8 OpenAeroStruct]$
  1. Now load Matlab.

Run: module load Matlab/R2017A

  1. Test the Matlab/Python connector. Use the Matlab functions OAS_setup.m, OAS_run.m, OAS_test.m.

Run: matlab OAS_test.m


To deactivate the virtual environment once you've finished, run `$MYDEACTIVATE`.

**Run:** `$MYDEACTIVATE`

When you want to work on the program again, you have to reload the python and mypython modules and activate the virtual environment.

**Run:** `module load Python/2.7.12-foss-2017A myPython/2.7.12-foss-2017A && $MYACTIVATE`


....Dont do the stuff below just yet ....

Add Sam's OpenAeroStruct fork to your local git repository for the matlab wrappers
`git remote add samtx https://github.com/samtx/OpenAeroStruct.git`

Create local branch to download and track changes from Sam's master branch which has the updated matlab wrappers
git checkout -b matlab
git branch -u samtx/master
git pull samtx master
git fetch samtx master
git fetch samtx
git branch --set-upstream matlab samtx/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment