Esempio n. 1
0
def entso_e_example():
    # Validation with example 4.3.3.1, p 35. ENTSO-E, COMMON INFORMATION MODEL (CIM) – MODEL EXCHANGE PROFILE 1, Ed 1.
    # https://eepublicdownloads.entsoe.eu/clean-documents/CIM_documents/Grid_Model_CIM/140610_ENTSO-E_CIM_Profile_v1_UpdateIOP2013.pdf
    print('Computing TransformerStartImpedance attributes...')
    pte = PowerTransformerEnd()
    pte.rated_s = 1630e6
    pte.rated_u = 400e3
    sc_test = ShortCircuitTest(power=2020180, voltage=11.85)
    tsi: TransformerStarImpedance = transformer_test_to_rx(pte=pte,
                                                           sc_test=sc_test)
    print(f'r = {tsi.r}, x = {tsi.x}')
def test_compute_star_impedance():
    # Validation parameter from example 4.3.3.1, p 35. ENTSO-E, COMMON INFORMATION MODEL (CIM) – MODEL EXCHANGE PROFILE 1, Ed 1.
    # https://eepublicdownloads.entsoe.eu/clean-documents/CIM_documents/Grid_Model_CIM/140610_ENTSO-E_CIM_Profile_v1_UpdateIOP2013.pdf
    r = 0.1216563664420942
    x = 11.63126562998702
    pte = PowerTransformerEnd()
    pte.rated_s = 1630e6
    pte.rated_u = 400e3
    sc_test = ShortCircuitTest(power=2020180, voltage=11.85)
    nl_test = NoLoadTest()
    tsi: TransformerStarImpedance = transformer_test_to_rx(pte=pte, sc_test=sc_test, nl_test=nl_test)
    assert tsi.r == r
    assert tsi.x == x
Esempio n. 3
0
def create_power_transformer_end(network: NetworkService, pt: PowerTransformer, t: Terminal, end_number: int = 0, **kwargs) -> PowerTransformerEnd:
    en = end_number if end_number > 0 else t.sequence_number
    te = PowerTransformerEnd(mrid=f"{pt.mrid}_e{en}", power_transformer=pt, terminal=t, end_number=en,
                             **kwargs)
    pt.add_end(te)
    network.add(te)
    return te
 def test_powertransformer_voltages(self):
     bv11k = BaseVoltage(nominal_voltage=11000)
     pt = PowerTransformer(base_voltage=bv11k)
     t1 = Terminal(conducting_equipment=pt)
     pte = PowerTransformerEnd(power_transformer=pt,
                               base_voltage=bv11k,
                               terminal=t1)
     pt.add_end(pte)
     assert pt.get_base_voltage(t1) is pte.base_voltage is t1.base_voltage
Esempio n. 5
0
def sincal_2wt_to_cim(twt: StdTwoWindingTransformer):
    print("Computing TransformerStarImpedance for ThreeWindingTransformer...")
    pte1 = PowerTransformerEnd()
    pte1.rated_s = twt.sn
    pte1.rated_u = twt.un1
    sc_test1 = ShortCircuitTest(voltage=twt.uk, voltage_ohmic_part=twt.ur)
    tsi: TransformerStarImpedance = transformer_test_to_rx(pte=pte1,
                                                           sc_test=sc_test1)
    if twt.flagZ0Input == 1:
        tsi = z0z1_r0x0_from_s2wt(tsi, twt)
    elif twt.flagZ0Input == 2:
        tsi = from_r0x0_for_s2wt(tsi, twt)
    elif twt.flagZ0Input == 3:
        tsi = from_r0R1_for_s2wt(tsi, twt)
    else:
        raise Exception(f'flagZ0Input : {twt.flagZ0Input} not supported')
    print(
        f'tsi: r = {round(tsi.r, 3)}, x = {tsi.x}, r0: {round(tsi.r0, 3)}, x0 = {round(tsi.x0, 3)} '
    )
