From d908c053d968b75034a24a78d755c5287a679ea6 Mon Sep 17 00:00:00 2001 From: Manoj Kumar Cebol Sundarrajan Date: Mon, 19 Dec 2022 09:58:09 -0700 Subject: [PATCH 1/6] update Caldera_ICM submodule reference to github repo --- .gitignore | 3 +++ .gitmodules | 7 +++---- CMakeLists.txt | 6 ++---- extern/Caldera_ICM | 1 + extern/caldera_charge_icm | 1 - source/ES500/CMakeLists.txt | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) create mode 160000 extern/Caldera_ICM delete mode 160000 extern/caldera_charge_icm diff --git a/.gitignore b/.gitignore index 7abebee..5a94ad6 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,6 @@ build/ #error files and output files inputs/*error* outputs/*.csv + +CMakeSettings.json +.vs/ diff --git a/.gitmodules b/.gitmodules index b02c572..6bc3ff0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,3 @@ -[submodule "extern/caldera_charge_icm"] - path = extern/caldera_charge_icm - url = https://hpcgitlab.hpc.inl.gov/caldera_charge/caldera_charge_icm.git - branch = main \ No newline at end of file +[submodule "extern/Caldera_ICM"] + path = extern/Caldera_ICM + url = https://github.com/idaholab/Caldera_ICM.git diff --git a/CMakeLists.txt b/CMakeLists.txt index bda6ccd..fe9ef95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,9 +13,7 @@ if (NOT (${PROJECT} STREQUAL "eMosaic" OR ${PROJECT} STREQUAL "EVs_at_Risk" OR $ message(FATAL_ERROR "PROJECT cmake variable must be equal to eMosaic or EVs_at_Risk or DirectXFC") endif() - # Find pybind11 - find_package(pybind11 CONFIG) # Update submodules @@ -33,7 +31,7 @@ if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") endif() endif() -if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/caldera_charge_icm/CMakeLists.txt") +if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/Caldera_ICM/CMakeLists.txt") message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.") endif() @@ -43,4 +41,4 @@ SET(INSTALL_DIR ${PROJECT_SOURCE_DIR}/libs) # Add subdirs to compile the necessary binaries add_subdirectory(source/ES500) -add_subdirectory(extern/caldera_charge_icm) +add_subdirectory(extern/Caldera_ICM) diff --git a/extern/Caldera_ICM b/extern/Caldera_ICM new file mode 160000 index 0000000..de73311 --- /dev/null +++ b/extern/Caldera_ICM @@ -0,0 +1 @@ +Subproject commit de733113552d35c960981242c0dc632506c0b49b diff --git a/extern/caldera_charge_icm b/extern/caldera_charge_icm deleted file mode 160000 index 6ee4778..0000000 --- a/extern/caldera_charge_icm +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6ee47783bd326eee6fc854074e238c0d0b581d29 diff --git a/source/ES500/CMakeLists.txt b/source/ES500/CMakeLists.txt index 051885b..d923220 100644 --- a/source/ES500/CMakeLists.txt +++ b/source/ES500/CMakeLists.txt @@ -1,4 +1,4 @@ -set(GLOBALS_DIR ${PROJECT_SOURCE_DIR}/extern/caldera_charge_icm/source/charging_models) +set(GLOBALS_DIR ${PROJECT_SOURCE_DIR}/extern/Caldera_ICM/source/charging_models) pybind11_add_module(ES500_Aggregator_Helper ${GLOBALS_DIR}/datatypes_global.cpp ${GLOBALS_DIR}/${PROJECT}/datatypes_global_SE_EV_definitions.cpp From 8cb793e0d674b2e52dbbaf4ad548c0db1cc4cd90 Mon Sep 17 00:00:00 2001 From: steven-schmidt-inl Date: Wed, 21 Dec 2022 15:29:16 -0700 Subject: [PATCH 2/6] Fixing linux compile issue by adding a line to CMakeLists.txt --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe9ef95..6c57455 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.5) project(Grid) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + # Check to see PROJECT cmake variable is set if (NOT DEFINED PROJECT) message(WARNING "PROJECT cmake variable not set defaulting to emosiac project") From cbf972424495b2c26b9971a5c1c2022d0e9f64a9 Mon Sep 17 00:00:00 2001 From: Steven Schmidt Date: Thu, 16 Feb 2023 12:35:44 -0700 Subject: [PATCH 3/6] Updating submodule, and fixing operator< functions to fix bug in macOS --- extern/Caldera_ICM | 2 +- source/ES500/ES500_aggregator_helper.h | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/extern/Caldera_ICM b/extern/Caldera_ICM index de73311..d261daa 160000 --- a/extern/Caldera_ICM +++ b/extern/Caldera_ICM @@ -1 +1 @@ -Subproject commit de733113552d35c960981242c0dc632506c0b49b +Subproject commit d261daa8009ea63c989d75a2a6e25060509561bb diff --git a/source/ES500/ES500_aggregator_helper.h b/source/ES500/ES500_aggregator_helper.h index 291fd1b..42c0b99 100644 --- a/source/ES500/ES500_aggregator_helper.h +++ b/source/ES500/ES500_aggregator_helper.h @@ -25,7 +25,12 @@ class ES500_aggregator_allocate_energy_to_PEVs int index; double charge_progression; - bool operator < (const SE_priority_element& rhs) + bool operator<(const SE_priority_element& rhs) const + { + return this->charge_progression < rhs.charge_progression; + } + + bool operator<(SE_priority_element& rhs) const { return this->charge_progression < rhs.charge_progression; } From 8e94f1620ed2f7f47790bf8dd8d442cb98558878 Mon Sep 17 00:00:00 2001 From: Manoj Kumar Cebol Sundarrajan Date: Tue, 28 Feb 2023 12:25:12 -0700 Subject: [PATCH 4/6] Fix helics depreciation warnings --- source/federates/Caldera_ICM_federate.py | 4 ++-- source/federates/OpenDSS_federate.py | 2 +- source/federates/typeA_control_federate.py | 4 ++-- source/federates/typeB_control_federate.py | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/source/federates/Caldera_ICM_federate.py b/source/federates/Caldera_ICM_federate.py index 80ad366..f185133 100644 --- a/source/federates/Caldera_ICM_federate.py +++ b/source/federates/Caldera_ICM_federate.py @@ -12,8 +12,8 @@ def caldera_ICM_federate(base_dir, json_config_file_name, simulation_time_constr config_file_path = base_dir + "/source/helics_config/" + json_config_file_name fed = h.helicsCreateCombinationFederateFromConfig(config_file_path) - sub_data_loaded = h.helicsFederateGetSubscription(fed, 'Load_Input_Files/data_loaded') - sub_dss_simulation_loaded = h.helicsFederateGetSubscription(fed, 'OpenDSS/dss_simulation_loaded') + sub_data_loaded = h.helicsFederateGetInputByTarget(fed, 'Load_Input_Files/data_loaded') + sub_dss_simulation_loaded = h.helicsFederateGetInputByTarget(fed, 'OpenDSS/dss_simulation_loaded') input_datasets_endpoint_local = h.helicsFederateGetEndpoint(fed, "input_datasets_endpoint") input_datasets_endpoint_remote = h.helicsEndpointGetDefaultDestination(input_datasets_endpoint_local) diff --git a/source/federates/OpenDSS_federate.py b/source/federates/OpenDSS_federate.py index e368c02..1ece9ef 100644 --- a/source/federates/OpenDSS_federate.py +++ b/source/federates/OpenDSS_federate.py @@ -11,7 +11,7 @@ def open_dss_federate(base_dir, json_config_file_name, simulation_time_constrain config_file_path = base_dir + "/source/helics_config/" + json_config_file_name fed = h.helicsCreateCombinationFederateFromConfig(config_file_path) - sub_data_loaded = h.helicsFederateGetSubscription(fed, 'Load_Input_Files/data_loaded') + sub_data_loaded = h.helicsFederateGetInputByTarget(fed, 'Load_Input_Files/data_loaded') pub_dss_simulation_loaded = h.helicsFederateGetPublication(fed, 'dss_simulation_loaded') input_datasets_endpoint_local = h.helicsFederateGetEndpoint(fed, "input_datasets_endpoint") diff --git a/source/federates/typeA_control_federate.py b/source/federates/typeA_control_federate.py index 37ada39..6543342 100644 --- a/source/federates/typeA_control_federate.py +++ b/source/federates/typeA_control_federate.py @@ -9,8 +9,8 @@ def typeA_control_federate(base_dir, json_config_file_name, simulation_time_cons config_file_path = base_dir + "/source/helics_config/" + json_config_file_name fed = h.helicsCreateCombinationFederateFromConfig(config_file_path) - sub_data_loaded = h.helicsFederateGetSubscription(fed, 'Load_Input_Files/data_loaded') - sub_dss_simulation_loaded = h.helicsFederateGetSubscription(fed, 'OpenDSS/dss_simulation_loaded') + sub_data_loaded = h.helicsFederateGetInputByTarget(fed, 'Load_Input_Files/data_loaded') + sub_dss_simulation_loaded = h.helicsFederateGetInputByTarget(fed, 'OpenDSS/dss_simulation_loaded') input_datasets_endpoint_local = h.helicsFederateGetEndpoint(fed, "input_datasets_endpoint") input_datasets_endpoint_remote = h.helicsEndpointGetDefaultDestination(input_datasets_endpoint_local) diff --git a/source/federates/typeB_control_federate.py b/source/federates/typeB_control_federate.py index cc22a4e..883e530 100644 --- a/source/federates/typeB_control_federate.py +++ b/source/federates/typeB_control_federate.py @@ -10,8 +10,8 @@ def typeB_control_federate(base_dir, json_config_file_name, simulation_time_cons config_file_path = base_dir + "/source/helics_config/" + json_config_file_name fed = h.helicsCreateCombinationFederateFromConfig(config_file_path) - sub_data_loaded = h.helicsFederateGetSubscription(fed, 'Load_Input_Files/data_loaded') - sub_dss_simulation_loaded = h.helicsFederateGetSubscription(fed, 'OpenDSS/dss_simulation_loaded') + sub_data_loaded = h.helicsFederateGetInputByTarget(fed, 'Load_Input_Files/data_loaded') + sub_dss_simulation_loaded = h.helicsFederateGetInputByTarget(fed, 'OpenDSS/dss_simulation_loaded') input_datasets_endpoint_local = h.helicsFederateGetEndpoint(fed, "input_datasets_endpoint") input_datasets_endpoint_remote = h.helicsEndpointGetDefaultDestination(input_datasets_endpoint_local) From 71d89cfa1c120dc94d29bc917f270fc6500a8ee9 Mon Sep 17 00:00:00 2001 From: Manoj Kumar Cebol Sundarrajan Date: Tue, 28 Feb 2023 12:32:43 -0700 Subject: [PATCH 5/6] Fix np.str is depreciated. --- source/base/load_input_files.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/base/load_input_files.py b/source/base/load_input_files.py index e8fa2b1..613ff36 100644 --- a/source/base/load_input_files.py +++ b/source/base/load_input_files.py @@ -507,7 +507,7 @@ def __get_supply_equipment_data(self, SE_data_file_path): if len(errors) == 0: grid_node_id_col_name = elements[4].strip() location_type_col_name = elements[6].strip() - df = pd.read_csv(SE_data_file_path, sep=',', header=0, dtype={grid_node_id_col_name:np.str, location_type_col_name:np.str}) + df = pd.read_csv(SE_data_file_path, sep=',', header=0, dtype={grid_node_id_col_name:str, location_type_col_name:str}) if len(df.columns) != number_of_fields: errors.append('NA, There must be {} columns in file.'.format(number_of_fields)) From f89b5f60d35827f82ce78010c4f96b0909062199 Mon Sep 17 00:00:00 2001 From: Manoj Kumar Cebol Sundarrajan Date: Tue, 28 Feb 2023 22:07:06 -0700 Subject: [PATCH 6/6] Updated documentation --- README.md | 135 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 104 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 420ef49..8e224ba 100644 --- a/README.md +++ b/README.md @@ -1,47 +1,120 @@ -# Caldera_Charge_Grid +# Caldera_Grid Caldera and OpenDSS co-simulation platform using HELICS ## Overview -Caldera Grid enables modeling EV charging on the electric grid. Caldera Grid cosimulation platform is built using HELICS (Hierarchical Engine for Large Scale Infrastructure Co-simulation) and cosimulates Caldera ICM with OpenDSS. The platfrom also provides an interface to apply custom control strategies to EV charge events. +Caldera Grid enables modeling EV charging on the electric grid. Caldera Grid co-simulation platform is built using HELICS (Hierarchical Engine for Large Scale Infrastructure Co-simulation) and cosimulates Caldera ICM with OpenDSS. The platfrom also provides an interface to apply custom control strategies to EV charge events. -## Prerequisites - -Caldera Grid depends on `C++ compiler`, `git`, `cmake`, `python` and `pybind11` to compile. ## Installation -Get a copy of Caldera ICM. -``` -git clone https://hpcgitlab.hpc.inl.gov/caldera_charge/caldera_charge_grid.git -``` -If you are interested in the most up to date version of Caldera ICM, the development version is available in the `develop` branch. -``` -git switch develop -``` -To install Caldera Grid using cmake -``` -cd caldera_charge_grid -mkdir build -cmake -DPROJECT= -DICM= ../ -make -make install -``` -If cmake cannot find C++ compiler, python or pybind11. They need to be pointed to its installed paths to find them. Refer to [pybind11](https://pybind11.readthedocs.io/en/stable/compiling.html#building-with-cmake) and [cmake](https://cmake.org/cmake/help/latest/guide/tutorial/index.html) documentations. - - -Caldera Grid compiles the Caldera ICM submodule and installs compiled python libraries in the `libs/` folder. - -`-DPROJECT` flag is used to specify the project specific EV-EVSE models to be used. Options are `DirectXFC`, `eMosaic` and `EVs_at_Risk`. `-DICM` flag turns ON/OFF compiling `Caldera_ICM` lib. Please refer to Caldera ICM project for more information with respect to Caldera ICM compilation. +### Windows + +The installation approach for windows is only a suggested approach which is well tested + + +#### Prerequisites + +Caldera Grid has the following requirements to be able to compile on windows + +1. Install git for windows +2. Install Anaconda +3. Install visual studio with C++ and cmake + +#### Anaconda environment setup + +1. Open anaconda prompt +2. Create a new conda environment + ``` + conda create -n Caldera python=3.9 # (recommended version >= 3.7.0) + ``` +3. Activate the new conda environment + ``` + conda activate Caldera + ``` +4. Install required python packages + ``` + conda install pybind11 # (recommended version >= 2.10) + conda install numpy # (recommended version >= 1.23.5) + conda install pandas # (recommended version >= 1.5.2) + conda install cvxopt # (recommended version >= 1.2.6) + pip install "OpenDSSDirect.py[extras]" # (recommended version >= 0.7.0) + pip install helics # (recommended version >= 3.4.0) + ``` + +#### Download Caldera Grid + +1. open git for windows +2. navigate to desired folder where you would like to download Caldera Grid + ``` + cd + ``` +3. clone Caldera Grid from Github + ``` + git clone https://github.com/idaholab/Caldera_Grid.git + ``` +4. Swich to develop branch. Develop branch has the most recent updates and bug fixes for Caldera Grid + ``` + git switch develop + ``` + +#### Compile Caldera Grid + +1. Open the downloaded Caldera Grid folder in Visual Studio + ``` + File -> Open -> Folder -> + ``` +2. Open CMakeSettings.json + ``` + Project -> CMake Settings + ``` +3. Set flages for the cmake compilation process in the CMake command arguments test box + ``` + -DPROJECT=eMosaic -DICM=ON -DPYTHON_EXECUTABLE=\envs\\python.exe -Dpybind11_DIR=\envs\\Library\share\cmake\pybind11 + ``` + - PROJECT - options are DirectXFC, eMosaic and EVs_at_Risk + - ICM - needs to be ON, Caldera_Grid needs ICM module +4. Configure CMake + - Saving CMakeSettings.json will kick off the configuration in the output tab +5. Build libraries + ``` + build -> build all + ``` +6. Install libraries + ``` + build -> Install Grid + ``` + +#### Running Caldera Grid + +1. Open Anaconda prompt +2. Navigate to project folder + ``` + cd + ``` +3. Activate Anaconda environment + ``` + conda activate Caldera + ``` +4. Run simulation + ``` + python start_execution.py + ``` + + - `start_execution.py` is set up to run a simple example of EVs charging on the IEEE 34 node test feeder. + + +__NOTE :__ If the excution takes longer time to run, Try using release mode to build ## Usage Please refer to [usage documentation](https://hpcgitlab.hpc.inl.gov/caldera_charge/caldera_charge_grid/-/raw/main/docs/Caldera-OpenDSS%20simulation%20platform.pptx) to learn on how to use the tool. -`start_execution.py` is set up to run a simple example of EVs charging on the IEEE 34 node test feeder. +## Citation +If you use Caldera Grid in your research, please cite: + +Sundarrajan, Manoj Kumar Cebol, Scoffield, Don R, Rumsey, Paden D, & USDOE Office of Nuclear Energy. (2022, December 13). idaholab/Caldera_Grid [Computer software]. https://www.osti.gov//servlets/purl/1907411. https://doi.org/10.11578/dc.20230103.3 + ## Authors 1. Don Scoffield, Senior Research Engineer, Idaho National Laboratory 2. Manoj Sundarrajan, Research Software Developer, Idaho National Laboratory - -## License -For open source projects, say how it is licensed.