First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!
![]() | 1 | initial version |
Hi,
You can try this simplest implementation.
def PT1(x,Ts,Tf,y0):
# The algorithm is based on the Euler backward difference scheme for the simplest 1st order filter :
#
# y(k)-y(k-1)=Ts*(x(k)-y(k))/Tf
#
# x - actual value of the input signal that is to be passed to 1st order (PT1) filter transfer
# function y=(1/(1+sTf)*x
# Ts (s) - time step (discretization time for the filter)
# Tf (s) - filter time constant
# y0 - output signal value from the previous step, must be assigned in the calling
# program (y0=y(k-1))
#
dy=Ts/(Tf+Ts)*x # output signal increment
y=Tf/(Tf+Ts)*y0+dy # updated output signal
return y # returns filtered input signal
This function should be called from a time loop implemented in a Python script. If you for eyample want to filter frequency deviation dfreq with filter time constant 10 seconds and filter discretization time of 20 ms, this call might look something like this (of course the basic time step in PSS/E dynamic simulation must be less or equal to filter discretization time and the initial frequency deviation is assumed to be zero):
dfreqf0=0.
for tstep in range(1,Nstep):
....
dfreqf=PT1(dfreq,0.02,10.,dfreqf0)
dfreqf0=dfreqf #
....
![]() | 2 | No.2 Revision |
Hi,
You can try this simplest implementation.
def PT1(x,Ts,Tf,y0):
# The algorithm is based on the Euler backward difference scheme for the simplest 1st order filter :
#
# y(k)-y(k-1)=Ts*(x(k)-y(k))/Tf
#
# x - actual value of the input signal that is to be passed to 1st order (PT1) filter transfer
# function y=(1/(1+sTf)*x
# Ts (s) - time step (discretization time for the filter)
# Tf (s) - filter time constant
# y0 - output signal value from the previous step, must be assigned in the calling
# program (y0=y(k-1))
#
dy=Ts/(Tf+Ts)*x # output signal increment
y=Tf/(Tf+Ts)*y0+dy # updated output signal
return y # returns filtered input signal
This function should be called from a time loop implemented in a Python script. If you for eyample example want to filter frequency deviation dfreq with filter time constant 10 seconds and filter discretization time of 20 ms, this call might look something like this (of course the basic time step in PSS/E dynamic simulation must be less or equal to filter discretization time and the initial frequency deviation is assumed to be zero):this:
dfreqf0=0.
for tstep in range(1,Nstep):
....
dfreqf=PT1(dfreq,0.02,10.,dfreqf0)
dfreqf0=dfreqf #
....
Of course the basic time step in PSS/E dynamic simulation must be less or equal to filter discretization time and the initial frequency deviation is assumed to be zero.
![]() | 3 | No.3 Revision |
Hi,
You can try this simplest implementation.
def PT1(x,Ts,Tf,y0):
# The algorithm is based on the Euler backward difference scheme for the simplest 1st order filter :
#
# y(k)-y(k-1)=Ts*(x(k)-y(k))/Tf
#
# x - actual value of the input signal that is to be passed to 1st order (PT1) filter transfer
# function y=(1/(1+sTf)*x
# Ts (s) - time step (discretization time for the filter)
# Tf (s) - filter time constant
# y0 - output signal value from the previous step, must be assigned in the calling
# program (y0=y(k-1))
#
dy=Ts/(Tf+Ts)*x # output signal increment
y=Tf/(Tf+Ts)*y0+dy # updated output signal
return y # returns filtered input signal
This function should be called from a time loop implemented in a Python script. If you for example want to filter the frequency deviation signal dfreq using a PT1 filter with filter time constant 10 seconds and filter discretization time of 20 ms, this ms and you are going to store the filtered value as dfreqf, that call might look something like this:
dfreqf0=0.
for tstep in range(1,Nstep):
....
dfreqf=PT1(dfreq,0.02,10.,dfreqf0)
dfreqf0=dfreqf #
....
Of course the basic time step in PSS/E dynamic simulation must be less or equal to filter discretization time and the initial frequency deviation is assumed to be zero.