ch17 = Switch(name='17', state=1) # GD switches ch18 = Switch(name='18', state=1) ch19 = Switch(name='19', state=1) ch20 = Switch(name='20', state=1) ch21 = Switch(name='21', state=1) # NO switch (new) ch22 = Switch(name='22', state=0) # Voltages vll_hv = p2r(115e3, 0.0) vll_mv = p2r(12.47e3, 0.0) vll_lv = p2r(0.48e3, 0.0) # Transformers t1 = TransformerModel( name="T1", primary_voltage=vll_mv, secondary_voltage=vll_lv, power=5e6, #connection ='nyyn', impedance=0 + 0.0046j) # ohms (0.1 pu / 12.47 kV) t2 = TransformerModel( name="T2",
line606 = UnderGroundLine(loc=spacing515, phasing=['a', 'b', 'c'], conductor=conduct4) line607 = UnderGroundLine(loc=spacing520, phasing=['a', 'n'], conductor=conduct5, neutral_conductor=conduct6) Zsys = np.array([[0.6273 + 6.0295j, -0.14 + 1.2443j, -0.14 + 1.2443j], [-0.14 + 1.2443j, 0.6273 + 6.0295j, -0.14 + 1.2443j], [-0.14 + 1.2443j, -0.14 + 1.2443j, 0.6273 + 6.0295j]], dtype=complex) vll_ht = p2r(115e3, 0.0) vll_mt = p2r(4.16e3, 0.0) vll_bt = p2r(480.0, 0.0) ##############################capacitors######################################## capacitor_675 = Shunt_Capacitor(vll=4.16e3, Qa=200e3, Qb=200e3, Qc=200e3, type_connection="wye") capacitor_611 = Shunt_Capacitor(vll=4.16e3, Qa=0.0e3, Qb=0.0e3, Qc=100e3, type_connection="wye") ##################################source########################################
def create_mygrid_model(file): data = json.load(file) vll_mt = p2r(13.8e3, 0.0) vll_bt = p2r(380.0, 0.0) eg1 = ExternalGrid(name='extern grid 1', vll=vll_mt) # switchs sw1 = Switch(name='sw_1', state=1) # transformers t1 = TransformerModel(name="T1", primary_voltage=vll_mt, secondary_voltage=vll_bt, power=225e3, impedance=0.01 + 0.2j) phase_conduct = Conductor(id=57) neutral_conduct = Conductor(id=44) line_model_a = LineModel(loc_a=0.0 + 29.0j, loc_b=2.5 + 29.0j, loc_c=7.0 + 29.0j, loc_n=4.0 + 25.0j, conductor=phase_conduct, neutral_conductor=neutral_conduct, neutral=False) phase_conduct_bt = Conductor(id=32) line_model_b = LineModel(loc_a=0.0 + 29.0j, loc_b=2.5 + 29.0j, loc_c=7.0 + 29.0j, loc_n=4.0 + 25.0j, conductor=phase_conduct_bt, neutral_conductor=neutral_conduct, neutral=False) nodes = dict() for node in data['nodes']: p = node['active_power'] * 1e3 q = node['reactive_power'] * 1e3 s = p + 1j * q if node['voltage_level'] == 'medium voltage': node_object = LoadNode(name=str(node['name']), power=s, voltage=vll_mt) if node['name'] == 0: node_object = LoadNode(name=str(node['name']), power=s, voltage=vll_mt, external_grid=eg1) elif node['voltage_level'] == 'low voltage': if node['phase'] == 'abc': node_object = LoadNode(name=str(node['name']), power=s, voltage=vll_bt) elif node['phase'] == 'a': node_object = LoadNode(name=str(node['name']), ppa=s, voltage=vll_bt) elif node['phase'] == 'b': node_object = LoadNode(name=str(node['name']), ppb=s, voltage=vll_bt) elif node['phase'] == 'c': node_object = LoadNode(name=str(node['name']), ppc=s, voltage=vll_bt) nodes[node['name']] = node_object sections = dict() for link in data['links']: if link['type'] == 'line': if data['nodes'][ link['source']]['voltage_level'] == 'medium voltage': if link['switch'] != None: sec_object = Section(name=link['name'], n1=nodes[link['source']], n2=nodes[link['target']], line_model=line_model_a, switch=sw1, length=link['length']) else: sec_object = Section(name=link['name'], n1=nodes[link['source']], n2=nodes[link['target']], line_model=line_model_a, length=link['length']) if data['nodes'][link['source']]['voltage_level'] == 'low voltage': sec_object = Section(name=link['name'], n1=nodes[link['source']], n2=nodes[link['target']], line_model=line_model_b, length=link['length']) elif link['type'] == 'transformer': sec_object = Section(name=link['name'], n1=nodes[link['source']], n2=nodes[link['target']], transformer=t1) sections[link['name']] = sec_object grid_elements = GridElements(name='my_grid_elements') grid_elements.add_switch([sw1]) grid_elements.add_load_node(list(nodes.values())) grid_elements.add_section(list(sections.values())) grid_elements.create_grid() # inicializa o dicionario que irá armazenar os dados das simulações for i in nodes.keys(): grid_data[str(i)] = dict(voltage=[], power=[]) for i in sections.keys(): grid_data[str(i)] = dict(current=[]) return grid_elements
def create_mygrid_model(file): data = json.load(file) vll_mt = p2r(13.8e3, 0.0) vll_bt = p2r(380.0, 0.0) eg1 = ExternalGrid(name='extern grid 1', vll=vll_mt) # switchs sw1 = Switch(name='sw_1', state=1) # transformers zpu = 3.5 / 100.0 # zpu = z% / 100.0 vbase = 220.0 # Volts sbase = 112.5 # kVA zbase = (vbase**2) / (sbase * 1e3) z = zpu * zbase # impedancia do trafo referica a baixa tensao a = 3.5 # relação x/r, valor adotado r = z / np.sqrt(1 + a**2) x = a * r t1 = TransformerModel(name="T1", primary_voltage=vll_mt, secondary_voltage=vll_bt, power=225e3, impedance=r + 1j * x) phase_conduct = Conductor(id=57) neutral_conduct = Conductor(id=44) line_model_a = LineModel(loc_a=0.0 + 29.0j, loc_b=2.5 + 29.0j, loc_c=7.0 + 29.0j, loc_n=4.0 + 25.0j, conductor=phase_conduct, neutral_conductor=neutral_conduct, neutral=False) phase_conduct_bt = Conductor(id=32) line_model_b = LineModel(loc_a=0.0 + 29.0j, loc_b=2.5 + 29.0j, loc_c=7.0 + 29.0j, loc_n=4.0 + 25.0j, conductor=phase_conduct_bt, neutral_conductor=neutral_conduct, neutral=False) nodes = dict() for node in data['nodes']: p = node['active_power'] * 1e3 q = node['reactive_power'] * 1e3 s = p + 1j * q if node['voltage_level'] == 'medium voltage': node_object = LoadNode(name='Node_' + str(node['name']), power=s, voltage=vll_mt) if node['name'] == 0: node_object = LoadNode(name='Node_' + str(node['name']), power=s, voltage=vll_mt, external_grid=eg1) elif node['voltage_level'] == 'low voltage': if node['phase'] == 'abc': node_object = LoadNode(name='Node_' + str(node['name']), power=s, voltage=vll_bt) elif node['phase'] == 'a': node_object = LoadNode(name='Node_' + str(node['name']), ppa=s, voltage=vll_bt) elif node['phase'] == 'b': node_object = LoadNode(name='Node_' + str(node['name']), ppb=s, voltage=vll_bt) elif node['phase'] == 'c': node_object = LoadNode(name='Node_' + str(node['name']), ppc=s, voltage=vll_bt) nodes[node['name']] = node_object sections = dict() for link in data['links']: if link['type'] == 'line': if data['nodes'][ link['source']]['voltage_level'] == 'medium voltage': if link['switch'] != None: sec_object = Section(name=link['name'], n1=nodes[link['source']], n2=nodes[link['target']], line_model=line_model_a, switch=sw1, length=link['length']) else: sec_object = Section(name=link['name'], n1=nodes[link['source']], n2=nodes[link['target']], line_model=line_model_a, length=link['length']) if data['nodes'][link['source']]['voltage_level'] == 'low voltage': sec_object = Section(name=link['name'], n1=nodes[link['source']], n2=nodes[link['target']], line_model=line_model_b, length=link['length']) elif link['type'] == 'transformer': sec_object = Section(name=link['name'], n1=nodes[link['source']], n2=nodes[link['target']], transformer=t1) sections[link['name']] = sec_object grid_elements = GridElements(name='my_grid_elements') grid_elements.add_switch([sw1]) grid_elements.add_load_node(list(nodes.values())) grid_elements.add_section(list(sections.values())) grid_elements.create_grid() return grid_elements
ch9 = Switch(name='9', state=1) ch10 = Switch(name='10', state=1) # switchs de Fronteira ch4 = Switch(name='4', state=0) ch5 = Switch(name='5', state=0) ch8 = Switch(name='8', state=0) ch11 = Switch(name='11', state=0) # switchs do alimentador de S2 ch6 = Switch(name='6', state=1) ch7 = Switch(name='7', state=1) # tensao nominal vll_mt = p2r(13.8e3, 0.0) vll_bt = p2r(380.0, 0.0) # transformers t1 = TransformerModel(name="T1", primary_voltage=vll_mt, secondary_voltage=vll_bt, power=225e3, impedance=0.01 + 0.2j) eg1 = ExternalGrid(name='extern grid 1', vll=vll_mt) # Definição GD's c2_PV = Generation(name="c2_PV", P=10e3 + 0j,