modeler module

Python wrapper for the native fedem modeler.

This module provides functionality for creating new Fedem models, and for modifying existing ones.

class modeler.FedemModeler(model_file=None, force_new=False, plugins=None)[source]

Bases: FedemModel

This subclass of fmm.FedemModel adds some basic modeling methods.

Parameters:
model_filestr, default=None

Absolute path to the fedem model file to open

force_newbool, default=False

If True, any existing model will be overwritten on save

pluginsstr or list of str, default=None

Plugin libraries with user-defined elements and functions

Methods

open:

Opens the specified model file

save:

Saves current model into the specified model file

close:

Closes the currently open model

make_triad:

Creates a triad at specified location or node

make_beam:

Creates a string of beam elements

make_beam_section:

Creates a beam cross section property object

make_beam_material:

Creates a material property object

make_spring:

Creates a spring element

make_damper:

Creates a damper element

make_joint:

Creates a joint object

make_load:

Creates an external load object

make_function:

Creates a general function object

make_sensor:

Creates a sensor object

make_fe_part:

Creates an FE part

make_strain_rosette:

Creates a strain rosette on an FE part

make_udelm:

Creates a string of user-defined elements

edit_triad:

Modifies an existing triad

edit_part:

Modifies an existing FE part

edit_joint:

Modifies an existing joint

edit_function:

Modifies an existing function

solver_setup:

Setting dynamics solver parameters

close(save=False, remove_singletons=False)[source]

Closes the currently open model.

Parameters:
savebool, default=False

If True, the model file is updated with the current model

remove_singletonsbool, default=False

If True, heap-allocated singelton objects are also released

Returns:
bool

True on success, otherwise False

edit_function(func_id, obj, var=None, dof=None)[source]

Modifies an existing function by changing its argument.

Parameters:
func_idint

User Id (or base Id, if negative) of the function to modify

objint or str or (int, int) or (str, str)

Base Id or tag of object(s) producing the response quantity to use

varFmVar, default=None=0

Response quantity to use as function argument

dofFmDof, default=None=0

Which component of var to be used if a multi-DOF quantity

Returns:
bool

True if the input is valid, otherwise False

edit_joint(obj_id, **kwargs)[source]

Modifies an existing joint.

Parameters:
obj_idint or str or list of int or list of str

Base Id or tag of the joint(s) to modify

kwargsdict

Keyword arguments containing the new joint attributes to assign. Currently, the following keywords are recognized:

  • Tx, Ty, Tz : Translation offset in global X, Y, and Z-direction

  • Rx, Ry, Rz : Euler angles (in degrees) for rotating the joint

  • tra_ref : Base Id of object used as translation reference

  • rot_ref : Base Id of object used as rotation reference

  • constraints : Dictionary with keywords for constraing DOFs, i.e., constraints={"Tx" : <value>, ..., "Rz" : <value>}, where <value> can be any of the enum values enums.FmDofStat. Only the DOFs that should be changed need to be specified. You can also use “All” as key which implies all DOFs in the joint.

  • init_vel : Dictionary with keywords specifying initial velocities, i.e., init_vel={"Tx" : <u01>, ..., "Rz" : <u06>}, where <u0i> is the initial velocity to be assigned local dof i.

  • load : Dictionary with keywords specifying constant DOF loads, i.e., load={"Tx" : <f1>, ..., "Rz" : <f6>}, where <fi> is the user Id of a general function defining the load in local dof i if the type is int, otherwise it is taken as the constant load to be assigned local dof i.

  • motion : Dictionary with keywords specifying prescribed motions, i.e., motion={"Tx" : <u1>, ..., "Rz" : <u6>}, where <ui> is the user Id of a general function defining the motion in local dof i if the type is int, otherwise it is taken as the constant motion to be prescribed in local dof i.

  • spring : Dictionary with keywords specifying spring stiffnesses, i.e., spring={"Tx" : <k1>, ..., "Rz" : <k6>}, where <ki> is the constant stiffness to be assigned local dof i.

  • damper : Dictionary with keywords specifying damping coefficients, i.e., load={"Tx" : <c1>, ..., "Rz" : <c6>}, where <ci> is the constant damping to be assigned local dof i.

  • length : Dictionary with keywords specifying stress-free lengths, i.e., length={"Tx" : <l1>, ..., "Rz" : <l6>}, where <li> is the user Id of a general function defining the stress-free length in local dof i.

Returns:
bool

True if the input is valid, otherwise False

edit_part(obj_id, **kwargs)[source]

Modifies an existing FE part.

Parameters:
obj_idint or str or list of int or list of str

Base Id or tag of the part(s) to modify

kwargsdict

