-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
195 changed files
with
23,050 additions
and
12,654 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+18.8 KB
(150%)
Grids_and_profiles/grids/fubm_case_57_14_2MTDC_ctrls.gridcal
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ fastapi | |
starlette | ||
uvicorn | ||
websockets | ||
cryptography | ||
opencv-python | ||
setuptools | ||
packaging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.