-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding solar controller and replacing AMR-Wind standin with FLORIS standin in example 07 #104
Changes from 68 commits
31705ee
471cb76
dead7ce
97f0a60
79f16e6
58ec136
0957591
19299db
14c4e38
46e161e
cc4ee8c
466bbd3
95618db
1c94d37
36e105a
44a7c6e
bc67bcf
4e43583
41e5a47
1b07044
c4289bb
f8f76c0
a2d73ce
68ab725
c575011
0be7f2a
74acc0a
1e38644
724112c
ad52112
3f8ff21
22a0051
83c84bf
829fd49
c9b6b38
6c546a2
6095ba3
1ad79a7
5fde32a
5e905d5
d2ab941
a914853
5fba773
f819252
b7adac6
9d37846
9731d41
6c07727
a2666da
2a62a40
b11abf8
7542eba
f05b8bc
e097b4b
1d86e56
13f1c53
6acadc3
34c972a
5ab9a6a
a6ed26b
ae47268
20c5f25
b45ae28
1d4660c
e4e2dc3
8cbecb9
42ebbd7
d6e4616
2dc720f
e50904e
d8aa1f2
908ca7a
43895cc
b018ada
757490d
67cbc22
10f36fa
67e6f94
6f9bed1
1972e79
b739314
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
# Ensure hercules conda or venv is activated before running this script | ||
|
||
# Run this script via the command: | ||
# bash batch_script.sh | ||
# ./batch_script.sh | ||
|
||
# Set the helics port to use: | ||
#make sure you use the same port number in the amr_input.inp and hercules_input_000.yaml files. | ||
export HELICS_PORT=32000 | ||
|
||
# Delete the logs within the outputs folder (it the output folder exists) | ||
if [ -d "outputs" ]; then | ||
rm -f outputs/*.log | ||
fi | ||
|
||
# Create the outputs folder | ||
mkdir -p outputs | ||
|
||
# Set up the helics broker | ||
helics_broker -t zmq -f 2 --loglevel="debug" --consoleloglevel=trace --local_port=$HELICS_PORT & | ||
# For debugging add --consoleloglevel=trace | ||
|
||
# Start the controller center and pass in input file | ||
echo "Starting hercules" | ||
# python3 hercules_runscript.py hercules_input_000.yaml >> outputs/loghercules.log 2>&1 & | ||
python3 hercules_runscript.py hercules_controller_input_000.yaml >> outputs/loghercules.log 2>&1 & | ||
|
||
# Start the floris standin | ||
# echo "Starting amr stand-in" | ||
# python3 hercules_runscript_amr_standin.py amr_input.inp >> outputs/logstandin.log 2>&1 & | ||
echo "Starting floris" | ||
python3 floris_runscript.py amr_input.inp >> outputs/logfloris.log 2>&1 & | ||
|
||
# If everything is successful | ||
echo "Finished running hercules" | ||
exit 0 | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import sys | ||
|
||
from hercules.floris_standin import launch_floris | ||
|
||
# Check that one command line argument was given | ||
if len(sys.argv) != 2: | ||
raise Exception("Usage: python floris_runscript.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 FLORIS standin with input file: {amr_input_file}") | ||
|
||
|
||
launch_floris(amr_input_file) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Input YAML for emy_python | ||
|
||
# Name | ||
name: example_000 | ||
|
||
### | ||
# Describe this emulator setup | ||
description: Floris and Solar PV | ||
|
||
dt: 0.5 | ||
|
||
hercules_comms: | ||
|
||
amr_wind: | ||
|
||
wind_farm_0: | ||
type: amr_wind_local #options are amr_wind or amr_wind_local | ||
amr_wind_input_file: amr_input.inp | ||
|
||
helics: | ||
|
||
config: | ||
name: hercules # What is the purpose of this name | ||
use_dash_frontend: False | ||
KAFKA: False | ||
KAFKA_topics: EMUV1py | ||
helics: | ||
# deltat: 1 # This will be assigned in software | ||
subscription_topics: [status] | ||
publication_topics: [control] | ||
endpoints: [] | ||
helicsport: 32000 | ||
publication_interval: 1 | ||
endpoint_interval: 1 | ||
starttime: 0 | ||
stoptime: 100 # must be at least 2*dt smaller than last timestep in weather file | ||
Agent: ControlCenter | ||
|
||
py_sims: | ||
|
||
solar_farm_0: # The name of py_sim object 1 | ||
|
||
py_sim_type: SolarPySAM | ||
weather_file_name: NonAnnualSimulation-sample_data-interpolated-daytime.csv | ||
system_info_file_name: 100MW_1axis_pvsamv1.json | ||
lat: 39.7442 | ||
lon: -105.1778 | ||
elev: 1829 | ||
|
||
# capacity: 100 # MW | ||
|
||
initial_conditions: | ||
|
||
power: 25 # MW | ||
dni: 1000 | ||
|
||
controller: | ||
|
||
external_data_file: solar_power_reference.csv | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is missing from the repo, I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added! |
||
|
||
|
||
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is maybe not used? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. README updated to clarify these options |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
""" | ||
Standalone Solar PySAM example - to test functionality without Helics | ||
for debugging PySAM integration | ||
""" | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
from hercules.python_simulators.solar_pysam import SolarPySAM | ||
|
||
# Initialize solar dict | ||
# -------- using interpolated data | ||
# solar_dict = { | ||
# "py_sim_type": SolarPySAM, | ||
# "weather_file_name": 'NonAnnualSimulation-sample_data-interpolated-daytime.csv', | ||
# "system_info_file_name": '100MW_1axis_pvsamv1.json', | ||
|
||
# "initial_conditions": { | ||
# "power": 25, | ||
# "irradiance": 1000 | ||
# }, | ||
# } | ||
|
||
# -------- testing functionality without a weather file - single timestep | ||
# solar_dict = { | ||
# "py_sim_type": SolarPySAM, | ||
# "weather_file_name": None, | ||
# "weather_data_input": { | ||
# "Timestamp": ['2018-05-10 12:31:00+00:00'], | ||
# "SRRL BMS Direct Normal Irradiance (W/m²_irr)": [330.8601989746094], | ||
# "SRRL BMS Diffuse Horizontal Irradiance (W/m²_irr)": [68.23037719726561], | ||
# "SRRL BMS Global Horizontal Irradiance (W/m²_irr)": [68.23037719726561], | ||
# "SRRL BMS Wind Speed at 19' (m/s)": [0.4400002620664621], | ||
# "SRRL BMS Dry Bulb Temperature (°C)": [11.990000406901045], | ||
# }, | ||
|
||
# "system_info_file_name": '100MW_1axis_pvsamv1.json', | ||
# # "system_info_file_name": None, | ||
# "lat": 39.7442, | ||
# "lon": -105.1778, | ||
# "elev": 1829, | ||
# "initial_conditions": { | ||
# "power": 25, | ||
# "dni": 1000 # direct normal irradiance | ||
# }, | ||
|
||
# "power_setpoints": {"time_s": 0.0, "power_mw": 10.} | ||
# } | ||
|
||
# -------- using interpolated data - five timesteps | ||
solar_dict = { | ||
"py_sim_type": SolarPySAM, | ||
"weather_file_name": 'fivetimesteps-sample_data-interpolated.csv', | ||
"system_info_file_name": '100MW_1axis_pvsamv1.json', | ||
"lat": 39.7442, | ||
"lon": -105.1778, | ||
"elev": 1829, | ||
"initial_conditions": { | ||
"power": 25, | ||
"dni": 1000 # direct normal irradiance | ||
}, | ||
|
||
# "power_setpoints": {"time_s": [0.0, 0.5, 1.0, 1.5, 2.0], | ||
# "power_mw": [10., 11., 12., 11., 10.]} | ||
|
||
"external_data_file": "solar_power_reference_data.csv" | ||
} | ||
|
||
dt = 0.5 # s - input file has a dt of 1 min | ||
|
||
time_start = 0 | ||
time_end = 2.5 # 11*3600 #[s] NonAnnualSimulation-sample-data contains 24 hrs | ||
|
||
# -------- start simulation | ||
SPS = SolarPySAM(solar_dict, dt) | ||
|
||
time_delta = dt | ||
time = np.arange(time_start, time_end, time_delta) | ||
print('time = ', time) | ||
|
||
def simulate(SPS, time): | ||
inputs = { | ||
"controller": {"signal": 0}, | ||
"py_sims": {"inputs": {"available_power": 100, | ||
"sim_time_s": 0}}, | ||
"external_signals": {"solar_power_reference": {"time_s": 0.0, "power_mw": 10.}}, | ||
} | ||
|
||
power = np.zeros(len(time)) | ||
dc_power = np.zeros(len(time)) | ||
aoi = np.zeros(len(time)) | ||
dni = np.zeros(len(time)) | ||
|
||
for i in range(len(time)): | ||
inputs["py_sims"]["inputs"]["sim_time_s"] = time[i] | ||
outputs = SPS.step(inputs) | ||
power[i] = outputs["power_mw"] | ||
dc_power[i] = outputs["dc_power_mw"] | ||
aoi[i] = outputs["aoi"] | ||
dni[i] = outputs["dni"] | ||
|
||
fig, ax = plt.subplots(3, 1, sharex="col") #, figsize=[6,5], dpi=250) | ||
|
||
ax[0].plot(time/3600, power, '.-', label="power") | ||
ax[0].set_ylabel('ac power') | ||
# ax[0].legend() | ||
|
||
# ax[1].plot(time/3600, dc_power, '.-', label="dc power") | ||
# ax[1].set_ylabel('dc power') | ||
|
||
ax[1].plot(time/3600, dni, '.-', label="irradiance") | ||
ax[1].set_ylabel('irradiance') | ||
# ax[1].legend() | ||
|
||
ax[2].plot(time/3600, aoi, '.-', label="aoi") | ||
ax[2].set_ylabel('aoi') | ||
ax[-1].set_xlabel('time [hr]') | ||
|
||
plt.show() | ||
|
||
simulate(SPS, time) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No big changes, just the path leading to the output file and a change in an output variable name