Skip to content

Building SolarTherm

Ye Wang edited this page May 3, 2024 · 47 revisions

The latest SolarTherm package is tested for

  • Ubuntu: 20.04
  • Python: 3.8
  • OpenModelica: 1.17.0 and 1.18.1

All tests are passed via Github Actions. See the details available here. The following is an instruction to build SolarTherm on Ubuntu 20.04.

Ubuntu 20.04.1 LTS

Open a terminal window and type the commands in the following boxes. You will need 'root' privileges on the machine to be able to install the necessary packages.

  1. Install OpenModelica
  • Specify the versions of OpenModelica (OM) and Modelica Standard Library (MSL), for example:
OM=1.17.0
MSL=3.2.3
  • Install OM, MSL and glpk
echo "deb https://build.openmodelica.org/omc/builds/linux/releases/${OM}/ `lsb_release -cs` release" | sudo tee /etc/apt/sources.list.d/openmodelica.list
wget -q http://build.openmodelica.org/apt/openmodelica.asc -O- | sudo apt-key add -
sudo apt-get update
sudo apt-get install build-essential omc omlib-modelica-${MSL} libglpk-dev
sudo apt install openmodelica
  1. Install SolarTherm dependencies
  • If pip is not installed on your machine, install it first by
sudo apt install python3-pip
sudo apt install python3-testresources
  • Install Python dependencies
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade setuptools wheel
python3 -m pip install scons scipy matplotlib DyMat pyswarm cma pytest openpyxl distro colorama
  1. Install Solstice and solsticepy

Solstice is an open-source command-line Monte-Carlo ray tracing (MCRT) software that is developed by Meso-star. Solsticepy is an open-source Python package that is developed by the ANU team. It is a Solstice Python wrapper that contains functions for heliostat field design, flux map analysis and annual optical performance simulations. They are integrated with SolarTherm for optical design and analyses.

python3 -m pip install solsticepy 
sudo apt install libpolyclipping-dev libtbb-dev libyaml-dev  libgomp1
export UBVER=`lsb_release -cs`
export SOLSTICEURL="https://github.com/anustg/installation-packages/releases/download/omc-dakota-solstice-installation/solstice-${SOLSTICEVER}-x86_64-$UBVER.tar.gz"
sudo tar zxv --strip-components=3 -C /usr/local < <(wget "$SOLSTICEURL" -q -O-)
export PATH=$PATH:/usr/local/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

To test Solstice is successfully installed:

solstice --version

You would see Solstice 0.9.0.

  1. Install DAKOTA

Dakota is a free software package developed by Sandia National Laboritories. It is integrated here for optimisation and uncertainty quantification.

sudo apt install openmpi-bin libltdl7 liblapack3 libhwloc15 \
  libgslcblas0 libquadmath0 libboost-regex1.71.0 libgsl23 \
  libevent-2.1-7 libgfortran5 libboost-filesystem1.71.0 libopenmpi3 \
  libicu66 libblas3 libstdc++6 libevent-pthreads-2.1-7 \
  libboost-serialization1.71.0
OS=ubuntu-20.04
DAKOTA_VERSION=6.17.0
export PKGN=dakota-${DAKOTA_VERSION}-${OS}-x86_64-jp
export DAKURL="https://github.com/anustg/installation-packages/releases/download/omc-dakota-solstice-installation/$PKGN.tar.gz"
sudo tar zxv --strip-components=3 -C /usr/local < <(wget "$DAKURL" -q -O-)
export PATH=$PATH:/usr/local/bin   
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib  

To test whether DAKOTA is successfully installed:

dakota --version
export PYTHONPATH=$PYTHONPATH:/usr/local/share/dakota/Python
python3 -c "import dakota.interfacing;print(dakota.interfacing.__file__)"

The version of DAKOTA and the __init__ path will be shown.

  1. Build and install SolarTherm
sudo apt install git
git clone https://github.com/SolarTherm/SolarTherm.git SolarTherm
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export PYTHONPATH=$PYTHONPATH:/usr/local/share/dakota/Python
cd SolarTherm
scons
scons install

Everything is installed in the default paths. It is recommend to update the LD_LIBRARY_PATH and PYTHONPATH in the bash profile so that you don't need to export the path every time before using/building SolarTherm. For example, open the file ~/.bashrc by a text editor and put the following two lines at the end of the file.

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export PYTHONPATH=$PYTHONPATH:/usr/local/share/dakota/Python

To quickly test that everything is running,

cd ~/solartherm/examples
st_simulate SimpleSystem.mo
st_plotmat SimpleSystem_res_0.mat Q_flow_rec:wea.wbus.dni E P_elec 

This last command will open a window with which you can see the full year simulation. You can also zoom in and see different parts of the simulation.

Screenshot

The key lines of output to check are (there will be other warnings and output, too):

index,epy (MWh/year),lcoe ($/MWh),capf (%),srev ($)
0,352.558326091,96.4900803985,40.246384257,16518.5840944

And you can keep going with other simulations. If you want to remove the variables without closing your terminal, you can run

exit

See the Tutorial if you want to see more examples of what can be done with the various 'st_' scripts.

If you later want to update your code to use newer stuff from this git repository,

cd ~/solartherm
git pull
scons
scons intall

Note, if you have any of the OpenModelica packages already installed on your system, it is recommended that you remove them before running the steps above. An instruction of removing a OM package is attached below. If SolarTherm is build against one version of OpenModelica, and then another version of OpenModelica is later installed, SolarTherm needs to be re-built.

  • For OM >= 1.20
sudo apt remove omc omlibrary openmodelica
sudo apt autoremove
  • For OM <= 1.18
sudo apt remove omc omlib-modelica-3.2.3 openmodelica
sudo apt autoremove