Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
SanPen committed Nov 28, 2023
2 parents b006bf6 + 577db2e commit 4c08bd1
Show file tree
Hide file tree
Showing 17 changed files with 769 additions and 455 deletions.
636 changes: 344 additions & 292 deletions .idea/workspace.xml

Large diffs are not rendered by default.

Binary file modified Grids_and_profiles/grids/IEEE39_1W.gridcal
Binary file not shown.
3 changes: 2 additions & 1 deletion examples/dc_linear_opf_ts_example.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from GridCalEngine.api import *

fname = '/home/santi/Documentos/Git/GitHub/GridCal/Grids_and_profiles/grids/Lynn 5 Bus pv (opf).gridcal'
# fname = '/home/santi/Documentos/Git/GitHub/GridCal/Grids_and_profiles/grids/Lynn 5 Bus pv (opf).gridcal'
# fname = '/home/santi/Documentos/Git/GitHub/GridCal/Grids_and_profiles/grids/IEEE39_1W.gridcal'
# fname = '/home/santi/Documentos/Git/GitHub/GridCal/Grids_and_profiles/grids/grid_2_islands.xlsx'
fname = 'C:\Git\Github\GridCal\Grids_and_profiles\grids\IEEE39_1W.gridcal'

main_circuit = FileOpen(fname).open()

Expand Down
7 changes: 6 additions & 1 deletion src/GridCal/Gui/GridEditorWidget/bus_branch_editor_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,12 @@ def plot_bus(self, i, api_object):
df = pd.DataFrame(data=power_data, index=x)
ax_1.set_title('Power', fontsize=14)
ax_1.set_ylabel('Injections [MW]', fontsize=11)
df.plot.area(ax=ax_1)
try:
# yt area plots
df.plot.area(ax=ax_1)
except ValueError:
# use regular plots
df.plot(ax=ax_1)

# voltage
if len(voltage.keys()):
Expand Down
9 changes: 3 additions & 6 deletions src/GridCal/Gui/Main/SubClasses/Model/diagrams.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ def auto_layout(self):
do_it = False

if do_it:

diagram_widget.auto_layout(sel=self.ui.automatic_layout_comboBox.currentText())

# graph, buses = diagram_widget.diagram.build_graph()
Expand Down Expand Up @@ -284,7 +283,6 @@ def adjust_all_node_width(self):
if isinstance(diagram, BusBranchEditorWidget):

for bus in self.circuit.buses:

diagram.diagram.query_point(bus).graphic_object.adapt()

