예제 #1
0
theta = 1/2.0 + epsilon              # theta for MoreauJeanOSI integrator
#theta = 1.0
E = 210e9 # young Modulus
S = 0.000314 #  Beam Section 1 cm  for the diameter
#S=0.1
L = 1.0 # length of the  beam
l = L/nDof # length of an element
rho = 7800.0  # specific mass
#rho=1.0
g = 9.81 # Gravity
g=0.0


M= SimpleMatrix(nDof,nDof,SPARSE,nDof)
K= SimpleMatrix(nDof,nDof,SPARSE,nDof)
K.setValue(0,0, 1.*E*S/l)
K.setValue(0,1,-1.*E*S/l)
M.setValue(0,0, 1/3.*rho*S*l)
M.setValue(0,1, 1/6.*rho*S*l)

for i in range(1,nDof-1):
    K.setValue(i,i,2.*E*S/l)
    K.setValue(i,i-1,-1.*E*S/l)
    K.setValue(i,i+1,-1.*E*S/l)
    M.setValue(i,i,2/3.*rho*S*l)
    M.setValue(i,i-1,1/6.*rho*S*l)
    M.setValue(i,i+1,1/6.*rho*S*l)


K.setValue(nDof-1,nDof-2,-1.*E*S/l)
K.setValue(nDof-1,nDof-1, 1.*E*S/l)
예제 #2
0
#nnz=0
# for i in range(n_dof):

#     idx = np.where(stiffness_mat_np[i,:]>=1e-14)
#     for j in idx[0]:
#         K.setValue(i,j,stiffness_mat_np[i,j])

#     idx = np.where(mass_mat_np[i,:]>=1e-14)
#     nnz = nnz + len(idx[0])
#     for j in idx[0]:
#         M.setValue(i,j,mass_mat_np[i,j])
# nnz=0

for i in range(n_dof):
    for j in range(n_dof):
        K.setValue(i, j, stiffness_mat_np[i, j])
        M.setValue(i, j, mass_mat_np[i, j])

#print('nnz=', nnz)
#M.display()

print(' -- set initial conditions -- ')

q_0 = u_old.vector().get_local()
v_0 = v_old.vector().get_local()

t0 = 0.0

print(' -- build dynamical system -- ')

body = LagrangianLinearTIDS(q_0, v_0, M)