Skip to content

Commit

Permalink
5.1.26
Browse files Browse the repository at this point in the history
  • Loading branch information
SanPen committed Sep 11, 2024
1 parent 24e068e commit 121a9b5
Show file tree
Hide file tree
Showing 17 changed files with 1,235 additions and 890 deletions.
766 changes: 481 additions & 285 deletions .idea/workspace.xml

Large diffs are not rendered by default.

52 changes: 21 additions & 31 deletions doc/rst_source/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,40 @@ your custom icon if you desire so.
First navigate to the GridCal user folder. If you don't know where that is, type `user_folder()`
on GridCal's scripting console. Usually it is located in a folder called `.GridCal` on your user folder.

Inside the `.GridCal` folder you will find a folder called `plugins`. We will create some files in there to
declare our plugin. The files are:
Inside the `.GridCal` folder you will find a folder called `plugins`.
For each plugin that we want to have, need three files in there to declare our plugin. The files are:

- `plugins.json`: This is the plugins index. It is a JSON file where you add your plugin information and should exist there for you.
- `plugins.plugin.json`: This is the plugin declaration file.
It is a JSON file where you add your plugin information.
- `plugin1.py`: This is where you write your plugin.
- `icon1.svg`: This is your icon to display in the plugins drop-down menu. You can create it with a design program such as InkScape.

The content of `plugins.json` is:
The content of `plugins.plugin.json` is:

.. code-block:: json
[
{
"name": "my_plugin1",
"path": "plugin1.py",
"icon_path": "icon1.svg",
"main_fcn": {
"name": "main",
"alias": "my function 1"
},
"investments_fcn": {
"name": "investments",
"alias": "investments function 1"
}
},
{
"name": "my_plugin2",
"path": "plugin2.py",
"icon_path": "icon2.svg",
"main_fcn": {
"name": "main",
"alias": "my function 2"
},
}
]
{
"name": "my_plugin1",
"path": "plugin1.py",
"icon_path": "icon1.svg",
"main_fcn": {
"name": "main",
"alias": "my function 1"
},
"investments_fcn": {
"name": "investments",
"alias": "investments function 1"
}
}
The four parameters that we must specify are:

- `name`: Name of the plugin to be displayed and referred to by GridCal.
- `path`: Path of the plugin file relative to the base folder `.GridCal/plugins`.
- `function_name`: Name of the entry point function inside the plugin file.
- `icon_path`: Path of the SVG icon that you want to use. you can leave the field blank and GridCal will use an internal icon.

Of course, we can add more entries for more plugins, following the JSON format.
- `main_fcn`: Entry to declare the main function of the plugin accesible from the `plugins`menu in the user interface.
- `investments_fcn`: (optional) this is a custom function to be called with the investments.

The content of `plugin1.py` is:

