Callbacks
- class ifm.callbacks
Callback functions can be reimplemented to inject custom code into the model that is executed at spectific points in FEFLOWs simulation sequence.
Notes
The Python API supports only a subset of the Callbacks available in the C++ API.
- getTensor(doc, time)
getTensor is called by FEFLOW if the option “General Anisotropy Defined By Tensor Expression” is active (Problem Settings > Anisotropy Setting) to obtain the K-Tensor definition.
It is usually set in the Anisotropy Settings in the FEFLOW GUI (“Edit Python Expression…”).
- Parameters:
doc (ifm.FeflowDoc) – the calling FEFLOW model
time (float) – The current absolute simuation time [days]
- Returns:
Must return the hydraulic conductivity Tensor as a NxN array (nested lists), where N is the number of dimensions: [[Kxx, Kxy, Kxz], [Kyx, Kyy, Kzz], [Kzx, Kzy, Kzz]]
- Return type:
[[int]]
Examples
>>> def getTensors(doc, time): >>> return [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
- onTimeStepConstraint(doc, current_time, proposed_time_step_length)
onTimeStepConstraint is called when the simulator determines the next time step. The current time as well as the proposed length of the time step are passed to this callback function. The proposed interval can be reduced due to the needs of the plug-in (adjusting to power function points, etc.). If the proposed interval is increased, a warning will appear.
- Parameters:
doc (ifm.FeflowDoc) – the calling FEFLOW model
current_time (float) – current absolute simulation time
proposed_time_step_length (float) – time step length proposed by the predictor
- Returns:
Must return a float value with the (new) time step length!
- Return type:
float
Examples
>>> def onTimeStepConstraint(doc, current_time, proposed_time_step_length): >>> >>> # choose a fixed time step for a specified time period >>> if current_time >= 38990 and current_time <= 39000: >>> proposed_time_step_length = 0.01 >>> >>> return proposed_time_step_length
- postEnterSimulator(doc)
PostEnterSimulator is called immediately after the simulator has been started. Remind the difference to PreSimulation! Use the callback to raise graphical elements related to the simulation process (e.g. diagrams). You should implement OnLeaveSimulator also to hide the raised elements.
- Parameters:
doc (ifm.FeflowDoc) – the calling FEFLOW model
- postFlowSimulation(doc, phase)
PostFlowSimulation is called immediately after solving the flow equations and allows the implementation of own functionality for properties and actions related to the flow problem after it has been solved.
- Parameters:
doc (ifm.FeflowDoc) – the calling FEFLOW model
- postHeatSimulation(doc, energy)
PostHeatSimulation is called immediately after solving the heat transport equations and allows the implementation of own functionality for properties and actions related to the heat transport problem after it has been solved.
- Parameters:
doc (ifm.FeflowDoc) – the calling FEFLOW model
energy (int) – reserved for future use
- postLoadDocument(doc, filename, filetype, filemode, fileversion)
PostLoadDocument is called after loading the current FEM problem including all IFM plug-ins.
- Parameters:
doc (ifm.FeflowDoc) – the calling FEFLOW model
filename (str) – the original filename of the document loaded
filetype ({1|2|3}) –
type of file:
1 = Supermesh file 2 = FEM problem file 3 = DAC results file
filemode ({1|2|4|16}) –
the file mode
1 = binary 2 = ASCII 4 = DEMO data format (DHI use only) 16 = binary with encryption 32 = XML interchange format
fileversion (int) – current or target file version in decimal format, e.g., 7302 for FEFLOW 7.3 update 2 format.
- postLoadTimeStep(doc, loaded_step_number, simulation_time)
postLoadTimeStep is called after loading a time step in a FEFLOW results (dac) file.
- Parameters:
doc (ifm.FeflowDoc) – the calling FEFLOW model
loaded_step_number (int) – number of the time step loaded
simulation_time (float) – absolute simulation time of the time step loaded.
- postMassSimulation(doc, species)
PostMassSimulation is called immediately after solving the mass transport equations and allows the implementation of own functionality for properties and actions related to the mass transport problem after it has been solved. The current species index is passed through the species argument.
- Parameters:
doc (ifm.FeflowDoc) – the calling FEFLOW model
species (int) – the index of the species being processes (multi-species ID)
- postSaveDocument(doc, filename, filetype, filemode, fileversion)
PostSaveDocument is called after saving the current FEM problem including all IFM plug-ins.
- Parameters:
doc (ifm.FeflowDoc) – the calling FEFLOW model
filename (str) – the original filename of the document loaded
filetype ({1|2|3}) –
type of file:
1 = Supermesh file 2 = FEM problem file 3 = DAC results file
filemode ({1|2|4|16}) –
the file mode
1 = binary 2= ASCII 4 = DEMO data format (DHI use only) 16 = binary with encryption 32 = XML interchange format
fileversion (int) – current or target file version in decimal format, e.g., 73002 for FEFLOW 7.3 update 2 format.
- postSimulation(doc, phase)
PostSimulation is called after running the simulation time loop and allows the implementation of own postprocessing functionality or freeing of memory which has been additionally allocated during the plug-in run.
- Parameters:
doc (ifm.FeflowDoc) – the calling FEFLOW model
phase (int) – reserved for future use.
- postTimeStep(doc)
PostTimeStep is called at the end of a current time step and allows the implementation of own functionality for updating time-related properties and user-specific actions.
- Parameters:
doc (ifm.FeflowDoc) – the calling FEFLOW model
- preEnterSimulator(doc)
PreEnterSimulator is called immediately before the simulator is going to be started. Remind the difference to PreSimulation! Use the callback to raise graphical elements related to the simulation process (e.g. diagrams). You should implement OnLeaveSimulator also to hide the raised elements.
- Parameters:
doc (ifm.FeflowDoc) – the calling FEFLOW model
- preFlowSimulation(doc, phase)
PreFlowSimulation is called immediately before solving the flow equations and allows the implementation of own functionality for properties and actions related to the flow problem before it becomes solved.
- Parameters:
doc (ifm.FeflowDoc) – the calling FEFLOW model
phase (int) – for future use only
- preHeatSimulation(doc, energy)
PreHeatSimulation is called immediately before solving the heat transport equations and allows the implementation of own functionality for properties and actions related to the heat transport problem before it becomes solved.
- Parameters:
doc (ifm.FeflowDoc) – the calling FEFLOW model
energy (int) – reserved for future use
- preMassSimulation(doc, species)
PreMassSimulation is called immediately before solving the mass transport equations and allows the implementation of own functionality for properties and actions related to the mass transport problem before it becomes solved. The current species index is passed through the species argument.
- Parameters:
doc (ifm.FeflowDoc) – the calling FEFLOW model
species (int) – the index of the species being processes (multi-species ID)
- preSaveDocument(doc, filename, filetype, filemode, fileversion)
PreSaveDocument is called just before the current FEM problem is going to be saved.
- Parameters:
doc (ifm.FeflowDoc) – the calling FEFLOW model
filename (str) – the original filename of the document loaded
filetype ({1|2|3}) –
type of file:
1 = Supermesh file 2 = FEM problem file 3 = DAC results file
filemode ({1|2|4|16}) –
the file mode
1 = binary 2= ASCII 4 = DEMO data format (DHI use only) 16 = binary with encryption 32 = XML interchange format
fileversion (int) – current or target file version in decimal format, e.g., 73002 for FEFLOW 7.3 update 2 format.
- preSimulation(doc, phase)
PreSimulation is called before running the simulation time loop and allows the implementation of own preprocessing functionality or allocation of additional memory needed for the plug-in.
- Parameters:
doc (ifm.FeflowDoc) – the calling FEFLOW model
phase (int) – reserved for future use.
- preTimeStep(doc)
PreTimeStep is called at beginning of each time step and allows the implementation of own functionality for updating time-related properties and user-specific actions
- Parameters:
doc (ifm.FeflowDoc) – the calling FEFLOW model