Skip to content

Commit

Permalink
Merge branch 'refs/heads/devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
SanPen committed Aug 29, 2024
2 parents b2bfac2 + 1d2c150 commit ace6332
Show file tree
Hide file tree
Showing 195 changed files with 23,050 additions and 12,654 deletions.
511 changes: 326 additions & 185 deletions .idea/workspace.xml

Large diffs are not rendered by default.

Binary file not shown.
Binary file modified Grids_and_profiles/grids/Illinois 200 Bus.gridcal
Binary file not shown.
Binary file modified Grids_and_profiles/grids/fubm_case_57_14_2MTDC_ctrls.gridcal
Binary file not shown.
Binary file added Grids_and_profiles/grids/simple2.gridcal
Binary file not shown.
Binary file added Grids_and_profiles/grids/test.gridcal
Binary file not shown.
12 changes: 4 additions & 8 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
import os
import sys

sys.path.insert(0, os.path.abspath('../src'))
sys.path.append("..")
from doc.auto_document_models import write_models_to_rst
Expand All @@ -22,15 +23,17 @@
# -- Project information -----------------------------------------------------

project = 'GridCal'
copyright = '2023, Santiago Peñate Vera'
copyright = '2024, Santiago Peñate Vera'
author = 'Santiago Peñate Vera'

# The full version, including alpha/beta/rc tags
release = __GridCalEngine_VERSION__


def setup(app):
app.add_css_file('style.css')


# -- General configuration ---------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
Expand Down Expand Up @@ -86,7 +89,6 @@ def setup(app):
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = None


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
Expand Down Expand Up @@ -122,7 +124,6 @@ def setup(app):
# Output file base name for HTML help builder.
htmlhelp_basename = 'GridCaldoc'


# -- Options for LaTeX output ------------------------------------------------

fh = open('latex_preamble.tex', 'r+')
Expand All @@ -145,15 +146,13 @@ def setup(app):
'preamble': PREAMBLE,
}


# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'GridCal.tex', 'GridCal Documentation', 'Santiago Pe\~nate Vera', 'manual'),
]


# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
Expand All @@ -163,7 +162,6 @@ def setup(app):
[author], 1)
]


# -- Options for Texinfo output ----------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
Expand All @@ -175,7 +173,6 @@ def setup(app):
'Miscellaneous'),
]


# -- Options for Epub output -------------------------------------------------

# Bibliographic Dublin Core info.
Expand All @@ -193,5 +190,4 @@ def setup(app):
# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']


# -- Extension configuration -------------------------------------------------
1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Contents
rst_source/benchmarks
rst_source/troubleshooting
rst_source/other_data_models
rst_source/plugins
rst_source/change_log
rst_source/api/auto/modules

Expand Down
589 changes: 286 additions & 303 deletions doc/rst_source/other_data_models.rst

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions doc/rst_source/plugins.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
Plugins
===========

You can write your own Plugin for GridCal, and it will create an entry in the plugins menu with
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:

