Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4118194
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:55:44+00:00 2026-05-20T22:55:44+00:00

I’m trying to control a grid connected photovoltaic system based on the grid voltage.

  • 0

I’m trying to control a grid connected photovoltaic system based on the grid voltage.
The idea is this: when the grid voltage rises above VMax, I want to switch off the system for timeOff. When timeOff has passed, i want to switch on again, but only when the grid voltage is lower than VMax.

I currently have two implementations; both are creating many events and i wonder if there’s a more efficient way. This is how it is implemented now:

package Foo
model PVControl1 "Generating most events"

parameter Real VMax=253;
parameter Real timeOff=60;

input Real P_init "uncontrolled power";
input Real VGrid;
Real P_final "controlled power";
Boolean switch (start = true) "if true, system is producing";
discrete Real restartTime (start=-1, fixed=true) 
  "system is off until time>restartTime";

equation
when {VGrid > VMax, time > pre(restartTime)} then
  if VGrid > VMax then
    switch = false;
    restartTime = time + timeOff;
  else
    switch = true;
    restartTime = -1;
  end if;
end when;

if pre(switch) then
  P_final = P_init;
else
  P_final = 0;
end if;
end PVControl1;

model PVControl2;
  "Generating less events, but off-time is no multiple of timeOff"

parameter Real VMax=253;
parameter Real timeOff=60;

input Real P_init "uncontrolled power";
input Real VGrid;
Real P_final "controlled power";
discrete Real stopTime( start=-1-timeOff, fixed=true) 
  "system is off until time > stopTime + timeOff";

equation 
when VGrid > VMax then
  stopTime=time;
end when;

if noEvent(VGrid > VMax) or noEvent(time < stopTime + timeOff) then
  P_final = 0;
else
  P_final = P_init;
end if;
end PVControl2;

model TestPVControl;
  "Simulate 1000s to get an idea"

PVControl pvControl2(P_init=4000, VGrid = 300*sin(time/100));
end TestPVControl;

end foo;

When run, I get 8 events with PVControl1, and 4 events with PVControl2.
Looking at PVControl2, I actually need only an event at the moment where VGrid becomes larger than VMax. This would give only 2 events. The other 2 events are generated when VGrid drops below VMax again.

Is there a way to improve my model further?
Thanks,
Roel

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:55:45+00:00Added an answer on May 20, 2026 at 10:55 pm

    I have a few comments. I think you are viewing an event as when the equations within a when clause are activated. But that isn’t quite right. An event occurs when the value of a discrete variable changes. The point is that the continuous integrator must be stopped at that point and the equations integrated with the new value.

    To understand how that is affecting you in this case, you should consider that an anonymous expression (like the one in your when clauses) is probably being treated as an anonymous discrete variable. In other words, you can think of it as being equivalent to this:

    Boolean c1 = VGrid > VMax;
    
    when c1 then
      ...
    end when;
    

    …and the important thing to note is that an event (i.e. a change in the value of c1) occurs both when VGrid becomes greater than VMax and when it becomes less than VMax. Now consider this:

    Boolean c1 = VGrid > VMax;
    Boolean c2 = time > pre(restartTime);
    
    when {c1, c2} then
      ...
    end when;
    

    Now you’ve got even more events because there are two conditions involved and you generate events each time either one of them changes value.

    All that having been said, are you actually having a performance issue here? Normally, such events only become an issue when you have “chattering” (cases where the value of the condition changes sign due to numerical noise in the integration process). Do you have any numbers to indicate how much of an issue these events really are? It might also help to know what tool you are using to simulate these things.

    Finally, one thing I don’t understand from your logic is what happens if VGrid>VMax and then, after timeOff, VGrid is still greater than VMax?

    Assuming it handles this last case correctly, I think PVControl2 is actually what you want (and generates exactly the number of events I would expect and for the reasons I would expect).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I am trying to loop through a bunch of documents I have to put
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.