Matpower on Matlab 2017 and Debian/GNU/Linux

2017-10-13 Thread Eliel Júnior
Hello, I tried to install Matpower on my Debian/GNU/Linux runing the 2017
version of Matlab, but it just doesen't work. I have no ideas on how to
proced now, and I wonder if there is an incompatibility. Should I try an
older version of Matlab?

I'm having these messages when I run test_matpower:

>> test_matpower
Insufficient number of outputs from right hand side of equal sign to
satisfy assignment.

Error in have_fcn (line 191)
vstr = v.Version;

Error in test_matpower (line 44)
if have_fcn('fmincon')


Re: Matpower on Matlab 2017 and Debian/GNU/Linux

2017-10-13 Thread Ray Zimmerman
I’m not aware of any incompatibility with Matlab R2017a or R2017b. I suspect it 
is something related to unexpected things in your Matlab path. Answering a 
couple of questions could help us track down the problem …

- What is the output of the following command?
v = ver('optim')

- What version of MATPOWER is this? The released v6.0, or the latest dev 
version from GitHub?

  Ray




> On Oct 13, 2017, at 8:53 AM, Eliel Júnior  
> wrote:
> 
> Hello, I tried to install Matpower on my Debian/GNU/Linux runing the 2017 
> version of Matlab, but it just doesen't work. I have no ideas on how to 
> proced now, and I wonder if there is an incompatibility. Should I try an 
> older version of Matlab?
> 
> I'm having these messages when I run test_matpower:
> 
> >> test_matpower
> Insufficient number of outputs from right hand side of equal sign to satisfy 
> assignment.
> 
> Error in have_fcn (line 191)
> vstr = v.Version;
> 
> Error in test_matpower (line 44)
> if have_fcn('fmincon')



Re: Doubt regarding adding constraints

2017-10-13 Thread Monisha Raju
I think I was doing something wrong. It works perfectly fine now. Thank you
so much, Sir.

Regards
Viswanath

On Oct 12, 2017 10:02 AM, "Ray Zimmerman"  wrote:

