-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathloadPert.m
76 lines (63 loc) · 1.9 KB
/
loadPert.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
function [Pload,Qload, NoiseVector]=loadPert(TimeMod, t,Pload0,Qload0,PertSet, PPertValues, QPertValues,TPert,TFinal,NoiseVector)
%LOADPERT produces a new load starting at Tpert
% [pload,qload]=loadPert(timeMod, t,pload0,qload0,nodepert_set, pertvalue_set, Tpert)
% produces a new real and reactive power load at Tpert
%
% Description of Outputs:
% 1. pload: the new real power load of size(N,1);
% 2. qload: the new reactive power load of size(N,1);
%
% Description of Inputs:
% 1. timeMod: a switch option for 'Steady-State' or 'Transient'.
% 2. t: the time instant (a scalar). If timeMod is set to 'Steady-State' is not used.
% 3. pload0: the initial real power load of size(N,1);
% 4. qload0: the intial reactive power load of size(N,1);
% 5. nodepert_set: set of nodes in which we would like the load to be
% perturbed.
% 6. pertvalue_set: set of pertubration values corresponding to
% nodepert_set
% 7. Tpert: time of load perturbation.
%
% Required:
% 1. Extend to Tpert vector
global NoiseVarianceSet FSample
switch TimeMod
case 'Steady-State'
N=length(Pload0);
pstep=zeros(N,1);
pstep(PertSet)=PPertValues;
qstep=zeros(N,1);
qstep(PertSet)=QPertValues;
Pload= Pload0 +pstep;
Qload=Qload0+qstep;
case 'Transient'
% N=length(pload0);
% step=zeros(N,1);
% step(pertSet)=pPertValues;
% Tramp=Tfinal/2;
%
noise=zeros(size(NoiseVector(:,1)));
if t>0
n1=floor(t*FSample);
n2=ceil(t*FSample);
alpha=n2-t*FSample;
noise=alpha*NoiseVector(:,n1+1)+(1-alpha)*NoiseVector(:,n2+1);
end
%
% if t<=Tramp
% pload=pload0+step.*((t-Tpert)./(Tramp-Tpert)).*(t>Tpert)'+noise.*(t>Tpert)';
% else
% pload=pload0+step.*(t>Tpert).'+noise.*(t>Tpert)';
% % qload=qload0+step.*(t>Tpert).'+noise.*(t>Tpert)';
% end
%
% qload=qload0;
N=length(Pload0);
pstep=zeros(N,1);
pstep(PertSet)=PPertValues;
qstep=zeros(N,1);
qstep(PertSet)=QPertValues;
Pload= Pload0 +pstep+noise;
Qload=Qload0+qstep;
end
end