Home page
Русский English
 

RastrWin

Macro Studio
Automation
Work with SQL
Estimation of parameters of transmission lines, TR
The effectiveness of the breaking the network
The voltage analysis in Microsoft Excel

Authorization

Remember me on this computer
  Forgot your password?
  Register



Site search


Subscription


Hits 67418592
9942
Hosts 3609009
2046
Visitors 53571132
9602

86


Home

Automation

Print version Print version

All of the macros can be used to solve specific problems by copying in the macro dialog box. Macros consist of the macro body (from line "Sub" to line "End Sub") and its call (the macro name and parameters separated by commas). The parameters should be replaced to the right in a specific problem to use the macro.

1.  Group correction.

In carrying out the correction in large volumes, or the same type of correction in different files, it is convenient to make the following macro:

r=setlocale("en-us")
Sub GrCor(tabl,param,viborka,formula)
    Set ptabl=Rastr.Tables(tabl)
    Set pparam=ptabl.Cols(param)
    ptabl.SetSel(viborka)
    pparam.Calc(formula)
End Sub
'
'Call the correction procedure for different situations:
'GrCor table-name, parameter-name, the sample, the formula

GrCor "node","pn","na=1","pn*1.15"  ' increase the load of the area 1 to 15%
GrCor "node","qn","na=1","pn*1.15"
GrCor "node","pq","na=2","pn*0.95"
GrCor "node","qg","na=2","pn*0.95"
GrCor "node","nsx","na=3","3"

If it is only needed to adjust the area load on a given ratio (active and reactive in proportion), then we can make the following macro:

r=setlocale("en-us")
Sub CorPQN(raion,koeff)
    Set ptabl=Rastr.Tables("node")
    Set ppn=ptabl.Cols("pn")
    Set pqn=ptabl.Cols("qn")
    ptabl.SetSel("na="&raion)
    ppn.Calc("pn*"&koeff)
    pqn.Calc("qn*"&koeff)
End Sub
' 
'And call it like this:
CorPQN 1,1.15  ' multiply P and Q of the area 1 by 1.15
CorPQN 3,0.9    ' multiply P and Q of the area 3 by 0.9

The macro can be easily adapted to change the generation and load:

r=setlocale("en-us")
Sub CorPQ(ng,raion,koeff)
    Set ptabl=Rastr.Tables("node")
    Set ppn=ptabl.Cols("p"&ng)
    Set pqn=ptabl.Cols("q" &ng)
    ptabl.SetSel("na="&raion)
    ppn.Calc("pn*"&koeff)
    pqn.Calc("qn*"&koeff)
End Sub
' 
' And call it like this:
CorPQ "n",1,1.15      ' multiply the load("n") P and Q of the area 1 by 1.15
CorPQ "g",2,0.95      ' multiply the generation ("g") P and Q of the area 2 by 0.9

2. Specifying the desired consumption of the area.

To change the load area so as to withstand a given demand (consumption - is the load plus losses). Reactive load varies in proportion to the active:

r=setlocale("en-us")
Sub CorPotr(raion,potr)
    max_it=10   ' the maximum number of iteration
    eps=0.001   ' accuracy of calculation
        reac_p=True ' The reactive consumption to change in proportion
    Set pnode=Rastr.Tables("node")
    pnode.SetSel("na="&raion)
    Set pn=pnode.Cols("pn")
    Set qn=pnode.Cols("qn")
    Rastr.printp "Area=" & raion
    Rastr.printp "Consumption given=" & potr
    for i=1 to max_it 
        pop=Rastr.Calc("val","area","pop","na="&raion)
        koef=potr/pop
        Rastr.printp "Current consumption =" & pop
        Rastr.printp "The given/current ratio =" & koef
        if( abs(koef -1) > eps) then
            pn.Calc("pn*"&koef)
            if(reac_p)    then qn.Calc("qn*"&koef)
            kod=Rastr.rgm("")
            if(kod <> 0) then
                Rastr.printp "---------Steady state calculation emergency stop ----------- "
                exit sub
            end if
        else exit sub
        end if
    next
end Sub
'The macro can be invoked as follows:
'
CorPotr 1,2000  'The consumption of the area 1 make equal to 2000
CorPotr 7,17000 'The consumption of the area 7 make equal to 17000

An iterative procedure is using since losing in the district vary nonlinearly. The maximum number of iterations (10) and the calculation accuracy (0.001 - the ratio given to the calculated consumption) is specified. The nodes powers in the area vary in proportion of the given and calculated consumption. The steady state is calculated. The results of the macro for test network:

