|
1 | 1 |
|
2 | | -**4. Quickstarter Notebook** |
| 2 | +**4. PowNet 2.0 Quick Start Guide** |
3 | 3 | ============================ |
| 4 | +This tutorial demonstrates how to use PowNet 2.0 to simulate a dummy power system over a 24-hour horizon for two simulation days. |
4 | 5 |
|
5 | | -**1. Install Jupyter Notebook** |
| 6 | +1. Model Overview |
| 7 | +----------------- |
6 | 8 |
|
7 | | -.. code:: shell |
| 9 | +The dummy power system includes a variety of generation sources and a single buyer. |
8 | 10 |
|
9 | | - >>> pip install jupyterlab |
| 11 | +:: |
10 | 12 |
|
11 | | -**2. Launch a Jupyter Notebook from the terminal** |
| 13 | + pOil |
| 14 | + | |
| 15 | + | |
| 16 | + Node 3 --- pGas |
| 17 | + | |
| 18 | + | |
| 19 | + Node 1 --- Node 2 --- pHydro --- Buyer |
| 20 | + | | |
| 21 | + | | |
| 22 | + Supplier pBiomass |
12 | 23 |
|
13 | | -.. code:: shell |
14 | 24 |
|
15 | | - >>> jupyter lab |
| 25 | +2. Setup |
| 26 | +---------- |
16 | 27 |
|
17 | | -**3. Download PowNet from CIS Lab GitHub Repo** |
| 28 | +* **Input Folder:** Define the directory containing the power system models (`input_folder`). This folder may contain multiple subdirectories. Ensure the `input_folder` contains a subdirectory named `model_name` with the necessary model data, which is a set of CSV files. |
18 | 29 |
|
19 | | -.. code:: shell |
20 | | - |
21 | | - >>> ! git clone https://github.com/Critical-Infrastructure-Systems-Lab/PowNet.git |
| 30 | +* **Model Year:** Specify the simulation year (`model_year`). This value must match the year associated with the time series data files within the `input_folder/model_name` directory. |
22 | 31 |
|
23 | | -**4. Change directory to PowNet folder** |
| 32 | +* **Simulation Parameters:** |
| 33 | + * `sim_horizon`: Define the simulation horizon in hours (e.g., 24 for a daily simulation). |
| 34 | + * `steps_to_run`: Specify the number of simulation steps (e.g., 2 for a two-day simulation). |
| 35 | + * `solver`: Select the optimization solver ('gurobi' or 'highs'). |
24 | 36 |
|
25 | | -.. code:: python |
| 37 | +3. Code Example |
| 38 | +--------------- |
26 | 39 |
|
27 | | - >>> import os |
28 | | - |
29 | | - >>> os.chdir('PowNet/') |
30 | | - |
31 | | - >>> os.getcwd() |
| 40 | +The following code has already been made available in the the `scripts` folder as `run_quickstart.py`. However, the code is also presented here. |
32 | 41 |
|
33 | | -**5. Make changes in user input variables** |
34 | | - |
35 | | -.. code:: python |
| 42 | +.. code-block:: python |
36 | 43 |
|
37 | | - >>> %load main.py |
| 44 | + """ This script provides an example of how to run PowNet 2.0. |
| 45 | + """ |
38 | 46 |
|
39 | | -*Make changes in* ``main.py`` *loaded in the notebaook [e.g.,* ``MODEL_NAME`` *to define region of interest,* ``T`` *for Simulation Horizon, |
40 | | -or* ``use_gurobi`` *to choose optimization solver] and then save changes.* |
| 47 | + import os |
| 48 | + from pownet.core import Simulator |
41 | 49 |
|
42 | | -.. code:: python |
43 | 50 |
|
44 | | - >>> %save main.py |
| 51 | + def main(): |
45 | 52 |
|
46 | | -**6. Add the PYTHONPATH environment variable** |
| 53 | + # --------- User inputs |
47 | 54 |
|
48 | | -.. code:: python |
| 55 | + input_folder = "..//model_library" |
| 56 | + output_folder = "..//temptemp" |
49 | 57 |
|
50 | | - >>> import sys |
51 | | - |
52 | | - >>> sys.path.append('/Path/to/PowNet Directory/src/') |
| 58 | + model_name = "dummy" |
| 59 | + model_year = 2016 |
53 | 60 |
|
54 | | -**7. Run PowNet Simulation** |
| 61 | + # Simulation parameters |
| 62 | + sim_horizon = 24 |
| 63 | + steps_to_run = 2 |
| 64 | + solver = "gurobi" # or highs |
55 | 65 |
|
56 | | -.. code:: python |
| 66 | + # --------- End of user inputs |
57 | 67 |
|
58 | | - >>> %run main.py |
| 68 | + # Run the simulation |
| 69 | + simulator = Simulator( |
| 70 | + input_folder=input_folder, |
| 71 | + model_name=model_name, |
| 72 | + model_year=model_year, |
| 73 | + ) |
| 74 | +
|
| 75 | + simulator.run( |
| 76 | + sim_horizon=sim_horizon, |
| 77 | + steps_to_run=steps_to_run, |
| 78 | + solver=solver, |
| 79 | + ) |
| 80 | +
|
| 81 | + # Write the simulation results |
| 82 | + if not os.path.exists(output_folder): |
| 83 | + os.makedirs(output_folder) |
| 84 | + simulator.write_results(output_folder) |
| 85 | +
|
| 86 | + # Plot the results |
| 87 | + simulator.plot_fuelmix("bar", output_folder) |
| 88 | + simulator.plot_unit_status(output_folder) |
| 89 | +
|
| 90 | +
|
| 91 | + if __name__ == "__main__": |
| 92 | + main() |
| 93 | +
|
| 94 | +
|
| 95 | +4. Running the Simulation |
| 96 | +------------------------- |
| 97 | + |
| 98 | +1. **Save:** Save the code above as a Python file (e.g., `run_tutorial.py`). |
| 99 | +2. **Run:** Execute the script from your terminal using `python run_pownet.py`. |
| 100 | + |
| 101 | +5. Outputs |
| 102 | +---------- |
| 103 | + |
| 104 | +* **Results:** Simulation results will be saved in the specified `output_folder`. |
| 105 | +* **Plots:** The code generates plots of the fuel mix and unit status, also saved in the `output_folder`. |
0 commit comments