- `plugins.json`: This is the plugins index. It is a JSON file where you add your plugin information and should exist there for you.
- `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:

.. code-block:: json
[
{
"name": "my_plugin1",
"path": "plugin1.py",
"function_name": "main",
"icon_path": "icon1.svg"
},
{
"name": "my_plugin2",
"path": "plugin2.py",
"function_name": "main",
"icon_path": "icon2.svg"
}
]
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.

The content of `plugin1.py` is:

.. code-block:: python
from GridCal.Gui.Main.GridCalMain import MainGUI
def main(gui_instance: MainGUI):
"""
Initial plugin function
:param gui_instance: Instance of the GridCal GUI object
"""
print("Hello from plugin1!")
grid = gui_instance.circuit
for bus in grid.buses:
print(bus.name)
This is a very simple example. However the function that you set as the starting point of your plugin must accept only
one argument of type `MainGUI`. See the function `main` in the code above. This is because GridCal will pass "itself"
into the plugin so that you can aquire total control and access to do whatever you want to do from the plugin.
Of course, with great power comes great responsability.
4 changes: 4 additions & 0 deletions doc/rst_source/theory/opf/nodal_cap_ex.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Linear example
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code-block:: python
"""
IEEE14 example with linear OPF
"""
Expand All @@ -21,7 +23,9 @@ Linear example
Non-linear example
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code-block:: python
"""
IEEE14 example with non-linear OPF
"""
Expand Down
11 changes: 11 additions & 0 deletions examples/assocations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os
import GridCalEngine.api as gce
import pandas as pd
pd.set_option('display.precision', 2)

folder = os.path.join('..', 'Grids_and_profiles', 'grids')
fname = os.path.join(folder, 'association_test.gridcal')

main_circuit = gce.open_file(fname)

print()
15 changes: 15 additions & 0 deletions examples/associations_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os
import GridCalEngine.api as gce
import pandas as pd

folder = os.path.join('..', 'Grids_and_profiles', 'grids')
fname = os.path.join(folder, 'simple2.gridcal')

main_circuit = gce.open_file(fname)

results = gce.power_flow(main_circuit)

print(main_circuit.name)
print('Converged:', results.converged, '\nerror:', results.error)
print(results.get_bus_df())
print(results.get_branch_df())
4 changes: 2 additions & 2 deletions examples/helm_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
Ysh0=inputs.Ysh,
pq=inputs.pq,
pv=inputs.pv,
sl=inputs.ref,
pqpv=inputs.pqpv,
vd=inputs.ref,
no_slack=inputs.pqpv,
tolerance=1e-6,
max_coefficients=10,
use_pade=False,
Expand Down
6 changes: 4 additions & 2 deletions examples/try_investment_optimization.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import os
import random
from typing import Union

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

from GridCalEngine.IO.file_handler import FileOpen
import GridCalEngine.Devices as dev
import GridCalEngine.Simulations as sim
from GridCalEngine.enumerations import InvestmentEvaluationMethod, ResultTypes
from GridCalEngine.enumerations import InvestmentEvaluationMethod, ResultTypes, DeviceType
from GridCalEngine.DataStructures.numerical_circuit import compile_numerical_circuit_at
from GridCalEngine.Simulations.PowerFlow.power_flow_worker import multi_island_pf_nc

Expand Down Expand Up @@ -40,7 +42,7 @@ def add_investments_to_grid(grid):
grid.add_line(line)
inv_group = dev.InvestmentsGroup(name='Ig' + str(i))
investment = dev.Investment(device_idtag=line.idtag, name='Investment' + str(i), CAPEX=1,
group=inv_group)
group=inv_group) # template=line.possible_tower_types[:]
grid.add_investment(investment)
grid.add_investments_group(inv_group)

Expand Down
61 changes: 61 additions & 0 deletions examples/try_template_loading.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import os
import GridCalEngine.api as gce
import GridCalEngine.Devices as dev
import GridCal.templates as templs
import GridCalEngine.Topology.topology as tp


def open_dummy_grid():
# fname = os.path.join('C:/Users/J/Downloads/temp_tr1.gridcal')
# fname = os.path.join('C:/Users/J/Downloads/temp_tr1_invested.gridcal')
# fname = os.path.join('C:/Users/J/Downloads/temp_tr2.gridcal')
fname = os.path.join('C:/Users/J/Downloads/vg1.gridcal')
main_circuit = gce.open_file(fname)
results = gce.power_flow(main_circuit)
print(results.voltage)

abc = main_circuit.get_branch_active_time_array()
# tp.find_different_states(states_array=abc[main_circuit.time_indices])

return main_circuit


def process_dummy_grid():
fname = os.path.join('C:/Users/J/Downloads/temp_tr1.gridcal')
main_circuit = gce.open_file(fname)
results = gce.power_flow(main_circuit)
print(results.voltage)

my_tr = main_circuit.transformers2w[0]

inv_group = dev.InvestmentsGroup(name='Ig0')
investment1 = dev.Investment(name='Investment 1x', group=inv_group, device_idtag=my_tr.idtag)
main_circuit.add_investment(investment1)
main_circuit.add_investments_group(inv_group)
gce.save_file(main_circuit, 'C:/Users/J/Downloads/temp_tr1_invested.gridcal')
return None


def create_dummy_grid():
grid = gce.MultiCircuit()

bus1 = gce.Bus(name='Bus1', Vnom=20)
bus2 = gce.Bus(name='Bus2', Vnom=20)
grid.add_bus(bus1)
grid.add_bus(bus2)
tr1 = gce.Transformer2W(bus_from=bus1, bus_to=bus2)
grid.add_transformer2w(tr1)

grid.transformer_types = templs.get_transformer_catalogue()
grid.underground_cable_types = templs.get_cables_catalogue()
grid.circuit_wire_types = templs.get_wires_catalogue()
grid.sequence_line_types = templs.get_sequence_lines_catalogue()

return grid


if __name__ == "__main__":
open_dummy_grid()
# pp = process_dummy_grid()
# gg = create_dummy_grid()

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fastapi
starlette
uvicorn
websockets
cryptography
opencv-python
setuptools
packaging
22 changes: 12 additions & 10 deletions src/GridCal/ExecuteGridCal.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# This file is part of GridCal.
# GridCal
# Copyright (C) 2015 - 2024 Santiago Peñate Vera
#
# GridCal is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# GridCal is distributed in the hope that it will be useful,
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GridCal. If not, see <http://www.gnu.org/licenses/>.
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import os
import sys
import ctypes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ def __init__(self,
editor=editor,
draw_labels=draw_labels)

self.editor: GridMapWidget = editor # re assign to make clear the editor type
self.editor: GridMapWidget = editor # reassign to make clear the editor type

self.nodes_list: List[NodeGraphicItem] = list()
self.segments_list: List[MapLineSegment] = list()
self.enabled = True
self.original = True
self.original = True # TODO: Que es esto?

def setWidthScale(self, val: float):
"""
Expand Down
Loading

0 comments on commit ace6332

Please sign in to comment.