Keyword arguments containing the new part attributes to assign. Currently, the following keywords are recognized:

  • Tx, Ty, Tz : Translation offset in global X, Y, and Z-direction

  • Rx, Ry, Rz : Euler angles (in degrees) for rotating the Part

  • tra_ref : Base Id of object used as translation reference

  • rot_ref : Base Id of object used as rotation reference

  • alpha1 : Mass-proportional damping coefficient

  • alpha2 : Stiffness-proportional damping coefficient

  • component_modes : Number of component modes

  • consistent_mass : If True, use consistent mass (lumped is default)

  • recovery : Flag for activating FE part recovery during solve (0=off, 1=stress recovery, 2=strain gage recovery, 3=both)

Returns:
bool

True if the input is valid, otherwise False

edit_triad(obj_id, **kwargs)[source]

Modifies an existing triad.

Parameters:
obj_idint or str or list of int or list of str

Base Id or tag of the triad(s) to modify

kwargsdict

Keyword arguments containing the new triad attributes to assign. Currently, the following keywords are recognized:

  • Tx, Ty, Tz : Translation offset in global X, Y, and Z-direction

  • Rx, Ry, Rz : Euler angles (in degrees) for rotating the Triad

  • tra_ref : Base Id of object used as translation reference

  • rot_ref : Base Id of object used as rotation reference

  • mass : Additional mass (and inertia) on the Triad

  • mass_func : User Id or base Id (if negative) of mass scaling function

  • constraints : Dictionary with keywords for constraing DOFs, i.e., constraints={"Tx" : <value>, ..., "Rz" : <value>}, where <value> can be any of the enum values enums.FmDofStat. Only the DOFs that should be changed need to be specified. You can also use “All” as key which implies all DOFs in the triad.

  • init_vel : Dictionary with keywords specifying initial velocities, i.e., init_vel={"Tx" : <u01>, ..., "Rz" : <u06>}, where <u0i> is the initial velocity to be assigned local dof i.

  • load : Dictionary with keywords specifying constant DOF loads, i.e., load={"Tx" : <f1>, ..., "Rz" : <f6>}, where <fi> is the user Id of a general function defining the load in local dof i if the type is int, otherwise it is taken as the constant load to be assigned local dof i.

  • motion : Dictionary with keywords specifying prescribed motions, i.e., motion={"Tx" : <u1>, ..., "Rz" : <u6>}, where <ui> is the user Id of a general function defining the motion in local dof i if the type is int, otherwise it is taken as the constant motion to be prescribed in local dof i.

Returns:
bool

True if the input is valid, otherwise False

make_assembly(name, objs=None)[source]

Creates a sub-assembly and moves the specified objects into it.

Parameters:
namestr

Description of the new sub-assembly

objslist of int or str or list of str, default=None

List of base Ids or tags of the objects to put into the new sub-assembly

Returns:
int

Base Id of the created sub-assembly

make_beam(name, triads, bprop=None, tag=None)[source]

Creates a string of beam elements.

Parameters:
namestr

Description of the new beam(s)

triadslist of int or list of str

List of base Ids or tags of the connected triads

bpropint or str, default=None

Base Id or tag of beam property to use

tagstr, default=None

Tag to associate the created beam(s) with

Returns:
list of int

Base Ids of the created beams, None if error

make_beam_material(name, mprops, tag=None)[source]

Creates a material property object.

Parameters:
namestr

Description of the new material property

mproplist of float

List of property data

tagstr, default=None

Tag to associate the created material property with

Returns:
int

Base Id of material property object, zero or negative on error

make_beam_section(name, mat, bprops, tag=None)[source]

Creates a beam cross section property object.

Parameters:
namestr

Description of the new beam property

matint or str

Cross section type flag. If zero, a Generic cross section is defined. If str or a non-zero int, a Pipe cross section is defined, and the value gives the tag or base Id of the material to use.

bproplist of float

List of property data

tagstr, default=None

Tag to associate the created beam property with

Returns:
int

Base Id of beam property object, zero or negative on error

make_damper(name, triads, **kwargs)[source]

Creates axial damper elements.

Parameters:
namestr

Description of the new damper(s)

triads(str, str) or (int, int) or list of (int, int)

Tags or base Ids of the connected triads. If a list of tuples is specified, one damper is created for each tuple.

kwargsdict

Keyword arguments defining the damper properties. The following keywords are currently supported:

  • tag : Tag to associate the created damper(s) with

  • def_vel_damper: If True, use deformational velocity

  • init_Damp_Coeff: Constant damping coefficient

  • fn: Base Id of damping coefficient function

  • xy: List of XY-pairs giving a piece-wise linear damping coefficient

  • extrapol_type: String, either “NONE” (default), “FLAT” or “LINEAR”

  • damp_characteristics: String, either “DA_TRA_COEFF” (default) or “DA_TRA_FORCE”