Esempio n. 6
0
def create_feeder():
    """
    Creates a small feeder based on https://bitbucket.org/zepben/cimdemo/src/master/lv_simple_net.png.
    :return: A NetworkService representing the feeder.
    """
    # Create the network. This will be used for sending all components of the feeder.
    network = NetworkService()

    # A network has multiple BaseVoltage's, each used to represent the intended nominal voltage of equipment operating
    # on a segment of the network.
    bv_11kv = BaseVoltage(mrid='11kv', nominal_voltage=11000, name='11kV')

    # We must add the BaseVoltage to the network directly if any ConductingEquipment relies on it.
    network.add(bv_11kv)

    # There is no required order for adding equipment to the network, as long as its dependencies are satisfied.
    # In this example, we will start with the main EnergySource, working towards the leaf nodes in the network
    # in a depth-first traversal.

    # Geographic coordinates and location details are stored as a Location against any type extending
    # PowerSystemResource.
    energy_source_loc = Location(mrid='es-loc')
    energy_source_loc.add_point(PositionPoint(152.9100276,-31.43952262))
    network.add(energy_source_loc)

    # Create the EnergySource, specifying any desired parameters plus passing in our BaseVoltage, EnergySourcePhase's,
    # Location, and Terminals. Note that terminals accepts a list of Terminals, however an EnergySource only has one.
    energy_source = EnergySource(mrid='EnergySource',
                                 name='Source',
                                 base_voltage=bv_11kv,
                                 voltage_magnitude=11000,
                                 voltage_angle=0.0,
                                 location=energy_source_loc)

    # Note that all types extending IdentifiedObject take an mrid. If it is not provided, a UUID will be generated
    # for you. We create a Terminal specifying its phase and connectivity_node. The ConnectivityNode will also
    # receive a reference to the Terminal as part of the constructor.
    es_t1 = Terminal(mrid='es-t1', phases=PhaseCode.ABC, conducting_equipment=energy_source)

    # This is the starting ConnectivityNode in our network
    # At a bare minimum, at least one connectivity node and one Terminal is required for an EnergySource to be
    # connected to the network. Note however that the network will allow you to add disconnected equipment if that
    # suits your use case.
    # NetworkService.connect_by_mrid is a helper method that will create a ConnectivityNode in the NetworkService for
    # the given mRID (in this case, SourceNode), and connect the passed in Terminal to it (es_t1).
    # You should ensure you always call connect_by_mrid or connect_by_terminal, as this keeps the references between
    # the ConnectivityNode and Terminal in sync.
    network.connect_by_mrid(es_t1, "SourceNode")

    # Any ConductingEquipment must have its terminals added to it before being utilised. This can be performed through
    # the constructor via the terminals_ parameter, or added after initialisation like below. The Terminal must also
    # have its conducting_equipment specified for add_terminal() to succeed.
    energy_source.add_terminal(es_t1)
    network.add(es_t1)

    # An EnergySource has an EnergySourcePhase representing each phase it supplies. This is primarily used for tracing,
    # however more attributes will be added at a later date.
    es_phases = [EnergySourcePhase(mrid="esp1", energy_source=energy_source, phase=SinglePhaseKind.A),
                 EnergySourcePhase(mrid="esp2", energy_source=energy_source, phase=SinglePhaseKind.B),
                 EnergySourcePhase(mrid="esp3", energy_source=energy_source, phase=SinglePhaseKind.C)]

    for phase in es_phases:
        energy_source.add_phase(phase)
        network.add(phase)

    network.add(energy_source)

    # Create the PowerTransformer
    # Note BaseVoltage is not used for the PowerTransformer as it has two separate voltages. rated_u must be populated
    # on both ends.
    power_transformer = PowerTransformer(mrid="PowerTransformer", vector_group=VectorGroup.DYN11)
    delta_pt_end = PowerTransformerEnd(mrid="delta-pt-end", rated_s=800000, rated_u=11000, connection_kind=WindingConnection.D, power_transformer=power_transformer)
    delta_tap_changer = RatioTapChanger(mrid="rtc1", high_step=4, low_step=1, step=2.0, neutral_step=2, normal_step=2, step_voltage_increment=0.25, transformer_end=delta_pt_end)
    delta_pt_end.ratio_tap_changer = delta_tap_changer

    network.add(delta_tap_changer)
    network.add(delta_pt_end)

    wye_pt_end = PowerTransformerEnd(mrid="wye-pt-end", rated_s=800000, rated_u=416, connection_kind=WindingConnection.Yn, power_transformer=power_transformer)
    wye_tap_changer = RatioTapChanger(mrid="rtc2", high_step=2, low_step=1, step=2.0, neutral_step=2, normal_step=2, step_voltage_increment=0.5, transformer_end=wye_pt_end)
    wye_pt_end.ratio_tap_changer = wye_tap_changer

    network.add(wye_tap_changer)
    network.add(wye_pt_end)

    # Terminals are required on the PowerTransformer, corresponding to each PowerTransformerEnd
    # Note that ordering of the Terminals is significant, and must correspond with the ordering of the ends.
    delta_terminal = Terminal(mrid='pt-t1', phases=PhaseCode.ABC, conducting_equipment=power_transformer)
    # Connect the terminal to the source ConnectivityNode
    network.connect_by_mrid(delta_terminal, 'SourceNode')
    power_transformer.add_terminal(delta_terminal)
    network.add(delta_terminal)

    # Set the terminal on the Delta PowerTransformerEnd (This allows us to correlate the Terminal with the voltage)
    delta_pt_end.terminal = delta_terminal

    # The wye Terminal is connected to the Bus 0 ConnectivityNode
    wye_terminal = Terminal(mrid='pt-t2', phases=PhaseCode.ABCN, conducting_equipment=power_transformer)
    # Connect the terminal to the ConnectivityNode
    network.connect_by_mrid(wye_terminal, 'Bus 0')
    power_transformer.add_terminal(wye_terminal)
    network.add(wye_terminal)

    # Set the terminal on the WYE PowerTransformerEnd (This allows us to correlate the Terminal with the voltage)
    wye_pt_end.terminal = wye_terminal

    # Location
    pt_loc = Location(mrid='pt-loc')
    pt_loc.add_point(PositionPoint(152.9100276,-31.43952262))
    power_transformer.location = pt_loc
    network.add(pt_loc)

    # Add the ends to the network
    power_transformer.add_end(delta_pt_end)
    power_transformer.add_end(wye_pt_end)

    # Add the PowerTransformer to the network
    network.add(power_transformer)

    # Create the Breaker. It requires a new BaseVoltage of 416V
    # Note Breaker constructor defaults all switch states to CLOSED.
    bv_416v = BaseVoltage(mrid="416v", nominal_voltage=416, name="0.416kV")
    network.add(bv_416v)

    # Create a location for the Breaker
    breaker_loc = Location(mrid='breaker-loc')
    breaker_loc.add_point(PositionPoint(152.9100276,-31.43952262))
    network.add(breaker_loc)

    breaker = Breaker(mrid="Breaker", base_voltage=bv_416v, location=breaker_loc)

    t1 = Terminal(mrid='br-t1', phases=PhaseCode.ABCN, conducting_equipment=breaker)
    network.connect_by_mrid(t1, 'Bus 0')
    breaker.add_terminal(t1)
    network.add(t1)

    t2 = Terminal(mrid='br-t2', phases=PhaseCode.ABCN, conducting_equipment=breaker)
    network.connect_by_mrid(t2, 'Bus 1')
    breaker.add_terminal(t2)
    network.add(t2)

    # Add the Breaker to the network
    network.add(breaker)

    # Create first AcLineSegment with a PerLengthSequenceImpedance and Location with two position_points
    # The properties of the conductor are contained in a PerLengthSequenceImpedance. All amounts are per metre.
    plsi_1 = PerLengthSequenceImpedance(mrid="4c_70", r=466.0, x=71.0, r0=1505.0, x0=83.0)
    network.add(plsi_1)

    # A line typically has two longlats representing each terminal point. Note these must be added in order and
    # correspond to the matching Terminal.
    acls1_loc = Location(mrid="acls1-loc")
    acls1_loc.add_point(PositionPoint(152.9144265,-31.43913816))
    acls1_loc.add_point(PositionPoint(152.910199,-31.439523))
    network.add(acls1_loc)

    acls1 = AcLineSegment(mrid="acls1",name="acls1",
                          base_voltage=bv_416v,
                          length=31.71938,
                          per_length_sequence_impedance=plsi_1,
                          location=acls1_loc)

    # Create and add the Terminal's for this ACLS
    acls1_t1 = Terminal(mrid='acls1-t1', phases=PhaseCode.ABCN, conducting_equipment=acls1)
    network.connect_by_mrid(acls1_t1, "Bus 1")
    acls1.add_terminal(acls1_t1)
    network.add(acls1_t1)

    acls1_t2 = Terminal(mrid='acls1-t2', phases=PhaseCode.ABCN, conducting_equipment=acls1)
    network.connect_by_mrid(acls1_t2, "Bus 25")
    acls1.add_terminal(acls1_t2)
    network.add(acls1_t2)

    # Add the ACLS to the network after adding all its dependencies
    network.add(acls1)

    # Create the rest of the lines. These are all quite similar to above.
    create_lines(network, bv_416v, "Bus 25", plsi_1)

    # Create first EnergyConsumer on 230V with a single phase
    bv_230v = BaseVoltage(mrid="230v", nominal_voltage=230, name="0.23kV")
    network.add(bv_230v)

    # Each EnergyConsumer has a list of phases it is connected on. These are optional and only used to
    # specify additional properties per phase when they are known.
    ecp = [EnergyConsumerPhase(mrid='ecp1', phase=SinglePhaseKind.A, p_fixed=800.0, q_fixed=200.0)]
    network.add(ecp[0])

    # Creaote the EnergyConsumer's Location
    ec1_loc = Location(mrid="ec1-loc")
    ec1_loc.add_point(PositionPoint(152.9172589,-31.44307421))
    network.add(ec1_loc)

    energy_consumer1 = EnergyConsumer(mrid="EnergyConsumer1",
                                      p=1000,
                                      q=334.27413609633844,
                                      name="Load 1",
                                      phase_connection=PhaseShuntConnectionKind.Y,
                                      energy_consumer_phases=ecp,
                                      base_voltage=bv_230v,
                                      location=ec1_loc)

    # Create and add the Terminal, Note that the ConnectivityNode will be retrieved from the network (Bus 34 was created in create_lines())
    ec1_t1 = Terminal(mrid='ec1-t1', phases=PhaseCode.A, conducting_equipment=energy_consumer1)
    network.connect_by_mrid(ec1_t1, "Bus 34")
    energy_consumer1.add_terminal(ec1_t1)
    network.add(ec1_t1)

    # Add the energy consumer to the network
    network.add(energy_consumer1)

    # Create PV EnergySource with a single phase and a location
    esp = [EnergySourcePhase(mrid='esp4', phase=SinglePhaseKind.A)]
    network.add(esp[0])

    es2_loc = Location(mrid="es2-loc")
    es2_loc.add_point(PositionPoint(152.9172589,-31.44307421))
    network.add(es2_loc)

    energy_source_pv = EnergySource(mrid="PV-DG",
                                    name='PV Distributed Generator',
                                    base_voltage=bv_230v,
                                    voltage_magnitude=416,
                                    voltage_angle=9.0,
                                    energy_source_phases=esp,
                                    location=es2_loc)
    es2_t1 = Terminal(mrid='es2-t1', phases=PhaseCode.A, conducting_equipment=energy_source_pv)
    network.connect_by_mrid(es2_t1, "Bus 34")
    energy_source_pv.add_terminal(es2_t1)
    network.add(es2_t1)

    # Add the EnergySource to the network.
    network.add(energy_source_pv)

    # Create second EnergyConsumer with a single phase of B and a Location.
    ecp = [EnergyConsumerPhase(mrid="ecp2", phase=SinglePhaseKind.B, p_fixed=800.0, q_fixed=200.0)]
    network.add(ecp[0])

    ec2_loc = Location(mrid="ec2-loc")
    ec2_loc.add_point(PositionPoint(152.9121734,-31.44320236))
    network.add(ec2_loc)

    energy_consumer2 = EnergyConsumer(mrid="EnergyConsumer2",
                                      p=1000,
                                      q=334.27413609633844,
                                      name="Load 2",
                                      phase_connection=PhaseShuntConnectionKind.Y,
                                      energy_consumer_phases=ecp,
                                      base_voltage=bv_230v,
                                      location=ec2_loc)

    # Create and connect the Terminal.
    ec2_t1 = Terminal(mrid='ec2-t1', phases=PhaseCode.B, conducting_equipment=energy_consumer2)
    network.connect_by_mrid(ec2_t1, "Bus 47")
    energy_consumer2.add_terminal(ec2_t1)
    network.add(ec2_t1)

    # Add the EnergyConsumer to the network
    network.add(energy_consumer2)

    # Create third EnergyConsumer with a single phase A and a Location.
    ecp = [EnergyConsumerPhase(mrid="ecp3", phase=SinglePhaseKind.A, p_fixed=800.0, q_fixed=200.0)]
    network.add(ecp[0])

    ec3_loc = Location(mrid="ec3-loc", position_points=[PositionPoint(152.9151775,-31.43624552)])
    network.add(ec3_loc)

    energy_consumer3 = EnergyConsumer(mrid="EnergyConsumer3",
                                      p=1000,
                                      q=334.27413609633844,
                                      name="Load 3",
                                      phase_connection=PhaseShuntConnectionKind.Y,
                                      energy_consumer_phases=ecp,
                                      base_voltage=bv_230v,
                                      location=ec3_loc)
    ec3_t1 = Terminal(mrid='ec3-t1', phases=PhaseCode.A, conducting_equipment=energy_consumer3)
    network.connect_by_mrid(ec3_t1, "Bus 70")
    energy_consumer3.add_terminal(ec3_t1)
    network.add(ec3_t1)

    # Add the last energy consumer to the network
    network.add(energy_consumer3)

    # Our network is complete and connected. Next we must send it.
    return network
