Skip to content

Commit

Permalink
Fixed OPF formulation issue when some constraints turn out to be 0==0
Browse files Browse the repository at this point in the history
  • Loading branch information
SanPen committed Nov 16, 2023
1 parent e5ecd4d commit 755af30
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 63 deletions.
75 changes: 34 additions & 41 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ for the future generations.
## Installation

GridCal is a software made in the Python programming language.
Therefore, it needs a python interpreter installed in your operative system.
Therefore, it needs a Python interpreter installed in your operative system.

### Standalone setup

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ networkx>=2.1
pandas>=1.1
xlwt>=1.3.0
xlrd>=1.1.0
ortools>=9.0.0
ortools>=9.8.0
matplotlib>=2.1.1
qtconsole>=4.3.1
pyDOE>=0.3.8
Expand Down
13 changes: 6 additions & 7 deletions src/GridCalEngine/Core/Compilers/circuit_to_newton_pa.py
Original file line number Diff line number Diff line change
Expand Up @@ -1187,19 +1187,18 @@ def get_newton_pa_linear_opf_options(opf_opt: "OptimalPowerFlowOptions",
bs.TimeGrouping.Monthly: npa.TimeGrouping.Monthly,
bs.TimeGrouping.Hourly: npa.TimeGrouping.Hourly}

opt = npa.LinearOpfOptions(solver=solver_dict[opf_opt.mip_solver])
# opt.solver = solver_dict[opf_opt.mip_solver]
opt.time_grouping = grouping_dict[opf_opt.time_grouping]
opt.unit_commitment = False
opt.compute_flows = opf_opt.zonal_grouping == ZonalGrouping.NoGrouping
opt = npa.LinearOpfOptions(solver=solver_dict[opf_opt.mip_solver],
grouping=grouping_dict[opf_opt.grouping],
unit_commitment=opf_opt.unit_commitment,
compute_flows=opf_opt.zonal_grouping == ZonalGrouping.NoGrouping,
pf_options=get_newton_pa_pf_options(pf_opt))

opt.check_with_power_flow = False
opt.add_contingencies = opf_opt.consider_contingencies
opt.skip_generation_limits = opf_opt.skip_generation_limits
opt.maximize_area_exchange = opf_opt.maximize_flows
opt.unit_commitment = opf_opt.unit_commitment
opt.use_ramp_constraints = False
opt.lodf_threshold = opf_opt.lodf_tolerance
opt.pf_options = get_newton_pa_pf_options(pf_opt)

if opf_opt.areas_from is not None:
opt.areas_from = [area_dict[e] for e in opf_opt.areas_from]
Expand Down
17 changes: 16 additions & 1 deletion src/GridCalEngine/Core/Devices/editable_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import numpy as np
from typing import List, Dict, AnyStr, Any, Optional, Union, Type, Tuple
from GridCalEngine.enumerations import DeviceType, TimeFrame, BuildStatus, WindingsConnection, TransformerControlType, ConverterControlType

from GridCalEngine.basic_structures import Vec, IntVec, BoolVec

class GCProp:
"""
Expand Down Expand Up @@ -392,6 +392,21 @@ def set_profile_values(self, t):
profile = getattr(self, self.properties_with_profile[magnitude])
setattr(self, magnitude, profile[t])

def get_profile(self, magnitude: str) -> Union[Vec, IntVec, BoolVec]:
"""
Get the profile of a property name
:param magnitude: name of the property
:return: Profile object
"""

# try to get the profile name
profile_name = self.properties_with_profile.get(magnitude, None)

if profile_name is None:
return None
else:
return getattr(self, profile_name)

def get_properties_dict(self, version=3):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def run(self) -> None:
"""
Run contingency analysis time series
"""
start = time.time()
self.tic()

if self.engine == bs.EngineType.GridCal:
self.results = self.run_contingency_analysis()
Expand All @@ -307,5 +307,4 @@ def run(self) -> None:
# default to GridCal mode
self.results = self.run_contingency_analysis()

end = time.time()
self.elapsed = end - start
self.toc()
5 changes: 2 additions & 3 deletions src/GridCalEngine/Simulations/NTC/ntc_ts_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,10 @@ def run(self):
:return:
"""
start = time.time()
self.tic()

self.opf()
self.progress_text.emit('Done!')

end = time.time()
self.results.elapsed = end - start
self.toc()

Loading

0 comments on commit 755af30

Please sign in to comment.