Expand Down
6 changes: 3 additions & 3 deletions src/GridCal/Gui/Analysis/AnalysisDialogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class GridAnalysisGUI(QtWidgets.QMainWindow):
"""
GridAnalysisGUI
"""
def __init__(self, circuit: MultiCircuit = None):
def __init__(self, circuit: MultiCircuit):
"""
:param circuit: MultiCircuit
Expand Down Expand Up @@ -72,7 +72,8 @@ def analyze_all(self):
branch_connection_voltage_tolerance=self.ui.lineNominalVoltageToleranceSpinBox.value() / 100.0,
min_vcc=self.ui.transformerVccMinSpinBox.value(),
max_vcc=self.ui.transformerVccMaxSpinBox.value(),
logger=self.log)
logger=self.log
)

# set logs
self.ui.logsTreeView.setModel(self.log.get_model())
Expand All @@ -82,7 +83,6 @@ def fix_all(self):
Fix all detected fixable errors
:return:
"""
print('Fixing issues...')
logger = Logger()
for fixable_err in self.fixable_errors:
fixable_err.fix(logger=logger,
Expand Down
28 changes: 28 additions & 0 deletions src/GridCal/Gui/Analysis/object_plot_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,14 @@ def analyze_lines(elements: List[Line],
propty="bus_to",
message="The bus to is None")

if elm.bus_to == elm.bus_from:
logger.add(object_type=elm.device_type.value,
element_name=elm,
element_index=i,
severity=LogSeverity.Error,
propty="bus_from, bus_to",
message="Branch connected in loop (bus_from = bus_to)")

if V1 > 0 and V2 > 0:
per = V1 / V2
if per < (1.0 - branch_connection_voltage_tolerance):
Expand Down Expand Up @@ -530,6 +538,14 @@ def analyze_transformers(elements: List[Transformer2W],
propty="bus_to",
message="The bus to is None")

if elm.bus_to == elm.bus_from:
logger.add(object_type=elm.device_type.value,
element_name=elm,
element_index=i,
severity=LogSeverity.Error,
propty="bus_from, bus_to",
message="Branch connected in loop (bus_from = bus_to)")

if elm.name == '':
logger.add(object_type=object_type.value,
element_name=elm.name,
Expand Down Expand Up @@ -1168,6 +1184,18 @@ def grid_analysis(circuit: MultiCircuit,
logger=logger,
fixable_errors=fixable_errors)

analyze_transformers(elements=circuit.get_windings(),
object_type=DeviceType.WindingDevice,
transformer_virtual_tap_tolerance=transformer_virtual_tap_tolerance,
eps_min=eps_min,
eps_max=eps_max,
min_vcc=min_vcc,
max_vcc=max_vcc,
tap_min=tap_min,
tap_max=tap_max,
logger=logger,
fixable_errors=fixable_errors)

Pgg, Pgg_prof = analyze_generators(elements=circuit.get_generators(),
object_type=DeviceType.GeneratorDevice,
time_profile=circuit.get_time_array(),
Expand Down
19 changes: 2 additions & 17 deletions src/GridCal/Gui/Diagrams/SchematicWidget/schematic_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -4386,21 +4386,6 @@ def add_devices_list(cls: str, dev_lst: List[ALL_DEV_TYPES]):
add_devices_list(cls="fluid_paths", dev_lst=fluid_paths)

# --------------------------------------------------------------------------------------------------------------
# if text_func is not None:
# text_func('Creating schematic transformer3w devices')
#
# nn = len(transformers3w)
# for i, elm in enumerate(transformers3w):
#
# if prog_func is not None:
# prog_func((i + 1) / nn * 100.0)
#
# x = int(elm.x * explode_factor)
# y = int(elm.y * explode_factor)
# diagram.set_point(device=elm, location=GraphicLocation(x=x, y=y))
# diagram.set_point(device=elm.winding1, location=GraphicLocation())
# diagram.set_point(device=elm.winding2, location=GraphicLocation())
# diagram.set_point(device=elm.winding3, location=GraphicLocation())

return diagram

Expand Down Expand Up @@ -4434,7 +4419,7 @@ def get_devices_to_expand(circuit: MultiCircuit, root_bus: Bus, max_level: int =
bus_dict = circuit.get_bus_index_dict()

# get all Branches
all_branches = circuit.get_branches()
all_branches = circuit.get_branches() + circuit.get_switches()
branch_dict = {b: i for i, b in enumerate(all_branches)}

# create a pool of buses
Expand Down Expand Up @@ -4519,7 +4504,7 @@ def get_devices_to_expand(circuit: MultiCircuit, root_bus: Bus, max_level: int =
switches.append(obj)

else:
raise Exception('Unrecognized branch type ' + obj.device_type.value)
raise Exception(f'Unrecognized branch type {obj.device_type.value}')

return (list(buses), list(busbars), list(cns), lines, dc_lines, transformers2w, transformers3w,
windings, hvdc_lines, vsc_converters, upfc_devices, series_reactances, switches,
Expand Down
Loading

0 comments on commit 121a9b5

Please sign in to comment.