-
Notifications
You must be signed in to change notification settings - Fork 95
/
test_short_circuit.py
46 lines (39 loc) · 1.99 KB
/
test_short_circuit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
# SPDX-License-Identifier: MPL-2.0
import os
import numpy as np
from GridCalEngine.api import *
def test_short_circuit():
fname = os.path.join('data', 'grids', 'IEEE39_1W.gridcal')
print('Reading...')
main_circuit = FileOpen(fname).open()
pf_options = PowerFlowOptions(solver_type=SolverType.NR, verbose=0, control_q=False)
####################################################################################################################
# PowerFlowDriver
####################################################################################################################
print('\n\n')
power_flow = PowerFlowDriver(main_circuit, pf_options)
power_flow.run()
print('\n\n', main_circuit.name)
print('\t|V|:', abs(power_flow.results.voltage))
print('\t|Sf|:', abs(power_flow.results.Sf))
print('\t|loading|:', abs(power_flow.results.loading) * 100)
print('\tReport')
print(power_flow.results.get_report_dataframe())
####################################################################################################################
# Short circuit
####################################################################################################################
print('\n\n')
print('Short Circuit')
sc_options = ShortCircuitOptions(bus_index=16)
# grid, options, pf_options:, pf_results:
sc = ShortCircuitDriver(grid=main_circuit, options=sc_options, pf_options=pf_options, pf_results=power_flow.results)
sc.run()
print('\n\n', main_circuit.name)
print('\t|V|:', abs(main_circuit.short_circuit_results.voltage1))
print('\t|Sf|:', abs(main_circuit.short_circuit_results.Sf1))
print('\t|loading|:', abs(main_circuit.short_circuit_results.loading1) * 100)
if __name__ == '__main__':
test_short_circuit()