Tekvel Magic
Loading...
Searching...
No Matches
Tutorial: Protection Testing Script

This tutorial explains how to write a custom protection testing script using Tekvel Magic. The process revolves around configuring SVPublisher and GOOSESubscriber to simulate an overcurrent scenario and monitor a protection IED's response.


Step 1: Understand Your Setup

Identify the setup involving:

  • IED: Configured to trip when receiving GOOSE signals or Sampled Values (SV).
  • MU (Merging Unit): Sends SV to IED.
  • GOOSE and SV Communication: GOOSE messages should include Start (Str) or Trip (Op) signals.

Original Setup:

___________ ___________
| | SV | |
| | -------------> | |
| MU | | IED |
| | GOOSE |Protection|
| | <------------ | |
|_________ | |__________|
| |
| |
| _________________ |
|------| |----|
| Network |
| Connection |
|_________________|
  1. The IED must be originally configured to subscribe to Sampled Values (SV) from a Merging Unit (MU).
  2. The SCD file must include both the MU with its SV configuration and the IED with a GOOSE message containing either a Trip or Start signal.
  3. The IED protection must be configured to trip at currents above 1200 A (RMS, primary).

Testing Setup:

___________ ___________
| This PC | SV (sim) | |
| | -------------> | |
| Tekvel | | IED |
| Magic | GOOSE |Protection|
| | <------------ | |
|_________ | |__________|
| |
| |
| _________________ |
|------| |----|
| Network |
| Connection |
|_________________|
  1. The IED must be set to accept simulated SV messages (typically LPHD.Sim=True).
  2. If simulation mode cannot be enabled on the IED, detach the MU from the network and set the simulation parameter in the script to False.

You can simulate SV with SVPublisher and monitor changes using GOOSESubscriber.


Step 2: Initialize the SCL Configuration

Load the SCL file using the SCL() initializer. This will prompt the user to select an SCL file containing both the Merging Unit (MU) and IED configurations.

scl = SCL() # Prompts the user to select an SCL file

The SCL file should contain the Merging Unit (MU) with SV configuration and an IED configured to send at least one GOOSE message with protection Start or Trip signal.


Step 3: Create and Configure SVPublisher

The SVPublisher simulates the Sampled Values (SV) that will be sent to the IED. Start by initializing the SVPublisher and selecting the appropriate SCL file:

sp1 = SVPublisher(scl=scl) # Prompt the user to select the IED and SV stream

Note that by default the SVPublihser would publish SV messages with Simulation flag set to True. If you want SV messages sent with Simulation flag set to False (which is strongly NOT recommended), pass simulation=False parameter to SVPublisher initializer, like this:

sp1 = SVPublisher(scl=scl, simulation=False)

Step 4: Initialize the Signal Generator

To simulate current and voltage states (pre-fault, fault, post-fault), you need to use the SGSineWave signal generator. The signal generator produces sine waves for signals inside the SV message. Link the generator to the SVSimulator's data attributes using set_signal_list():

sgSin1 = SGSineWave(sp1.ss.ied_name, sp1.ss.ap_name, 3) # Initialize generator with 3 states and links it to the ServerSimulator initialized previously.
sgSin1.set_signal_list(sp1.get_fcda_ref_list()) # Link generator to SV data attributes

Define the different current and voltage states for the simulation:

state1 = SG3PhaseState(cRms=1000, vRms=10000) # Pre-fault
state2 = SG3PhaseState(cRms=20000, vRms=7000) # Fault
state3 = SG3PhaseState(cRms=100, vRms=10000) # Post-fault

These states will be used during the test to simulate different fault conditions for the IED. You can now assign these states to the signal generator:

sgSin1.set_state(0, state1)
sgSin1.set_state(1, state2)
sgSin1.set_state(2, state3)

The signal generator will now produce a sine wave representing these different states for the SV message.

Step 5: Set Up GOOSESubscriber

The GOOSESubscriber monitors the IED's GOOSE messages for any data changes (produced by Trip or Start in case of protection testing). Initialize the GOOSESubscriber and wait for messages:

