Skip to content

Commit

Permalink
Docs restructuring (#637)
Browse files Browse the repository at this point in the history
* Summary of Significant Features on this PR: Added test for time domain reduction module, VREStor module, electrolyzer module, PiecewiseFuel CO2 module, method of Morris;  Added new test over 3 zones and 5 repres days, Added test case for multi-stage module, Refactored tests to include multistage, Fixed print suppression in test, Refactored solve_genx_model_testing to include Morris, Fixed filenames in test to match JuMP convention, Added GH action to run tests, Added GITHUB_TOKEN to the repository secrets, Test logs updated, Added ThreeZone test to list of tests, Added rounding to the objective func value in the tests, Updated GH workflow, Added the license sentence on the opening page, which has been missing, Moved TDR from Model Concept to User Guide; Moved Multistage and maintenance from Model_concept to Model Reference, Updated make.jl with new section for API Reference, GenX logo PNG file, Updated the Julia version for GenX runs, Inserted ZENODO DOI badge

---------

Co-authored-by: Chakrabarti, Sambuddha (Sam) <[email protected]>
  • Loading branch information
lbonaldo and sambuddhac authored Mar 18, 2024
1 parent 5462c79 commit 293ad2c
Show file tree
Hide file tree
Showing 148 changed files with 4,806 additions and 1,582 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Documenter

on:
pull_request:
push:
branches: [main]
tags: ['*']

jobs:
Documenter:
permissions:
contents: write
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-docdeploy@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
204 changes: 20 additions & 184 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[deps]
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
GenX = "5d317b1e-30ec-4ed6-a8ce-8d2d88d7cfac"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
140 changes: 87 additions & 53 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,91 +1,125 @@
push!(LOAD_PATH,"../src/")
#=cd("../")
include(joinpath(pwd(), "package_activate.jl"))
genx_path = joinpath(pwd(), "src")
push!(LOAD_PATH, genx_path)=#
import DataStructures: OrderedDict
using GenX
using Documenter
using GenX
import DataStructures: OrderedDict

DocMeta.setdocmeta!(GenX, :DocTestSetup, :(using GenX); recursive=true)
println(pwd())
genx_docpath = joinpath(pwd(), "docs/src")
push!(LOAD_PATH, genx_docpath)

pages = OrderedDict(
"Welcome Page" => [
"GenX: Introduction" => "index.md",
"Running GenX Cases" => "how_to_run_genx.md",
"Multi-Stage Capacity Expansion Planning with GenX" => "multi_stage_genx.md",
"Installation Guide" => "installation.md",
"Limitation of GenX" => "limitations_genx.md",
"Third Party Extensions" => "third_party_genx.md"
],
"Getting Started" => [
"Running GenX" => "Getting_Started/examples_casestudies.md",
"Commertial solvers" => "Getting_Started/commercial_solvers.md",
],
"Tutorials" => [
"Tutorials Overview" => "Tutorials/Tutorials_intro.md",
"Tutorial 1: Configuring Settings" => "Tutorials/Tutorial_1_configuring_settings.md",
"Tutorial 2: Network Visualization" => "Tutorials/Tutorial_2_network_visualization.md",
"Tutorial 3: K-Means and Time Domain Reduction" => "Tutorials/Tutorial_3_K-means_time_domain_reduction.md",
"Tutorial 4: Model Generation" => "Tutorials/Tutorial_4_model_generation.md",
"Tutorial 5: Solving the Model" => "Tutorials/Tutorial_5_solve_model.md",
"Tutorial 6: Post Processing" => "Tutorials/Tutorial_6_solver_settings.md",
],
"User Guide" => [
"Overall workflow" => "User_Guide/workflow.md",
"Model Configuration" => "User_Guide/model_configuration.md",
"Solver Configuration" => "User_Guide/solver_configuration.md",
"Model Inputs" => "User_Guide/model_input.md",
"Time-domain Reduction Inputs" => "User_Guide/TDR_input.md",
"Running the Time-domain Reduction" => "User_Guide/running_TDR.md",
"MGA package" => "User_Guide/generate_alternatives.md",
"Multi-stage Model" => "User_Guide/multi_stage_input.md",
"Slack Variables for Policies" => "User_Guide/slack_variables_overview.md",
"Method of Morris Inputs" => "User_Guide/methodofmorris_input.md",
"Running the Model" => "User_Guide/running_model.md",
"Model Outputs" => "User_Guide/model_output.md",
],
"Model Concept and Overview" => [
"Model Introduction" => "model_introduction.md",
"Notation" => "model_notation.md",
"Objective Function" => "objective_function.md",
"Power Balance" => "power_balance.md"
"Model Introduction" => "Model_Concept_Overview/model_introduction.md",
"Notation" => "Model_Concept_Overview/model_notation.md",
"Objective Function" => "Model_Concept_Overview/objective_function.md",
"Power Balance" => "Model_Concept_Overview/power_balance.md",
],
"Model Function Reference" => [
"Core" => "core.md",
"Model Reference" => [
"Core" => "Model_Reference/core.md",
"Resources" => [
"Curtailable Variable Renewable" => "curtailable_variable_renewable.md",
"Flexible Demand" => "flexible_demand.md",
"Curtailable Variable Renewable" => "Model_Reference/Resources/curtailable_variable_renewable.md",
"Flexible Demand" => "Model_Reference/Resources/flexible_demand.md",
"Hydro" => [
"Hydro Reservoir" => "hydro_res.md",
"Long Duration Hydro" => "hydro_inter_period_linkage.md"
"Hydro Reservoir" => "Model_Reference/Resources/hydro_res.md",
"Long Duration Hydro" => "Model_Reference/Resources/hydro_inter_period_linkage.md"
],
"Must Run" => "must_run.md",
"Must Run" => "Model_Reference/Resources/must_run.md",
"Storage" => [
"Storage" => "storage.md",
"Investment Charge" => "investment_charge.md",
"Investment Energy" => "investment_energy.md",
"Long Duration Storage" => "long_duration_storage.md",
"Storage All" => "storage_all.md",
"Storage Asymmetric" => "storage_asymmetric.md",
"Storage Symmetric" => "storage_symmetric.md"
"Storage" => "Model_Reference/Resources/storage.md",
"Investment Charge" => "Model_Reference/Resources/investment_charge.md",
"Investment Energy" => "Model_Reference/Resources/investment_energy.md",
"Long Duration Storage" => "Model_Reference/Resources/long_duration_storage.md",
"Storage All" => "Model_Reference/Resources/storage_all.md",
"Storage Asymmetric" => "Model_Reference/Resources/storage_asymmetric.md",
"Storage Symmetric" => "Model_Reference/Resources/storage_symmetric.md"
],
"Co-located VRE and Storage" => "vre_stor.md",
"Co-located VRE and Storage" => "Model_Reference/Resources/vre_stor.md",
"Thermal" => [
"Thermal" => "thermal.md",
"Thermal Commit" => "thermal_commit.md",
"Thermal No Commit" => "thermal_no_commit.md"
"Thermal" => "Model_Reference/Resources/thermal.md",
"Thermal Commit" => "Model_Reference/Resources/thermal_commit.md",
"Thermal No Commit" => "Model_Reference/Resources/thermal_no_commit.md"
],
"Hydrogen Electrolyzers" => "electrolyzers.md",
"Scheduled maintenance for various resources" => "maintenance.md",
"Resource types" => "resource.md"
"Hydrogen Electrolyzers" => "Model_Reference/Resources/electrolyzers.md",
"Retrofit" => "Model_Reference/Resources/retrofit.md",
"Scheduled maintenance for various resources" => "Model_Reference/Resources/maintenance.md",
"Resource types" => "Model_Reference/Resources/resource.md"
],
"Multi_stage" => [
"Configure multi-stage inputs" => "configure_multi_stage_inputs.md",
"Model multi stage: Dual Dynamic Programming Algorithm" => "dual_dynamic_programming.md",
"Maintenance" => "Model_Reference/maintenance_overview.md",
"Policies" => "Model_Reference/policies.md",
"Solver Configurations" => "Model_Reference/solver_configuration_api.md",
"Inputs Functions" => "Model_Reference/load_inputs.md",
"Generate the Model" => "Model_Reference/generate_model.md",
"Solving the Model" => "Model_Reference/solve_model.md",
"Time-domain Reduction" => "Model_Reference/TDR.md",
"Outputs Functions" => "Model_Reference/write_outputs.md",
"Modeling to Generate Alternatives" => "Model_Reference/mga.md",
"Multi-stage" => [
"Multi-Stage Modeling Introduction" => "Model_Reference/Multi_Stage/multi_stage_overview.md",
"Configure multi-stage inputs" => "Model_Reference/Multi_Stage/configure_multi_stage_inputs.md",
"Model multi stage: Dual Dynamic Programming Algorithm" => "Model_Reference/Multi_Stage/dual_dynamic_programming.md",
"Endogenous Retirement" => "Model_Reference/Multi_Stage/endogenous_retirement.md"
],
"Policies" => "policies.md",
"Slack Variables for Policies" => "slack_variables_overview.md",
"Method of Morris" => "Model_Reference/methodofmorris.md",
"Utility Functions" => "Model_Reference/utility_functions.md",
],
"Methods" => "methods.md",
"Solver Configurations" => "solver_configuration.md",
"Solving the Model" => "solve_model.md",
"Model Inputs/Outputs Documentation" => [
"Single-stage Model" => "data_documentation.md",
"Multi-stage Model" => "multi_stage_model_overview.md",
"Public API Reference" => [
"Public API" => "Public_API/public_api.md",

],
"GenX Inputs Functions" => "load_inputs.md",
"GenX Outputs Functions" =>"write_outputs.md",
"Additional Features" => "additional_features.md",
"Third Party Extensions" => "additional_third_party_extensions.md",
"Developer Docs" => "developer_guide.md",
)

# Build documentation.
# ====================

makedocs(;
modules=[GenX],
authors="Jesse Jenkins, Nestor Sepulveda, Dharik Mallapragada, Aaron Schwartz, Neha Patankar, Qingyu Xu, Jack Morris, Sambuddha Chakrabarti",
#repo="https://github.com/sambuddhac/GenX.jl/blob/{commit}{path}#{line}",
sitename="GenX",
format=Documenter.HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://genxproject.github.io/GenX/stable",
assets=String[],
assets = ["assets/genx_style.css"],
sidebar_sitename=false,
collapselevel=1
),
pages=[p for p in pages]
)

# Deploy built documentation.
# ===========================

deploydocs(;
repo="github.com/GenXProject/GenX.git",
target = "build",
Expand Down
30 changes: 30 additions & 0 deletions docs/src/Getting_Started/commercial_solvers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## Using commercial solvers: Gurobi or CPLEX

If you want to use the commercial solvers Gurobi or CPLEX:

- Make sure you have a valid license and the actual solvers for either of Gurobi or CPLEX installed on your machine
- Add Gurobi or CPLEX to the Julia Project.

```
$ julia --project=/home/youruser/GenX
julia> <press close-bracket ] to access the package manager>
(GenX) pkg> add Gurobi
-or-
(GenX) pkg> add CPLEX
```
```@meta
#TODO: Add instructions for adding Gurobi or CPLEX to the Julia Project with the new PR.
```

- Edit the `Run.jl` file to use the commercial solver. For example, to use Gurobi, you can add the following lines to the `Run.jl` file:

```julia
using Gurobi
using GenX

run_genx_case!(dirname(@__FILE__), Gurobi.Optimizer)
```

!!! warning "Warning"
Note that if you have not already installed the required Julia packages or you do not have a valid Gurobi license on your host machine, you will receive an error message and Run.jl will not run to completion.
146 changes: 146 additions & 0 deletions docs/src/Getting_Started/examples_casestudies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Running GenX

This section describes how to run GenX with the examples provided in the repository and with user-defined cases. To have a deeper understanding of how to structure the input files and the settings, please refer to the [User Guide](@ref).

## Example cases
GenX repository contains several examples to get you started with GenX. These examples are located in the [example_systems](https://github.com/GenXProject/GenX/tree/main/example_systems) folder of the repository and are designed to be easy to run and to demonstrate the main features of GenX.

The available examples are:

- [1\_three\_zones](https://github.com/GenXProject/GenX/tree/main/example_systems/1_three_zones)
- [2\_three\_zones\_w\_electrolyzer](https://github.com/GenXProject/GenX/tree/main/example_systems/2_three_zones_w_electrolyzer)
- [3\_three\_zone\_w\_co2\_capture](https://github.com/GenXProject/GenX/tree/main/example_systems/3_three_zone_w_co2_capture)
- [4\_three\_zones\_w\_policies\_slack](https://github.com/GenXProject/GenX/tree/main/example_systems/4_three_zones_w_policies_slack)
- [5\_three\_zones\_w\_piecewise\_fuel](https://github.com/GenXProject/GenX/tree/main/example_systems/5_three_zones_w_piecewise_fuel)
- [6\_three\_zones\_w\_multistage](https://github.com/GenXProject/GenX/tree/main/example_systems/6_three_zones_w_multistage)
- [7\_three\_zones\_w\_colocated\_VRE\_storage](https://github.com/GenXProject/GenX/tree/main/example_systems/7_three_zones_w_colocated_VRE_storage)
- [IEEE\_9\_bus\_DC\_OPF](https://github.com/GenXProject/GenX/tree/main/example_systems/IEEE_9_bus_DC_OPF)

!!! note "Note"
The following instructions assume that you have already installed GenX and its dependencies. If you haven't, please follow the instructions in the [Installation Guide](@ref).

To run an example, follow these steps:
1. Open a terminal and run Julia with an environment containing GenX;
2. Run the `Run.jl` file located in the example folder.

For example, to run the `1_three_zones` example, you can use the following commands:
```
$ julia
julia> <press close-bracket ] to access the package manager>
(@v1.9) pkg> activate /path/to/env
julia> using GenX
julia> include("/path/to/GenX/example_systems/1_three_zones/Run.jl")
```
where `/path/to/env` is the path to the environment containing GenX and `/path/to/GenX` is the path to the `GenX` repository containing the examples.

The `Run.jl` file will read the `.csv` input files which define the system, the resources, and the policies, will solve the model, and finally will write the results in a `results` folder located in the same directory as `Run.jl`.

!!! tip "Tip"
You could also run the example from the terminal using the following command:
```
$ julia --project=/path/to/env /path/to/GenX/example_systems/1_three_zones/Run.jl`
```
This is equivalent to open a Julia REPL and call the `Run.jl` file using the `include` function.
The first option is recommended if you want to run GenX multiple times with different settings because it avoids the overhead of recompiling the code every time you run it.

!!! note "Note"
The default solver for GenX is [HiGHS](https://github.com/jump-dev/HiGHS.jl).

For more information on what happens when you run a GenX case, see the [Running GenX](@ref) section.

!!! note "Note"
The first seven examples are based on a one-year example with hourly resolution, containing zones representing Massachusetts, Connecticut, and Maine. The ten represented resources include natural gas, solar PV, wind, and lithium-ion battery storage.


## Running GenX with user-defined cases
To run GenX with a user-defined case, you need to create a folder `MyCase` with the following structure:

```
MyCase
├── settings/
├── system/
├── policies/
├── resources/
├── README.md
└── Run.jl
```

where the `settings` folder contains the configuration files for the model and the solver, the `system` folder contains the `.csv` input files related to the system under study, the `resource` folder contains the `.csv` input files with the list of generators to include in the model, and the `policies` folder contains the `.csv` input files which define the policies to be included in the model.
For instance, one case could have the following structure:

```
MyCase
├── settings
│ ├── genx_settings.yml # GenX settings
│ ├── [solver_name]_settings.yml # Solver settings
│ ├── multi_stage_settings.yml # Multi-stage settings
│ └── time_domain_reduction.yml # Time-domain clustering settings
├── system
│ ├── Demand_data.csv
│ ├── Fuel_data.csv
│ ├── Generators_variability.csv
│ └── Network.csv
├── policies
│ ├── CO2_cap.csv
│ ├── Minimum_capacity_requirement.csv
│ └── Energy_share_requirement.csv
├── resources
│ ├── Thermal.csv
│ ├── Storage.csv
│ ├── Vre.csv
│ ├── Hydro.csv
│ └── policy_assignments
| ├── Resource_minimum_capacity_requirement.csv
│ └── Resource_energy_share_requirement.csv
└── Run.jl
```

In this example, `MyCase` will define a case with `Themal`, `Storage`, `Vre`, and `Hydro` resources, the `system` folder will provide the data for the demand, fuel, generators' variability, and network, the `policies` folder will include a CO2 cap, a minimum capacity requirement, and an energy share requirement, and the `settings` folder will contain the configuration files for the model.

The `Run.jl` file should contain the following code:
```julia
using GenX

run_genx_case!(dirname(@__FILE__))
```
which will run the case using the default solver. To use a different solver, you can pass the Optimizer object as an argument to `run_genx_case!` function. For example, to use Gurobi as the solver, you can use the following code:

```julia
using GenX
using Gurobi

run_genx_case!(dirname(@__FILE__), Gurobi.Optimizer)
```

To run the case, open a terminal and run the following command:
```
$ julia --project="/path/to/env"
julia> include("/path/to/MyCase/Run.jl")
```
where `/path/to/env` is the path to the environment with `GenX` installed, and `/path/to/MyCase` is the path to the folder of the `MyCase` case.
Alternatively, you can run the case directly from the terminal using the following command:
```
$ julia --project="/path/to/env" /path/to/MyCase/Run.jl
```

## What happens when you run a case
*Added in 0.3.4*

The entry point for running a GenX case is the `run_genx_case!("path/to/case")` function, where `path/to/case` is the path to the case directory that contains the `.csv` files with the inputs for GenX and the `settings` folder with the configuration files.

The following are the main steps performed in this function:

1. Establish path to environment setup files and GenX source files.
2. Read in model settings `genx_settings.yml` from the example directory.
3. Configure solver settings.
4. Load the model inputs from the example directory and perform time-domain clustering if required.
5. Generate a GenX model instance.
6. Solve the model.
7. Write the output files to a specified directory.

After the script runs to completion, results will be written to a folder called `results`, located in the current working directory.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Finally, the model is usually configured to consider a full year of operating de
With appropriate configuration of the model, GenX thus allows the user to tractably consider several interlinking decision layers in a single, monolithic optimization problem that would otherwise have been necessary to solve in different separated stages or models. The following figure reflects the range of configurations currently possible along the three key dimensions of chronological detail, operational detail, and network detail.


![Range of configurations currently implemented in GenX along three key dimensions of model resolution](assets/Dimensions_graphic3_background.png)
![Range of configurations currently implemented in GenX along three key dimensions of model resolution](../assets/Dimensions_graphic3_background.png)
*Figure. Range of configurations currently implemented in GenX along three key dimensions of model resolution*

The model can be configured to consider a single future planning year or multiple planning stages (or investment periods) in sequence.
Expand Down
Loading

0 comments on commit 293ad2c

Please sign in to comment.