Menu

Pausing parallel processing Simulations for System Checks

2024-09-03
3 days ago
  • Alexis amako

    Alexis amako - 2024-09-03

    Hello everyone,
    I'm currently working on a concurrent simulation using OpenDSS parallel processing. In this setup, I have a storage system placed on two buses within the IEEE 13-bus system. My optimization code, written in MATLAB and interfacing with OpenDSS through the COM interface, assigns each storage system, circuit, and optimization code to a separate OpenDSS Actor. The simulation is then run using this approach, similar to the example format provided in the OpenDSS documentation:

    OpenDSS/Code/ [r3807]/trunk/Version8/Distrib/Examples/Parallel_Processing/MATLAB

    1. My current challenge is to pause both DSS actors concurrently during the simulation at a specific time interval to perform system-wide checks/controls on voltage and storage parameters.
      Ideally, I'd like to pause, conduct system-wide checks, and then resume the simulation from the last paused state. For reference, I've reviewed the training material available at

    https://sourceforge.net/p/electricdss/code/HEAD/tree/trunk/Training/UPRM-2019/Session6.pptx. which makes use of DSS commands such as: DSSCircuit.Solution.SolveAll. and DSSParallel.Wait

    1. Also, is it accurate to compose the model with the IEEE test system on each actor when you want to solve simultaneous optimizations on both storage systems at different buses.

    Any insights or suggestions on achieving this concurrent pause and system check functionality within the OpenDSS parallel processing framework would be greatly appreciated.

     

    Related

    Commit: [r3807]


    Last edit: Alexis amako 2024-09-03
    • Davis Montenegro

      Hello,

      Pausing an actor does not necessarily the best way to go since, depending on the sample time and determinism of the observer (host), you may end up pausing in different parts of the simulation. However, there is an easy way. You can always use the option "number" (set number=..) to specify the number of time steps the simulation will run, this way, you can simulate each actor and stop at certain point, do your "checks" and keep going with the simulation at each actor independently.
      By setting the "number" of time steps per actor, it will be waiting once the number of steps is done, no need for dedicated poling routines or processes.

      Best regards,

       
  • Alexis amako

    Alexis amako - 2024-09-03

    Thanks for your prompt reply.

    My other question was
    * Also, is it accurate to compose the model with the IEEE test system on each actor when you want to solve simultaneous optimizations on both storage systems at different buses as i have set it up below:

    DSSCircuit = DSSObj.ActiveCircuit;
    DSSText.Command = 'ClearAll';
    DSSText.Command = 'Set Parallel=No';

    DSSParallel = DSSCircuit.Parallel;
    CPUs = 2;
    DSSText.Command = 'compile "C:\Users......\MasterCircuit.dss"';
    DSSText.Command = 'set maxiterations=1000 maxcontroliter=1000';
    DSSText.Command = ['Clone ', int2str(CPUs - 1)];

    for i=1:CPUs
    DSSParallel.ActiveActor=i;
    if i == 1

        %%% the Battery storage system script for Bus A here
        sim_stepsize = '30m';
        DSSText.Command = 'set mode=daily number=1';
        DSSText.Command = ['set stepsize=', sim_stepsize];
        DSSText.Command = 'Set controlmode=Time';
        DSSText.Command = 'Set number=48';
    
        originalSteps = DSSObj.ActiveCircuit.Solution.Number;
        DSSObj.ActiveCircuit.Solution.Number = 1;
    
        for stepNumber = 1:originalSteps
    
            %%% My Optimization Codes Here !!
            DSSCircuit.Solution.SolveSnap;         
            DSSObj.ActiveCircuit.Solution.FinishTimeStep();
        end
    end
    if i == 2
    
        %%% the Battery storage system script for Bus B here
        sim_stepsize = '30m';
        DSSText.Command = 'set mode=daily number=1';
        DSSText.Command = ['set stepsize=', sim_stepsize];
        DSSText.Command = 'Set controlmode=Time';
        DSSText.Command = 'Set number=48';
    
        originalSteps = DSSObj.ActiveCircuit.Solution.Number;
        DSSObj.ActiveCircuit.Solution.Number = 1;
    
        for stepNumber = 1:originalSteps
    
            %%% My Optimization Codes Here !!
            DSSCircuit.Solution.SolveSnap;            
            DSSObj.ActiveCircuit.Solution.FinishTimeStep();
        end
    end
    

    end

    DSSText.Command = 'Set Parallel=Yes';
    DSSCircuit.Solution.SolveAll;
    DSSParallel.Wait;

    Thanks for your response

     
    • Davis Montenegro

      Hello,

      I was wondering: What makes you think it's not accurate? Each actor is independent and can host different versions/configurations of the same or different systems. Changes can be applied to each actor independently, just be careful on activating the correct actor before applying changes. This is demonstrated in the following example:

      https://sourceforge.net/p/electricdss/code/HEAD/tree/trunk/Version8/Distrib/Examples/Parallel_Processing/MATLAB/Example_4/

      Best regards,

       
  • Alexis amako

    Alexis amako - 2024-09-04

    Thanks for your response

     
  • Alexis amako

    Alexis amako - 3 days ago

    Hello Davis
    I noticed an issue during the simulation. When stopping at certain points to perform checks, the irradiance values for PV1 are being used as the starting values for PV2 at Actor 2. This happens even though PV1 and PV2 have different irradiance loadshape profiles (MyIrrad1 and MyIrrad2).
    Specifically, the irradiance value at hour 1 for PV2 is taken from MyIrrad1’s hour 13 value instead of using MyIrrad2’s hour 1 value. I tried renaming the loadshapes, but the first loaded irradiance loadshape is always used.
    Please I don’t know why this happen? And do I need to clear the loaded irradiance loadshape before calling Actor 2?

    %%% Initialization codes !!
    DSSText.Command = 'set mode=Daily stepsize=1h number=12 hour=0 controlmode=Time';

    for ActorIdx = 1:2
    DSSParallel.ActiveActor = ActorIdx;

    if ActorIdx == 1
        DSSText.Command = 'set ActiveActor = 1';
    
        DSSText.Command = 'New XYCurve.MyPvsT npts=4 xarray=[0 25 75 100] yarray=[1.2 1.0 0.8 0.6]';
        DSSText.Command = 'New XYCurve.Eff npts=4 xarray=[.1  .2  .4  1.0] yarray=[.86  .9  .93  .97]';
        DSSText.Command = 'New Loadshape.MyIrrad1 npts=24 interval=1 csvfile=[Irrad 1.csv]';
        DSSText.Command = 'New Tshape.MyTemp npts=24 interval=1 temp=[25  25  25  25  25  25  25  25  35  40  45  50  60  60  55  40  35  30  25  25  25  25  25  25]';
        % Add PV systems to the desired bus locations
    
        y = 350; 
        DSSText.Command = ['New PVSystem.PV1 phases=3 bus1=tf1 kV=0.48 kVA=' num2str(y) ' debugtrace=no irrad=.98 Pmpp=' num2str(y) ' temperature=25 PF=0.98 %cutin=0.1 %cutout=0.1 effcurve=Eff P-TCurve=MyPvsT Daily=MyIrrad1 TDaily=MyTemp'];
    
        %%% Rest of the codes here !!
    end
    
    if ActorIdx == 2
        DSSText.Command = 'set ActiveActor = 1';
    
        DSSText.Command = 'New XYCurve.MyPvsT npts=4 xarray=[0 25 75 100] yarray=[1.2 1.0 0.8 0.6]';
        DSSText.Command = 'New XYCurve.Eff npts=4 xarray=[.1  .2  .4  1.0] yarray=[.86  .9  .93  .97]';
        DSSText.Command = 'New Tshape.MyTemp npts=24 interval=1 temp=[25  25  25  25  25  25  25  25  35  40  45  50  60  60  55  40  35  30  25  25  25  25  25  25]';
        DSSText.Command = 'New Loadshape.MyIrrad2 npts=24 interval=1 csvfile=[Irrad 2.csv]';
        z = 250;
        DSSText.Command = ['New PVSystem.PV2 phases=3 bus1=tf2 kV=0.48 kVA=' num2str(z) ' debugtrace=no irrad=.98 Pmpp=' num2str(z) ' temperature=25 PF=0.98 %cutin=0.1 %cutout=0.1 effcurve=Eff P-TCurve=MyPvsT Daily=MyIrrad2 TDaily=MyTemp'];
    
        %%% Rest of the codes here !!
    end
    

    end

    DSSCircuit.Solution.SolveAll;

     
    • Davis Montenegro

      Hello,

      It feels like if you are setting the daily simulation mode for one of the actor only. Since they are independent, you need to set the simulation mode and other parameters for every actor. You can do this by using the option:

      set ActiveActor = *
      

      This will broadcast every command you send to every actor, however, be careful, after setting up the actors you need to activate actor 1 before starting a simulation. There is an example that shows how to use the * argument for the active actor to setup the simulation globally:

      https://sourceforge.net/p/electricdss/code/HEAD/tree/trunk/Version8/Distrib/Examples/Parallel_Processing/MATLAB/Example_3/

      Best regards,

       

Log in to post a comment.