Skip to content

Commit

Permalink
Merge pull request #61 from NREL/develop
Browse files Browse the repository at this point in the history
* Updating controller to align with WHOC (#41)

* Skeleton for a turbine yaw simulator.

* Implementation mostly in place.

* Simple yaw controller running on dummy. Need to make back compatible.

* Handling case where no yaw simulator specified (or specified as none)

* Removing input_dict.echo from git repo. Can indo if needed.

* Removing previous, more realistic implementation that has not yet been fleshed out.

* Clean up commit.

* Running, but seems theres a timing issue.

* Small updates to installation procedure; also updated intstuctions for running locally.;

* Updates to allow example_06 to run

* Renaming dummy example for clarity.

* Reverting; plan to use one directory only, if possible.

* Runs on eagle and local.

* Revert, take 2.

* Removing old yaw simulator from pysims.

* Removing temporary examples.

* Starting renaming to hercules.

* More name updates.

* Cleaning up, renaming more.

* AMR wind version now runs.

* Removing controller.py in favor of controllers/controller_base.py

* Switching helicsport (not sure if needed?)

* Updates to read in time step.

* Reorganizing emulator somewhat to allow clearer execution of main loop and swap send and receive to AMRwind. Removes KAFKA pieces (were not being used?)

* Commiting to change branch.

* Removing unneded controllers in favor of whoc.

* Emulator controller set up as desired; still tbd where time should come from

* Adding back a pass-through controller in case WHOC not available.

* Replacing controllers/control_base with controller_standin.

* Adding comment about time issue.

* Reinstating nominal yaw control in pass-through.

* Add comments to explain temporary AD connection.

* Copying in old controller code for possible later use.

* Aligning with develop branch.

* Add KAFKA code back in, commented out, in case needed later.

* Changing helicsport to sidestep bug with not connecting on correct port.

* put sim_tim_s_amr_wind in emulator main_dict in init

* Change back to 32000.

---------

Co-authored-by: misha <msinner@nrel.gov>
Co-authored-by: Zachary <ztully@nrel.gov>

* Update to public seas (#39) (#43)

* update ci to install seas

* Update install docs

* Add a test of seas and convert to pytest

Co-authored-by: paulf81 <paul.fleming@nrel.gov>

* Feature/battery example (#30)

* Skeleton for a turbine yaw simulator.

* Implementation mostly in place.

* Simple yaw controller running on dummy. Need to make back compatible.

* Handling case where no yaw simulator specified (or specified as none)

* Removing input_dict.echo from git repo. Can indo if needed.

* Removing previous, more realistic implementation that has not yet been fleshed out.

* Clean up commit.

* Running, but seems theres a timing issue.

* Small updates to installation procedure; also updated intstuctions for running locally.;

* Updates to allow example_06 to run

* Renaming dummy example for clarity.

* Reverting; plan to use one directory only, if possible.

* Runs on eagle and local.

* Revert, take 2.

* Removing old yaw simulator from pysims.

* Removing temporary examples.

* Starting renaming to hercules.

* More name updates.

* Cleaning up, renaming more.

* AMR wind version now runs.

* Removing controller.py in favor of controllers/controller_base.py

* Switching helicsport (not sure if needed?)

* Updates to read in time step.

* Reorganizing emulator somewhat to allow clearer execution of main loop and swap send and receive to AMRwind. Removes KAFKA pieces (were not being used?)

* save commit

* zct battery model

* battery example first commit

* Copy over battery example

* git ignore vscode settings

* remove vscode settings

* clean up controller and comments

* small change in high-level controller organization

* generate_amr_standin_data can read amr-wind actuator outputs and moved to tools

* delete unneeded comments

* update battery example branch to match NREL/develop

* Commiting to change branch.

* Removing unneded controllers in favor of whoc.

* Emulator controller set up as desired; still tbd where time should come from

* Adding back a pass-through controller in case WHOC not available.

* Replacing controllers/control_base with controller_standin.

* Adding comment about time issue.

* Reinstating nominal yaw control in pass-through.

* small change in batch script

* save before merging emulator from Misha's branch

* whoc battery controller

* troubleshooting WHOC format battery controller

* delete obsolete control_methods folder

* delete duplicate lines

* delete unused controller import

* add exmple 06 readme file for amr standin data instructions

* fix example 06 jupyter notebook

---------

Co-authored-by: misha <msinner@nrel.gov>
Co-authored-by: misha <misi9170@colorado.edu>
Co-authored-by: Zachary <ztully@nrel.gov>

* Stand-in AMR-wind uses stop time defined in amr_input.inp (#47)

* Set stand-in stop time from amr_input file.

* Controlling amr standin stop time via endtime rather than absolute_helics_time.

* Setting stop_time to 100.0 to mimic earlier behavior.

* Updating stop times in other dummy amr_input files.

---------

Co-authored-by: misi9170 <msinner@nrel.gov>

* Improved PV solar model (#58)

* created dummy example for amr wind dummy + solar

* final commit before creating feature branch

* standalone solar pysam example

* working standalone example of solar pysam model

* removed time as explicit input in step

* working example of solar pysam and hercules (but pysam has a bug)

* changing hardcoded stoptime of 100 s to 1000 s to demo solar module

* cleaning before pull request review of misha's changes

* working solar pysam example with test amr wind

* adding updated results in jupyter notebook

* trying to run after git pull of develop

* solar model runs successfully, but there is a time issue

* correcting irradiance field and removing unnecessary comments

* removing unnecessary files

* removing test amr wind and solar example, saving for separate PR

* adding environment yaml file needed for pysam

* updating setup and docs to include pysam and restrict python version

* adding missing csv weather file

* Minor changes for running the code

* Minor cleanup in example.

* remove environment.yml

---------

Co-authored-by: Genevieve Starke <Genevieve.Starke@nrel.gov>
Co-authored-by: misi9170 <michael.sinner@nrel.gov>

* Fix documentation download command

* Feature/rename dummyamr (#48)

* Renaming AMR dummy to AMR standin

* Delete previous example 02

* Ignoring logstandin.

* A few extra references in text.

* Renaming solar updates.

---------

Co-authored-by: misi9170 <msinner@nrel.gov>

* Add WHOC installation instructions to Hercules documentation (#59)

* Add WHOC installation instructions to Hercules documentation

* Add note about develop branch on WHOC

* Fix cd command

* Add ruff and pre-commit files (#46)

* Feature/add ruff (#60)

* Ruff changes and updates to CI

* Ruff reformatting changes

* py_sims_test update

* Final ruff edits to files

---------

Co-authored-by: Paul <paul.fleming@nrel.gov>
Co-authored-by: misi9170 <39596329+misi9170@users.noreply.github.com>
Co-authored-by: misha <msinner@nrel.gov>
Co-authored-by: Zachary <ztully@nrel.gov>
Co-authored-by: Zachary Tully <107644545+ZackTully@users.noreply.github.com>
Co-authored-by: misha <misi9170@colorado.edu>
Co-authored-by: Brooke Stanislawski <34248707+brookeslawski@users.noreply.github.com>
Co-authored-by: misi9170 <michael.sinner@nrel.gov>
  • Loading branch information
9 people authored Dec 20, 2023
2 parents a7c00ea + e574c9e commit 2c22ff2
Show file tree
Hide file tree
Showing 62 changed files with 87,197 additions and 1,051 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/continuous-integration-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
fail-fast: False
matrix:
python-version: ["3.9", "3.10", "3.11"]
os: [ubuntu-latest]
Expand All @@ -24,6 +24,11 @@ jobs:
pip install -e ".[develop]"
pip install git+https://github.com/NREL/electrolyzer.git
pip install https://github.com/NREL/SEAS/blob/main/SEAS.tar.gz?raw=true
# - uses: pre-commit/action@v3.0.0
- name: Run ruff
run: |
ruff .
# ruff format
- name: Run tests and collect coverage
run: |
# -rA displays the captured output for all tests after they're run
Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
data.db
*.python-version
*.DS_Store
*.conda
slices

# macOS files
Expand Down Expand Up @@ -38,4 +39,8 @@ hercules/local_amr_wind_demo/sample_copy.nc
t_00*
logdummy
loghercules
*echo
logstandin
*echo
*out-example.json

.vscode/*
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-executables-have-shebangs
- id: check-yaml
args: [--unsafe]
- id: check-merge-conflict
- id: check-symlinks
- id: mixed-line-ending

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.7
hooks:
# Run the linter.
- id: ruff
types_or: [ python, pyi, jupyter ]
args: [ --fix ]
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi, jupyter ]
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: standalone-solar-pysam-example.py",
"type": "python",
"request": "launch",
// "program": "${file}",
"console": "integratedTerminal",
"justMyCode": false,
// "cwd": "${workspaceFolder}\\example_case_folders\\07_amr_wind_dummy_and_solar_pysam",
"cwd": "${fileDirname}",
"program": "standalone-solar-pysam-example.py",
}
]
}
26 changes: 24 additions & 2 deletions docs/install_old.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Installation
Create a new conda environment for hercules:
```
conda create --name hercules python
conda create --name hercules python=3.11
conda activate hercules
```

Expand Down Expand Up @@ -65,6 +65,28 @@ cd ..
pip install -e electrolyzer
```

NREL's PySAM software is also required for hercules. To install, use
```
pip install nrel-pysam==4.2.0
```

If you run hercules and get an error that `pyyaml` is missing, you may also need to install it using
```
conda install -c conda-forge pyyaml
```

NREL's Wind Hybrid Open Controller (WHOC) software is used to implement controllers in the Hercules platform. This package is not essential to run Hercules by itself, but is needed to implement any controls in the platform. Example 06 has an example of how this is used to control a battery based on wind farm power output.

To install:
Go back to herc_root

```
git clone git@github.com:NREL/wind-hybrid-open-controller.git
cd wind-hybrid-open-controller
git fetch --all
pip install -e .
```
Note: if you want the newest updates to the WHOC repository, you can checkout the develop branch instead of the main branch.
<!--
# Other steps for era 5
Now need to add a file called APIKEY which contains the API Key you'll find in your data.planetos account
Expand All @@ -86,7 +108,7 @@ activate hercules`).

In the first terminal, run
```
helics_broker -t zmq -f 2 --loglevel="debug"
helics_broker -f 2 --consoleloglevel=trace --loglevel=debug --local_port=$HELICS_PORT &
```
from any directory.

Expand Down
32 changes: 30 additions & 2 deletions docs/install_on_kestrel.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ This will be needed for the remaining installations

```
module load anaconda3
conda create --name hercules python
conda create --name hercules python=3.11
conda activate hercules
```

Expand Down Expand Up @@ -206,10 +206,38 @@ git switch develop
pip install -e .
```

## Install PySAM

Note: This section is untested.
Go back to herc_root
```
pip install nrel-pysam==4.2.0
```

If you run hercules and get an error that `pyyaml` is missing, you may also need to install it using
```
conda install -c conda-forge pyyaml
```
## Install the NREL Wind Hybrid Open Controller (WHOC)

This module is used to implement controllers in the Hercules platform. Example 06 has an example of how this is used to control a battery based on wind farm power output.

Note: if you want the newest updates to the WHOC repository, you can checkout the develop branch instead of the main branch.

Installation instructions:
Go back to herc_root

```
git clone git@github.com:NREL/wind-hybrid-open-controller.git
cd wind-hybrid-open-controller
git fetch --all
pip install -e .
```

## Try an example!

Look at
herc_root/hercules/example_case_folders/02_amr_wind_dummy_only
herc_root/hercules/example_case_folders/02_amr_wind_standin_only

(May need to edit the port from 32000 to 32001 in bash_script.sh)

Expand Down
2 changes: 1 addition & 1 deletion example_case_folders/01_amr_wind_only/batch_script.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ python3 hercules_runscript.py hercules_input_000.yaml >> loghercules 2>&1 & # S

# Now go back to scratch folder and launch the job
# cd /scratch/pfleming/c2c/example_sim_02
mpirun -n 72 /home/pfleming/amr-wind/build/amr_wind amr_input.inp >> logamr 2>&1
mpirun -n 72 /home/pfleming/amr-wind/build/amr_wind amr_input.inp >> logamr 2>&1
14 changes: 5 additions & 9 deletions example_case_folders/01_amr_wind_only/hercules_runscript.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import sys

from hercules.controller_standin import ControllerStandin
from hercules.emulator import Emulator
from hercules.controller import Controller
from hercules.py_sims import PySims
from hercules.utilities import load_yaml

import sys



input_dict = load_yaml(sys.argv[1])

controller = Controller(input_dict)
controller = ControllerStandin(input_dict)
py_sims = PySims(input_dict)


emulator = Emulator(controller, py_sims, input_dict)
emulator.run_helics_setup()
emulator.enter_execution(function_targets=[],
function_arguments=[[]])

emulator.enter_execution(function_targets=[], function_arguments=[[]])

This file was deleted.

1 change: 0 additions & 1 deletion example_case_folders/02_amr_wind_dummy_only/readme.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨#
# SIMULATION STOP #
#.......................................#
time.stop_time = 10800.0 # Max (simulated) time to evolve
time.stop_time = 100.0 # Max (simulated) time to evolve
time.max_step = -1 # Max number of time steps

#¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨#
Expand Down Expand Up @@ -76,7 +76,7 @@ ABL.stats_output_format = netcdf

# Whether to use helics
helics.activated = true
helics.broker_port =32000
helics.broker_port = 32000

#¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨#
# ADAPTIVE MESH REFINEMENT #
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ export HELICS_PORT=32000
#make sure you use the same port number in the amr_input.inp and hercules_input_000.yaml files.

# Set up the helics broker
helics_broker -f 2 --consoleloglevel=trace --loglevel=debug --local_port=$HELICS_PORT &
helics_broker -t zmq -f 2 --loglevel="debug" --local_port=$HELICS_PORT &
#helics_broker -f 2 --consoleloglevel=trace --loglevel=debug --local_port=$HELICS_PORT >> loghelics &

# Need to set this to your hercules folder
# cd /home/pfleming/hercules/hercules
python3 hercules_runscript.py hercules_input_000.yaml >> loghercules 2>&1 & # Start the controller center and pass in input file


python3 hercules_runscript_dummy_amr.py amr_input.inp >> logdummy 2>&1
python3 hercules_runscript_amr_standin.py amr_input.inp >> logstandin 2>&1
# Now go back to scratch folder and launch the job

# cd /scratch/pfleming/c2c/example_sim_02
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: example_000

###
# Describe this emulator setup
description: AMR-wind (Dummy) Only
description: AMR-wind (Standin) Only

dt: 0.5

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import sys

from hercules.controller_standin import ControllerStandin
from hercules.emulator import Emulator
from hercules.controller import Controller
from hercules.py_sims import PySims
from hercules.utilities import load_yaml

import sys



input_dict = load_yaml(sys.argv[1])


controller = Controller(input_dict)
controller = ControllerStandin(input_dict)
py_sims = PySims(input_dict)


emulator = Emulator(controller, py_sims, input_dict)
emulator.run_helics_setup()
emulator.enter_execution(function_targets=[],
function_arguments=[[]])

emulator.enter_execution(function_targets=[], function_arguments=[[]])
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import sys

from hercules.amr_wind_standin import launch_amr_wind_standin

# Check that one command line argument was given
if len(sys.argv) != 2:
raise Exception("Usage: python hercules_runscript_amr_standin.py <amr_input_file>")

# # Get the first command line argument
# This is the name of the file to read
amr_input_file = sys.argv[1]
print(f"Running AMR-Wind standin with input file: {amr_input_file}")


launch_amr_wind_standin(amr_input_file)
1 change: 1 addition & 0 deletions example_case_folders/02_amr_wind_standin_only/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This example runs the AMR Wind standin without any additional generation
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
],
"source": [
"# Read the output file\n",
"df = pd.read_csv('hercules_output.csv', index_col=False)\n",
"df = pd.read_csv(\"hercules_output.csv\", index_col=False)\n",
"df.head()"
]
},
Expand Down
14 changes: 5 additions & 9 deletions example_case_folders/03_amr_wind_and_solar/hercules_runscript.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import sys

from hercules.controller_standin import ControllerStandin
from hercules.emulator import Emulator
from hercules.controller import Controller
from hercules.py_sims import PySims
from hercules.utilities import load_yaml

import sys



input_dict = load_yaml(sys.argv[1])

controller = Controller(input_dict)
controller = ControllerStandin(input_dict)
py_sims = PySims(input_dict)


emulator = Emulator(controller, py_sims, input_dict)
emulator.run_helics_setup()
emulator.enter_execution(function_targets=[],
function_arguments=[[]])

emulator.enter_execution(function_targets=[], function_arguments=[[]])
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import sys

from hercules.controller_standin import ControllerStandin
from hercules.emulator import Emulator
from hercules.controller import Controller
from hercules.py_sims import PySims
from hercules.utilities import load_yaml

import sys



input_dict = load_yaml(sys.argv[1])

controller = Controller(input_dict)
controller = ControllerStandin(input_dict)
py_sims = PySims(input_dict)


emulator = Emulator(controller, py_sims, input_dict)
emulator.run_helics_setup()
emulator.enter_execution(function_targets=[],
function_arguments=[[]])

emulator.enter_execution(function_targets=[], function_arguments=[[]])
Loading

0 comments on commit 2c22ff2

Please sign in to comment.