pyemsol API Reference#
This page documents the public API for users of the Python package pyemsol. Functions callable from Python are not listed here if they are reserved for internal integration with eMotorSolution or EMSOptimizer.
General Usage Rules#
Pass a JSON-compatible
dict/list/str/bool/int/float/Nonecomposed only of built-in Python types asinputJson. NumPy arrays, NumPy scalars, and tuples cannot be passed directly to this API.Running multiple analyses concurrently in the same process is not supported. Use separate processes for parallel parameter surveys.
Check the result of update APIs that return
bool. Always end iterative analyses withfinalize(), and end external step analyses withclose()or awithstatement.For input-data details, see Input Control Files.
Choosing an API#
Run an analysis once:
run(input_json, run_directory)Iterate while updating conditions:
initialize()→ update APIs →solve()→finalize()Supply values from an external system at each time:
with CoupledSession(...)→ repeatstep()
Single-Run and Iterative Analyses#
- run(inputJson, run_directory) dict#
Runs one analysis without changing the input and returns results equivalent to
output.jsonas adict. Do not combineinitialize(),solve(), orfinalize()before or afterrun().
- initialize(inputJson, run_directory) dict#
Initializes the internal state for iterative analysis and returns design element information when a design domain is present. After
initialize()succeeds, callfinalize()exactly once, including when an exception occurs.
- solve() dict#
Runs an analysis using the current initialized conditions and returns the results. It can be called repeatedly after update APIs.
- finalize() int#
Ends iterative analysis and releases internal resources. The current return value on normal completion is
0.
design_space = pyemsol.initialize(input_json, str(model_dir))
try:
# 必要に応じて入力を更新する
output = pyemsol.solve()
finally:
pyemsol.finalize()
Updates During Iterative Analysis#
- update_Time_Function(inputJson) bool#
Updates a Time Function based on an existing
TIME_IDin18_Time_Function. ReturnsFalsewhen the corresponding block is absent.
- update_properties_in_design_domain(inputJson) bool#
Updates
16_Material_Propertiesfor materials initialized as a design domain. Pass either the complete input JSON or a dictionary containing16_1_3D_Element_Properties.
External Mesh Morphing Integration#
The input/output specification and constraints for CoupledSession, static volume meshes, and coordinate payloads used with an external mesh morphing tool are described in External Mesh Morphing Integration. Check the schema version, coordinate system, and supported-model constraints before use.
Compatibility APIs for Existing Scripts#
The following module-level APIs are provided for existing code. Use CoupledSession in new code.
prepare_step_calculation(inputJson, run_directory) -> dictstep_calculation() -> intstep_calculation(time, delta_time, inputs={}, deformation=None) -> dictdescribe_coupling_ports() -> dictdescribe_deformation() -> dictdescribe_deformation_mesh() -> dictclose() -> dict
Information#
- version() dict#
Returns version information.