示例#1
0
def test_bar2():
    '''Clamped bar composed of two linked bars loaded at the right end
    [00]-[01]-[02]-[03]-[04]-[05]-[06]-[07]-[08]-[09]-[10]
    [11]-[12]-[13]-[14]-[15]-[16]-[17]-[18]-[19]-[20]-[21]
    u[0] = 0, u[5] = u[16], R[-1] = R[21] = 10
    '''
    fets_eval = FETS1D2L(mats_eval=MATS1DElastic(E=10., A=1.))

    # Discretization
    fe_domain1 = FEGrid(coord_max=(10., 0., 0.),
                        shape=(10, ),
                        n_nodal_dofs=1,
                        dof_r=fets_eval.dof_r,
                        geo_r=fets_eval.geo_r)

    fe_domain2 = FEGrid(coord_min=(10., 0., 0.),
                        coord_max=(20., 0., 0.),
                        shape=(10, ),
                        n_nodal_dofs=1,
                        dof_r=fets_eval.dof_r,
                        geo_r=fets_eval.geo_r)

    ts = TS(iterms=[(fets_eval, fe_domain1), (fets_eval, fe_domain2)],
            dof_resultants=True,
            bcond_list=[
                BCDof(var='u', dof=0, value=0.),
                BCDof(var='u',
                      dof=5,
                      link_dofs=[16],
                      link_coeffs=[1.],
                      value=0.),
                BCDof(var='f', dof=21, value=10)
            ],
            rtrace_list=[
                RTraceGraph(name='Fi,right over u_right (iteration)',
                            var_y='F_int',
                            idx_y=0,
                            var_x='U_k',
                            idx_x=1),
            ])

    # Add the time-loop control
    tloop = TLoop(tstepper=ts, tline=TLine(min=0.0, step=1, max=1.0))
    u = tloop.eval()
    print 'u', u
    #
    # '---------------------------------------------------------------'
    # 'Clamped bar composed of two linked bars control displ at right'
    # 'u[0] = 0, u[5] = u[16], u[21] = 1'
    # Remove the load and put a unit displacement at the right end
    # Note, the load is irrelevant in this case and will be rewritten
    #
    ts.bcond_list = [
        BCDof(var='u', dof=0, value=0.),
        BCDof(var='u', dof=5, link_dofs=[16], link_coeffs=[1.], value=0.),
        BCDof(var='u', dof=21, value=1.)
    ]
    # system solver
    u = tloop.eval()
    print 'u', u
def test_bar2( ):
    '''Clamped bar composed of two linked bars loaded at the right end
    [00]-[01]-[02]-[03]-[04]-[05]-[06]-[07]-[08]-[09]-[10]
    [11]-[12]-[13]-[14]-[15]-[16]-[17]-[18]-[19]-[20]-[21]
    u[0] = 0, u[5] = u[16], R[-1] = R[21] = 10
    '''
    fets_eval = FETS1D2L(mats_eval = MATS1DElastic(E=10., A=1.))        

    # Discretization
    fe_domain1 = FEGrid( coord_max = (10.,0.,0.), 
                                    shape   = (10,),
                                    n_nodal_dofs = 1,
                                    dof_r = fets_eval.dof_r,
                                    geo_r = fets_eval.geo_r )

    fe_domain2 = FEGrid( coord_min = (10.,0.,0.),  
                               coord_max = (20.,0.,0.), 
                               shape   = (10,),
                               n_nodal_dofs = 1,
                               dof_r = fets_eval.dof_r,
                               geo_r = fets_eval.geo_r )

    ts = TS( iterms = [ ( fets_eval, fe_domain1 ), (fets_eval, fe_domain2 ) ],
             dof_resultants = True,
             bcond_list =  [BCDof(var='u', dof = 0, value = 0.),
                           BCDof(var='u', dof = 5, link_dofs = [16], link_coeffs = [1.],
                                  value = 0. ),
                           BCDof(var='f', dof = 21, value = 10 ) ],
             rtrace_list =  [ RTraceGraph(name = 'Fi,right over u_right (iteration)' ,
                                   var_y = 'F_int', idx_y = 0,
                                   var_x = 'U_k', idx_x = 1),
                                   ]             
                )

    # Add the time-loop control
    tloop = TLoop( tstepper = ts,
                        tline  = TLine( min = 0.0,  step = 1, max = 1.0 ))    
    u = tloop.eval()
    print 'u', u
    #
    # '---------------------------------------------------------------'
    # 'Clamped bar composed of two linked bars control displ at right'
    # 'u[0] = 0, u[5] = u[16], u[21] = 1'
    # Remove the load and put a unit displacement at the right end
    # Note, the load is irrelevant in this case and will be rewritten
    #
    ts.bcond_list =  [BCDof(var='u', dof = 0, value = 0.),
                      BCDof(var='u', dof = 5, link_dofs = [16], link_coeffs = [1.],
                            value = 0. ),
                            BCDof(var='u', dof = 21, value = 1. ) ]
    # system solver
    u = tloop.eval()
    print 'u',u
