In [1]:
from sympy import symbols, Rational as rat, Eq, latex
%load_ext sympyprinting
from IPython.core.display import Image, display, Math, Latex
m, k, p, L, u, a, delta = symbols('m k p_0 L u_G a_G delta')
d = delta*u
In [2]:
Image(filename='figures/rigid.png')
Out[2]:
The CIR of left body, $\Omega_1$, is at the intersection of an horizontal line in A and a vertical line in C, hence the coordinates of $\Omega_1$ are $(L,L)$ if we put the origin in B.
The CIR of the right body, $\Omega_2$, is at the intersection of an horizontal line in G and a $135^o$ line going from D, internal hinge, to $\Omega_1$, hence the coordinates of $\Omega_2$ are $(0,2L)$.
The rotation $\theta_2$ is given in terms of $u_G$ by $\theta_2\\,3L=u_G$, the rotation $\theta_1$ is $\theta_1=2\theta_2$.
In our problem, we have two type of objects, 1) the rotation of a rigid body characterized by the coordinates of the centre of rotation and the angle of rotation and 2) the significant points on a rigid body, characterized by the rotation, the attached mass, the attached spring etc.
We define two simple classes that model the behaviour of our objects.
In [3]:
class Centre:
def __init__(self, x, y, rot):
self.x = x ; self.y = y ; self.r = rot
class Point:
def __init__(self, x, y, centre, mass=0, kx=0, ky=0, px=0, py=0, length=0):
if kx*ky: raise NameError('Only one stiffness can be different from zero.')
j_r = mass*length**2/12
ux = -(y-centre.y)*centre.r
uy = +(x-centre.x)*centre.r
self.mvw = -a*d*(mass*(ux*ux+uy*uy)+j_r*centre.r**2)
self.kvw = -u*d*(kx*ux**2+ky*uy**2)
self.pvw = +d*(px*ux+py*uy)
In [4]:
w1 = Centre( L, L, rat(2,3)/L)
w2 = Centre( 0, 2*L, rat(1,3)/L)
The significant points are A (external force), B (point mass), D (spring), F (both spring and center of mass of the vertical segment of DEFG bar) and GDE (centre of mass of the horizontal segment).
A Point object is initialized for each significant point, with the relevant quantities explicited.
In [5]:
A = Point( 0, L, w1, py=-p)
B = Point( 0, 0, w1, mass=3*m)
D = Point( 2*L, 0, w1, ky=k)
F = Point( 3*L, L, w2, kx=k, mass=2*m, length=2*L)
GDE = Point( rat(5,2)*L, 0, w2, mass=m, length=L)
In [6]:
def sum_vw(which):
return sum([getattr(point,which) for point in (A,B,D,F,GDE)])
We use our handy function to compute the individual contributions to the virtual work.
In [7]:
vw_inertial_f = sum_vw('mvw')
display(Math(r'\delta W_I = '+latex(vw_inertial_f/d)+'\\,'+latex(d)+','))
vw_elastic_f = sum_vw('kvw')
display(Math(r'\delta W_S = '+latex(vw_elastic_f/d)+'\\,'+latex(d)+','))
vw_external_f = sum_vw('pvw')
display(Math(r'\delta W_E = '+latex(vw_external_f/d)+'\\,'+latex(d)+'.'))
In [8]:
display(Eq( -vw_inertial_f/d - vw_elastic_f/d, vw_external_f/d))
In [9]:
display(Latex(r'The generalized mass is $m^* = %s$, '%latex(-vw_inertial_f/d/a) +
r'the generalized stiffness is $k^* = %s$, '%latex(-vw_elastic_f/d/u) +
r'the generalized load is $p^* = %s\,\mathrm{f}(t)$.'%latex(vw_external_f/d)))