Returns:
int or list of int

Base Id(s) of the created damper(s), None if an error occurs

make_fe_part(file, name=None, tag=None)[source]

Creates an FE part.

Parameters:
filestr

Absolute path to the FE data file

namestr, default=None

Description of the new part, use file basename if not specified

tagstr, default=None

Tag to associate the created part with

Returns:
int

Base Id of the FE part object, zero or negative on error

make_function(name, **kwargs)[source]

Creates a general function of time.

The type of function to be created is determined by which keyword arguments are provided. The keyword determining the function type is below marked by an asterix (*) in each case.

Parameters:
namestr

Description of the new function

kwargsdict

Keyword arguments depending on function type. The following function types and keywords are currently supported:

  1. Polyline

xy*: List of XY-pairs giving a piece-wise linear curve
extrapol_type: String, either “NONE” (default), “FLAT” or “LINEAR”
  1. Polyline-from-file

filename*: Name of file containing XY-pairs
ch_name: String identifying the column to use for multi-column files
sc_factor: Scaling factor, default=1.0
z_adjust: If True, the y-values are shifted such that the first value is zero, default=False
v_shift: Additional shift of the y-values, default=0.0
  1. Sine

frequency*: Angular frequency
amplitude: Scaling factor, default=1.0
delay: Phase shift, default=0.0
mean_value: Constant shift, default=0.0
end: Default=0.0, if greater than zero, the function value is constant for x greater than end

The Sine function therefore evaluates to:

f(x) = amplitude*sin(frequency*x-delay) + mean_value

for x-values less than end, whereas f(x) = f(end) for x greater than end.

  1. Constant

value*: The constant function value, i.e., f(x) = value for any x
  1. Linear

slope*: The scaling factor, i.e., f(x) = slope*x
  1. Ramp

start_ramp*: Start point of sloped function domain
start_val: Function value before start_ramp, default=0.0
slope: The scaling factor, default=1.0

The Ramp function therefore evaluates to:

f(x) = start_val + slope*(x-start_ramp)
for x-values greater than start_ramp, whereas
f(x) = start_val for x less than or equal to start_ramp.
  1. Limited Ramp

start_ramp: Start point of sloped function domain, default=0.0
end_ramp*: End point of sloped function domain
start_val: Function value before start_ramp, default=0.0
slope: The scaling factor, default=1.0

The Limited Ramp function therefore evaluates to:

f(x) = start_val + slope*(x-start_ramp)
for x-values in the range [start_ramp, end_ramp]
whereas f(x) = start_val for x less than start_ramp,
and f(x) = f(end_ramp) for x greater than end_ramp.
  1. Math expression

expression*: String containing the expression to use
  1. External function

No keywords

In addition, the tag keyword is accepted for all function types, to associate a specified tag with the created function, and the base_id keyword is used to indicate if the base Id of the created function should be returned, instead of the default user Id.

Returns:
int

User Id or base Id of created function object. Will be 0 or negative if an error occurs.

make_joint(name, joint_type, follower, followed=None, tag=None)[source]

Creates a joint object.

Parameters:
namestr

Description of the new joint

joint_typeFmType

Type of joint

followerint or str

Base Id or tag of the dependent joint triad

followedint or str or list of int, default=None

Base Id or tag of the independent joint triad(s). If None, the joint is connected to ground and the independent triad is created at the same location as the dependent triad. For point-to-path joints, the first two triads specified are taken as the end points of the glider.

tagstr, default=None

Tag to associate the created joint with

Returns:
int

Base Id of joint object, zero or negative on error

make_load(name, load_type, triad, load_dir, magnitude=None, fn=0, tag=None)[source]

Creates an external load object.

Parameters:
namestr

Description of the new load

load_typeFmLoadType

Type of load

triadint or str

Base Id or tag of triad where the load attacks

load_dir(float, float, float)

Load direction vector

magnitudestr, default=None

Load magnitude expression

fnint, default=0

User Id of load magnitude function

tagstr, default=None

Tag to associate the created load with

Returns:
int

Base Id of load object, zero or negative on error

make_sensor(name, obj, var, dof=None, tag=None)[source]

Creates a sensor object.

Parameters:
namestr

Description of the new sensor

objint or str or (int, int) or (str, str)

Base Id or tag of object(s) to measure

varFmVar

The variable to measure

dofFmDof, default=None

Local DOF to measure if var is a multi-DOF quantity

tagstr, default=None