示例#3
0
文件: bctest.py 项目: simvisage/bmcs
                    fets_eval=fets_eval
                    )

    ts = TS(sdomain=domain,
            dof_resultants=True
            )
    tloop = TLoop(tstepper=ts,
                  tline=TLine(min=0.0,  step=1, max=1.0))

    '''Clamped bar loaded at the right end with unit displacement
    [00]-[01]-[02]-[03]-[04]-[05]-[06]-[07]-[08]-[09]-[10]
    'u[0] = 0, u[10] = 1'''

    domain.coord_max = (10, 0, 0)
    domain.shape = (10,)
    ts.bcond_list = [BCDof(var='u', dof=0, value=0.),
                     BCDof(var='u', dof=10, value=1.)]
    ts.rtrace_list = [RTDofGraph(name='Fi,right over u_right (iteration)',
                                 var_y='F_int', idx_y=10,
                                 var_x='U_k', idx_x=10)]

    u = tloop.eval()
    # expected solution
    u_ex = array([0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.],
                 dtype=float)
    difference = sqrt(norm(u - u_ex))
    print('difference')
    # compare the reaction at the left end
    F = ts.F_int[0]
    print(F)
示例#4
0
    fets_eval = FETS1D2L(mats_eval=MATS1DElastic(E=10.0))

    # Discretization
    domain = FEGrid(coord_max=(10.0, 0.0, 0.0), shape=(1,), fets_eval=fets_eval)

    ts = TS(sdomain=domain, dof_resultants=True)
    tloop = TLoop(tstepper=ts, debug=False, tline=TLine(min=0.0, step=1, max=1.0))

    """Clamped bar loaded at the right end with unit displacement
    [00]-[01]-[02]-[03]-[04]-[05]-[06]-[07]-[08]-[09]-[10]
    'u[0] = 0, u[10] = 1"""

    domain.coord_max = (1, 0, 0)
    domain.shape = (3,)
    ts.bcond_list = [
        BCDof(var="u", dof=0, value=0.0),
        BCDof(var="u", dof=1, link_dofs=[2], link_coeffs=[0.5]),
        BCDof(var="u", dof=3, value=1.0),
    ]
    ts.rtrace_list = [
        RTraceGraph(name="Fi,right over u_right (iteration)", var_y="F_int", idx_y=3, var_x="U_k", idx_x=3)
    ]

    u = tloop.eval()
    # expected solution
    print "u", u
    # compare the reaction at the left end
    F = ts.F_int[-1]

    print "F", F
示例#5
0
    domain = FEGrid( coord_max = (10.,0.,0.), 
                     shape   = (1,),
                     fets_eval = fets_eval )
    
    ts = TS( sdomain = domain,
                  dof_resultants = True
                        )
    tloop = TLoop( tstepper = ts,
                        tline  = TLine( min = 0.0,  step = 1, max = 1.0 ))
    
        
    domain.coord_max = (10,0,0)
    domain.shape = (10,)
    bc_left  = BCSlice( var = 'u', value = 0., slice = domain[ 0, 0] )
    bc_right = BCSlice( var = 'u', value = 1., slice = domain[1:,:] )
    ts.bcond_list =  [ bc_left, bc_right ]