> Are you saying that your solution includes voltage angles whose absolute
> value is greater than 0.26 radians or 14.9 degrees?
>
>Ray
>
>
> On Oct 11, 2017, at 8:52 PM, Viswanath Hariharan 
> wrote:
>
> First, thank you so much for your time, Sir.
> So I tried the first approach first. I want to added box constraints for
> Voltage angle, -0.26 < theta < 0.26.  I created the A matrix and l and u
> vectors and passed it to the opf function. The solution converged and I did
> get results. But the problem is that the added constraints look like they
> had no effect on the result.
>
> I also tried the toggle_reserves() method you suggested in the previous
> email of this thread where you asked me rename toggle_reserves and all the
> callback functions within it and modify its contents to toggle the addition
> of constraints. I did that too. results = runopf(mpc) and results.om had
> 5 linear constraints added to it. But again this had no effect on the
> results. I even tried changing the bounds to see if there was any
> difference but there wasn't.
>
> What is it that I'm missing out here?
>
> Regards
> Viswanath
>
>
>
> On Tue, Oct 10, 2017 at 9:09 AM, Ray Zimmerman  wrote:
>
>> It appears you have fundamentally misunderstood callback functions and
>> how they work. I suggest that you read carefully the entirety of sections
>> 7.2–7.5 in the User’s Manual and make sure you understand the
>> toggle_reserves() example used to illustrate the approach.
>>
>> To implement your own constraints, I would recommend copying and renaming
>> toggle_reserves() to something like toggle_myconstraints(). Then rename
>> all of the callback functions defined in that file to e.g.
>> userfcn_myconstraints_ext2int(), userfcn_myconstraints_formulation(),
>> etc., and modify their contents to reflect the constraints you want to add
>> (as opposed to those implemented for the zonal reserves case). The
>> “formulation” callback is where you’ll be calling add_constraints().
>> Then you can simply toggle your constraints on and use runopf() normally.
>>
>> mpc = loadcase('');
>> mpc = toggle_myconstraints(mpc, 'on');
>> results = runopf(mpc);
>>
>> Hope this helps,
>>
>> Ray
>>
>>
>>
>> On Oct 5, 2017, at 12:18 PM, Viswanath Hariharan 
>> wrote:
>>
>> Sir
>>
>> I tried adding constraints using the callback functions method described
>> in Section 7.2 but I am not sure I followed it correctly.
>> mpopt = mpoption;
>> om = opf_setup(mpc, mpopt);
>> om = add_constraints(om, 'Vm', A1, l1, u1);
>> om = add_constraints(om, 'Va', A2, l2, u2);
>> mpc = get_mpc(om)
>> results2 = runopf(mpc);
>>
>> om gets updated with 10 linear constraints (case5 is being used here).
>> But mpc doesn't get updated and hence when I run this code and check and
>> results.var.mu.l.Va , the constraints
>> aren't updated. Not only that, the mpc file isn't getting updated as well.
>> I think I am making some mistake with this line : mpc = get_mpc(om) because
>> om is fine. What am I missing here? Or should I take another approach?
>> Thank you so much for your time Sir.
>>
>> Regards
>> Viswanath Hariharan
>>
>> On Thu, Oct 5, 2017 at 10:27 AM, Ray Zimmerman  wrote:
>>
>>> You only need to use the add_constraints() function if you are using
>>> Callback Functions as described in Section 7.2 as opposed to Direct
>>> Specification as described in Section 7.1 of the User’s Manual
>>> .
>>>
>>> You convergence failure my just imply that your variable bounds are
>>> tight enough that there is no feasible solution. Try relaxing the limits
>>> and see if it converges.
>>>
>>> Vm, Pg and Qg all have limits specified directly in the bus and gen
>>> matrices. Vm is bounded by the VMIN and VMAX columns in the bus matrix.
>>> Pg and Qg are bounded by the PMIN, PMAX and QMIN, QMAX columns of the
>>> gen matrix, respectively. Va is not normally constrained (except at the
>>> reference bus), so the bus matrix doesn’t contain bounds for it. In that
>>> case, you have to use the standard linear constraints of equation (6.25) to
>>> impose bounds.
>>>
>>> At a lower lever, variable bounds are defined when variables are added
>>> via the add_vars() method. The Va, Vm, Pg and Qg variables are added
>>> automatically (with their bounds) in opf_setup(), so you can’t really
>>> modify them there. But for any variables you add later, you supply the
>>> bounds when you call add_vars().
>>>
>>>Ray
>>>
>>>
>>>
>>> On Oct 4, 2017, at 3:52 PM, Viswanath Hariharan 
>>> wrote:
>>>
>>> So I do not need to use the add_constraints function? Because when I
>>> used the code you mentioned and then runopf(mpc), convergence fails. In
>>> general, how to add box constraints for Va,Vm, Pg and Qg of xr (r =
>>> runopf

Re: Doubt regarding adding constraints

2017-10-13 Thread Viswanath Hariharan
Thank you for your help sir. I think I was doing something wrong. It works
alright now.

Regards
Viswanath

On Oct 12, 2017 10:03 AM, "Ray Zimmerman"  wrote:

> Are you saying that your solution includes voltage angles whose absolute
> value is greater than 0.26 radians or 14.9 degrees?
>
>Ray
>
>
> On Oct 11, 2017, at 8:52 PM, Viswanath Hariharan 
> wrote:
>
> First, thank you so much for your time, Sir.
> So I tried the first approach first. I want to added box constraints for
> Voltage angle, -0.26 < theta < 0.26.  I created the A matrix and l and u
> vectors and passed it to the opf function. The solution converged and I did
> get results. But the problem is that the added constraints look like they
> had no effect on the result.
>
> I also tried the toggle_reserves() method you suggested in the previous
> email of this thread where you asked me rename toggle_reserves and all the
> callback functions within it and modify its contents to toggle the addition
> of constraints. I did that too. results = runopf(mpc) and results.om had
> 5 linear constraints added to it. But again this had no effect on the
> results. I even tried changing the bounds to see if there was any
> difference but there wasn't.
>
> What is it that I'm missing out here?
>
> Regards
> Viswanath
>
>
>
> On Tue, Oct 10, 2017 at 9:09 AM, Ray Zimmerman  wrote:
>
>> It appears you have fundamentally misunderstood callback functions and
>> how they work. I suggest that you read carefully the entirety of sections
>> 7.2–7.5 in the User’s Manual and make sure you understand the
>> toggle_reserves() example used to illustrate the approach.
>>
>> To implement your own constraints, I would recommend copying and renaming
>> toggle_reserves() to something like toggle_myconstraints(). Then rename
>> all of the callback functions defined in that file to e.g.
>> userfcn_myconstraints_ext2int(), userfcn_myconstraints_formulation(),
>> etc., and modify their contents to reflect the constraints you want to add
>> (as opposed to those implemented for the zonal reserves case). The
>> “formulation” callback is where you’ll be calling add_constraints().
>> Then you can simply toggle your constraints on and use runopf() normally.
>>
>> mpc = loadcase('');
>> mpc = toggle_myconstraints(mpc, 'on');
>> results = runopf(mpc);
>>
>> Hope this helps,
>>
>> Ray
>>
>>
>>
>> On Oct 5, 2017, at 12:18 PM, Viswanath Hariharan 
>> wrote:
>>
>> Sir
>>
>> I tried adding constraints using the callback functions method described
>> in Section 7.2 but I am not sure I followed it correctly.
>> mpopt = mpoption;
>> om = opf_setup(mpc, mpopt);
>> om = add_constraints(om, 'Vm', A1, l1, u1);
>> om = add_constraints(om, 'Va', A2, l2, u2);
>> mpc = get_mpc(om)
>> results2 = runopf(mpc);
>>
>> om gets updated with 10 linear constraints (case5 is being used here).
>> But mpc doesn't get updated and hence when I run this code and check and
>> results.var.mu.l.Va , the constraints
>> aren't updated. Not only that, the mpc file isn't getting updated as well.
>> I think I am making some mistake with this line : mpc = get_mpc(om) because
>> om is fine. What am I missing here? Or should I take another approach?
>> Thank you so much for your time Sir.
>>
>> Regards
>> Viswanath Hariharan
>>
>> On Thu, Oct 5, 2017 at 10:27 AM, Ray Zimmerman  wrote:
>>
>>> You only need to use the add_constraints() function if you are using
>>> Callback Functions as described in Section 7.2 as opposed to Direct
>>> Specification as described in Section 7.1 of the User’s Manual
>>> .
>>>
>>> You convergence failure my just imply that your variable bounds are
>>> tight enough that there is no feasible solution. Try relaxing the limits
>>> and see if it converges.
>>>
>>> Vm, Pg and Qg all have limits specified directly in the bus and gen
>>> matrices. Vm is bounded by the VMIN and VMAX columns in the bus matrix.
>>> Pg and Qg are bounded by the PMIN, PMAX and QMIN, QMAX columns of the
>>> gen matrix, respectively. Va is not normally constrained (except at the
>>> reference bus), so the bus matrix doesn’t contain bounds for it. In that
>>> case, you have to use the standard linear constraints of equation (6.25) to
>>> impose bounds.
>>>
>>> At a lower lever, variable bounds are defined when variables are added
>>> via the add_vars() method. The Va, Vm, Pg and Qg variables are added
>>> automatically (with their bounds) in opf_setup(), so you can’t really
>>> modify them there. But for any variables you add later, you supply the
>>> bounds when you call add_vars().
>>>
>>>Ray
>>>
>>>
>>>
>>> On Oct 4, 2017, at 3:52 PM, Viswanath Hariharan 
>>> wrote:
>>>
>>> So I do not need to use the add_constraints function? Because when I
>>> used the code you mentioned and then runopf(mpc), convergence fails. In
>>> general, how to add box constraints for Va,Vm, Pg and Qg of xr (r =
>>> runopf(m

Querry to add renewable generators in the caseformat

2017-10-13 Thread Charalambos Ioannou
Dear Ray,


I am trying to add renewable generators into the case format.  For example the 
following is what i am trying to do:




function mpc = michalis()
%   bus Capacity(MW) Curtailment(0==no, 1==yes) Priority
mpc.renwgen = [ 2 20  1   1
   3 10  1   1
  ];

%% MATPOWER Case Format : Version 2
mpc.version = '2';

%%-  Power Flow Data  -\%%
%% system MVA base
mpc.baseMVA = 100;

%% bus data
%   bus_i   typePd  Qd  Gs  Bs  areaVm  Va  
baseKV  zoneVmaxVmin
mpc.bus = [
1   2   50   0   0   0   1   1   0  
 100  1   1.1 0.9;
2   1   -50  0   0   0   1   1   0  
 100  1   1.1 0.9;
3   1   -50  0   0   0   1   1   0  
 100  1   1.1 0.9;
4   3   00   0   0   1   1   0  
 100  1   1.1 0.9;
];

%% generator data
%   bus Pg  Qg  QmaxQminVg  mBase   status  Pmax
PminPc1 Pc2 Qc1min  Qc1max  Qc2min  Qc2max  ramp_agcramp_10 
ramp_30 ramp_q  apf
mpc.gen = [
1   200  0   200-200 1  100   1  200
 0   0   0   0   0   0   0   0   0   0  
 0   0;
4   00   0   0   1  100   1  0  
 0   0   0   0   0   0   0   0   0   0  
 0   0;

];

%% branch data
%   fbustbusr   x   b   rateA   rateB   rateC   ratio   
angle   status  angmin  angmax
mpc.branch = [
1   2   0.10.10.1200 200 200 0  
 0   1   -360360;
2   3   0.10.10.1100 100 100 0  
 0   1   -360360;
3   4   0.10.10.1100 100 100 0  
 0   1   -360360;
];

%% generator cost data
% 1 startup shutdown n x1 y1 ... xn yn
% 2 startup shutdown n c(n-1) ... c0
mpc.gencost = [
2 0 0 2 10 0;
2 0 0 2 10 0;
];

Do i have to define it in a different file which i have to create the buses and 
everything? If you can give me your opinion on this i will appreciate it.

Thanks in advance.

Regards,

Charalampos


Re: Querry to add renewable generators in the caseformat

2017-10-13 Thread Ray Zimmerman
Since MATPOWER does not have any mechanism to automatically handle renewable 
generators in the way you envision, you have to implement that functionality 
yourself. And, of course, you are free to specify the data where you like. If 
you want to specify it as a renwgen field in the MATPOWER case struct, that’s 
fine. If you want to specify it in a separate file or data structure that is 
fine as well. Since you are writing the code to take that data and do something 
with it to modify model, you simply need to have that code be consistent in 
where it looks for the data.

I hope that answers your question.

   Ray



> On Oct 13, 2017, at 10:32 AM, Charalambos Ioannou  
> wrote:
> 
> Dear Ray, 
> 
> I am trying to add renewable generators into the case format.  For example 
> the following is what i am trying to do: 
> 
>  
> function mpc = michalis()
> %   bus Capacity(MW) Curtailment(0==no, 1==yes) Priority 
> mpc.renwgen = [ 2 20  1   1
>3 10  1   1
>   ];
> 
> TCL MERGE ERROR ( 10/13/2017 10:45:39 ): "invalid command name "MATPOWER""
OutmailID: 121941184, List: 'matpower-l', MemberID: 75174736
SCRIPT: "MATPOWER Case Format : Version 2 > mpc.version = '2'; >  >"
-  Power Flow Data  -%%
> TCL MERGE ERROR ( 10/13/2017 10:45:39 ): "invalid command name "system""
OutmailID: 121941184, List: 'matpower-l', MemberID: 75174736
SCRIPT: "system MVA base > mpc.baseMVA = 100; >  >"
 bus data
> %   bus_i   typePd  Qd  Gs  Bs  areaVm  Va
>   baseKV  zoneVmaxVmin
> mpc.bus = [
> 1   2   50   0   0   0   1   1   0
>100  1   1.1 0.9;
> 2   1   -50  0   0   0   1   1   0
>100  1   1.1 0.9;
> 3   1   -50  0   0   0   1   1   0
>100  1   1.1 0.9;
> 4   3   00   0   0   1   1   0
>100  1   1.1 0.9;
> ];
> 
> TCL MERGE ERROR ( 10/13/2017 10:45:39 ): "invalid command name ">""
OutmailID: 121941184, List: 'matpower-l', MemberID: 75174736
SCRIPT: "generator data > %   bus Pg  Qg  QmaxQminVg
  mBase   status  PmaxPminPc1 Pc2 Qc1min  Qc1max  Qc2min  
Qc2max  ramp_agcramp_10 ramp_30 ramp_q  apf > mpc.gen = [ > 1   
200  0   200-200 1  100   1  200 0   0  
 0   0   0   0   0   0   0   0   0   0; 
> 4   00   0   0   1  100   1  0
   0   0   0   0   0   0   0   0   0   0
   0   0; >  > ]; >  >"
 branch data
> %   fbustbusr   x   b   rateA   rateB   rateC   ratio 
>   angle   status  angmin  angmax
> mpc.branch = [
> 1   2   0.10.10.1200 200 200 0
>0   1   -360360;
> 2   3   0.10.10.1100 100 100 0
>0   1   -360360;
> 3   4   0.10.10.1100 100 100 0
>0   1   -360360;
> ];
> 
> TCL MERGE ERROR ( 10/13/2017 10:45:39 ): "extra characters after close-quote"
OutmailID: 121941184, List: 'matpower-l', MemberID: 75174736
SCRIPT: "generator cost data > % 1  startup shutdown > n x1  y1 ...  xn yn > % 
2  startup shutdown > n c(n-1) > ... c0 > mpc.gencost = [ > 2  0 0 2 > 10 0; > 
2  0 0 2 > 10 0; > ]; >  > Do i have to define it in a different file which i 
have to create the buses and everything? If you can give me your opinion on 
this i will appreciate it.  >  > Thanks in advance. >  > Regards,  >  > 
Charalampos--Apple-Mail=_24AB2BB2-DBC3-4144-80AB-34421D9CA427 
Content-Transfer-Encoding: quoted-printable Content-Type: text/html;  
charset="utf-8"  Since 
MATPOWER does not have any mechanism to automatically handle renewable 
generators in the way you envision, you have to implement that functionality 
yourself. And, of course, you are free to specify the data where you like. If 
you want to specify it as a renwgen field 
in the MATPOWER case struct, that’s fine. If you want to specify it in a 
separate file or data structure that is fine as well. Since you are writing the 
code to take that data and do something with it to modify model, you simply 
need to have that code be consistent in where it looks for the data.I hope that answers your 
question.  
 RayOn Oct 13, 2017, at 10:32 AM, Charalambos Ioannou xaralambo...@hotmail.com> wrote:Dear Ray, I am trying to add renewable generators into the 
case format.  For example the following is what i am trying to 
do:  function mpc = michalis()%   bus Capacity(MW) 
Curtailment(0==no, 1==yes) Priority mpc.renwgen = [ 2 20  1  
 1                      
         

Re: Doubt regarding adding constraints

2017-10-13 Thread Viswanath Hariharan
Sir
So I used the toggle_myconstraints method you had suggested to add Voltage
angle constraints to the problem. After getting the solution, I update the
constraints set and call toggle_myconstraints again. But this time, I get
an error :
Caused by:
Error using add_userfcn (line 119)
add_userfcn: the function 'userfcn_myconstraints_formulation' has
already been added

How do I avoid this problem? Is there a way to overwrite what's already
written in both add_userfcn and the linear constraints section in om (in
this case 'Va')?

Regards
Viswanath

On Fri, Oct 13, 2017 at 10:04 AM, Viswanath Hariharan 
wrote:

> Thank you for your help sir. I think I was doing something wrong. It works
> alright now.
>
> Regards
> Viswanath
>
> On Oct 12, 2017 10:03 AM, "Ray Zimmerman"  wrote:
>
>> Are you saying that your solution includes voltage angles whose absolute
>> value is greater than 0.26 radians or 14.9 degrees?
>>
>>Ray
>>
>>
>> On Oct 11, 2017, at 8:52 PM, Viswanath Hariharan 
>> wrote:
>>
>> First, thank you so much for your time, Sir.
>> So I tried the first approach first. I want to added box constraints for
>> Voltage angle, -0.26 < theta < 0.26.  I created the A matrix and l and u
>> vectors and passed it to the opf function. The solution converged and I did
>> get results. But the problem is that the added constraints look like they
>> had no effect on the result.
>>
>> I also tried the toggle_reserves() method you suggested in the previous
>> email of this thread where you asked me rename toggle_reserves and all the
>> callback functions within it and modify its contents to toggle the addition
>> of constraints. I did that too. results = runopf(mpc) and results.om had
>> 5 linear constraints added to it. But again this had no effect on the
>> results. I even tried changing the bounds to see if there was any
>> difference but there wasn't.
>>
>> What is it that I'm missing out here?
>>
>> Regards
>> Viswanath
>>
>>
>>
>> On Tue, Oct 10, 2017 at 9:09 AM, Ray Zimmerman  wrote:
>>
>>> It appears you have fundamentally misunderstood callback functions and
>>> how they work. I suggest that you read carefully the entirety of sections
>>> 7.2–7.5 in the User’s Manual and make sure you understand the
>>> toggle_reserves() example used to illustrate the approach.
>>>
>>> To implement your own constraints, I would recommend copying and
>>> renaming toggle_reserves() to something like toggle_myconstraints().
>>> Then rename all of the callback functions defined in that file to e.g.
>>> userfcn_myconstraints_ext2int(), userfcn_myconstraints_formulation(),
>>> etc., and modify their contents to reflect the constraints you want to add
>>> (as opposed to those implemented for the zonal reserves case). The
>>> “formulation” callback is where you’ll be calling add_constraints().
>>> Then you can simply toggle your constraints on and use runopf()
>>> normally.
>>>
>>> mpc = loadcase('');
>>> mpc = toggle_myconstraints(mpc, 'on');
>>> results = runopf(mpc);
>>>
>>> Hope this helps,
>>>
>>> Ray
>>>
>>>
>>>
>>> On Oct 5, 2017, at 12:18 PM, Viswanath Hariharan 
>>> wrote:
>>>
>>> Sir
>>>
>>> I tried adding constraints using the callback functions method described
>>> in Section 7.2 but I am not sure I followed it correctly.
>>> mpopt = mpoption;
>>> om = opf_setup(mpc, mpopt);
>>> om = add_constraints(om, 'Vm', A1, l1, u1);
>>> om = add_constraints(om, 'Va', A2, l2, u2);
>>> mpc = get_mpc(om)
>>> results2 = runopf(mpc);
>>>
>>> om gets updated with 10 linear constraints (case5 is being used here).
>>> But mpc doesn't get updated and hence when I run this code and check and
>>> results.var.mu.l.Va , the constraints
>>> aren't updated. Not only that, the mpc file isn't getting updated as well.
>>> I think I am making some mistake with this line : mpc = get_mpc(om) because
>>> om is fine. What am I missing here? Or should I take another approach?
>>> Thank you so much for your time Sir.
>>>
>>> Regards
>>> Viswanath Hariharan
>>>
>>> On Thu, Oct 5, 2017 at 10:27 AM, Ray Zimmerman  wrote:
>>>
 You only need to use the add_constraints() function if you are using
 Callback Functions as described in Section 7.2 as opposed to Direct
 Specification as described in Section 7.1 of the User’s Manual
 .

 You convergence failure my just imply that your variable bounds are
 tight enough that there is no feasible solution. Try relaxing the limits
 and see if it converges.

 Vm, Pg and Qg all have limits specified directly in the bus and gen
 matrices. Vm is bounded by the VMIN and VMAX columns in the bus matrix.
 Pg and Qg are bounded by the PMIN, PMAX and QMIN, QMAX columns of the
 gen matrix, respectively. Va is not normally constrained (except at
 the reference bus), so the bus matrix doesn’t contain bounds for it. In
 that case, you have to use

Re: Doubt regarding adding constraints

2017-10-13 Thread Viswanath Hariharan
I tried getting out of the problem by assigning allow_multiple = 1 for
add_userfcn. But I couldn't get past this error:
Error using opt_model/add_constraints (line 87)
Error detected on worker 4.
@opt_model/add_constraints: linear constraint set named 'Va' already exists

Could you guide me as to how I can overwrite this too?
Thank you sir

Regards
Viswanath

On Fri, Oct 13, 2017 at 11:22 AM, Viswanath Hariharan 
wrote:

> Sir
> So I used the toggle_myconstraints method you had suggested to add Voltage
> angle constraints to the problem. After getting the solution, I update the
> constraints set and call toggle_myconstraints again. But this time, I get
> an error :
> Caused by:
> Error using add_userfcn (line 119)
> add_userfcn: the function 'userfcn_myconstraints_formulation' has
> already been added
>
> How do I avoid this problem? Is there a way to overwrite what's already
> written in both add_userfcn and the linear constraints section in om (in
> this case 'Va')?
>
> Regards
> Viswanath
>
> On Fri, Oct 13, 2017 at 10:04 AM, Viswanath Hariharan <
> vhari...@buffalo.edu> wrote:
>
>> Thank you for your help sir. I think I was doing something wrong. It
>> works alright now.
>>
>> Regards
>> Viswanath
>>
>> On Oct 12, 2017 10:03 AM, "Ray Zimmerman"  wrote:
>>
>>> Are you saying that your solution includes voltage angles whose absolute
>>> value is greater than 0.26 radians or 14.9 degrees?
>>>
>>>Ray
>>>
>>>
>>> On Oct 11, 2017, at 8:52 PM, Viswanath Hariharan 
>>> wrote:
>>>
>>> First, thank you so much for your time, Sir.
>>> So I tried the first approach first. I want to added box constraints for
>>> Voltage angle, -0.26 < theta < 0.26.  I created the A matrix and l and u
>>> vectors and passed it to the opf function. The solution converged and I did
>>> get results. But the problem is that the added constraints look like they
>>> had no effect on the result.
>>>
>>> I also tried the toggle_reserves() method you suggested in the previous
>>> email of this thread where you asked me rename toggle_reserves and all the
>>> callback functions within it and modify its contents to toggle the addition
>>> of constraints. I did that too. results = runopf(mpc) and results.om
>>> had 5 linear constraints added to it. But again this had no effect on the
>>> results. I even tried changing the bounds to see if there was any
>>> difference but there wasn't.
>>>
>>> What is it that I'm missing out here?
>>>
>>> Regards
>>> Viswanath
>>>
>>>
>>>
>>> On Tue, Oct 10, 2017 at 9:09 AM, Ray Zimmerman  wrote:
>>>
 It appears you have fundamentally misunderstood callback functions and
 how they work. I suggest that you read carefully the entirety of sections
 7.2–7.5 in the User’s Manual and make sure you understand the
 toggle_reserves() example used to illustrate the approach.

 To implement your own constraints, I would recommend copying and
 renaming toggle_reserves() to something like toggle_myconstraints().
 Then rename all of the callback functions defined in that file to e.g.
 userfcn_myconstraints_ext2int(), userfcn_myconstraints_formulation(),
 etc., and modify their contents to reflect the constraints you want to add
 (as opposed to those implemented for the zonal reserves case). The
 “formulation” callback is where you’ll be calling add_constraints().
 Then you can simply toggle your constraints on and use runopf()
 normally.

 mpc = loadcase('');
 mpc = toggle_myconstraints(mpc, 'on');
 results = runopf(mpc);

 Hope this helps,

 Ray



 On Oct 5, 2017, at 12:18 PM, Viswanath Hariharan 
 wrote:

 Sir

 I tried adding constraints using the callback functions method
 described in Section 7.2 but I am not sure I followed it correctly.
 mpopt = mpoption;
 om = opf_setup(mpc, mpopt);
 om = add_constraints(om, 'Vm', A1, l1, u1);
 om = add_constraints(om, 'Va', A2, l2, u2);
 mpc = get_mpc(om)
 results2 = runopf(mpc);

 om gets updated with 10 linear constraints (case5 is being used here).
 But mpc doesn't get updated and hence when I run this code and check and
 results.var.mu.l.Va , the constraints
 aren't updated. Not only that, the mpc file isn't getting updated as well.
 I think I am making some mistake with this line : mpc = get_mpc(om) because
 om is fine. What am I missing here? Or should I take another approach?
 Thank you so much for your time Sir.

 Regards
 Viswanath Hariharan

 On Thu, Oct 5, 2017 at 10:27 AM, Ray Zimmerman 
 wrote:

> You only need to use the add_constraints() function if you are using
> Callback Functions as described in Section 7.2 as opposed to Direct
> Specification as described in Section 7.1 of the User’s Manual
> .
>
>

Storage on Redispatch

2017-10-13 Thread Stephen Suffian
Hey everyone,

I have a question regarding how storage is calculated for each time step
during an economic dispatch run. I am attempting to simulate a 24-hour
economic dispatch followed by hourly re-dispatch of units with an updated
load forecast. With an identical forecast, I would assume that the
redispatch would be identical to the initial dispatch. This is in fact the
case with the normal generators (generators in mpc) and also any wind
generators that are added.

However, when I add hydro (as energy-limiting storage units), it seems to
shift around which time periods are using different levels of storage power
during the re-dispatch, despite all other conditions being identical. This
is problematic, because I calculate an added operational cost to the grid
between the initial dispatch and the redispatch, despite the same load
being met.

The following is a simple example with a single generator, a single storage
unit, a flat load, running on a no-bus network, with no terminal targets.
To reiterate, I ideally would want the levels of power dispatched from
storage to be identical between the initial 4-hour dispatch and each
subsequent re-dispatch, but that doesn't seem to be the case below.

Any help understanding better how the storage outputs are calculated, or
whether I am doing something wrong in this code or otherwise, would be
greatly appreciated.

Thanks!
Stephen Suffian

define_constants
this_load_profile.values = [125; 125; 125; 125];
nt = size(this_load_profile.values,1);

warning('off','all')
mpopt = mpoption('verbose', 0);
mpopt = mpoption(mpopt, 'most.dc_model', 0);% use model with no network
mpopt = mpoption(mpopt, 'most.storage.cyclic', 0);
mpopt = mpoption(mpopt, 'most.storage.terminal_target',0);

mpc_orig.version = '2';
mpc_orig.baseMVA = 100;
mpc_orig.bus = [ 1300001101351
1.050.95;];
mpc_orig.gen = [
1125025-2511001200000
0000025060000;
1-200000110010-60000
0000050050000;
];
mpc_orig.branch = [];
mpc_orig.gencost = [
20030   1  0;
200301000;
];
xgd_table.colnames = {};
xgd_table.data = [];

%Storage
storage.gen=[ 1000011001150 00
00000151500];
storage.xgd_table.colnames = {};
storage.xgd_table.data = [];
storage.sd_table.colnames = {
'InitialStorage', ...
'InitialStorageLowerBound', ...
'InitialStorageUpperBound', ...
'InitialStorageCost', ...
'TerminalStoragePrice', ...
'MinStorageLevel', ...
'MaxStorageLevel', ...
'OutEff', ...
'InEff', ...
'LossFactor', ...
'rho', ...

'ExpectedTerminalStorageMin',...

'ExpectedTerminalStorageMax',...
};
storage.sd_table.data=[3535350003511
00  0 0];

for index = 1: 2
mpc = mpc_orig;
xgd = loadxgendata(xgd_table, mpc_orig);
profiles = getprofiles(this_load_profile);
profiles(1).values=profiles(1).values(index:end);
[iess, mpc, xgd, sd] = addstorage(storage, mpc, xgd);
remaining_nt = nt-index+1;
mdi = loadmd(mpc, remaining_nt, xgd, sd, [], profiles);
mdo_re = most(mdi, mpopt);
mdo_re.results.ExpectedDispatch
end


%%OUTPUT (The third row should be identical (so if the first ans is [0 15
15 5], the second should be [15 15 5], as it is the re-dispatch at time t=2.

ans =

  125.  110.  110.  120.
 -125. -125. -125. -125.
 0   15.   15.5.


ans =

  120.  110.  110.
 -125. -125. -125.
5.   15.   15.