Skip to content

Commit

Permalink
clean the way to init lightsim2grid
Browse files Browse the repository at this point in the history
  • Loading branch information
BDonnot committed Jul 25, 2024
1 parent 6a2483f commit 1accc80
Show file tree
Hide file tree
Showing 32 changed files with 2,512 additions and 70 deletions.
1 change: 0 additions & 1 deletion lightsim2grid/_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ def f(cls):
setattr(_DoNotUseAnywherePandaPowerBackend, "_clear_grid_dependant_class_attributes", classmethod(f))



except ImportError as exc_:
# grid2op is not installed, we do not use it.
pass
19 changes: 17 additions & 2 deletions lightsim2grid/gridmodel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@
# SPDX-License-Identifier: MPL-2.0
# This file is part of LightSim2grid, LightSim2grid implements a c++ backend targeting the Grid2Op platform.

__all__ = ["init", "GridModel"]
__all__ = ["GridModel"]

from lightsim2grid_cpp import GridModel

try:
from lightsim2grid.gridmodel.from_pandapower import init as init_from_pandapower
__all__.append("init_from_pandapower")
except ImportError:
# pandapower is not installed
pass

try:
from lightsim2grid.gridmodel.from_pypowsybl import init as init_from_pypowsybl
__all__.append("init_from_pypowsybl")
except ImportError:
# pandapower is not installed
pass

from lightsim2grid.gridmodel.initGridModel import init, GridModel
11 changes: 11 additions & 0 deletions lightsim2grid/gridmodel/from_pandapower/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (c) 2024, RTE (https://www.rte-france.com)
# See AUTHORS.txt
# This Source Code Form is subject to the terms of the Mozilla Public License, version 2.0.
# If a copy of the Mozilla Public License, version 2.0 was not distributed with this file,
# you can obtain one at http://mozilla.org/MPL/2.0/.
# SPDX-License-Identifier: MPL-2.0
# This file is part of LightSim2grid, LightSim2grid implements a c++ backend targeting the Grid2Op platform.

__all__ = ["init"]

from lightsim2grid.gridmodel.from_pandapower.initGridModel import init
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,21 @@
Use the pandapower converter to properly initialize a GridModel c++ object.
"""

__all__ = ["init", "GridModel"]

import numpy as np
from numbers import Number
import warnings

import pandapower
import lightsim2grid
from lightsim2grid_cpp import GridModel, PandaPowerConverter
from lightsim2grid.gridmodel._aux_add_sgen import _aux_add_sgen
from lightsim2grid.gridmodel._aux_add_load import _aux_add_load
from lightsim2grid.gridmodel._aux_add_trafo import _aux_add_trafo
from lightsim2grid.gridmodel._aux_add_line import _aux_add_line
from lightsim2grid.gridmodel._aux_add_gen import _aux_add_gen
from lightsim2grid.gridmodel._aux_add_shunt import _aux_add_shunt
from lightsim2grid.gridmodel._aux_check_legit import _aux_check_legit
from lightsim2grid.gridmodel._aux_add_slack import _aux_add_slack
from lightsim2grid.gridmodel._aux_add_storage import _aux_add_storage
from lightsim2grid.gridmodel._aux_add_dc_line import _aux_add_dc_line
from ._aux_add_sgen import _aux_add_sgen
from ._aux_add_load import _aux_add_load
from ._aux_add_trafo import _aux_add_trafo
from ._aux_add_line import _aux_add_line
from ._aux_add_gen import _aux_add_gen
from ._aux_add_shunt import _aux_add_shunt
from ._aux_check_legit import _aux_check_legit
from ._aux_add_slack import _aux_add_slack
from ._aux_add_storage import _aux_add_storage
from ._aux_add_dc_line import _aux_add_dc_line


def init(pp_net: "pandapower.auxiliary.pandapowerNet") -> GridModel:
Expand Down
11 changes: 11 additions & 0 deletions lightsim2grid/gridmodel/from_pypowsybl/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (c) 2024, RTE (https://www.rte-france.com)
# See AUTHORS.txt
# This Source Code Form is subject to the terms of the Mozilla Public License, version 2.0.
# If a copy of the Mozilla Public License, version 2.0 was not distributed with this file,
# you can obtain one at http://mozilla.org/MPL/2.0/.
# SPDX-License-Identifier: MPL-2.0
# This file is part of LightSim2grid, LightSim2grid implements a c++ backend targeting the Grid2Op platform.

__all__ = ["init"]

from ._from_pypowsybl import init
File renamed without changes.
Loading

0 comments on commit 1accc80

Please sign in to comment.