#    ts.bcond_list =  [BCDof(var='u', dof = 0, value = 0.),
#                      BCDof(var='u', dof = 1, link_dofs = [2], link_coeffs = [0.5] ),
#                      BCDof(var='u', dof = 2, link_dofs = [3], link_coeffs = [1.] ),
#                      BCDof(var='u', dof = 3, value = 1. ) ]
    
    ts.rtrace_list = [ RTraceGraph(name = 'Fi,right over u_right (iteration)' ,
                                   var_y = 'F_int', idx_y = 10,
                                   var_x = 'U_k',   idx_x = 10) ]
    
    u = tloop.eval()
    print 'u',u
    # expected solution
    u_ex = array([ 0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1. ],
                 dtype = float )
示例#6
0
    # Discretization
    domain = FEGrid( coord_max = (10.,0.,0.), 
                                shape   = (1,),
                                fets_eval = fets_eval )

    ts = TS( sdomain = domain,
                  dof_resultants = True
                        )
    tloop = TLoop( tstepper = ts,
                        tline  = TLine( min = 0.0,  step = 1, max = 1.0 ))
            
    domain.coord_max = (3,0,0)
    domain.shape = (3,)
    ts.bcond_list =  [BCDof(var='u', dof = 0, value = 0.),
                      BCDof(var='u', dof = 1, link_dofs = [2], link_coeffs = [0.5] ),
                      BCDof(var='u', dof = 2, link_dofs = [3], link_coeffs = [1.] ),
                      BCDof(var='f', dof = 3, value = 1 ) ]
    # system solver
    u = tloop.eval()
    # expected solution
    print u
    u_ex = array([-0. ,  0.1 , 0.2 , 0.2],
                  dtype = float )
    difference = sqrt( norm( u-u_ex ) )
    print difference
    #self.assertAlmostEqual( difference, 0 )         
    #
    # '---------------------------------------------------------------'
    # 'Clamped bar with recursive constraints (displ at right end)'
    # 'u[1] = 0.5 * u[2], u[2] = 1.0 * u[3], u[3] = 1'
    ts.bcond_list =  [BCDof(var='u', dof = 0, value = 0.),
示例#7
0
    # Discretization
    domain = FEGrid(coord_max=(10., 0., 0.), shape=(1, ), fets_eval=fets_eval)

    ts = TS(sdomain=domain, dof_resultants=True)
    tloop = TLoop(tstepper=ts,
                  debug=False,
                  tline=TLine(min=0.0, step=1, max=1.0))
    '''Clamped bar loaded at the right end with unit displacement
    [00]-[01]-[02]-[03]-[04]-[05]-[06]-[07]-[08]-[09]-[10]
    'u[0] = 0, u[10] = 1'''

    domain.coord_max = (1, 0, 0)
    domain.shape = (3, )
    ts.bcond_list = [
        BCDof(var='u', dof=0, value=0.),
        BCDof(var='u', dof=1, link_dofs=[2], link_coeffs=[0.5]),
        BCDof(var='u', dof=3, value=1.)
    ]
    ts.rtrace_list = [
        RTDofGraph(name='Fi,right over u_right (iteration)',
                   var_y='F_int',
                   idx_y=3,
                   var_x='U_k',
                   idx_x=3)
    ]

    u = tloop.eval()
    # expected solution
    print('u', u)
    # compare the reaction at the left end
    F = ts.F_int[-1]
示例#8
0
                    fets_eval=fets_eval)

    ts = TS(sdomain=domain,
            dof_resultants=True
            )
    tloop = TLoop(tstepper=ts, debug=False,
                  tline=TLine(min=0.0, step=1, max=1.0))

    '''Clamped bar loaded at the right end with unit displacement
    [00]-[01]-[02]-[03]-[04]-[05]-[06]-[07]-[08]-[09]-[10]
    'u[0] = 0, u[10] = 1'''

    domain.coord_max = (1, 0, 0)
    domain.shape = (3, )
    ts.bcond_list = [BCDof(var='u', dof=0, value=0.),
                     BCDof(var='u', dof=1, link_dofs=[2], link_coeffs=[0.5]),
                     BCDof(var='u', dof=3, value=1.)]
    ts.rtrace_list = [RTraceGraph(name='Fi,right over u_right (iteration)',
                                  var_y='F_int', idx_y=3,
                                  var_x='U_k', idx_x=3)]

    u = tloop.eval()
    # expected solution
    print 'u', u
    # compare the reaction at the left end
    F = ts.F_int[-1]

    print 'F', F

    ts.bcond_mngr.configure_traits()