def zoom_in(self):
Expand Down Expand Up @@ -525,7 +523,8 @@ def grid_colour_function(self, plot_function, current_study: str, current_step:

elif current_study == sim.OptimalPowerFlowTimeSeriesDriver.tpe.value:
results: sim.OptimalPowerFlowTimeSeriesResults = self.session.get_results(
sim.SimulationTypes.OPFTimeSeries_run)
sim.SimulationTypes.OPFTimeSeries_run
)
bus_active = [bus.active_prof[current_step] for bus in self.circuit.buses]
br_active = [br.active_prof[current_step] for br in self.circuit.get_branches_wo_hvdc()]
hvdc_active = [hvdc.active_prof[current_step] for hvdc in self.circuit.hvdc_lines]
Expand Down Expand Up @@ -1045,7 +1044,6 @@ def set_diagram_widget(self, diagram: Union[BusBranchEditorWidget, GridMapWidget
index = self.ui.diagramsListView.model().index(row, 0)
self.ui.diagramsListView.setCurrentIndex(index)


def plot_style_change(self):
"""
Change the style
Expand Down Expand Up @@ -1118,7 +1116,6 @@ def set_xy_from_lat_lon(self):
if yes_no_question("All nodes in the current diagram will be positioned to a 2D plane projection "
"of their latitude and longitude. "
"Are you sure of this?"):

diagram.fill_xy_from_lat_lon(destructive=True)
diagram.center_nodes()

Expand Down Expand Up @@ -1172,6 +1169,7 @@ def set_big_bus_marker_colours(self,
if graphic_obj is not None:
graphic_obj.add_big_marker(color=color)
graphic_obj.setSelected(True)

def clear_big_bus_markers(self):
"""
Set a big marker at the selected buses
Expand Down Expand Up @@ -1448,4 +1446,3 @@ def delete_from_all_diagrams(self, elements: List[dev.EditableDevice]):
elif isinstance(diagram_widget, GridMapWidget):
pass
# diagram_widget.delete_diagram_elements(elements)

4 changes: 1 addition & 3 deletions src/GridCal/Gui/Main/SubClasses/simulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,9 +642,7 @@ def get_opf_ts_results(self, use_opf: bool) -> sim.OptimalPowerFlowTimeSeriesRes
"""
if use_opf:

drv, opf_time_series_results = self.session.get_driver_results(
SimulationTypes.OPFTimeSeries_run
)
drv, opf_time_series_results = self.session.get_driver_results(SimulationTypes.OPFTimeSeries_run)

if opf_time_series_results is None:
if use_opf:
Expand Down
2 changes: 1 addition & 1 deletion src/GridCal/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
_current_year_ = datetime.datetime.now().year

# do not forget to keep a three-number version!!!
__GridCal_VERSION__ = "5.0.6"
__GridCal_VERSION__ = "5.0.8"

url = 'https://github.com/SanPen/GridCal'

Expand Down
90 changes: 84 additions & 6 deletions src/GridCalEngine/Core/Devices/multi_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,48 @@ def get_hvdc_names(self) -> StrVec:
"""
return np.array([elm.name for elm in self.hvdc_lines])

def get_fuels(self) -> List[dev.Fuel]:
"""
:return:
"""
return self.fuels

def get_fuel_number(self) -> int:
"""
:return:
"""
return len(self.fuels)

def get_fuel_names(self) -> StrVec:
"""
:return:
"""
return np.array([elm.name for elm in self.fuels])

def get_emissions(self) -> List[dev.EmissionGas]:
"""
:return:
"""
return self.emission_gases

def get_emission_number(self) -> int:
"""
:return:
"""
return len(self.emission_gases)

def get_emission_names(self) -> StrVec:
"""
:return:
"""
return np.array([elm.name for elm in self.emission_gases])

def get_loads(self) -> List[dev.Load]:
"""
Returns a list of :ref:`Load<load>` objects in the grid.
Expand Down Expand Up @@ -3772,14 +3814,44 @@ def get_branch_contingency_rates_wo_hvdc(self) -> Vec:

def get_generator_indexing_dict(self) -> Dict[str, int]:
"""
Get the a dictionary that relates the generator uuid's with their index
Get a dictionary that relates the generator uuid's with their index
:return: Dict[str, int]
"""
gen_index_dict: Dict[str, int] = dict()
for k, elm in enumerate(self.get_generators()):
gen_index_dict[elm.idtag] = k # associate the idtag to the index
return gen_index_dict

def get_fuel_indexing_dict(self) -> Dict[str, int]:
"""
Get a dictionary that relates the fuel uuid's with their index
:return: Dict[str, int]
"""
index_dict: Dict[str, int] = dict()
for k, elm in enumerate(self.get_fuels()):
index_dict[elm.idtag] = k # associate the idtag to the index
return index_dict

def get_emissions_indexing_dict(self) -> Dict[str, int]:
"""
Get a dictionary that relates the fuel uuid's with their index
:return: Dict[str, int]
"""
index_dict: Dict[str, int] = dict()
for k, elm in enumerate(self.get_emissions()):
index_dict[elm.idtag] = k # associate the idtag to the index
return index_dict

def get_technology_indexing_dict(self) -> Dict[str, int]:
"""
Get a dictionary that relates the fuel uuid's with their index
:return: Dict[str, int]
"""
index_dict: Dict[str, int] = dict()
for k, elm in enumerate(self.technologies):
index_dict[elm.idtag] = k # associate the idtag to the index
return index_dict

def get_fuel_rates_sparse_matrix(self) -> csc_matrix:
"""
Get the fuel rates matrix with relation to the generators
Expand All @@ -3788,14 +3860,16 @@ def get_fuel_rates_sparse_matrix(self) -> csc_matrix:
"""
nfuel = len(self.fuels)
gen_index_dict = self.get_generator_indexing_dict()
fuel_index_dict = self.get_fuel_indexing_dict()
nelm = len(gen_index_dict)

gen_fuel_rates_matrix: lil_matrix = lil_matrix((nfuel, nelm), dtype=float)

# create associations between generators and fuels
for i, entry in enumerate(self.generators_fuels):
for entry in self.generators_fuels:
gen_idx = gen_index_dict[entry.generator.idtag]
gen_fuel_rates_matrix[gen_idx, i] = entry.rate
fuel_idx = fuel_index_dict[entry.fuel.idtag]
gen_fuel_rates_matrix[fuel_idx, gen_idx] = entry.rate

return gen_fuel_rates_matrix.tocsc()

Expand All @@ -3807,14 +3881,16 @@ def get_emission_rates_sparse_matrix(self) -> csc_matrix:
"""
nemissions = len(self.emission_gases)
gen_index_dict = self.get_generator_indexing_dict()
em_index_dict = self.get_emissions_indexing_dict()
nelm = len(gen_index_dict)

gen_emissions_rates_matrix: lil_matrix = lil_matrix((nemissions, nelm), dtype=float)

# create associations between generators and emissions
for i, entry in enumerate(self.generators_emissions):
for entry in self.generators_emissions:
gen_idx = gen_index_dict[entry.generator.idtag]
gen_emissions_rates_matrix[gen_idx, i] = entry.rate
em_idx = em_index_dict[entry.emission.idtag]
gen_emissions_rates_matrix[em_idx, gen_idx] = entry.rate

return gen_emissions_rates_matrix.tocsc()

Expand All @@ -3826,13 +3902,15 @@ def get_technology_connectivity_matrix(self) -> csc_matrix:
"""
ntech = len(self.technologies)
gen_index_dict = self.get_generator_indexing_dict()
tech_index_dict = self.get_technology_indexing_dict()
nelm = len(gen_index_dict)

gen_tech_proportions_matrix: lil_matrix = lil_matrix((ntech, nelm), dtype=int)

# create associations between generators and technologies
for i, entry in enumerate(self.generators_technologies):
gen_idx = gen_index_dict[entry.generator.idtag]
gen_tech_proportions_matrix[gen_idx, i] = entry.proportion
tech_idx = tech_index_dict[entry.technology.idtag]
gen_tech_proportions_matrix[tech_idx, gen_idx] = entry.proportion

return gen_tech_proportions_matrix.tocsc()
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class InvestmentsEvaluationDriver(DriverTemplate):
name = 'Investments evaluation'
tpe = SimulationTypes.InvestmestsEvaluation_run

def __init__(self, grid: MultiCircuit, method: InvestmentEvaluationMethod, max_eval: int,
def __init__(self, grid: MultiCircuit,
method: InvestmentEvaluationMethod,
max_eval: int,
pf_options: PowerFlowOptions):
"""
InputsAnalysisDriver class constructor
Expand Down
Loading

0 comments on commit 4c08bd1

Please sign in to comment.