def line_to_cim(self, connectivity_node1, connectivity_node2, length, name, circuit_voltage, lat, lon): line = ACLineSegment( name=CimWriter.escape_string(str(name.encode('utf-8') if name else None)) + '_' + connectivity_node1.name + '_' + connectivity_node2.name, bch=0, r=0.3257, x=0.3153, r0=0.5336, x0=0.88025, length=length, BaseVoltage=self.base_voltage(int(circuit_voltage)), Location=self.add_location(lat, lon)) line.UUID = str(CimWriter.uuid()) self.cimobject_by_uuid_dict[line.UUID] = line terminal1 = Terminal(ConnectivityNode=connectivity_node1, ConductingEquipment=line, sequenceNumber=1) terminal1.UUID = str(CimWriter.uuid()) self.cimobject_by_uuid_dict[terminal1.UUID] = terminal1 terminal2 = Terminal(ConnectivityNode=connectivity_node2, ConductingEquipment=line, sequenceNumber=2) terminal2.UUID = str(CimWriter.uuid()) self.cimobject_by_uuid_dict[terminal2.UUID] = terminal2
def attach_load(self, osm_substation_id, winding_voltage, transformer): transformer_winding = None if len(transformer.getTransformerWindings()) >= 2: for winding in transformer.getTransformerWindings(): if winding_voltage == winding.ratedU: transformer_winding = winding break # add winding for lower voltage, if not already existing or # add winding if sub-station is a switching station (only one voltage level) if transformer_winding is None: transformer_winding = self.add_transformer_winding( osm_substation_id, winding_voltage, transformer) connectivity_node = self.connectivity_by_uuid_dict[ transformer_winding.UUID] estimated_load = LoadEstimator.estimate_load( self.population_by_station_dict[str(osm_substation_id)] ) if self.population_by_station_dict is not None else LoadEstimator.estimate_load_country( self.country_name, self.count_substations) load_response_characteristic = LoadResponseCharacteristic( exponentModel=False, pConstantPower=estimated_load) load_response_characteristic.UUID = str(CimWriter.uuid()) energy_consumer = EnergyConsumer( name='L_' + osm_substation_id, LoadResponse=load_response_characteristic, BaseVoltage=self.base_voltage(winding_voltage)) energy_consumer.UUID = str(CimWriter.uuid()) self.cimobject_by_uuid_dict[ load_response_characteristic.UUID] = load_response_characteristic self.cimobject_by_uuid_dict[energy_consumer.UUID] = energy_consumer terminal = Terminal(ConnectivityNode=connectivity_node, ConductingEquipment=energy_consumer, sequenceNumber=1) terminal.UUID = str(CimWriter.uuid()) self.cimobject_by_uuid_dict[terminal.UUID] = terminal
def add_transformer_winding(self, osm_substation_id, winding_voltage, transformer): new_transformer_winding = TransformerWinding(name='TW_' + str(osm_substation_id) + '_' + str(winding_voltage), b=0, x=1.0, r=1.0, connectionType='Yn', ratedU=winding_voltage, ratedS=5000000, BaseVoltage=self.base_voltage(winding_voltage)) # init with primary index = 0 for winding in transformer.getTransformerWindings(): # already a primary winding with at least as high voltage as the new one if winding.ratedU >= winding_voltage: index += 1 else: self.increase_winding_type(winding) new_transformer_winding.windingType = self.winding_types[index] new_transformer_winding.setPowerTransformer(transformer) new_transformer_winding.UUID = str(CimWriter.uuid()) self.cimobject_by_uuid_dict[new_transformer_winding.UUID] = new_transformer_winding connectivity_node = ConnectivityNode(name='CN_' + str(osm_substation_id) + '_' + str(winding_voltage)) connectivity_node.UUID = str(CimWriter.uuid()) self.cimobject_by_uuid_dict[connectivity_node.UUID] = connectivity_node terminal = Terminal(ConnectivityNode=connectivity_node, ConductingEquipment=new_transformer_winding, sequenceNumber=1) terminal.UUID = str(CimWriter.uuid()) self.cimobject_by_uuid_dict[terminal.UUID] = terminal self.connectivity_by_uuid_dict[new_transformer_winding.UUID] = connectivity_node return new_transformer_winding
def generator_to_cim(self, generator, circuit_voltage): if generator.id in self.uuid_by_osmid_dict: generating_unit = self.cimobject_by_uuid_dict[self.uuid_by_osmid_dict[generator.id]] else: generating_unit = GeneratingUnit(name='G_' + str(generator.id), maxOperatingP=generator.nominal_power, minOperatingP=0, nominalP=generator.nominal_power if generator.nominal_power else '', Location=self.add_location(generator.lat, generator.lon)) synchronous_machine = SynchronousMachine( name='G_' + str(generator.id) + '_' + CimWriter.escape_string(str(generator.name.encode('utf-8') if generator.name else None)), operatingMode='generator', qPercent=0, x=0.01, r=0.01, ratedS='' if generator.nominal_power is None else generator.nominal_power, type='generator', GeneratingUnit=generating_unit, BaseVoltage=self.base_voltage(int(circuit_voltage))) generating_unit.UUID = str(CimWriter.uuid()) synchronous_machine.UUID = str(CimWriter.uuid()) self.cimobject_by_uuid_dict[generating_unit.UUID] = generating_unit self.cimobject_by_uuid_dict[synchronous_machine.UUID] = synchronous_machine self.uuid_by_osmid_dict[generator.id] = generating_unit.UUID connectivity_node = ConnectivityNode(name='CN_' + str(generator.id) + '_' + str(circuit_voltage)) connectivity_node.UUID = str(CimWriter.uuid()) self.cimobject_by_uuid_dict[connectivity_node.UUID] = connectivity_node terminal = Terminal(ConnectivityNode=connectivity_node, ConductingEquipment=synchronous_machine, sequenceNumber=1) terminal.UUID = str(CimWriter.uuid()) self.cimobject_by_uuid_dict[terminal.UUID] = terminal self.connectivity_by_uuid_dict[generating_unit.UUID] = connectivity_node return self.connectivity_by_uuid_dict[generating_unit.UUID]
def line_to_cim(self, connectivity_node1, connectivity_node2, length, name, circuit_voltage, lat, lon, line_length, cables, voltages, wires): r = 0.3257 x = 0.3153 # r0 = 0.5336 # x0 = 0.88025 r0 = 0 x0 = 0 coeffs_of_voltage = { 220000: dict(wires_typical=2.0, r=0.08, x=0.32, c=11.5, i=1.3), 380000: dict(wires_typical=4.0, r=0.025, x=0.25, c=13.7, i=2.6) } length_selected = round(line_length) cables_selected = CSVWriter.convert_max_set_to_string(cables) voltage_selected = CSVWriter.convert_max_set_to_string(voltages) wires_selected = CSVWriter.convert_max_set_to_string(wires) voltage_selected_round = 0 if 360000 <= int(voltage_selected) <= 400000: voltage_selected_round = 380000 elif 180000 <= int(voltage_selected) <= 260000: voltage_selected_round = 220000 try: if length_selected and cables_selected and int( voltage_selected_round ) in coeffs_of_voltage and wires_selected: coeffs = coeffs_of_voltage[int(voltage_selected_round)] # Specific resistance of the transmission lines. if coeffs['wires_typical']: r = coeffs['r'] / (int(wires_selected) / coeffs['wires_typical']) / ( int(cables_selected) / 3.0) # Specific reactance of the transmission lines. x = coeffs['x'] / (int(wires_selected) / coeffs['wires_typical']) / ( int(cables_selected) / 3.0) except Exception as ex: print('Error line_to_cim') line = ACLineSegment( name=CimWriter.escape_string(name) + '_' + connectivity_node1.name + '_' + connectivity_node2.name, bch=0, r=r, x=x, r0=r0, x0=x0, length=length, BaseVoltage=self.base_voltage(int(circuit_voltage)), Location=self.add_location(lat, lon)) line.UUID = str(CimWriter.uuid()) self.cimobject_by_uuid_dict[line.UUID] = line terminal1 = Terminal(ConnectivityNode=connectivity_node1, ConductingEquipment=line, sequenceNumber=1) terminal1.UUID = str(CimWriter.uuid()) self.cimobject_by_uuid_dict[terminal1.UUID] = terminal1 terminal2 = Terminal(ConnectivityNode=connectivity_node2, ConductingEquipment=line, sequenceNumber=2) terminal2.UUID = str(CimWriter.uuid()) self.cimobject_by_uuid_dict[terminal2.UUID] = terminal2