-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathexa_13_new_constr.py
75 lines (55 loc) · 1.87 KB
/
exa_13_new_constr.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 11 18:54:16 2015
@author: oliver
"""
import numpy as np
from sympy import symbols, sin
import mubosym as mbs
###############################################################
# general system setup example
myMBS = mbs.MBSworld('new_constraint', connect=True, force_db_setup=False)
#prepare a standard
I = [0.,0.,0.]
######################################
# choose
setup = 'one-dof'
setup = 'two-dof'
if setup == 'two-dof':
myMBS.add_marker('world_M1','world', 0.,0.,0., 0., 0.,0.)
myMBS.add_body_3d('b1','world_M1', 1.0, I, 'xy-plane', parameters = [])
myMBS.add_force_special('b1', 'grav')
x0 = np.hstack((1.,0.,0.,0.))
#
elif setup == 'one-dof':
myMBS.add_marker('world_M1','world', 0.,0.,0., 0., 0.,0.)
myMBS.add_body_3d('b1','world_M1', 1.0, I, 'rod-1-cardanic-efficient', parameters = [1,0,0.])
myMBS.add_force_special('b1', 'grav')
x0 = np.hstack(( np.pi/2. * np.ones(myMBS.dof), 0. * np.ones(myMBS.dof)))
else:
exit(0)
factor = 10.
R = myMBS.get_frame('world_M0')
x = R[0]
y = R[1]
z = R[2]
if setup == 'two-dof':
equ1 = x**2 + y**2 - 1
myMBS.add_geometric_constaint('b1', equ1, 'world_M0', factor)
#################################################
# constants
g = symbols('g')
constants = [ g ] # Parameter definitions
constants_vals = [9.81] # Numerical value
const_dict = dict(zip(constants, constants_vals))
myMBS.set_const_dict(const_dict)
myMBS.kaneify()
fixed_frames_in_graphics = ['world_M1']
frames_in_graphics = ['b1']
forces_in_graphics = ['b1']
myMBS.prep_lambdas(frames_in_graphics, fixed_frames_in_graphics, forces_in_graphics)
dt = 0.01 # 10 ms for a nice animation result
t_max = 10.
myMBS.inte_grate_full(x0, t_max, dt, mode = 0, tolerance = 1e+0)
myMBS.prepare(mbs.DATA_PATH, save=True)
myMBS.animate(t_max, dt, scale = 4, time_scale = 0.5, t_ani = 10.)