Menu

mode=time starts with last element from loadshape

Help
2015-05-11
2015-05-15
  • Wilfried Hennings

    Hello and thank you for all your help so far.

    If my script with daily loadshapes is executed in mode=daily, in the first time step the first element of each loadshape is used.

    But if my script is executed from Excel VBA in mode=time, in the first time step the LAST element of each loadshape is used, in the second step the first element, in the third step the second element, and so on.
    The solution time is correctly reported, running from 0 to 23.9166
    I extract the solution before the solve command, as the document "Custom Scripting of OpenDSS Time Simulations" sais: "Time is incremented by the stepsize after the solution has been performed."

    Extract from my script:

    MyText.Command = "Compile (one_load+pv+storage_controlled.DSS)"
    MyText.Command = "Set Mode=Time Stepsize=5m Loadshapeclass=Daily"
    
    Dim i, j, k As Integer
    
    For k = 1 To 288
        j = k + 1
        i = k - 1
        ActiveSheet.Cells(j, 1).Value = MySolution.dblHour
        MyText.Command = "Solve"
        MyMonitors.SaveAll
        MyMonitors.Name = "MonP01P"
        ActiveSheet.Cells(j, 5).Value = MyMonitors.Channel(1)(i)
    Next k
    
     

    Last edit: Wilfried Hennings 2015-05-11
  • Roger Dugan

    Roger Dugan - 2015-05-15

    I thought I already answered this post, but sometimes the forum loses my post and I don't notice right away.

    You have discovered how Mode=Time works. Time is incremented After the solution is performed while other modes increment time at the beginning of the loop. Time mode was designed to assist folks who were previously scripting everything in Snapshot mode -- setting time, solving, and sampling -- all the specifics. You can do that of course, and it works quite well. Some use computer programs to write the scripts. Then they load the script and execute it. Time mode does the sampling and time incrementing automatically so that doesn't have to be done in the DSS script.

    Loadshapes in OpenDSS wrap around if the simulation goes beyond the definition of the number of points. So you can assign a 24-hour daily curve to a Load for a 8760-h yearly simulation and it will simply repeat over and over. Since time was at 0 when your simulation started, it used the last point in the loadshape.

    If you want it to start with the 1st point, set time explicitly at the beginning of the loop to 5 minutes. You can do Mytext.command="set sec=300" for example. There's about half a dozen other ways to set time since you are using the COM interface.

     

Log in to post a comment.