BDonnot / lightsim2grid

LightSim2grid implements a c++ backend targeting the Grid2Op (https://github.com/rte-france/grid2op) platform.
https://lightsim2grid.readthedocs.io/en/latest/
Mozilla Public License 2.0
49 stars 9 forks source link

Implement a function for time series calculation for pandapower #49

Closed rbolgaryn closed 6 months ago

rbolgaryn commented 2 years ago

Is your feature request related to a problem? Please describe.

However, it would be better to also have a function that receives the Ybus and other inputs, including the arrays for P values fro gen and P and Q values for sgen, load and receives the results of the time series calculation that uses the approach from the Computers class:

for(Eigen::Index i = 0; i < nb_steps; ++i){
        conv = false;
        conv = compute_one_powerflow(Ybus,
                                     V, 
                                     _Sbuses.row(i),
                                     slack_ids,
                                     slack_weights,
                                     bus_pv,
                                     bus_pq,
                                     max_iter,
                                     tol_);
        if(!conv){
            _timer_total = timer.duration();
            return _status;
        }
        if(conv && step_diverge < 0) _voltages.row(i)(id_ac_solver_to_me) = V.array();
        else step_diverge = i;
    }

Describe alternatives you've considered

The alternative would be to have the grid2op based solution in the background, using the "init" for the loghtsim2grid model with the pp converter. However, the pp converter is not (yet) implemented for all the corner cases that pandapower considers, and adding them to lightsim2grid would require a lot of effort. Using the Ybus after pandapower generates it would be more convenient. Then, pp.run_timeseries can switch to using the lightsim2grid implementation in the background if only P and Q are adjusted, similarly to how it happens now with pp.run.

Additional context

BDonnot commented 2 years ago

Hi 😊

I think it would be a great idea!

Unfortunately I'm not sure I'll have the time at the moment to do it.

And also, I might need to further check, but I'm not sure you could benefit from a large speed up if you change the pv indexes or pq indexes.

For the rest this sounds reasonable.

Benjamin

BDonnot commented 1 year ago

About that, i'm not sure, but maybe you can use directly the solver as shown here https://github.com/BDonnot/lightsim2grid/blob/bd-dev/lightsim2grid/newtonpf/newtonpf.py more specially here https://github.com/BDonnot/lightsim2grid/blob/d12271541dd3d7ae718926ce6b76be4f72199d5d/lightsim2grid/newtonpf/newtonpf.py#L206

But i'm not sure it's worth the trouble to be honest. Most of the time is already spent in computing the Ybus in pandapower I think.

Most of the gain in computation time for SecurityAnalysis and TimeSeries module is precisely because the Ybus is computed once, the KLU solver is initialize once (which cost time) and then reused to solve other linear equations.