SolverVariable

Class SolverVariable()

SolverVariable(parent='MODEL', name='SolverVariable_n', label='SolverVariable_n', 
active=True, use_ic=False, ic=0, is_implicit=False, static_hold=False, autobalance='Default', 
penalty=100, penalty1=100)

Creates a solver variable.

Keyword Arguments

Argument Data Type Description Default
name String The variable name. SolverVariable_n, for next available integer n.
label String The descriptive label. SolverVariable_n, for next available integer n.
parent Object The parent. MODEL
active Boolean Used to activate or deactivate this entity. True
use_ic Boolean Decides if initial conditions are not to be specified. False
ic Double Optional argument which gives the value of the solver variable at the time when the solver runs an initial conditions analysis.  
is_implicit Boolean This option is only valid in the MotionSolve solver mode. If this flag is set to True, the defined function is considered an implicit equation. The solver could impose a constraint to satisfy the equation based on the autobalance setting. False
static_hold Boolean This option is applicable if initial conditions are specified. This option is only applicable if implicit is True. False
autobalance Enum This option is used when implicit is set to true. One of "Default", "Unconditional", "Disabled", "Penalty". Default
penalty Double The value of penalty. This data works in conjunction with the autobalance option set to Penalty. 100
penalty1 Double The value of penalty1. This data works in conjunction with the autobalance option set to Penalty. 100
user Boolean Use user defined properties, if true. False
usr_sub Function The expression passed to the user dll. When using solver expressions, Templex syntax (within ``) is used and all variables are enclosed in braces {} and the rest is treated as literal. 'USER()'
local_funcname String The function/subroutine name. 'MOTSUB'
use_local_dll Bool Uses a local function instead of default if True. False
local_dll File The path of the local dll which has the local_funcname. ''
local_func_type Enum The type of the user subroutine. One of DLL, PYTHON or MATLAB. 'DLL'

Instances

value (Nonlinear) : The value or function expression describing the solver variable. This variable can be used to create algebraic based variables that can be used in additional function expressions.

Examples

   >>> # Import the mview module
   >>> from hw import mview
   >>> # Create a body and sphere for visual purpose
   >>> b1 = mview.Body(name = 'ball', inertia_props_from_graphic = True)
   >>> s1 = mview.Sphere(origin = 'P_Global_Origin', body = b1, radius = 5)
   >>> # Create a Bushing between the body and Ground
   >>> bush = mview.Bushing(b1 = b1, b2 = 'B_Ground', origin = 'P_Global_Origin')
   >>> # Create a SolverVariable for variable damping in the bushing
   >>> solvar = mview.SolverVariable(name = 'solvar',label = 'Variable damping')
   >>> # Change the type of value from linear to expression
   >>> solvar.value.type
   'LIN'
   >>> solvar.value.type = 'EXPR'
   >>> # Set the expression as the displacement of ball in Z direction
   >>> solvar.value.expr = '`DZ({ball.cm.idstring})`'
   >>> # Get the value to cross check the expression
   >>> solvar.value.expr
   'DZ(30102000)'
   >>> # Set the bushing Z direction damping as SolverVariable*0.1
   >>> bush.cz.type ='EXPR'
   >>> bush.cz.expr = '`{solvar.VARVAL}*0.1`'
   >>> # This will increase the damping as the displacement increases due to gravity