Area=1
Consumption given=2000
Current consumption=2219.1337961166
The given/current ratio=0.901252553361102

  It  Max.imbalance   Node    >V      Node    <V       Node   Delta      Line                          
   0           26.5   1440    1.07    1605    0.87     1203   24.5    812-811         48.7 
   1           14.6   1418    1.07    1605    0.87     1203   24.5    812-811         42.1 
   2            3.7    802    1.07    1605    0.88     1203   24.3    812-811          2.4 
   3           72.6      4    1.07    1605    0.88     1203   24.3    812-811          0.0 
   4            0.9      4    1.07    1605    0.89     1203   24.3    812-811          0.2 
Current consumption = 2004.12509379647
The given/current ratio = 0.997941698445252

   It  Max.imbalance  Node    >V      Node    <V       Node   Delta      Line                          
   0             0.9     4   1.07    1605     0.89     1203   24.3    812-811          0.9 
Current consumption = 2000.15714284794
The given/current ratio = 0.999921434749013

The dialog version of this macro is in the Run menu. It is differ by calling the macro:

n=Rastr.SendCommandMain(8,"Enter the area number","",0)
pop=Rastr.SendCommandMain(8,"Enter the new consumption","",0)
CorPotr n+0,pop+0

3. Unloading of a given section to the required value.

Only the generating units (tip> 1) are used during the unloading. The limits (P_min and P_max) are not controlled in order to simplify. Unloading is carried out according to the criterion - the minimum change in power generation. The initial generation is stored in an array pg_nom.

r=setlocale("en-us")
Sub KorSech(ns,newp)
    viborka="tip>1 &!sta & abs(dr_p) >0.01"   ' The sample for the nodes involving in regulating
        eps=1
    Set grline=Rastr.Tables("grline")
    Set node=Rastr.Tables("node")
    Set pg=node.Cols("pg")
    Set pg_nom=node.Cols("pg_nom")
    Set ip=grline.Cols("ip")
    Set iq=grline.Cols("iq")
    pg_nom.Calc("pg")
    For inini=1 to 10
        ps=Rastr.Calc("sum","sechen","psech","ns="&ns)   
        Rastr.printp " Power of the section  = " & ps
        if (  abs(ps-newp)  < eps )  then exit sub
        Rastr.sensiv_start ""
        grline.SetSel("ns="&ns)
        k=grline.FindNextSel(-1)
        While k <>-1
            i=ip.Z(k)
            j=iq.Z(k)
            Rastr.sensiv_back 4,1.,i,j,0
            k=grline.FindNextSel(k)
        Wend 
        Rastr.sensiv_write ""
        Rastr.sensiv_end
        Set dr_p=node.Cols("dr_p")
        db=Rastr.Calc("sum","node","dr_p",viborka)
        if ( abs(db) < 0.000001 ) then
            Rastr.printp "Impossible to change power in the section"
            exit sub
        end if
        rd=(ps-newp)/db
        node.SetSel(viborka)
        pg.Calc("pg + dr_p*"&rd)
        kod=Rastr.rgm("")
        if(kod <> 0) then
            Rastr.printp "---------Steady state calculation emergency stop----------- "
            exit sub
        end if
    next
End Sub
'
'
' The macro can be invoked as follows:

KorSech 1,1500  'Changing the power of the section 1 to 1500
'

Similarly, macro calls through the dialogue:

' The macro call from the dialogue 
n=Rastr.SendCommandMain(8,"Enter the section number","",0)
pop=Rastr.SendCommandMain(8,"Enter the new power of the section","",0)
KorSech n+0,pop+0

The calculation of influence coefficients is used at the macro. The nodes capacities changing take place in accordance with them. If necessary the sample

viborka="tip>1 &!sta & abs(dr_p) >0.01"   ' The sample for the nodes involving in regulating

can be changed as desired, for example:

viborka="sel &!sta & abs(dr_p) >0.01"   ' The sample for the nodes involving in regulating

In this case, the only marked nodes take part in regulation of the section power. In case if the more detailed analysis is necessary, a form (based on the nodes or generation nodes) could be created, which will display the initial generation (pg_nom) and the influence coefficients (dr_p, dr_q, dr_v).

Scripts provided by V.G. Neuymin.




Powered by Bitrix Site Manager
Software complex «RastrWin»
© «RastrWin», 1988-2019