Index Error: index 1 is out of bounds for axis 0 with size 1

Estou tendo o seguinte erro ao tentar gerar uma matriz, mas estou tendo erro ao utilizar o comando for, ao final do problema.

import numpy as np

#1. Dados do material e da barra
A=(0.3*0.15) #area total
#print(A)
E=210e9 #modulo de elasticidade
L=2.5
a=L/2
I=((0.3*(0.15)**3)/12)
#print(I)

#2. Dados de Entrada
nnodes= 14 #numero de nos
nel=  25   #numero de elementos
ndof= 3   #numero de GDL por no
nnel= 2   #numero de nos por elemento
edof= ndof*nnel   #numero de GDL por elemento
sdof= nnodes*ndof  #numero de GDL do sistema

#3. Coordenada dos nós
gcoord=np.array([[0,0],[2.5,0],[5,0],[7.5,0],[2.5,2.5],[5,2.5],[2.5,5],[5,5],[7.5,5],[10,5],[2.5,7.5],[5,7.5],[7.5,7.5],[10,7.5]])
#print(gcoord)

#4. Incidencia - Conectividade nodal
nodes=np.array([[1,2],[2,3],[3,4],[1,5],[2,5],[2,6],[3,6],[4,6],[5,6],[5,7],[5,8],[6,8],[7,8],[7,11],[11,8],[8,12],[11,12],[8,9],[8,13],[9,13],[12,13],[9,10],[10,13],[10,14],[13,14]])


#6. Matriz de Rigidez
K=np.zeros((sdof,sdof))
#print(K)
for i in range (0,nel):
  deltay=gcoord[nodes[i,1]-1,1]-gcoord[nodes[i,0]-1,1]
  deltax=gcoord[nodes[i,1]-1,0]-gcoord[nodes[i,0]-1,0]

  theta=np.arctan(deltay/deltax) #angulo de rotacao

  c=np.cos(theta)
  s=np.sin(theta)
  R=np.array([[c,s,0,0,0,0],[-s,c,0,0,0,0],[0,0,1,0,0,0],[0,0,0,c,s,0],[0,0,0,-s,c,0],[0,0,0,0,0,1]]) #matriz de rotacao
  #print(R)
  L=np.sqrt(deltax**2+deltay**2)
  ke=((E*I)/(L**3))*np.array([[((A*(L**2))/I),0,0,-((A*(L**2))/I),0,0],[0,12,6*L,0,-12,6*L],[0,6*L,(4*(L**2)),0,-6*L,(2*(L**2))],[-((A*(L**2))/I),0,0,((A*(L**2))/I),0,0],[0,-12,-6*L,0,12,-6*L],[0,6*L,(2*(L**2)),0,-6*L,(4*(L**2))]])
  Rt=np.transpose(R)
  Ke=Rt*ke*R #matriz de rigidez do sistema global
  #print(Ke)

  index=np.array([[3*nodes[i,0]-3,3*nodes[i,0]-2,3*nodes[i,0]-1,3*nodes[i,1]-3,3*nodes[i,1]-2,3*nodes[i,1]-1]])
  for m in range (0,edof):
    for n in range (0,edof):
      K[index[m],index[n]]+=Ke[m,n]+K[index[m],index[n]]
      print (K)

O erro está na linha:

 K[index[m],index[n]]+=Ke[m,n]+K[index[m],index[n]]

E recebo a seguinte mensagem: Index Error: index 1 is out of bounds for axis 0 with size 1

1 answer

  • answered 2019-09-10 02:22 Manjot singh

    The Answer is in English language. TRY: edof=6 It will work.