interface between the liov and emtp-rv borghetti...- description of the code used to build the...
TRANSCRIPT
www.lisep.ing.unibo.it
Outline
Interface between the LIOV (Ligthning Induced Overvoltage) code and the EMTP-RV
- Brief review on the functions of the LIOV code
- Explanation of the interface method
- Description of the code used to build the EMTP-rv dynamic-link library
- Couple of examples (one conductor and three conductors)
Scripts for the calculation of voltage profile and short circuit currents in distribution
networks with embedded generation using EMTP-RV
- Scripts for the exchange of data and results between EMTP-rv and Excel.
- Scripts for the repetition of load flow and steady state calculations.
Brief review of the LIOV codeThe LIOV (Lightning-Induced OverVoltage) code is a computer program developed in the
framework of an international collaboration involving the Universities of Bologna
(Department of Electrical Engineering), the Swiss Federal Institute of Technology (Power
Systems Laboratory), and the University of Rome "La Sapienza" (Department of Electrical
Engineering).
The LIOV code allows for the calculation of lightning-induced voltages along an overhead
line as a function of lightning current waveshape (amplitude, front steepness, duration),
return-stroke velocity, line geometry (height, length, number and position of conductors
8), stroke location with respect to the line, ground resisitivity and relative perimittivity,
and value of termination impedances.
The LIOV code is composed by two parts
1) the calculation of the electromagnetic field radiated by the lightning channel that
interacts with the conductors of the overhead line;
2) FTFD solution of the field-to-overhead line coupling equations.
C.A. Nucci, F. Rachidi, “Lightning protection of medium voltage lines”, Chapter 13 of
"Lightning Protection", IEE Power and Energy series 58, IEE Press, London, 2010.
Coupling model
Field-to-transmission line coupling model for a lossless
single conductor overhead line
),,(),(
'),(
thxEt
txiL
x
txv ex
s
=∂
∂+∂
∂
0),(
'),( =
∂∂+
∂∂
t
txvC
x
txi s
∫−=+=ih
ez
si
ei
sii dztzxEtxvtxvtxvtxv
0
),,(),(),(),(),(
1. A.K. Agrawal, H.J. Price, S.H. Gurbaxani, "Transient response of a multiconductor
transmission line excited by a nonuniform electromagnetic field", IEEE Trans. on
Electromagnetic Compatibility, Vol. EMC-22, No. 2, pp. 119-129, May 1980.
FDTD solution of the coupling model
∆−+−
∆−∆−
∆−∆−= −+−+−++
21111
2111 2
2''22' x
vvv
x
EhEh
CL
t
x
ii
C
tvv
nk
nk
nk
nk
nk
nk
nkn
knk
∆−+
∆−+∆+
−
∆−∆−=
−+−+−++
t
EhEhC
x
iii
CL
tEh
x
vv
L
tii
nk
nk
nk
nk
nkn
k
nk
nkn
knk 2
'2
''22'
11
211
2111
n n i v 0 0 , n k
n k i v max max ,
n k
n k i v ,
R 0
∫ h
e z dz t E
0 ) , 0 , 0 ( ∫
h e z dz t L E
0 ) , 0 , (
R L
) t , h , x ( E e x
n+1
n
n - 1
k k+1 k - 1 spatial discretization
time discretization
n-port (EMTP-RV)
LIOV-lines
LIOV-EMTP interface structure
( ) ∫+Γ−=h
ez
n dztEiv0
000 ),0,0(
( ) ∫+Γ=h
ezkk
nk dztLEiv
0
max ),0,(maxmax
Scattered
voltages
Boundary conditionsThe spatial numerical discretization at the two line terminations
(x=0 and x=L) is replaced by means of two Bergeron lines suitably
extended to take into account the presence of the exciting LEMP.
∫∆
−∆−∆−∆−∆=−tu
ex
ss dxthxEtttuZitttuvtZitv0
),,(),(),(),0(),0(
∫∆−
+∆−∆−+∆−∆−=+L
tuL
ex
ss dxthxEtttuLZitttuLvtLZitLv ),,(),(),(),(),(
ut
x =∆∆where
( )nnnnnn EhEhx
ZivZiv 11
0111
01
0 2+∆−−=− +++
( )nk
nk
nk
nk
nk
nk EhEh
xZivZiv 1
111
11
maxmaxmaxmaxmaxmax 2 −+
−−++ +∆++=+
Boundary conditions
( )00 iΓ
( )nn EhEhx
11
02+∆ +
( )hEzn ⋅+10
( )nk
nk EhEh
x1
1
maxmax2 −+ +∆
( )hEznk ⋅+1
max
11
11 , ++ nn iv 1
21
2 , ++ nn iv1
21
2 maxmax, +
−+
−nk
nk iv 1
11
1 maxmax, +
−+
−nk
nk iv
……1
01
0 , ++ nn iv11
maxmax, ++ n
knk iv
( )maxmax kk iΓ
Z Z Z Z
EMTP-RV EMTP-RVLIOV line
0GmaxkG0'G max
'kG
( )nnnnnn EhEhx
ZivZiv 11
0111
01
0 2+∆−−=− +++
( )nk
nk
nk
nk
nk
nk EhEh
xZivZiv 1
111
11
maxmaxmaxmaxmaxmax 2 −+
−−++ +∆++=+
Integration with the augmented nodal analysis
technique implemented in EMTP-RV
The main system of equations in EMTP-RV is given by:
=
v
n
V
n
dr
cn
v
i
i
v
VV
VY
� Yn is the nodal admittance matrix;
� submatrices Vc, Vr and Vd are used to include non-nodal type
equations, such as branch relations (called voltage-defined
equations), but can also use current coefficients;
� vn, iV unknown quantities (nodal voltages and branch currents);
� in current injections and vv voltage-defined equations.
DLL
interface
DLL
interface
Description of the code used to build the EMTP-rv
dynamic-link library
Single_line.ecf
File options.txt
2 fields (1=read, 2=calculate, 3=calculate and write)0 save voltage maximums (0=no, 1=save the extremities max, 2=save the max along the line)1 transient ground resistance (0=no 1=yes)topo.txt topology filename (leave at least a blank character after the filename)1 current (1=Heidler, 2=trapezium)10.7D3,0.25D-6,2.5D-6,2.D0 I01,TAU11,TAU12,NW1 first Heidler6.5D3,2.1D-6,230.D-6,2.D0 I02,TAU21,TAU22,NW2 second Heidler11.2D3,2.D-6 Ip,Tr trapezium4 RS model (1=TL, 2=MTLL, 3=MTLE, 4=TL using analytical formulation)2.D3,1.D-5 LAMBDA (MTLE), linear decay (MTLL)1.3D8 V return stroke speed15 NSIMP (for MTLL and MTLE or numerical TL)8.D3 channel height500,50 X,Y stroke location coordinates1 option minimum delay jump (1=yes)1 option ground (1=lossy, 2=lossless)1.E-2,10. SIGMA,EPSR ground conductivity and permettivity5.D-8,1.D-6 sampling times of Heidler's fuctions in first and second time window1.2 first time window duration / time to peak
File topo.txt
1,1 Number of lines, type of topology file (1 = this one!)
LINEA_1
0,0 X,Y coordinates of the first point of the line (m)
0 angle between the line and the x-axis (degree)
200 length of the line (m)
C:\Programmi\EMTPWorks\Documentation\Help Files\devices\dll\EMTP_dll.pdf
2n power signals
2n voltage sources
0 current sources
0 nonlinear nodes
0 control input signals
0 control output signals
1 means that the file “liov.dll” is in the same folder of the .ecf file
ParamsA
n = number of conductors
MODULE FDTD_DATAUSE sizelimitsUSE default_precisionUSE simulation_dataUSE variableTYPE, PUBLIC :: data_holder
CHARACTER(LEN=max_len_comp_id) :: myname !unique n ame for this device CHARACTER(LEN=40) :: path1INTEGER :: idev !unique d evice number REAL(krealhp), ALLOCATABLE :: Vh(:,:)REAL(krealhp), ALLOCATABLE :: Ih(:,:)REAL(krealhp), ALLOCATABLE :: V(:,:)REAL(krealhp), ALLOCATABLE :: I(:,:)REAL(krealhp), ALLOCATABLE :: DI(:,:,:)REAL(krealhp), ALLOCATABLE :: L(:,:) !line inductanc e matrix pulREAL(krealhp), ALLOCATABLE :: LINV(:,:) !line capaci tance matrix pulREAL(krealhp), ALLOCATABLE :: Z(:,:) !line charact i mpedance matrix[…]
END TYPETYPE(data_holder), POINTER, PUBLIC :: LINE=>NULL()TYPE(data_holder), POINTER, PUBLIC :: LINE_first=>N ULL()LOGICAL, PUBLIC :: EXISTENCE=.FALSE. !indi cates if this device existsLOGICAL, PUBLIC :: EXISTENCE2=.FALSE.[…]
END MODULE
Liov.f90
MODULE FDTD_DATAUSE sizelimitsUSE default_precisionUSE simulation_dataUSE variable
C:\Programmi\EMTPWorks\EMTP\DLL_build\EMTP_Release
SUBROUTINE DLL_INITIALIZE_NEW(myname,idev,Data_Section,DLL_NAME)USE FDTD_DATA!DEC$ ATTRIBUTES DLLEXPORT:: DLL_INITIALIZE_NEWCHARACTER(LEN=*), INTENT(IN) :: myname ! device name in EMTPWorksINTEGER, INTENT(IN) :: idev ! device number in the list of devices of this DLLCHARACTER(LEN=*), INTENT(IN) :: Data_Section(*) !Complete data section of this instanceCHARACTER(LEN=*), INTENT(IN) :: DLL_NAME !the name of this DLL as referenced in EMTPWorksCHARACTER (LEN=100):: drive,dir,name,extIF( EXISTENCE ) THEN !at least one device already exists
ALLOCATE(LINE%next);LINE=>LINE%nextLINE%next=>LINE_first;
ELSEALLOCATE(LINE)LINE_first=>LINE;
ENDIFTotal_number_of_devices=Total_number_of_devices+1;LINE%myname= myname;LINE%idev =idev;
READ(Data_Section(1),*,ERR=999,END=999) LINE%NC[…]END SUBROUTINE DLL_initialize_new
SUBROUTINE DLL_POST_INITIALIZE_NEW(myname,idev,power_signal_no des,n_nodes)
USE FDTD_DATA!DEC$ ATTRIBUTES DLLEXPORT:: DLL_POST_INITIALIZE_NE WCHARACTER(LEN=*), INTENT(IN) :: mynameINTEGER, INTENT(IN) :: idevINTEGER, INTENT(IN) :: power_signal_nodes(*)INTEGER, INTENT(IN) :: n_nodesINTEGER istatLINE=>LINE_first;CALL find_mydev(idev)ALLOCATE(LINE%power_signal_nodes(n_nodes), STAT=ist at);IF(istat.NE.0) CALL device_error_(LINE%myname,'Inte rnal bug.',.TRUE.)LINE%power_signal_nodes=power_signal_nodes(1:n_node s);
END SUBROUTINE DLL_POST_INITIALIZE_NEW
SUBROUTINE DLL_PUT_VOLTAGE_ROW_EQUATIONS(idev,first _voltage_row)USE DFLIBUSE FDTD_DATA!DEC$ ATTRIBUTES DLLEXPORT:: DLL_PUT_VOLTAGE_ROW_EQUATIONSEXTERNAL BIND,BRADREAL(krealhp) :: I_HEID,Imax,IAINTEGER, INTENT(IN) :: idevINTEGER, INTENT(IN) :: first_voltage_rowINTEGER NUM,I,J,K,N,N0,NMAXH,NMAXH1CALL find_mydev(idev)jj=first_voltage_row; !we can increment jj for othe r voltage rowsLINE%first_voltage_row=first_voltage_row;DO k=1,2*LINE%NC
CALL put_(LINE%power_signal_nodes(k),jj+k-1)CALL put_(jj+k-1,LINE%power_signal_nodes(k))
END DOALLOCATE (LINE%L(1:LINE%NC,1:LINE%NC))ALLOCATE (LINE%LINV(1:LINE%NC,1:LINE%NC))ALLOCATE (LINE%Z(1:LINE%NC,1:LINE%NC))ALLOCATE (LINE%DTA2LDXZINV(1:LINE%NC,1:LINE%NC))ALLOCATE (LINE%OTARG(1:LINE%NC,1:2))[…] END SUBROUTINE DLL_PUT_VOLTAGE_ROW_EQUATIONS
Add rows and columns to the EMTP matrix
SUBROUTINE DLL_PUT_IN_YAUG(idev)USE FDTD_DATA
!DEC$ ATTRIBUTES DLLEXPORT:: DLL_PUT_IN_YAUGINTEGER, INTENT(IN) :: idevCALL find_mydev(idev)jj=LINE%first_voltage_row
DO k=1,2*LINE%NCCALL fillreplace_(LINE%power_signal_nodes(k),jj+k-1 ,one)CALL fillreplace_(jj+k-1,LINE%power_signal_nodes(k) ,one)
END DOEND SUBROUTINE DLL_PUT_IN_YAUG
Vs2Vs19Vs1Vs3Is3Is1
Is2Is1900VLVR
=
SUBROUTINE DLL_PUT_IN_IAUG(idev)USE FDTD_DATA!DEC$ ATTRIBUTES DLLEXPORT:: DLL_PUT_IN_IAUGEXTERNAL EXIND,EXRAD,EXSTATEXTERNAL EZIND,EZRAD,EZSTATINTEGER, INTENT(IN) :: idevINTEGER :: jj,kj,K,Jtempo=Simtime%TCALL find_mydev(idev)jj=LINE%first_voltage_rowLINE%ct=LINE%ct+1LINE%Vh=LINE%VLINE%DI(:,0,LINE%ct-1)=LINE%Ih(:,0)LINE%DI(:,LINE%KMAX,LINE%ct-1)=LINE%Ih(:,LINE%KMAX)LINE%Ih=LINE%ILINE%EH3=LINE%EH2LINE%EH2=LINE%EH1LINE%EVh=LINE%EVIF (opzionecampi.EQ.1) THEN[…]DO kj=1,LINE%NC
SimData%vector_b(jj)=LINE%OTARG(kj,1)jj=jj+1SimData%vector_b(jj)=LINE%OTARG(kj,2)jj=jj+1
END DOEND SUBROUTINE DLL_PUT_IN_IAUG
!*Integration using Trapezoidal methodSUBROUTINE DLL_UPDATE_AT_T(idev)USE FDTD_DATAuse numerical_libraries!DEC$ ATTRIBUTES DLLEXPORT:: DLL_UPDATE_AT_TINTEGER, INTENT(IN) :: idevtime=Simtime%TCALL find_mydev(idev)jj=LINE%first_voltage_rowDO kj=1,LINE%NC
LINE%I(kj,0)=SimData%vector_x(jj)jj=jj+1LINE%I(kj,LINE%KMAX)=-SimData%vector_x(jj)jj=jj+1
END DO[…]DO k=1,LINE%KMAX-1
LINE%V(:,k)=1.5E8*MATMUL(LINE%L,(LINE%Ih(:,k-1)-LIN E%Ih(:,k+1)))&+(LINE%Vh(:,k+1)+LINE%Vh(:,k-1))/2&+LINE%deltax*(LINE%EH2(:,k-1)-LINE%EH2(:,k+1))/4
[…]END DO[…]END SUBROUTINE DLL_UPDATE_AT_T
Values of the currents from EMTP
Vector_x
SUBROUTINE DLL_END(idev)USE FDTD_DATA!DEC$ ATTRIBUTES DLLEXPORT :: DLL_ENDINTEGER, INTENT(IN) :: idevCALL find_mydev(idev)
[…]open(1,file=TRIM(cur_path)//'massimo.dat',ACCESS='A PPEND')
WRITE(1,'(D13.7,1X,D13.7,1X,F4.0,1X,F3.0,1X,F3.0)') MAXIMUMclose (1)
[…]
END SUBROUTINE DLL_END
1 – “Load Data & Report”
2 – “Check Line and bus”
3 – “short circuit”
3 sections:
Scripts for DG impact analysis
Node search
parseScriptFile('make_file_name.dwj'); //always nee ded
cct=currentCircuit()nodeNames = cct.signals();writeln(nodeNames) ;var output_file = make_Newfile_name ('_nodi_rete.xls');fid = SPFile(output_file);if(fid.openCreate()){
for(k=0; k<nodeNames.length; k++) { fid.appendLine (nodeNames[k]);}
fid.close() ; }alert('Operazione terminata');
//parseScriptFile('make_file_name.dwj'); //always needed[…]PI_lines=cct.devices('Part','PI'); writeln(PI_lines);[…]for(il=0;il<PI_lines.length;il++){myLine=PI_lines[il];pin_linea=myLine.pins; segnale_sx[il]=myLine.pins[0].signal; segnale_dx[il]=myLine.pins[1].signal; line_type=myLine.getAttribute('ModelData1');line_type=line_type.split(","); //read: [0] line type, [1] cond type; [2] line lengthline_arerea_cavo[il]=line_type[0];line_code[il]=line_type[1];line_length[il]=parseFloat(line_type[2]);
excel_filename=prompt("Nome file Excel:","datiRete.xls");
var Excel;Excel = new ActiveXObject("Excel.Application");Excel.Visible = false;cartExcel = Excel.Workbooks.Open(current_dir+excel_filename);for(k=0; k<PI_lines.length; k++) {
cartExcel.Worksheets("Linee").Cells(k+2,1).Value=PI_lines[k];[…]}cartExcel.SavecartExcel.Close(false);Excel.Quit();Excel = null;alert('Operazione terminata');
PI-line search
//parseScriptFile('make_file_name.dwj'); //always nee ded[…]PQ_loads=cct.devices( 'Part','PQload' );writeln(PQ_loads);PQload_pin=new Array(); for(k=0;k<PQ_loads.length;k++){
myLoad=PQ_loads[k];pin_load=myLoad.pins; PQload_pin[k]=myLoad.pins[0].signal;
}
excel_filename=prompt("Nome file Excel:","datiRete. xls");var Excel;Excel = new ActiveXObject("Excel.Application");Excel.Visible = false;cartExcel = Excel.Workbooks.Open(current_dir+excel_ filename);for(k=0; k<PQ_loads.length; k++) {
cartExcel.Worksheets("Carichi").Cells(k+2,1).Value= PQ_loads[k];cartExcel.Worksheets("Carichi").Cells(k+2,2).Value= PQload_pin[k];
}
cartExcel.SavecartExcel.Close(false);Excel.Quit();Excel = null;alert('Operazione terminata');
PQ-load search
parseScriptFile('make_file_name.dwj'); […]PI_lines=cct.devices( 'Part','PI' ); […]excel_filename=prompt("Nome file Excel:","datiRete. xls");
if( excel_filename==null )//cancel{
writeln('...caricamento dati linee è stato sospeso. ')halt();
} var Excel;Excel = new ActiveXObject("Excel.Application");Excel.Visible = false;cartExcel = Excel.Workbooks.Open(current_dir+excel_ filename);noCod=0;for(i=0;i<PI_lines.length;i++)// scansiona tutte le linee{linea_non_codificata=true;myLine=PI_lines[i];line_type=myLine.getAttribute('ModelData1');
line_type=line_type.split(","); line_length=parseFl oat(line_type[2]); var k=0; if(line_type[0]=='aerea')// if ciclo linee aeree{
while( cartExcel.Worksheets("Tipologia aeree").Cells(4*k+2 ,1).Value!=null ){
line_type_data=String(cartExcel.Worksheets("Tipolog ia aeree").Cells(4*k+2,3).Value) ;if(line_type[1]==line_type_data){
linea_non_codificata=false;R11=cartExcel.Worksheets("Tipologia aeree").Cells(4 *k+2,4).Value*line_length;R12=cartExcel.Worksheets("Tipologia aeree").Cells(4 *k+2,5).Value*line_length;
[…]data_line=R11+' '+R12+' '+R13+'\n'+R21+' '+R22+' '+ R23+'\n'+R31+' '+R32+' '+R33+'\n';[…]myLine.setAttribute('ModelData',data_line);myLine.setAttribute('ParamsA','3,1,0,1Ohm,0,1S,0,1, 1,1,1,')myLine.setAttribute('Category',portataAerea);myLine.fillColor=11; //white
[…]
Load line parameters
parseScriptFile('check_my_filename.dwj');parseScriptFile('make_file_name.dwj'); //always nee dedparseScriptFile('program_.dwj'); //always nee dedparseScriptFile('run_emtp.dwj'); //always nee ded prepare_design_folder(); //always nee dedcurrentCircuit.save();
//Generate the Netlist for the first simulation, ju st in case the netlist does not existstr=runExportToString('report scripts/EMTP Netlist. rfm',null,'NETLIST'); var netlist_file = Netlist_file_name(); //the file must exist
cct=currentCircuit(); current_dir=cct.fileDir;name_cct=cct.fileName;
// add connections OPEN and slack lib=DWLibrary('Pseudo Devices.clf');newType=lib.loadType('Node connector 3-phase');cct.addDevice(newType,-16000,-5000); //add a connec tioncct.addDevice(newType,-15000,-5000); //add a connec tionconnessioni=cct.devices('Part','Pjump3'); // find d evices Pjump3connessioni[0].setAttribute('Name','OPEN',1);connessioni[1].setAttribute('Name','slack',1);segnale_sx=new Array(); // signal sx of Pjump3segnale_dx=new Array(); // signal dx of Pjump3for(il=0;il<connessioni.length;il++){
myConn=connessioni[il];myConn.makeUnique(true); //nomeConn='Connessione '+il;//myConn.setAttribute('Name',nomeConn);
pin_connessione=myConn.pins; segnale_sx[il]=myConn.pins[0].signal; segnale_dx[il]=myConn.pins[1].signal;
if(connessioni[il]=='OPEN') {segnale_dx[il].setAttribute('Name','OPEN',1);}else if (connessioni[il]=='slack') {segnale_dx[il].setAttribute('Name','slack',1);}}
Short-curcuit
AllNodes=cct.signals();sizeAllNodes=AllNodes.length;listaNodiCC=new Arrayexcel_filename=prompt("Nome file Excel:","datiRete. xls"); [...]// auxiliary bussesipg=0;//rappresenta i punti di guasto
for(i=0;i<sizeAllNodes;i++){ if(AllNodes[i]=='Guasto')
{ NodoCC=AllNodes[i]; }else if(AllNodes[i]=='OPEN')
{ NodoOpen=AllNodes[i];}else if(AllNodes[i]=='slack')
{NodoSlack=AllNodes[i]; }else
{ var ii=1;while (cartExcel.Worksheets("CC").Cells(ii+1,1).Val ue!=null)
{if (AllNodes[i]==cartExcel.Worksheets("CC").Cells(i i+1,1).Value)
{listaNodiCC[ipg]=AllNodes[i];ipg=ipg+1;}
ii++;}if(ii==1)
[…]}
}
//----------------------start calculation---------- ---------------------[…]for(i=0;i<listaNodiCC.length;i++)
{[…]
listaNodiCC[i].setAttributeVis('Name',true);listaNodiCC[i].color=1;memoNomePuntoCC=listaNodiCC[i].name;listaNodiCC[i].connectByName(NodoOpen);NodoCC.connectByName(listaNodiCC[i]);runExportToString('report scripts/EMTP Netlist.rfm' ,null,'NETLIST');run_emtp(netlist_file,false); // run---> in "Steady-State"
[...]NodoOpen.connectByName(listaNodiCC[i]);NodoSlack.connectByName(NodoOpen);listaNodiCC[i].color=0;
} // fine ciclo nodi di guasto
writeln(simuRecAllPI_Icc)
//----------------->> end
//------------original solution Steady-state
runExportToString('report scripts/EMTP Netlist.rfm' ,null,'NETLIST');run_emtp(netlist_file,false);
[...]
// rimuovo le connessioni aggiunteconnessioni[0].remove();connessioni[1].remove();
//cartExcel.Close(false);//Excel.Quit();Excel = null;