Access to reliable, resilient power systems is important in 21st century now more than ever. Terrestrial weather events exacerbated by climate change and extreme weather conditions are happening with greater frequency and intensity. Cyberattacks are seen at an increasing frequency against the power grid, and the attacks are becoming more sophisticated and targeted towards electric energy systems. The Idaho National Laboratory (INL), with funding from the Department of Energy (DOE) Wind Energy Technologies Office (WETO), has developed a [Resilinece Framework](http://www.spine-model.org for electric energy delivery systems (EEDS). The framework provides detailed steps for evaluating resiliency in the planning, operational, and future stages, and encompasses five core functions of resilience. It allows users to evaluate the resilience of distributed wind, taking into consideration the resilience of the wind systems themselves, as well as the effect they have on the resiliency of any systems they are connected to. This application follows the framework to allow stakeholders to evaluate their current position, create resiliency goals, compare different configuration and operation options, and decide which metrics are most appropriate for their system.
This tool is implemented as a Flask (Python) web application. It is currently primarily intended to be run/hosted locally by the end user. The app uses the Spine Toolbox and SpineOpt modeling tools to calculate values for resilience metrics. The input to Spine is an Excel spreadsheet of user system data and hazard modeling data.
-
Clone the project and submodules.
git clone https://github.com/idaholab/ResDEEDS.git
-
Run the install script.
cd ResDEEDS
sudo install/install.sh
-
Using Git Bash, clone the project and submodules.
git clone https://github.com/idaholab/ResDEEDS.git
-
Create and activate a Python virtual environment for the project.
cd ResDEEDS
py -m venv venv
. venv/Scripts/activate
-
Update pip.
python -m pip install --upgrade pip
-
Install the project.
pip install -r requirements.txt
-
Install Julia.
python -m jill install --confirm
-
Install Julia dependencies.
~/AppData/Local/julias/bin/julia.cmd -e 'using Pkg; Pkg.add(url="https://github.com/spine-tools/SpineInterface.jl.git")'
~/AppData/Local/julias/bin/julia.cmd -e 'using Pkg; Pkg.add(url="https://github.com/spine-tools/SpineOpt.jl.git")'
~/AppData/Local/julias/bin/julia.cmd -e 'using Pkg; Pkg.add(["XLSX", "DataFrames", "Distributions", "CSV", "Revise", "Cbc", "Clp"])'
-
Run Spine Toolbox to initialize configuration. You can close it after it opens.
python -m spinetoolbox &
-
Configure Spine Toolbox's Julia paths.
python venv/src/spinetoolbox/bin/configure_julia.py "C:/Users/$(whoami)/AppData/Local/julias/bin/julia.cmd" ""
-
Create
config/local.json
and override default config settings as needed. At a minimum, override"app_secret_key"
with a random string.
-
Navigate into the project folder using GitBash or PowerShell (we don't recommend running the app in an IDE-integrated terminal).
cd $PROJECT_ROOT
where
$PROJECT_ROOT
is yourResDEEDS
folder. On at least some version of Windows, you can also navigate to the folder in File Explorer, right-click on a blank space, and selectOpen in Terminal
. -
Activate the Python virtual environment.
. venv\Scripts\activate
-
Run
python src/app.py
.
- Run
install/run.sh
.
In a web browser, visit http://localhost:5000
, or the URL printed to the console during startup, if different.
Configuration is done via JSON in config/local.json
(create this file if it does not exist). This JSON overrides the values found in config/config.json
.
app_secret_key
- identifies your Flask app. Should remain secret.debug_mode
- set totrue
to enable Flask debugging.verbose_logging
- set totrue
to enable debug log messages.use_okta
- set totrue
to enable Okta authentication. Configure your Okta instance in aconfig/client_secrets.json
. If this is set tofalse
, the app runs in an unauthenticated mode, where all users can see all projects. For a single user running the app locally, we recommend setting this tofalse
.okta
- partial Okta configuration. The remainder is found in aconfig/client_secrets.json
file like this one.orgUrl
- the Okta organization URL, e.g. https://example.okta.com.token
- your API token.
database
- database configuration.dialect
- the dialect used for SQLAlchemy. Options are "sqlite" and "mysql".db_name
- the name of the SQL database.db_user
- (mysql only) the name of the SQL database user. The user should have all privileges on the database.db_pass
- (mysql only) the password of the SQL database user.db_host
- (mysql only) the host for the SQL server. Uselocalhost
if running locally.drop_and_recreate
- iftrue
, drops and recreates the database on Flask app startup. Intended for development/debugging only.
SQLite is used by default. MySQL is experimentally supported. To use MySQL, install the mysqlclient
package with pip.
If you are using the mysql dialect option for the database, you will need a MySQL or MariaDB server to connect to. These instructions are for if you want to run it locally on Windows.
You can install MariaDB via Chocolatey or via the installer for MariaDB Server available at https://mariadb.org/download/. If you plan to run the app locally, you do not need to enable networking for MariaDB server.
To start the MySQL service, open the Services app in Windows, find the MySQL service, right-click it and select Start.
Assuming MariaDB, open MySQL Client (installed along with MariaDB). The default password is blank.
To create the database for the project, run:
CREATE DATABASE resilience_calculator;
To create the database user, run:
GRANT ALL PRIVILEGES ON resilience_calculator.* TO resilience_calculator@localhost IDENTIFIED BY '<your_password>';
Your database password should be set as db_pass
in config/local.json
.