def run_powerflow(self, session, method='onthefly', export_pypsa=False, debug=False):
        """ Performs power flow calculation for all MV grids

        Args:
            session : sqlalchemy.orm.session.Session
                Database session
            method: str
                Specify export method
                If method='db' grid data will be exported to database
                
                If method='onthefly' grid data will be passed to PyPSA directly (default)
        export_pypsa: bool
            If True PyPSA networks will be exported as csv to output/debug/grid/<MV-GRID_NAME>/
        debug: bool, defaults to False
            If True, information is printed during process
        
        """

        if method == 'db':
            # Empty tables
            pypsa_io.delete_powerflow_tables(session)

            for grid_district in self.mv_grid_districts():
                if export_pypsa:
                    export_pypsa_dir = repr(grid_district.mv_grid)
                else:
                    export_pypsa_dir = None
                grid_district.mv_grid.run_powerflow(session, method='db',
                                                    export_pypsa_dir=export_pypsa_dir,
                                                    debug=debug)

        elif method == 'onthefly':
            for grid_district in self.mv_grid_districts():
                if export_pypsa:
                    export_pypsa_dir = repr(grid_district.mv_grid)
                else:
                    export_pypsa_dir = None
                grid_district.mv_grid.run_powerflow(session,
                                                    method='onthefly',
                                                    export_pypsa_dir=export_pypsa_dir,
                                                    debug=debug)
def run_powerflow ( self , session , method = 'onthefly' , export_pypsa = False , debug = False ) : if method == 'db' : pypsa_io . delete_powerflow_tables ( session ) for grid_district in self . mv_grid_districts ( ) : if export_pypsa : export_pypsa_dir = repr ( grid_district . mv_grid ) else : export_pypsa_dir = None grid_district . mv_grid . run_powerflow ( session , method = 'db' , export_pypsa_dir = export_pypsa_dir , debug = debug ) elif method == 'onthefly' : for grid_district in self . mv_grid_districts ( ) : if export_pypsa : export_pypsa_dir = repr ( grid_district . mv_grid ) else : export_pypsa_dir = None grid_district . mv_grid . run_powerflow ( session , method = 'onthefly' , export_pypsa_dir = export_pypsa_dir , debug = debug )
Performs power flow calculation for all MV grids

        Args:
            session : sqlalchemy.orm.session.Session
                Database session
            method: str
                Specify export method
                If method='db' grid data will be exported to database
                
                If method='onthefly' grid data will be passed to PyPSA directly (default)
        export_pypsa: bool
            If True PyPSA networks will be exported as csv to output/debug/grid/<MV-GRID_NAME>/
        debug: bool, defaults to False
            If True, information is printed during process