fmm module

Python wrapper for the Fedem Mechanism Model database library. Used for convenience in order to hide native type convertions.

class fmm.FedemModel(lib_path, plugin1=None, plugin2=None)[source]

Bases: object

This class wraps the Fedem model file handling functionality.

Parameters:
lib_pathstr

Absolute path to the Fedem model database shared object library

plugin1str, default=None

Absolute path to user-defined element plugin (optional)

plugin2str, default=None

Absolute path to user-defined function plugin (optional)

Methods

fm_open:

Opens the specified Fedem model file

fm_save:

Saves current model with updated results to file

fm_new:

Initializes an empty model

fm_close:

Closes current model

fm_count:

Counts mechanism objects of specified type

fm_get_objects:

Returns a list of base Ids for all objects of specified type

fm_tag_object:

Tags the specified object(s) in the model

fm_get_pos:

Returns the global position of the specified object

fm_get_node:

Returns the FE node number matching a spatial point

fm_sync_part:

Syncronizes an FE part with content on disk

fm_write_reducer:

Writes reducer input files for an FE part

fm_write_solver:

Writes solver input files

fm_solver_setup:

Defines some basis solver setup parameters

fm_solver_tol:

Defines the solver convergence tolerances

def fm_get_func_tag:

Returns the tag of an indexed external function

fm_close(remove_singletons=False)[source]

This method closes the currently open Fedem model to clean up memory.

Parameters:
remove_singletonsbool, default=False

If True, heap-allocated singelton objects are also released

Returns:
bool

Always True

fm_count(object_type=FmType.ALL)[source]

This method returns the number of objects of the given type.

Parameters:
object_typeFmType, default=ALL

Enum value identifying which object type to count the instances of

Returns:
int

Number of instances of the indicated object type

fm_get_func_tag(channel)[source]

This method returns the tag of an indexed external function.

Parameters:
channelint

Channel index of the external function

Returns:
str

The tag of the function, None if channel is out of range

fm_get_node(part_id, pos)[source]

This method returns the FE node number matching a spatial point.

Parameters:
part_idint

Base Id or tag of the FE part that the node belongs to

pos(float, float, float)

X-, Y-, and Z-coordinate of the node

Returns:
int

Node Id

fm_get_objects(object_type=FmType.ALL, tag=None)[source]

This method returns the base Id of all objects of the given type, and/or those with the specified tag.

Parameters:
object_typeFmType, default=ALL

Enum value identifying which object type to return base Id of

tagstr or list of str, default=None

Return objects having this tag only, unless None

Returns:
list

Base Id list of all instances in the model of the specified type

fm_get_pos(object_id)[source]

This method returns the global position of the specified object.

Parameters:
object_idint or str

Base Id or tag of the object to return the position for

Returns:
(float, float, float)

Global X-, Y-, and Z-coordinate

fm_new(fname=None)[source]

This method initializes an empty Fedem model.

Parameters:
fnamestr, default=None

Absolute path to the fmm-file to write to on next save. If not given, the name “untitled.fmm” will be used.

Returns:
bool

Always True

fm_open(fname)[source]

This method opens the specified Fedem model file and reads its content into the internal datastructure.

Parameters:
fnamestr

Absolute path to the fmm-file to read

Returns:
bool

True on success, otherwise False

fm_save(fname=None)[source]

This method saves the currently open Fedem model such that the model file is updated to reflect the current results data found on disk.

Parameters:
fnamestr, default=None

Absolute path to the fmm-file to write to. If not given, the current model file as specified by the last call to fm_open() or fm_new() is overwritten.

Returns:
bool

True on success, otherwise False

fm_solver_setup(t_start=0.0, t_end=1.0, t_inc=0.01, t_quasi=0.0, n_modes=0, e_inc=0.0, add_opt=None)[source]

This method (re)defines some basis solver setup parameters.

Parameters:
t_startfloat, default=0

Start time

t_endfloat, default=1

Stop time

t_incfloat, default=0.01

Time step size

t_quasifloat, default=0

Stop time for quasi-static simulation. If equal to t_start, also perform initial equilibrium analysis before starting the time stepping.

n_modesint, default=0

If non-zero, perform eigenvalue analysis during the simulation, and calculate this number of modes each time

e_incfloat, default=0

Time between each eigenvalue analysis

add_optstr, default=None

Additional solver options

fm_solver_tol(tol_ene=-1.0, tol_dis=-1.0, tol_vel=-1.0, tol_res=-1.0)[source]

This method (re)defines the solver convergence tolerances.

Parameters:
tol_enefloat, default=-1.0

Energy norm tolerance

tol_disfloat, default=-1.0

Displacement norm tolerance

tol_velfloat, default=-1.0

Velocity norm tolerance

tol_resfloat, default=-1.0

Residual force norm tolerance

fm_sync_part(base_id)[source]

This method syncronizes the currently open Fedem model with contents on disk for the specified FE part. It is typically used after the reduction process for an FE part is finished.

Parameters:
base_idint

Base Id of the FE part to syncronize the model and disk content for

Returns:
bool

True on success, otherwise (e.g., if base_id is invalid) False

fm_tag_object(base_id, tag)[source]

This method tags the specified object(s) identified by the base Id.

Parameters:
base_idint or list of int

Base Id of the object(s) to tag

tagstr

The tag to assign

Returns:
int

Number of tagged objects

fm_write_reducer(base_id)[source]

This method writes reducer input files for the specified FE part, unless that part is already reduced.

Parameters:
base_idint

Base Id of the FE part to generate reducer input files for

Returns:
str

Absolute path to the working directory of the reduction process

fm_write_solver(keep_old_res=False, ude=None, udf=None)[source]

This method writes solver input files for the currently loaded model.

Parameters:
keep_old_resbool, default=False

Option to not overwrite any existing res-file in the RDB directory

udestr, default=None

Absolute path to user-defined element plugin (optional)

udfstr, default=None

Absolute path to user-defined function plugin (optional)

Returns:
str

Absolute path to the working directory of the solver process