Project Set-Up¶
Here is a brief overview of steps to set up the full project. Steps have been reproduced successfully in Ubuntu Focal 20.04.2 LTS.
Ultimately, through this process you will clone and build the SAM repositories:
You will also clone:
But don’t worry, I have added bash scripts to this neup-ies repository to automate the building process.
Note
The neup-ies project must be cloned into a directory alongside the other SAM projects.
It is recommended that an environment variable $DEVDIR is created to represent this parent directory.
Add repository to your PYTHONPATH¶
First, open your bashrc file through an open terminal (or manually if you wish)
gedit $HOME/.bashrc
then add the lines
export DEVDIR=<full-path-to-parent-directory>
export PYTHONPATH=$PYTHONPATH:$DEVDIR/neup-ies/simulations
export git=git@github.com
Your $DEVDIR variable could be, for example: home/user_name/Documents/NE2. Then, the neup-ies as well as the SAM directories would be placed in the shown NE2 parent directory.
The github line just facilitates cloning with an SSH key.
Next, clone this repository in the parent directory. Note that you must have an SSH key set up.
cd $DEVDIR
git clone git@github.com:uw-esolab/neup-ies
Build Debug Version of SAM¶
If running for the first time:
- Make sure you delete the following directories if they exist:
$DEVDIR/build_debug$DEVDIR/ssc$DEVDIR/sam
create a CMakeLists file
cd $DEVDIR touch CMakeLists.txt gedit CMakeLists.txt
Fill in the file with:
cmake_minimum_required(VERSION 3.12) Project(system_advisor_model VERSION 1.0.0) add_subdirectory(lk) add_subdirectory(wex) add_subdirectory(ssc) add_subdirectory(sam) option(SAM_SKIP_TOOLS "Skips the sdktool and tcsconsole builds" ON) option(SAM_SKIP_TESTS "Skips building tests" ON) option(SAMAPI_EXPORT "Export of ssc binaries to the SAM_api directory; for Unix, compile ssc libraries for SAM_api" ON) option(SAM_SKIP_AUTOGEN "Re-generate the SAMAPI files from export_config" OFF)
- Follow these particular Linux Build instructions found at this link:
Platform Requirements
Step 1.2 only
- Step 2 (all steps)
In step 2.4, the complete path I used was
$DEVDIR/wxWidgets-3.1.1/lib/wx-3.1.1
Run the bash script to build a debug version of
SAMcd $DEVDIR/neup-ies source ./build_debug_SAM
Bash script was created using steps found here for mixed-mode debugging.
Verify that the project and libraries are built in the correct places:
There should be a new directory in
$DEVDIR/build_debug.There should be individual subdirectories for each of
lk,wex,ssc, andsamCheck that
$DEVDIR/build_debug/ssc/ssc/libsscd.solibrary existsCheck that
googletestcreated its libraries at$DEVDIR/googletest/build_debug/lib. These should be calledlibgtestd.aamong others.A CodeLite IDE workspace is created at
$DEVDIR/build_debug/system_advisor_model.workspace
If rebuilding a new debug version OR you already have an export version installed:
- Make sure you delete the following directories:
$DEVDIR/build_debug$DEVDIR/ssc$DEVDIR/sam
1. Note that the bash script at
$DEVDIR/neup-ies/build_debug_SAMchecks out specific branches of theSSCandSAMrepositories. * The script should check out a specified, stable tag ofSAM, if it doesn’t work you could try to contact someone at NREL.The script defaults to a stable branch of my forked
SSCrepository, but the bash script call takes in an extra argument to override
Run the bash script to build a debug version of
SAMcd $DEVDIR/neup-ies source ./build_debug_SAM <optional-SSC-branch-name>
If you want to specify the
SSCbranch to check out, add an extra argument as shown with the branch name, otherwise leave that blank.
Build Export Version of SAM linked through PySAM¶
If running for the first time:
- Make sure you delete the following directories if they exist:
$DEVDIR/build_sam_export$DEVDIR/build_ssc_export$DEVDIR/ssc$DEVDIR/sam$DEVDIR/pysam
run steps 1, 2 and 3 from the above debug section
Run the bash script to build an export version of
SAMand dedicatedPySAMlibrariescd $DEVDIR/neup-ies source ./build_pysam
Bash script was created using steps found here for building PySAM with modified SSC modules.
Verify that the project and libraries are built in the correct places:
There should be a new directory:
$DEVDIR/build_ssc_export.There should be a new directory:
$DEVDIR/build_sam_export.In each of the individual subdirectories of
lk,wex,ssc, andsamthere should be abuildsubdirectory with a_.alibraryCheck that
$DEVDIR/build_ssc_export/ssc/libssc.solibrary existsCheck that
googletestcreated its libraries at$DEVDIR/googletest/build/lib. These should be calledlibgtest.aamong others. Note this is a separate directory from the debug versionA CodeLite IDE workspace is created at
$DEVDIR/build_ssc_export/sam_simulation_core.workspace. Note that this is hardly used because currently there is no mixed-mode debugging throughPySAMThere should be .whl and .egg files in the
$DEVDIR/pysam/distdirectoryCheck that
$DEVDIR/pysam/files/libssc.soand$DEVDIR/pysam/files/libSAM_api.solibrary exists
If rebuilding a new export version OR you already have a debug version installed:
- Make sure you delete the following directories:
$DEVDIR/build_sam_export$DEVDIR/build_ssc_export$DEVDIR/ssc$DEVDIR/sam$DEVDIR/pysam
- Note that the bash script at
$DEVDIR/neup-ies/build_pysamchecks out specific branches of thepysam,SSCandSAMrepositories. The script should check out a stable tag of
SAM, if it doesn’t work you could try to contact someone at NREL.The script defaults to a specified, stable branch of my forked
SSCrepository, but the bash script call takes in an extra argument to overrideThe script currently checks out the default
pysambranch
- Note that the bash script at
Run the bash script to build
PySAMand an export version ofSAMcd $DEVDIR/neup-ies source ./build_pysam <optional-SSC-branch-name>
If you want to specify the
SSCbranch to check out, add an extra argument as shown with the branch name, otherwise leave that blank.