Implement Tangent Stiffness Matrix as function of elemental cross-section areas #24
Replies: 2 comments
-
Okay, here is a tutorial how to achieve this with the current code of TrussPy (please update TrussPy via pip first): Create a ModelIn a first step we have to create the Model and set the maximum allowed increments to 1 (0 is not possible in TrussPy). We call this function import trusspy as tp
def create_model():
'''Create a TrussPy-Model and return the Model instance.'''
M = tp.Model(log=0)
with M.Nodes as MN:
MN.add_node( 1, coord=( 0, 0, 0))
MN.add_node( 2, coord=( 1, 0, 1))
MN.add_node( 3, coord=( 2, 0, 0))
with M.Elements as ME:
ME.add_element( 1, conn=(1,2), gprop=[1] )
ME.add_element( 2 ,conn=(2,3), gprop=[1] )
ME.assign_material( 'all', [1])
with M.Boundaries as MB:
MB.add_bound_U( 1, (0,0,0) )
MB.add_bound_U( 2, (0,0,1) )
MB.add_bound_U( 3, (0,0,0) )
with M.ExtForces as MF:
MF.add_force( 2, ( 0, 0,-1) )
M.Settings.incs = 1
return M Function for stiffness evaluationIn a second step we create a function which uses a list of elemental areas as its argument, runs the model and returns the stiffness matrix for the initial increment of zero deformation (may be adapted to your needs). Finally a reduced stiffness matrix for all active degree of freedoms ( def stiffness(list_of_areas):
'''Calculate the stiffness matrix as a function of elemental
cross-section areas (passed as list).'''
M = create_model()
M.Elements.assign_geometries('all', list_of_areas)
M.build()
M.run()
R0 = M.Results.R[1]
# return K (full system), Kred (only active DOF)
# or Kmod (see Documentation)
return R0.Kred Now we have a function which evaluates the stiffness matrix based on a list of elemental areas. Code snippet inside a scriptlist_of_areas = [2,3]
K = stiffness(list_of_areas) Have fun! |
Beta Was this translation helpful? Give feedback.
-
@Giannis1993 please have a look - hope that helps! |
Beta Was this translation helpful? Give feedback.
-
Follow-Up of #10 .
Beta Was this translation helpful? Give feedback.
All reactions