Skip to content

Commit

Permalink
DC OPF (#543)
Browse files Browse the repository at this point in the history
* DC OPF changes: Added DC OPF method for power flow calculations, Added IEEE 9-Bus test case (for both single time-stamp and time-series), Update transmission.jl with splitting DC OPF and non-DC-OPF

Documentation for DC-OPF: deactivate network expansion when dcopf is used, changed angle limit unit to radiant and modified column names for consistency, fixed input files, computation of DC-OPF coefficient, and write_angles.jl to output radians not degrees, Update investment_transmission.jl, Modified the writing of angles and flows to only write hourly values, fixed automated tests

---------

Co-authored-by: Chakrabarti, Sambuddha (Sam) <[email protected]>
Co-authored-by: Filippo <[email protected]>
Co-authored-by: lbonaldo <[email protected]>
  • Loading branch information
4 people authored Feb 26, 2024
1 parent 153d4f3 commit 6e77c7d
Show file tree
Hide file tree
Showing 48 changed files with 27,127 additions and 159 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Maintenance formulation for thermal-commit plants (#556).
- Add new tests for GenX: three-zone, multi-stage, electrolyzer, VRE+storage,
piecewise_fuel+CO2, and TDR (#563 and #578).
- Added a DC OPF method (#543) to calculate power flows across all lines
- Added write_operating_reserve_price_revenue.jl to compute annual operating reserve and regulation revenue.
Added the operating reserve and regulation revenue to net revenue (PR # 611)
- Add functions to compute conflicting constraints when model is infeasible if supported by the solver (#624).
Expand Down
5 changes: 5 additions & 0 deletions Example_Systems/DC_OPF/IEEE_9BUS/Demand_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Voll,Demand_Segment,Cost_of_Demand_Curtailment_per_MW,Max_Demand_Curtailment,$/MWh,Rep_Periods,Timesteps_per_Rep_Period,Sub_Weights,Time_Index,Demand_MW_z1,Demand_MW_z2,Demand_MW_z3,Demand_MW_z4,Demand_MW_z5,Demand_MW_z6,Demand_MW_z7,Demand_MW_z8,Demand_MW_z9
2000000,1,1,1,2000,1,1,1,1,0,0,0,0,90,0,100,0,125
,2,0.9,0.04,1800,,,,,,,,,,,,,
,3,0.55,0.024,1100,,,,,,,,,,,,,
,4,0.2,0.003,400,,,,,,,,,,,,,
3 changes: 3 additions & 0 deletions Example_Systems/DC_OPF/IEEE_9BUS/Fuels_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Time_Index,natural_gas,coal,nuclear,None
0,0.05306,0.05306,0.05306,0.05306
1,0.05306,0.05306,0.05306,0.05306
3 changes: 3 additions & 0 deletions Example_Systems/DC_OPF/IEEE_9BUS/Generators_variability.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Time_Index,z1_natural_gas,z2_natural_gas,z3_natural_gas
0,1,1,1
1,1,1,1
10 changes: 10 additions & 0 deletions Example_Systems/DC_OPF/IEEE_9BUS/Network.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
,Network_zones,Network_Lines,Start_Zone,End_Zone,Line_Max_Flow_MW,transmission_path_name,distance_mile,Line_Loss_Percentage,Line_Max_Reinforcement_MW,Line_Reinforcement_Cost_per_MWyr,DerateCapRes_1,CapRes_1,CapRes_Excl_1,Angle_Limit_Rad,Line_Voltage_kV,Line_Resistance_Ohms,Line_Reactance_Ohms
BUS1,z1,1,1,4,250,BUS1_to_BUS4,0.5,0.015,500,12000,0.95,0,0,0.785398,345,0,68.5584
BUS2,z2,2,4,5,250,BUS4_to_BUS5,0.5,0.015,500,12000,0.95,0,0,0.785398,345,20.23425,109.503
BUS3,z3,3,5,6,150,BUS5_to_BUS6,0.5,0.015,500,12000,0.95,0,0,0.785398,345,46.41975,202.3425
BUS4,z4,4,3,6,300,BUS3_to_BUS6,0.5,0.015,500,12000,0.95,0,0,0.785398,345,0,69.74865
BUS5,z5,5,6,7,150,BUS6_to_BUS7,0.5,0.015,500,12000,0.95,0,0,0.785398,345,14.163975,119.9772
BUS6,z6,6,7,8,250,BUS7_to_BUS8,0.5,0.015,500,12000,0.95,0,0,0.785398,345,10.117125,85.698
BUS7,z7,7,8,2,250,BUS8_to_BUS2,0.5,0.015,500,12000,0.95,0,0,0.785398,345,0,74.390625
BUS8,z8,8,8,9,250,BUS8_to_BUS9,0.5,0.015,500,12000,0.95,0,0,0.785398,345,38.088,191.63025
BUS9,z9,9,9,4,250,BUS9_to_BUS4,0.5,0.015,500,12000,0.95,0,0,0.785398,345,11.9025,101.17125
17 changes: 17 additions & 0 deletions Example_Systems/DC_OPF/IEEE_9BUS/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# IEEE 9-BUS Test case

They are total of 3 generators and three loads

To run the model, first navigate to the example directory at `GenX/Example_Systems/DC_OPF/IEEE_9BUS`:

`cd("Example_Systems/DC_OPF/IEEE_9BUS")`

Next, ensure that your settings in `Settings/genx_settings.yml` are correct.
The default settings use the solver HiGHS.
Other optional policies include minimum capacity requirements, a capacity reserve margin, and more.

Once the settings are confirmed, run the model with the `Run.jl` script in the example directory:

`include("Run.jl")`

Once the model has completed, results will write to the `Results` directory.
4 changes: 4 additions & 0 deletions Example_Systems/DC_OPF/IEEE_9BUS/Resources/thermal.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Resource,Zone,Model,New_Build,Can_Retire,Existing_Cap_MW,Min_Cap_MW,Max_Cap_MW,Inv_Cost_per_MWyr,Fixed_OM_Cost_per_MWyr,Var_OM_Cost_per_MWh,Start_Cost_per_MW,Start_Fuel_MMBTU_per_MW,Cap_Size,Heat_Rate_MMBTU_per_MWh,Fuel,Min_Power,Ramp_Up_Percentage,Ramp_Dn_Percentage,Up_Time,Down_Time,Reg_Max,Rsv_Max,Reg_Cost,Rsv_Cost,MGA,Resource_Type,region,cluster
z1_natural_gas,1,1,0,1,250,10,0,0,5,0.1,0,0,250,0.1,natural_gas,0.04,1,1,0,0,1,1,0,0,1,natural_gas,BUS1,1
z2_natural_gas,2,1,0,1,300,10,0,0,1.2,0.1,0,0,300,0.1,natural_gas,0.033333333,1,1,0,0,1,1,0,0,1,natural_gas,BUS2,1
z3_natural_gas,3,1,0,1,270,10,0,0,1,0.1,0,0,270,0.1,natural_gas,0.037037037,1,1,0,0,1,1,0,0,1,natural_gas,BUS3,1
3 changes: 3 additions & 0 deletions Example_Systems/DC_OPF/IEEE_9BUS/Run.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using GenX

run_genx_case!(dirname(@__FILE__))
10 changes: 10 additions & 0 deletions Example_Systems/DC_OPF/IEEE_9BUS/Settings/cplex_settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# CPLEX Solver Parameters
Feasib_Tol: 1.0e-05 # Constraint (primal) feasibility tolerances.
Optimal_Tol: 1e-5 # Dual feasibility tolerances.
Pre_Solve: 1 # Controls presolve level.
TimeLimit: 110000 # Limits total time solver.
MIPGap: 1e-3 # Relative (p.u. of optimal) mixed integer optimality tolerance for MIP problems (ignored otherwise).
Method: 2 # Algorithm used to solve continuous models (including MIP root relaxation).
BarConvTol: 1.0e-08 # Barrier convergence tolerance (determines when barrier terminates).
NumericFocus: 0 # Numerical precision emphasis.
SolutionType: 2 # Solution type for LP or QP.
21 changes: 21 additions & 0 deletions Example_Systems/DC_OPF/IEEE_9BUS/Settings/genx_settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
OverwriteResults: 0 # Overwrite existing results in output folder or create a new one; 0 = create new folder; 1 = overwrite existing results
PrintModel: 1 # Write the model formulation as an output; 0 = active; 1 = not active
NetworkExpansion: 0 # Transmission network expansionl; 0 = not active; 1 = active systemwide
Trans_Loss_Segments: 0 # Number of segments used in piecewise linear approximation of transmission losses; 1 = linear, >2 = piecewise quadratic
Reserves: 0 # Regulation (primary) and operating (secondary) reserves; 0 = not active, 1 = active systemwide
EnergyShareRequirement: 0 # Minimum qualifying renewables penetration; 0 = not active; 1 = active systemwide
CapacityReserveMargin: 0 # Number of capacity reserve margin constraints; 0 = not active; 1 = active systemwide
CO2Cap: 0 # CO2 emissions cap; 0 = not active (no CO2 emission limit); 1 = mass-based emission limit constraint; 2 = load + rate-based emission limit constraint; 3 = generation + rate-based emission limit constraint
StorageLosses: 0 # Energy Share Requirement and CO2 constraints account for energy lost; 0 = not active (DO NOT account for energy lost); 1 = active systemwide (DO account for energy lost)
MinCapReq: 0 # Activate minimum technology carveout constraints; 0 = not active; 1 = active
MaxCapReq: 0 # Activate maximum technology carveout constraints; 0 = not active; 1 = active
ParameterScale: 0 # Turn on parameter scaling wherein load, capacity and power variables are defined in GW rather than MW. 0 = not active; 1 = active systemwide
WriteShadowPrices: 1 # Write shadow prices of LP or relaxed MILP; 0 = not active; 1 = active
UCommit: 0 # Unit committment of thermal power plants; 0 = not active; 1 = active using integer clestering; 2 = active using linearized clustering
TimeDomainReductionFolder: "TDR_Results" # Directory name where results from time domain reduction will be saved. If results already exist here, these will be used without running time domain reduction script again.
TimeDomainReduction: 0 # Time domain reduce (i.e. cluster) inputs based on Load_data.csv, Generators_variability.csv, and Fuels_data.csv; 0 = not active (use input data as provided); 0 = active (cluster input data, or use data that has already been clustered)
ModelingToGenerateAlternatives: 0 # Modeling to generate alternatives; 0 = not active; 1 = active. Note: produces a single solution as output
ModelingtoGenerateAlternativeSlack: 0.1 # Slack value as a fraction of least-cost objective in budget constraint used for evaluating alternative model solutions; positive float value
ModelingToGenerateAlternativeIterations: 3 # Number of MGA iterations with maximization and minimization objective
MethodofMorris: 0 #Flag for turning on the Method of Morris analysis
DC_OPF: 1 #Flag for running DC-OPF: 0 = not active (transport model); 1 = active
15 changes: 15 additions & 0 deletions Example_Systems/DC_OPF/IEEE_9BUS/Settings/gurobi_settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Gurobi Solver Parameters
# Common solver settings
Feasib_Tol: 1.0e-05 # Constraint (primal) feasibility tolerances.
Optimal_Tol: 1e-5 # Dual feasibility tolerances.
TimeLimit: 110000 # Limits total time solver.
Pre_Solve: 1 # Controls presolve level.
Method: 2 # Algorithm used to solve continuous models (including MIP root relaxation).

#Gurobi-specific solver settings
MIPGap: 1e-3 # Relative (p.u. of optimal) mixed integer optimality tolerance for MIP problems (ignored otherwise).
BarConvTol: 1.0e-06 # Barrier convergence tolerance (determines when barrier terminates).
NumericFocus: 0 # Numerical precision emphasis.
Crossover: 0 # Barrier crossver strategy.
PreDual: 0 # Decides whether presolve should pass the primal or dual linear programming problem to the LP optimization algorithm.
AggFill: 10 # Allowed fill during presolve aggregation.
11 changes: 11 additions & 0 deletions Example_Systems/DC_OPF/IEEE_9BUS/Settings/highs_settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# HiGHS Solver Parameters
# Common solver settings
Feasib_Tol: 1.0e-05 # Primal feasibility tolerance # [type: double, advanced: false, range: [1e-10, inf], default: 1e-07]
Optimal_Tol: 1.0e-05 # Dual feasibility tolerance # [type: double, advanced: false, range: [1e-10, inf], default: 1e-07]
TimeLimit: 1.0e23 # Time limit # [type: double, advanced: false, range: [0, inf], default: inf]
Pre_Solve: choose # Presolve option: "off", "choose" or "on" # [type: string, advanced: false, default: "choose"]
Method: ipm #HiGHS-specific solver settings # Solver option: "simplex", "choose" or "ipm" # [type: string, advanced: false, default: "choose"]

# run the crossover routine for ipx
# [type: string, advanced: "on", range: {"off", "on"}, default: "off"]
run_crossover: "off"
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
#####
#
# TIME DOMAIN REDUCTION SETTINGS
#
# Set parameters here that organize how your full timeseries
# data will be divided into representative period clusters.
# Ensure that time_domain_reduction is set to 1 in GenX_settings.yml
# before running. Run within GenX or use PreCluster.jl to test and
# examine representative period output before proceeding.
# Specify your data input directory as inpath within Run_test.jl
# or PreCluster.jl.
#
#####

# - TimestepsPerRepPeriod
# Typically 168 timesteps (e.g., hours) per period, this designates
# the length of each representative period.
TimestepsPerRepPeriod: 1

# - ClusterMethod
# Either 'kmeans' or 'kmedoids', this designates the method used to cluster
# periods and determine each point's representative period.
ClusterMethod: 'kmeans'

# - ScalingMethod
# Either 'N' or 'S', this designates directs the module to normalize ([0,1])
# or standardize (mean 0, variance 1) the input data.
ScalingMethod: "S"

# - MaxPeriods
# The maximum number of periods - both clustered periods and extreme periods -
# that may be used to represent the input data. If IterativelyAddPeriods is on and the
# error threshold is never met, this will be the total number of periods.
MaxPeriods: 11

# - MinPeriods
# The minimum number of periods used to represent the input data. If using
# UseExtremePeriods, this must be at least the number of extreme periods requests. If
# IterativelyAddPeriods if off, this will be the total number of periods.
MinPeriods: 8

# - IterativelyAddPeriods
# Either 'yes' or 'no', this designates whether or not to add periods
# until the error threshold between input data and represented data is met or the maximum
# number of periods is reached.
IterativelyAddPeriods: 1

# - IterateMethod
# Either 'cluster' or 'extreme', this designates whether to add clusters to
# the kmeans/kmedoids method or to set aside the worst-fitting periods as a new extreme periods.
# The default option is 'cluster'.
IterateMethod: "cluster"

# - Threshold
# Iterative period addition will end if the period farthest (Euclidean Distance)
# from its representative period is within this percentage of the total possible error (for normalization)
# or ~95% of the total possible error (for standardization). E.g., for a threshold of 0.01,
# every period must be within 1% of the spread of possible error before the clustering
# iterations will terminate (or until the max number of periods is reached).
Threshold: 0.05

# - nReps
# The number of times to repeat each kmeans/kmedoids clustering at the same setting.
nReps: 100

# - LoadWeight
# Default 1, this is an optional multiplier on load columns in order to prioritize
# better fits for load profiles over resource capacity factor profiles.
LoadWeight: 1

# - WeightTotal
# Default 8760, the sum to which the relative weights of representative periods will be scaled.
WeightTotal: 24

# - ClusterFuelPrices
# Either 'yes' ro 'no', this indicates whether or not to use the fuel price
# time series in Fuels_data.csv in the clustering process. If 'no', this function will still write
# Fuels_data_clustered.csv with reshaped fuel prices based on the number and size of the
# representative weeks, assuming a constant time series of fuel prices with length equal to the
# number of timesteps in the raw input data.
ClusterFuelPrices: 1

# - MultiStageConcatenate
# (Only considered if MultiStage = 1 in genx_settings.yml)
# If 1, this designates that the model should time domain reduce the input data
# of all model stages together. Else if 0, the model will time domain reduce each
# stage separately
MultiStageConcatenate: 0

# - UseExtremePeriods
# Either 'yes' or 'no', this designates whether or not to include
# outliers (by performance or load/resource extreme) as their own representative periods.
# This setting automatically includes the periods with maximum load, minimum solar cf and
# minimum wind cf as extreme periods.
UseExtremePeriods: 1

# STILL IN DEVELOPMENT - Currently just uses integral max load, integral min PV and wind.
# - ExtremePeriods
# Use this to define which periods to be included among the final representative periods
# as "Extreme Periods".
# Select by profile type: load ("Load"), solar PV capacity factors ("PV"), and wind capacity factors ("Wind").
# Select whether to examine these profiles by zone ("Zone") or across the whole system ("System").
# Select whether to look for absolute max/min at the timestep level ("Absolute")
# or max/min sum across the period ("Integral").
# Select whether you want the maximum ("Max") or minimum ("Min") (of the prior type) for each profile type.
ExtremePeriods:
Load:
Zone:
Absolute:
Max: 0
Min: 0
Integral:
Max: 0
Min: 0
System:
Absolute:
Max: 1
Min: 0
Integral:
Max: 0
Min: 0
PV:
Zone:
Absolute:
Max: 0
Min: 0
Integral:
Max: 0
Min: 1
System:
Absolute:
Max: 0
Min: 0
Integral:
Max: 0
Min: 0
Wind:
Zone:
Absolute:
Max: 0
Min: 0
Integral:
Max: 0
Min: 1
System:
Absolute:
Max: 0
Min: 0
Integral:
Max: 0
Min: 0
Loading

0 comments on commit 6e77c7d

Please sign in to comment.