Tag to associate the created sensor with

Returns:
int

User Id of sensor object, zero or negative on error

make_spring(name, triads, **kwargs)[source]

Creates axial spring elements.

Parameters:
namestr

Description of the new spring(s)

triads(str, str) or (int, int) or list of (int, int)

Tags or base Ids of the connected triads. If a list of tuples is specified, one spring is created for each tuple.

tagstr, default=None

Tag to associate the created beam(s) with

kwargsdict

Keyword arguments defining the spring properties. The following keywords are currently supported:

  • tag : Tag to associate the created spring(s) with

  • constDefl: Constant stress free deflection

  • constLength: Constant stress free length

  • length: User Id of general function defining stress free length

  • init_Stiff_Coeff: Constant spring stiffness coefficient

  • fn: Base Id of spring stiffness function

  • xy: List of XY-pairs giving a piece-wise linear spring stiffness

  • extrapol_type: String, either “NONE” (default), “FLAT” or “LINEAR”

  • spring_characteristics: String, either “SPR_TRA_STIFF” (default) or “SPR_TRA_FORCE”

Returns:
int or list of int

Base Id(s) of the created spring(s), None if an error occurs

make_strain_rosette(name, part_id, **kwargs)[source]

Creates a strain rosette on an FE part.

Parameters:
namestr

Description of the new strain rosette

part_idint or str

Base Id or tag of FE part on which the rosette will be created

kwargsdict

Keyword arguments defining the strain rosette properties. The following keywords are recognized:

  • tag : Tag to associate the created strain rosette with

  • nodes: List of nodes to connect the strain rosette to

  • pos: List of connection point coordinates, on the format [(x1,y1,z1), (x2,y2,z2), (x3,y3,z3), (x4,y4,z4)]. The last tuple is skipped if a 3-noded rosette is desired.

  • direction: Tuple (x,y,z) defining the local X-axis direction vector of the strain rosette

  • angle : Angle between strain gage direction and local X-axis

  • start_at_zero : If True, the start strains are set to zero

Returns:
int

Base Id of the strain rosette, zero or negative on error

make_triad(name, pos=None, rot=None, node=0, on_part=0, tag=None)[source]

Creates a new triad at specified location or nodal point.

Parameters:
namestr

Description of the new triad

pos(float, float, float)

Global XYZ-coordinates of new triad

rot(float, float, float), default=None

Global Euler angles giving the orientation of new triad

nodeint, default=0

FE node number to associate the triad with. Used only if on_part is specified.

on_partint or str, default=0

Base Id or tag of the part that this triad should be attached to. You can also specify the Reference plane here, to create a new triad that is attached to ground.

tagstr, default=None

Tag to associate the created triad with

Returns:
int

Base Id of new triad, zero or negative on error

make_udelm(name, triads, **kwargs)[source]

Creates a string of 2-noded user-defined elements.

Parameters:
namestr

Description of the new element(s)

triadslist of int or list of str

List of base Ids or tags of the connected triads

kwargsdict

Keyword arguments defining some element properties. Currently, the following keywords are recognized:

  • alpha1 : Mass-proportional damping coefficient

  • alpha2 : Stiffness-proportional damping coefficient

  • tag : Tag to associate the created element with

Returns:
list of int

Base Ids of the created elements, None if error

open(model_file)[source]

Opens the specified model file and prints out some key model parameters.

Parameters:
model_filestr

Absolute path of the Fedem model file to open

Returns:
bool

True on success, otherwise False

save(model_file=None)[source]

Saves current model into the specified model file.

If no model_file is given, that last opened model file is overwritten.

Parameters:
model_filestr, default=None

Absolute path of the Fedem model file to save to

Returns:
bool

True on success, otherwise False

solver_setup(**kwargs)[source]

Setting up solver parameters, t_quasi, t_inc and t_end. Switching off initial equilibrium by setting t_quasi negative.

Parameters:
kwargsdict

Keyword arguments containing the solver settings to assign. Currently, the following keywords are recognized:

  • t_start : Start time

  • t_end : Stop time

  • t_inc : Time step size

  • t_quasiStop time for quasi-static simulation.

    If equal to t_start, perform initial equilibrium analysis before starting the dynamics time integration.

  • n_modesIf non-zero, perform eigenvalue analysis during the simulation,

    and calculate this number of modes each time

  • e_inc: Time between each eigenvalue analysis

  • add_opt: Additional solver options

  • tol_ene: Convergence tolerance in energy norm

  • tol_dis: Convergence tolerance in displacement norm

  • tol_vel: Convergence tolerance in velocity norm

  • tol_res: Convergence tolerance in force residual norm