27. Building the primary stiffness matrix

Questions and discussion for this lecture live here. Fire away by hitting Reply below :fire:

Hey, Sean. I’m getting this error

TypeError                                 Traceback (most recent call last)
Input In [14], in <cell line: 2>()
      1 nDoF = np.amax(members)*6 #The total number of degrees of freedom in the problem
----> 2 Kp = np.zeros([nDoF,nDoF]) #Initialise the primary stiffness matrix
      4 for n, mbr in enumerate(members):
      5     node_i = mbr[0] #Node number for node i of this member    

TypeError: 'numpy.float64' object cannot be interpreted as an integer

Looks like nDoF has been defined as a float when it should be an integer. Try recasting it as an Int before using it to initialise the primary stiffness matrix:

nDoF = int(nDoF)