pyroll-project / pyroll-core

PyRoll rolling simulation framework - core library.
https://pyroll.readthedocs.io
BSD 3-Clause "New" or "Revised" License
11 stars 7 forks source link

Add Additional Init Functions to Init the Solution Procedure for Plugins #202

Closed axtimhaus closed 2 months ago

axtimhaus commented 2 months ago

A list holding special init functions which are called just after the classic init_solve method while initializing the procedure in solve.

Add your functions to this list using append. Each subclass holds its own instance. Functions of base classes are evaluated first, then those of subclasses.

def init_fun(self):
        self.test_var = 42

Unit.additional_inits.append(init_fun)
axtimhaus commented 2 months ago

Maybe provide the append process as decorator to feel similar to hook function definitions

@Unit.additional_init
def init_fun(self):
        self.test_var = 42