def _routine_import(self): """ Dynamically import routines as defined in ``routines/__init__.py``. The command-line argument ``--routine`` is defined in ``__cli__`` in each routine file. A routine instance will be stored in the system instance with the name being all lower case. For example, a routine for power flow study should be defined in ``routines/pflow.py`` where ``__cli__ = 'pflow'``. The class name for the routine should be ``Pflow``. The routine instance will be saved to ``PowerSystem.pflow``. Returns ------- None """ for file, cls_list in all_routines.items(): for cls_name in cls_list: file = importlib.import_module('andes.routines.' + file) the_class = getattr(file, cls_name) attr_name = cls_name self.__dict__[attr_name] = the_class( system=self, config=self._config_from_file) self.programs[attr_name] = self.__dict__[attr_name]
def import_routines(self): """ Import routines as defined in ``routines/__init__.py``. Routines will be stored as instances with the name as class names. All groups will be stored to dictionary ``System.groups``. Examples -------- ``System.PFlow`` is the power flow routine instance, and ``System.TDS`` and ``System.EIG`` are time-domain analysis and eigenvalue analysis routines, respectively. """ for file, cls_list in all_routines.items(): for cls_name in cls_list: file = importlib.import_module('andes.routines.' + file) the_class = getattr(file, cls_name) attr_name = cls_name self.__dict__[attr_name] = the_class( system=self, config=self._config_object) self.routines[attr_name] = self.__dict__[attr_name] self.routines[attr_name].config.check()