Esempio n. 7
0
def gen_trafo_end(**kwargs):
    mrid = _get_mrid()
    return PowerTransformerEnd(mrid=mrid, **kwargs)
Esempio n. 8
0
def sincal_3wt_to_cim_tsi(twt: StdThreeWindingTransformer):
    pte1 = PowerTransformerEnd()
    pte1.rated_s = twt.sn12
    pte1.rated_u = twt.un1
    sct1 = ShortCircuitTest(voltage=twt.uk12, voltage_ohmic_part=twt.ur12)
    pte2 = PowerTransformerEnd()
    pte2.rated_s = twt.sn23
    pte2.rated_u = twt.un2
    pte3 = PowerTransformerEnd()
    sct2 = ShortCircuitTest(voltage=twt.uk23, voltage_ohmic_part=twt.ur23)
    pte3.rated_s = twt.sn31
    pte3.rated_u = twt.un3
    sct3 = ShortCircuitTest(voltage=twt.uk31, voltage_ohmic_part=twt.ur31)
    tsi1: TransformerStarImpedance = transformer_test_to_rx(pte=pte1,
                                                            sc_test=sct1)
    tsi2: TransformerStarImpedance = transformer_test_to_rx(pte=pte2,
                                                            sc_test=sct2)
    tsi3: TransformerStarImpedance = transformer_test_to_rx(pte=pte3,
                                                            sc_test=sct3)
    if twt.flagZ0Input == 1:
        tsi1 = z0z1_r0x0(tsi1, twt, 1)
        tsi2 = z0z1_r0x0(tsi2, twt, 2)
        tsi3 = z0z1_r0x0(tsi3, twt, 3)
    elif twt.flagZ0Input == 2:
        tsi1 = from_r0x0(tsi1, twt, 1)
        tsi2 = from_r0x0(tsi2, twt, 2)
        tsi3 = from_r0x0(tsi3, twt, 3)
    elif twt.flagZ0Input == 3:
        # TODO: Implement this case
        pass
    else:
        raise Exception(f'flagZ0Input : {twt.flagZ0Input} not supported')

    print(
        f'tsi1: r = {round(tsi1.r, 3)}, x = {tsi1.x}, r0: {round(tsi1.r0, 3)}, x0 = {round(tsi1.x0, 3)} '
    )
    print(
        f'tsi2: r = {round(tsi2.r, 3)}, x = {tsi2.x}, r0: {round(tsi2.r0, 3)}, x0 = {round(tsi2.x0, 3)}'
    )
    print(
        f'tsi3: r = {round(tsi3.r, 3)}, x = {tsi3.x}, r0: {round(tsi3.r0, 3)}, x0 = {round(tsi3.x0, 3)}'
    )