Exemplo n.º 1
0
def ElasticForcesStatic(XBINPUT,XBOPTS,PosDeforStatic,PsiDeforStatic): 
    '''
    Given the results of a static simulation computes the stresses 
    along the beam
    
    - XBINPUT & XBOPTS are either:
        1. objects of the Xbinput/Xbopts classes (see PyBeam.Utils.DerivedTypes)
           with attributes defined as c_types
        2. objects from a class having the same attributes (but not defined 
           as c_types)
    
    The elastic forces are returned in the format:
        S = [  Node, component ]
    '''
    
    # Prepare classes
    if not(isinstance(XBOPTS,PyBeam.Utils.DerivedTypes.Xbopts)):
        H=copy.deepcopy(XBOPTS)
        XBOPTS=PyBeam.Utils.DerivedTypes.Xbopts()
        XBOPTS.init_from_class(H)
    
    # Initialise beam
    XBINPUT, XBOPTS, NumNodes_tot, \
    XBELEM, PosIni, PsiIni, XBNODE, NumDof = BeamInit.Static(XBINPUT,XBOPTS)
    del XBNODE, NumDof
    
    # Extract Elements Type
    if isinstance(XBINPUT,PyBeam.Utils.DerivedTypes.Xbinput):
        NumNodesElem=XBINPUT.NumNodesElem.value 
    else:
        NumNodesElem=XBINPUT.NumNodesElem
    
    # Prepare Node List
    if NumNodesElem == 2:
        NodeList=[ii for ii in range(int(NumNodes_tot.value))] 
    elif NumNodesElem == 3:
        # midpoint nodes not supported
        NodeList=[2*ii for ii in range(int(0.5*NumNodes_tot.value))]
    else:
        raise NameError('Incorrect Number of Nodes per Element in XBINPUT!')

    Fmat = BeamIO.localFstifz(PosDeforStatic, PsiDeforStatic, 
                              PosIni, PsiIni,
                            XBELEM, NodeList)

    return Fmat, NodeList
Exemplo n.º 2
0
def ElasticForces(XBINPUT,XBOPTS,DynOut,PsiList): 
    '''
    Given the results of a simulation computes the stresses along
    the beam at each time step.
    
    - PsiList is a list of CRV at each step of the simulation. 
    - DynOut is an array containing all the displacements.
    - XBINPUT & XBOPTS are either:
        1. objects of the Xbinput/Xbopts classes (see PyBeam.Utils.DerivedTypes)
           with attributes defined as c_types
        2. objects from a class having the same attributes (but not defined 
           as c_types)
    
    The elastic forces are returned in the format:
        S = [ time_step, Node, component ]
        
           
    Remark:
    - PsiList and DynOut are equivalent (one for displ one for rotation)
      but the format is inconsistent!
    '''
    
    # Prepare classes
    if not(isinstance(XBOPTS,PyBeam.Utils.DerivedTypes.Xbopts)):
        H=copy.deepcopy(XBOPTS)
        XBOPTS=PyBeam.Utils.DerivedTypes.Xbopts()
        XBOPTS.init_from_class(H)
    
    # Initialise beam
    XBINPUT, XBOPTS, NumNodes_tot, \
    XBELEM, PosIni, PsiIni, XBNODE, NumDof = BeamInit.Static(XBINPUT,XBOPTS)
    
    # Extract Elements Type
    if isinstance(XBINPUT,PyBeam.Utils.DerivedTypes.Xbinput):
        NumNodesElem=XBINPUT.NumNodesElem.value 
    else:
        NumNodesElem=XBINPUT.NumNodesElem
    
    # Prepare Node List
    if NumNodesElem == 2:
        NodeList=[ii for ii in range(int(NumNodes_tot.value))] 
    elif NumNodesElem == 3:
        # midpoint nodes not supported
        NodeList=[2*ii for ii in range(int(0.5*NumNodes_tot.value))]
    else:
        raise NameError('Incorrect Number of Nodes per Element in XBINPUT!')
    
    # get number of steps
    NumSteps = int( DynOut.shape[0]/NumNodes_tot.value ) - 1
    
    print('dynout shape', DynOut.shape       )
    print('NumNodes'    , NumNodes_tot.value )
    print('NumSteps'    , NumSteps           )
    
    PosDef=PyBeam.Utils.PostPr.reshape_DynOut(DynOut,NumSteps)
    
    # compute stresses
    Fmat=np.empty(( NumSteps, len(NodeList), 6 ))
    for tt in range(NumSteps):
        
        #### as per function ElasticForces
        #Fmat[tt,:,:]=BeamIO.localElasticForces(PosDef[tt,:,:], PsiList[tt], 
        #                                         PosIni,  PsiIni, 
        #                                         XBELEM, NodeList)
        
        #### copied from BeamIO.localElasticForces
        # same as per function ElasticForces    
        F = np.zeros((len(NodeList),6))
        
        #strains = BeamIO.localStrains(PosDef[tt,:,:], PsiList[tt], 
        #                      PosIni, PsiIni,
        #                       XBELEM, NodeList)
        #iOut = 0 # Output index
        #for iNode in NodeList:
        #    iElem, iiElem = BeamIO.iNode2iElem(iNode, PosDef.shape[0]-1, XBELEM.NumNodes[0])
        #    del iiElem
        #    elemStrain = strains[iOut,:]
        #    elemK = XBELEM.Stiff[iElem*6:(iElem+1)*6,:]
        #    F[iOut,:] = np.dot(elemK,elemStrain)
        #    iOut += 1
        
        F = BeamIO.localFstifz(PosDef[tt,:,:], PsiList[tt], 
                              PosIni, PsiIni,
                               XBELEM, NodeList)
        
        #print('Fstiff z size')
        #print(F.shape)
        #print('Expected')
        #print((len(NodeList), 6))
        
        # END of iElem
        Fmat[tt,:,:]=F.copy()
        
        
    
    return Fmat, NodeList