Skip to content

Implement Tangent Stiffness Matrix as function of elemental cross-section areas #13

Closed

Description

@adtzlr

Follow-Up of #10 .

Activity

  1. adtzlr commented on Jun 1, 2020

    @adtzlr
    OwnerAuthor

    Okay, here is a tutorial how to achieve this with the current code of TrussPy (please update TrussPy via pip first):

    Create a Model

    In 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 create_model.

    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 evaluation

    In 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 (Kred) is returned. This may also be changed to the whole system stiffness matrix (K) or the one which is used by TrussPy (Kmod). See the documentation for further informations about Kmod.

    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[0]
        # 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 script

    list_of_areas = [2,3]
    K = stiffness(list_of_areas)

    Have fun!

  2. adtzlr commented on Jun 1, 2020

    @adtzlr
    OwnerAuthor

    @Giannis1993 please have a look - hope that helps!

  3. Repository owner locked and limited conversation to collaborators on Dec 17, 2022
  4. converted this issue into a discussion #24 on Dec 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions