solve.py¶
-
jcmwave.
solve
(project_file, keys=None, mode='solve', process_keys=None, return_results=True, table_format='named', cartesianfields_format='squeeze', logfile=None, working_dir=None, project_suffix=None, temporary=False, cache_finished_jobs=True, resultbag=None, jcmt_pattern=None, resources=[])¶ Starts JCMsolve.
Parameters: - project_file (filepath) – path name of a JCMwave project or post-process file.
- keys (dictionary) – parameter (nested) dictionary for embedded script input file. When keys is present, the embedded script files
materials.jcmt
,sources.jcmt
,boundary_conditions.jcmt
and<project>.jcmpt
are processed to generate the actual .jcm input files by call of jcmwave.jcmt2jcm(<jcmt-file>, keys). Additionally, thejcmwave.geo(<project_dir>, keys)
is called to automatically update the grid file. - mode (str) –
sets the solver mode
The possible modes are
’version’prints version tag, needs no project_file’solve’
starts JCMsolve’post_process’
starts JCMsolve to execute post-processes’license_info’
prints license information - return_results (boolean) – If set to
True
, the function returns a list of references to the computed data. - table_format (str) – table format option when loading table result files, cf. section ‘Output’ below.
table_format
is equivalent to theformat
option ofjcmwave.loadtable()
. - cartesianfields_format (str) – format option when loading a cartesian fieldbag.
cartesianfields_format
is equivalent to theformat
option ofjcmwave.loadcartesianfields()
, but with a further allowed valuefilepath
, for which the filepath of the cartesian field bag file is returned only. - logfile (filepath) –
redirects console output to a file. logfile must be
- a string refering to a file path to which the output is piped
- a valid file descriptor
- working_dir (dirpath) – copies .jcm files into working directory, runs solver therein.
- project_suffix (str) – add suffix to project file name, e.g. project.jcmp -> project.<suffix>.jcmp
- temporary (boolean) – project runs in a temporary directory (excludes working_dir)
- cache_finished_jobs (boolean) – In daemon mode finished jobs with temporary data storage are cached and temporary disk storage is freed (default: True).
- jcmt_pattern (str) – pattern for selection of .jcmt files. For example, sources.<pattern>.jcmt is used instead of sources.jcmt when present.
- resultbag (Resultbag) –
An instance of the class
jcmwave.Resultbag
.jcmwave.solve
uses the result bag to check whether the result with the keys parameter was already computed. If not it adds the new result to the result bag. In daemon modejcmwave.daemon.wait`()
has to be called with the resultbag parameter in order for the result to be added to the result bag. If the result is already stored in the result bag the daemon is not triggered. The resultbag can be created by callingmy_resultbag = jcmwave.Resultbag(‘filname.rbg’, [keys])Results for a specific keys-structure can be retrieved by calling
result = my_resultbag.get_result(keys)Logs for a specific keys-structure can be retrieved by calling
log = my_resultbag.get_log(keys) - resources (default []) (list) – list of resource identifiers which can be used for this job. This option is only used in daemon mode
Returns: When return_results==False no output is returned. Otherwise the output is a list containing references to the computed data.
When called with mode solve,
results[0]
refers to the solution. It is a dictionary with the fields’file’
file path to the solution fieldbag (if pressent)
’computational_costs’
jcm table with computation costs statistics
’eigenvalues’
eigenvalue table (only for eigenvalue problems)
results[1], ... results[nPost]
refer to the results of the post processes in the same order as they appear in the project file. For mode post_process, the results list refers to the performed post-process only.For any postprocess, each entry
results[i]
is a dictionary of the shape as loaded by loadtable (for tables), or loadcartesianfields (for Cartesian fieldbags).