Python Kernel Control Methods
Kernel control methods enable the user to start/stop the kernel, to load/save documents, and to control the simulation.
The following kernel control methods are provided:
ifm.forceLicense()
Initializes the FEFLOW kernel with a certain license, e.g., ‘feflow:server=netlm’. The syntax is the same as for the FEFLOW command-line mode.
- Example 1: ifm.forceLicense('feflow:options=FMH3,feflow:model=floating')
- Example 2: license_info='server=geysir:1800,feflow:options=FM3,timeout=10,model=floating'
ifm.forceLicense(license_info)
- Example 3 for internet license: ifm.forceLicense('user=XXX,passwd=XXX,options=FMH3')
doc = ifm.loadDocument()
The loadDocument method tries to load the given FEFLOW model. The single argument is the full path to the document. The method returns the loaded document in case of success. Otherwise the method returns a boolean value isinstance(doc, bool) == true:
-
true: an internal error occurred (kernel not started, no license, file not found, …)
-
false: an external error occurred (no argument or argument not of type string)
FEFLOW can currently only handle one document (model or results file) at a time. Thus you have to make sure to close the previously loaded document before loading a new one. To copy or compare data between two models, you'll have to open the first file, then keep the data to copy/compare in memory, close the first file, and only then open the second file as shown in the code examples. |
doc.saveDocument()
Next to file name, the function support several arguments parsed through a Python list: file[, [list time-steps, version[, file format]]])
Saves the current document using the given file name. Optional a file version (e.g., 7000) and the file type (0: default, 1 = binary, 2 = ASCII) can be specified. For DAC files only an optional list of output time-steps can be defined. The method returns true if succeeded, otherwise false.
doc.startSimulator()
Starts the simulation of the current document or continues a paused simulation. Returns true if successful. Optionally, up to three arguments are supported:
-
filename to an output DAR or DAC file
-
File format to be stored: 0 = default, 1 = binary and 2 = ASCII.
-
Either a list of time-steps to for result output to DAC or the number of output steps to be skipped between outputs (single integer).
doc.pauseSimulator()
Pauses the current simulation. Returns true if successful. This method may throw an exception.
doc.stopSimulator()
Stops the current (running) simulation or terminates the simulation mode after simulation has completed. Returns true if successful. This method may throw an exception.
doc.getNumberOfTimeSteps()
Returns the number existing time steps (DAC only).
doc.getTimeSteps()
Returns the list of time-step tuples [ [index, time],… ] (DAC only).
doc.loadTimeStep(n)
Load time step t (DAC only) with n <= 0 < doc.getNumberOfTimeSteps(). Returns true if successful, otherwise false.
doc.submitPendingChanges()
Forces a rebuild of changed structures, e.g., Multilayer wells. Implicitly done and thus not required after changes done in a callback and before running a simulation or saving a file.
A complete list of kernel control methods and API functions can be retrieved by the Python command dir(ifm).