Simple AC Generator AC Load - Learning how to use MATLAB Link  


0

 I've recently installed the MATLAB Link within my HOMER software. The modelling I am undertaking of remote communities consist of dispatch strategies which require MATLAB to accurately model the real world settings I am working in. I have had limited exposure to MATLAB in my undergrad a decade ago but virtually none since. I am getting up to speed on the software but it is taking some time. I am currently trying to mimic a community load with a fairly straight forward dispatch strategy. The community consists of three generators of three sizes. When the load is above a certain threshold, Gen 1 supplies power to the load. When the load is below a certain threshold, Gen 3 supplies power to the load. And, when the load falls within the upper and lower thresholds, Gen 2 supplies power to the load. 

 

I am unfamiliar with how to correctly set up my script and as a result, my code errors out relatively quickly. The logic in my head makes sense, I think there is just something missing from how I am structuring my script which, as a MATLAB novice, continues to escape me. Any help would be greatly appreciated.

 

- Dave

 
0

Hello Dave,

 

What are the errors that you get?

 

Best,

Dhiwaakar Purusothaman

Hi Dhiwaakar,

The errors have progressed as I've mulled forward through the model. At first, I received what I understand to be a standard error:

MATLAB error while executing '[new_simulation_state, custom_variables] = MatlabDispatch(simulation_parameters, simulation_state, custom_variables);': Reference to non-existent field 'ac_bus.load_requested'. Error in MatlabDispatch(line 7) if simulation_state.ac_bus.load_requested>328;

I've seen this style error in various HOMER help menus but am unsure why it came about, my best guess is there is something missing from my code that my inexperience and lack of fundamentals isn't catching. Regardless, I plugged forward working the problem, tweaking my script and eventually got to a point where my error became:

Function with duplicate name "MatlabDispatch" cannot be defined

At first I suspected that HOMER was able to bring the MATLAB script through its first iteration and when it tried to model the second hour of my model time series, MATLAB was confused and produced and error, although I know longer think this to be the case.

I  dove back into HOMER help and implemented save('testvariables.mat'); into my script to produce a matrix with all the dispatch variables. This has been helpful as I now could see where MATLAB was getting to. A few more tweaks and my third and current error produced was:

Infeasible due to the capacity shortage constraint

I tried setting the Maximum annual capacity shortage (%) constraint to 100% from 10% in HOMER and tried the model again. I was able to produce a result but the output I exported to Excel showed that no generators produced power once during the year, since I set the MACS to 100%. I also noticed, when I load testvariables.mat into the workspace that the various variables remain the same. No matter what iteration I attempt to call on with the save, I only see the results to the first iteration when I load the file. Something is going on with my script where MATLAB can't call the correct load in HOMER, or doesn't understand how I've assigned the generator setpoints. I believe this stems from my being a "nuub" so to speak to MATLAB. Because of this, I've developed my start and end simulation functions by basically copying verbatim what HOMER help recommended as well as from example scripts you have developed. This could be causing issues as well that I don't understand.

 

Apologies for the long winded response, trying to paint the most detailed picture possible.

I think I'm missing something in front of my eyes, but I can't seem to see how to upload a zip folder of my files for you to see. Could you point me in the correct direction on that? I suspect files would be a great benefit to solving the issue.

 

Many thanks,

Dave

0

Oh dammit, I put the errors in italics and they seem to have disappeared. Apologies. First error should be on second line and reads:

MATLAB error while executing '[new_simulation_state, custom_variables] = MatlabDispatch(simulation_parameters, simulation_state, custom_variables);': Reference to non-existent field 'ac_bus.load_requested'. Error in MatlabDispatch(line7) if simulation_state.ac_bus.load_requested>328;

The second error should be on the fourth line and reads:

Function with duplicate name "MatlabDispatch" cannot be defined

Third error should be on eighth line and reads:

Infeasible due to the capacity shortage constraint.

 

Sorry about that

Dave

 
  
Working

Please Login or Register