gs1 = GOOSESubscriber(scl=scl, da_ref="") # Prompt for IED and GOOSE message
gs1.wait_for_goose(timeout=10000) # Wait for the first GOOSE message

The wait_for_goose() method shall be used to ensure that the GOOSE message can be seen on the network before the test. It is also required for GOOSESubscriber to get initial values of the dataset in the message before the protection trips to detect data changes further.


Step 6: Simulate the Protection Test

Now simulate the protection scenario by switching between states and checking for IED responses:

  1. Switch to Pre-Fault State:
    sgSin1.switch_to_state(0) # Pre-fault state
  2. Switch to Fault State and monitor for protection trip signal in the GOOSE message:
    sgSin1.switch_to_state(1) # Fault state
    gs1.wait_for_goose_change(timeout=30000) # Wait for Trip signal
  3. Switch to Post-Fault State:
    sgSin1.switch_to_state(2) # Post-fault state

    Step 7: Add Timer to Measure Time Delays

Use Stopwatch class to measure timedelays. Stopwatch start measuring time since initialized.

t = Stopwatch()

To stop the timer use stop() method:

t.stop()

Use get_deltas() method to obtain the interval between the start and stop:

dt = t.get_deltas()[0]

Step 8: Finalizing the Script

After the test is completed, clean up resources and ensure results are logged properly:

del sp1
del gs1
TestEngine.set_result(Result.SUCCESS)

It is also higly recommended to wrap the whole script into try ... except ... construction to finalize the script correctly even under the exception conditions. Use this wrapper as a template:

try:
#HERE GOES THE SCRIPT BODY>>
#....
#....
TestEngine.set_result(Result.SUCCESS, "The test has been completed successfully")
except Exception as err:
err_str = f"{err}" #convert error trace to string to display it in the message
TestEngine.log(f"Test failed: {err}")
TestEngine.set_result(Result.FAIL, err_str)

Finally your script should look like this:

try:
scl = SCL() # Prompts the user to select an SCL file
sp1 = SVPublisher(scl=scl) # Prompt the user to select the IED and SV stream
sgSin1 = SGSineWave(sp1.ss.ied_name, sp1.ss.ap_name, 3) # Initialize generator with 3 states and links it to the ServerSimulator initialized previously.
sgSin1.set_signal_list(sp1.get_fcda_ref_list()) # Link generator to SV data attributes
state1 = SG3PhaseState(cRms=1000, vRms=10000) # Pre-fault
state2 = SG3PhaseState(cRms=20000, vRms=7000) # Fault
state3 = SG3PhaseState(cRms=100, vRms=10000) # Post-fault
sgSin1.set_state(0, state1)
sgSin1.set_state(1, state2)
sgSin1.set_state(2, state3)
gs1 = GOOSESubscriber(scl=scl, da_ref="") # Prompt for IED and GOOSE message
gs1.wait_for_goose(timeout=10000) # Wait for the first GOOSE message
sgSin1.switch_to_state(0) # Pre-fault state
t = Stopwatch()
sgSin1.switch_to_state(1) # Fault state
gs1.wait_for_goose_change(timeout=30000) # Wait for Trip signal
t.stop()
sgSin1.switch_to_state(2) # Post-fault state
# Clean up
del sp1
del gs1
TestEngine.set_result(Result.SUCCESS)
except Exception as err:
err_str = f"{err}"
TestEngine.log(f"Test failed: {err}")
TestEngine.set_result(Result.FAIL, err_str)

Step 9: Test Setup Considerations

  • The IED must accept simulated SV messages (typically by setting LPHD.Sim=True).
  • If the IED cannot accept simulated SV, detach the real Merging Unit (MU) from the network, and adjust the simulation flag in the script to False.
  • The SCD file must describe both the MU (with SV configuration) and IED (with GOOSE protection signals).

Final Notes:

Creating a protection testing script involves configuring and simulating real-time data flow between MUs and IEDs. By using SVPublisher and GOOSESubscriber, you can create dynamic scenarios for testing protection trip conditions in IEDs. This process allows you to effectively simulate fault conditions and monitor the IED's response to overcurrent conditions.