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 example_2d(): from ibvpy.api import FEDomain, FERefinementGrid, FEGrid, TStepper as TS, \ BCDofGroup, RTraceDomainListField from ibvpy.core.tloop import TLoop, TLine from ibvpy.mesh.xfe_subdomain import XFESubDomain from ibvpy.mats.mats2D.mats2D_elastic.mats2D_elastic import MATS2DElastic from ibvpy.mats.mats2D.mats2D_sdamage.mats2D_sdamage import MATS2DScalarDamage from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q from ibvpy.fets.fets2D.fets2D4q8u import FETS2D4Q8U from ibvpy.fets.fets2D.fets2D4q9u import FETS2D4Q9U from ibvpy.fets.fets2D.fets2D4q12u import FETS2D4Q12U from ibvpy.fets.fets2D.fets2D4q16u import FETS2D4Q16U from ibvpy.fets.fets_ls.fets_crack import FETSCrack fets_eval = FETS2D4Q( mats_eval = MATS2DScalarDamage( E = 1., nu = 0. ) ) xfets_eval = FETSCrack( parent_fets = fets_eval, int_order = 1 ) # Discretization fe_domain = FEDomain() fe_level1 = FERefinementGrid( domain = fe_domain, fets_eval = fets_eval ) fe_grid1 = FEGrid( coord_max = ( 2., 1., 0. ), shape = ( 2, 1 ), fets_eval = fets_eval, level = fe_level1 ) fe_xdomain = XFESubDomain( domain = fe_domain, rt_quad = False, fets_eval = xfets_eval, #fe_grid_slice = fe_grid1['Y - 0.5@ X < .5'] fe_grid_slice = fe_grid1['X - 0.5'] ) fe_xdomain.deactivate_sliced_elems() ts = TS( dof_resultants = True, sdomain = fe_domain ) ts.setup() # print 'parent elems ', fe_xdomain.fe_grid_slice.elems # print 'intersection points ', fe_xdomain.fe_grid_slice.r_i # print 'ip_coords ', fe_xdomain.dots.ip_coords print 'state array step 1 ', fe_xdomain.dots.state_array fe_xdomain.dots.state_array[:3] = [1, 2, 3] print 'state array write ', fe_xdomain.dots.state_array fe_xdomain.fe_grid_slice = fe_grid1['Y-0.5'] # print 'parent elems ', fe_xdomain.fe_grid_slice.elems # print 'intersection points ', fe_xdomain.fe_grid_slice.r_i # print 'ip_coords ', fe_xdomain.dots.ip_coords print 'state array step 2 ', fe_xdomain.dots.state_array
def run_example(): from ibvpy.api import \ TStepper as TS, RTraceGraph, RTraceDomainListField, \ RTraceDomainListInteg, TLoop, \ TLine, BCDof, IBVPSolve as IS, DOTSEval from ibvpy.mats.mats2D.mats2D_conduction.mats2D_conduction import MATS2DConduction from ibvpy.api import BCDofGroup fets_eval = FETS2D4Q4T(mats_eval=MATS2DConduction(k=1.)) print fets_eval.vtk_node_cell_data from ibvpy.mesh.fe_grid import FEGrid from ibvpy.mesh.fe_refinement_grid import FERefinementGrid from ibvpy.mesh.fe_domain import FEDomain from mathkit.mfn import MFnLineArray # Discretization fe_grid = FEGrid(coord_max=(1., 1., 0.), shape=(2, 2), fets_eval=fets_eval) tstepper = TS( sdomain=fe_grid, bcond_list=[ BCDofGroup(var='u', value=0., dims=[0], get_dof_method=fe_grid.get_left_dofs), # BCDofGroup( var='u', value = 0., dims = [1], # get_dof_method = fe_grid.get_bottom_dofs ), BCDofGroup(var='u', value=.005, dims=[0], get_dof_method=fe_grid.get_top_right_dofs) ], rtrace_list=[ # RTraceDomainListField(name = 'Damage' , # var = 'omega', idx = 0, # record_on = 'update', # warp = True), # RTraceDomainListField(name = 'Displacement' , # var = 'u', idx = 0, # record_on = 'update', # warp = True), # RTraceDomainListField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ]) print tstepper.setup() return # Add the time-loop control tloop = TLoop(tstepper=tstepper, debug=False, tline=TLine(min=0.0, step=1.0, max=1.0)) tloop.eval()
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 run_example(): from ibvpy.api import \ TStepper as TS, RTraceGraph, RTraceDomainListField, \ RTraceDomainListInteg, TLoop, \ TLine, BCDof, IBVPSolve as IS, DOTSEval from ibvpy.mats.mats2D.mats2D_conduction.mats2D_conduction import MATS2DConduction from ibvpy.api import BCDofGroup fets_eval = FETS2D4Q4T(mats_eval=MATS2DConduction(k=1.)) print fets_eval.vtk_node_cell_data from ibvpy.mesh.fe_grid import FEGrid from ibvpy.mesh.fe_refinement_grid import FERefinementGrid from ibvpy.mesh.fe_domain import FEDomain from mathkit.mfn import MFnLineArray # Discretization fe_grid = FEGrid(coord_max=(1., 1., 0.), shape=(2, 2), fets_eval=fets_eval) tstepper = TS(sdomain=fe_grid, bcond_list=[BCDofGroup(var='u', value=0., dims=[0], get_dof_method=fe_grid.get_left_dofs), # BCDofGroup( var='u', value = 0., dims = [1], # get_dof_method = fe_grid.get_bottom_dofs ), BCDofGroup(var='u', value=.005, dims=[0], get_dof_method=fe_grid.get_top_right_dofs)], rtrace_list=[ # RTraceDomainListField(name = 'Damage' , # var = 'omega', idx = 0, # record_on = 'update', # warp = True), # RTraceDomainListField(name = 'Displacement' , # var = 'u', idx = 0, # record_on = 'update', # warp = True), # RTraceDomainListField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ] ) print tstepper.setup() return # Add the time-loop control tloop = TLoop(tstepper=tstepper, debug=False, tline=TLine(min=0.0, step=1.0, max=1.0)) tloop.eval()
def setUp(self): self.fets_eval = FETS1D2L(mats_eval = MATS1DElastic(E=10.)) # Discretization self.fe_domain1 = FEGrid( coord_max = (3.,0.,0.), shape = (3,), fets_eval = self.fets_eval ) self.fe_domain2 = FEGrid( coord_min = (3.,0.,0.), coord_max = (6.,0.,0.), shape = (3,), fets_eval = self.fets_eval ) self.fe_domain3 = FEGrid( coord_min = (3.,0.,0.), coord_max = (6.,0.,0.), shape = (3,), fets_eval = self.fets_eval ) self.ts = TS( dof_resultants = True, sdomain = [ self.fe_domain1, self.fe_domain2 , self.fe_domain3 ], bcond_list = [BCDof(var='u', dof = 0, value = 0.), BCDof(var='u', dof = 4, link_dofs = [3], link_coeffs = [1.], value = 0. ), BCDof(var='f', dof = 7, value = 1, link_dofs = [2], link_coeffs = [2] ) ], 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 self.tloop = TLoop( tstepper = self.ts, tline = TLine( min = 0.0, step = 1, max = 1.0 ))
def _get_tstepper(self): #self.fe_grid.dots = self.dots ts = TStepper( sdomain=self.fe_grid, bcond_mngr=self.bcond_mngr, rtrace_list=[self.rt_Pu, # RTraceDomainField(name = 'Stress' , # var = 'sig_app', idx = 0, # record_on = 'update'), # RTraceDomainListField(name='Displacement', # var='u', idx=0), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ] ) return ts
def setUp(self): self.fets_eval = FETS1D2L(mats_eval=MATS1DElastic(E=10.)) # Discretization self.fe_domain1 = FEGrid(coord_max=(3., 0., 0.), shape=(3, ), fets_eval=self.fets_eval) self.fe_domain2 = FEGrid(coord_min=(3., 0., 0.), coord_max=(6., 0., 0.), shape=(3, ), fets_eval=self.fets_eval) self.fe_domain3 = FEGrid(coord_min=(3., 0., 0.), coord_max=(6., 0., 0.), shape=(3, ), fets_eval=self.fets_eval) self.ts = TS( dof_resultants=True, sdomain=[self.fe_domain1, self.fe_domain2, self.fe_domain3], bcond_list=[ BCDof(var='u', dof=0, value=0.), BCDof(var='u', dof=4, link_dofs=[3], link_coeffs=[1.], value=0.), BCDof(var='f', dof=7, value=1, link_dofs=[2], link_coeffs=[2]) ], 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 self.tloop = TLoop(tstepper=self.ts, tline=TLine(min=0.0, step=1, max=1.0))
from ibvpy.mats.mats1D.mats1D_elastic.mats1D_elastic import MATS1DElastic from ibvpy.mesh.fe_grid import FEGrid from ibvpy.fets.fets1D.fets1D2l import FETS1D2L if __name__ == '__main__': fets_eval = FETS1D2L(mats_eval = MATS1DElastic(E=10., A=1.)) # 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],
class TestMultiDomain( unittest.TestCase): ''' Test functionality connected with kinematic constraints on multiple domains. ''' def setUp(self): self.fets_eval = FETS1D2L(mats_eval = MATS1DElastic(E=10.)) # Discretization self.fe_domain1 = FEGrid( coord_max = (3.,0.,0.), shape = (3,), fets_eval = self.fets_eval ) self.fe_domain2 = FEGrid( coord_min = (3.,0.,0.), coord_max = (6.,0.,0.), shape = (3,), fets_eval = self.fets_eval ) self.fe_domain3 = FEGrid( coord_min = (3.,0.,0.), coord_max = (6.,0.,0.), shape = (3,), fets_eval = self.fets_eval ) self.ts = TS( dof_resultants = True, sdomain = [ self.fe_domain1, self.fe_domain2 , self.fe_domain3 ], bcond_list = [BCDof(var='u', dof = 0, value = 0.), BCDof(var='u', dof = 4, link_dofs = [3], link_coeffs = [1.], value = 0. ), BCDof(var='f', dof = 7, value = 1, link_dofs = [2], link_coeffs = [2] ) ], 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 self.tloop = TLoop( tstepper = self.ts, tline = TLine( min = 0.0, step = 1, max = 1.0 )) def test_bar2( self ): '''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 ''' self.fe_domain1.set( coord_min = (0,0,0), coord_max = (10,0,0), shape = (10,) ) self.fe_domain2.set( coord_min = (10,0,0), coord_max = (20,0,0), shape = (10,) ) self.ts.set( sdomain = [ self.fe_domain1, self.fe_domain2 ], 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 ) ] ) u = self.tloop.eval() # expected solution u_ex = array([0., 1., 2., 3., 4., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 6., 7., 8., 9.,10.], dtype = float ) for u_, u_ex_ in zip( u, u_ex ): self.assertAlmostEqual( u_, u_ex_ ) return # @todo - reactivate this test. # # '---------------------------------------------------------------' # '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 # self.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 = self.tloop.eval() # expected solution u_ex = array([0., 1/10., 2/10. , 3/10. , 4/10. , 5/10., 5/10. , 5/10. , 5/10. , 5/10., 5/10., 5/10., 5/10., 5/10., 5/10., 5/10., 5/10., 6/10., 7/10., 8/10., 9/10., 1. ], dtype = float ) for u_, u_ex_ in zip( u, u_ex ): self.assertAlmostEqual( u_, u_ex_ ) # def test_bar4( self ): '''Clamped bar 3 domains, each with 2 elems (displ at right end) [0]-[1]-[2] [3]-[4]-[5] [6]-[7]-[8] u[0] = 0, u[2] = u[3], u[5] = u[6], u[8] = 1''' self.fe_domain1.set( coord_min = (0,0,0), coord_max = (2,0,0), shape = (2,) ) self.fe_domain2.set( coord_min = (2,0,0), coord_max = (4,0,0), shape = (2,) ) self.fe_domain3.set( coord_min = (4,0,0), coord_max = (6,0,0), shape = (2,) ) self.ts.set( sdomain = [ self.fe_domain1, self.fe_domain2, self.fe_domain3 ], dof_resultants = True, bcond_list = [BCDof(var='u', dof = 0, value = 0.), BCDof(var='u', dof = 2, link_dofs = [3], link_coeffs = [1.], value = 0. ), BCDof(var='u', dof = 5, link_dofs = [6], link_coeffs = [1.], value = 0. ), BCDof(var='u', dof = 8, value = 1 ) ], rtrace_list = [ RTraceGraph(name = 'Fi,right over u_right (iteration)' , var_y = 'F_int', idx_y = 0, var_x = 'U_k', idx_x = 1), ] ) # system solver u = self.tloop.eval() # expected solution u_ex = array([0., 1/6., 1/3., 1/3., 1/2. , 2/3., 2/3., 5/6., 1. ], dtype = float ) for u_, u_ex_ in zip( u, u_ex ): self.assertAlmostEqual( u_, u_ex_ ) # def test_bar5( self ): '''Clamped bar with 4 elements. Elements 2-4 are reinforced with another bar with 3 elements [0]-[1]-[2]-[3]-[4] [5]-[6]-[7] u[0] = 0, u[1] = u[5], u[3] = u[7], u[4] = 1 ''' self.fe_domain1.set( coord_min = (0,0,0), coord_max = (4,0,0), shape = (4,) ) self.fe_domain2.set( coord_min = (1,0,0), coord_max = (3,0,0), shape = (2,) ) self.ts.set( sdomain = [ self.fe_domain1, self.fe_domain2 ], bcond_list = [ BCDof(var='u', dof = 0, value = 0.), BCDof(var='u', dof = 5, link_dofs = [1], link_coeffs = [1.], value = 0. ), BCDof(var='u', dof = 7, link_dofs = [3], link_coeffs = [1.], value = 0. ), BCDof(var='u', dof = 4, value = 1 ) ] ) u = self.tloop.eval() # expected solution u_ex = array([0., 1/3., 0.5, 2/3., 1., 1/3., 0.5, 2/3.], dtype = float ) for u_, u_ex_ in zip( u, u_ex ): self.assertAlmostEqual( u_, u_ex_ ) def test_bar6( self ): '''Clamped bar with 4 elements. Elements 2-4 are reinforced with another bar with 1 element linked proportianally [0]-[1]-[2]-[3]-[4] [5]-[6] u[0] = 0, u[1] = u[5], u[3] = u[7], u[4] = 1''' self.fe_domain1.set( coord_min = (0,0,0), coord_max = (4,0,0), shape = (4,) ) self.fe_domain2.set( coord_min = (1.5,0,0), coord_max = (2.5,0,0), shape = (1,) ) self.ts.set( sdomain = [ self.fe_domain1, self.fe_domain2 ], bcond_list = [ BCDof(var='u', dof = 0, value = 0.), BCDof(var='u', dof = 5, link_dofs = [1,2], link_coeffs = [.5,.5] ), BCDof(var='u', dof = 6, link_dofs = [2,3], link_coeffs = [.5,.5] ), BCDof(var='u', dof = 4, value = 1 ) ] ) u = self.tloop.eval() # expected solution u_ex = array([-0., 0.3, 0.5 , 0.7 , 1. , 0.4, 0.6], dtype = float ) for u_, u_ex_ in zip( u, u_ex ): self.assertAlmostEqual( u_, u_ex_ ) def test_bar7( self ): '''Two clamped beams link in parallel and loaded by force at right end [5]-[6]-[7]-[8]-[9] [0]-[1]-[2]-[3]-[4] u[5] = u[0], u[0] = 0, u[4] = u[9], R[4] = 1''' self.fe_domain1.set( coord_min = (0,0,0), coord_max = (4,0,0), shape = (4,) ) self.fe_domain2.set( coord_min = (0,0,0), coord_max = (4,0,0), shape = (4,) ) self.ts.set( sdomain = [ self.fe_domain1, self.fe_domain2 ], bcond_list = [BCDof(var='u', dof = 0, value = 0.), BCDof(var='u', dof = 5, link_dofs = [0], link_coeffs = [1.] ), BCDof(var='u', dof = 4, link_dofs = [9], link_coeffs = [0.5] ), BCDof(var='f', dof = 4, value = 1 ), BCDof(var='f', dof = 9, value = 1 ) ] ) u = self.tloop.eval() # expected solution u_ex = array([-0. , 0.06, 0.12, 0.18, 0.24, 0., 0.12, 0.24 , 0.36, 0.48], dtype = float ) for u_, u_ex_ in zip( u, u_ex ): self.assertAlmostEqual( u_, u_ex_ )
from ibvpy.mats.mats1D.mats1D_elastic.mats1D_elastic import MATS1DElastic from ibvpy.mesh.fe_grid import FEGrid from numpy import array, sqrt from scipy.linalg import norm if __name__ == '__main__': fets_eval = FETS1D2L(mats_eval=MATS1DElastic(E=10.)) # 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)) '''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)]
self.ax6.set_ylim(np.amin(self.sig_record), np.amax(self.sig_record)) self.figure.canvas.draw() view = View( Group( Item('time', label='t/T_max'), ), dock='vertical', resizable=True, height=0.9, width=1.0 ) if __name__ == '__main__': ts = TStepper() n_dofs = ts.domain.n_dofs loading_scenario = LoadingScenario() ts.bc_list = [BCDof(var='u', dof=0, value=0.0), BCDof( var='u', dof=n_dofs - 1, time_function=loading_scenario.time_func)] tl = TLoop(ts=ts) loading_scenario = LoadingScenario() window = BondSlipModel( mats_eval=ts.mats_eval, fets_eval=ts.fets_eval, time_stepper=ts, time_loop=tl, loading_scenario=loading_scenario) # window.draw()
fe_domain1 = FEGrid(coord_max=(10., 0., 0.), shape=(10,), fets_eval=fets_eval) fe_domain2 = FEGrid(coord_min=(10., 0., 0.), coord_max=(20., 0., 0.), shape=(10,), fets_eval=fets_eval) fe_domain = FEDomain(subdomains=[fe_domain1, fe_domain2]) ts = TS(dof_resultants=True, sdomain=fe_domain, 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)) ts.set(sdomain=FEDomain(subdomains=[fe_domain1, fe_domain2])) ts.set(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)])
import unittest from ibvpy.api import TStepper as TS, RTraceGraph, RTraceDomainField, TLoop, TLine, BCDof, IBVPSolve as IS, DOTSEval from ibvpy.mats.mats1D.mats1D_elastic.mats1D_elastic import MATS1DElastic from ibvpy.mesh.fe_grid import FEGrid from ibvpy.fets.fets1D.fets1D2l import FETS1D2L if __name__ == "__main__": 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)
from ibvpy.bcond.bc_slice import BCSlice from ibvpy.mesh.fe_grid import FEGrid from ibvpy.fets.fets1D.fets1D2l import FETS1D2L if __name__ == '__main__': fets_eval = FETS1D2L(mats_eval = MATS1DElastic(E=10., A=1.)) # 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 = (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. ) ]
#from sys_matrix import SysSparseMtx, SysDenseMtx from ibvpy.api import \ TStepper as TS, RTDofGraph, TLoop, \ TLine, BCDof from ibvpy.fets.fets1D.fets1D2l import FETS1D2L from ibvpy.mats.mats1D.mats1D_elastic.mats1D_elastic import MATS1DElastic from ibvpy.mesh.fe_grid import FEGrid if __name__ == '__main__': fets_eval = FETS1D2L(mats_eval=MATS1DElastic(E=10.)) # 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 = [
class TestMultiDomain(unittest.TestCase): ''' Test functionality connected with kinematic constraints on multiple domains. ''' def setUp(self): self.fets_eval = FETS1D2L(mats_eval=MATS1DElastic(E=10.)) # Discretization self.fe_domain1 = FEGrid(coord_max=(3., 0., 0.), shape=(3, ), fets_eval=self.fets_eval) self.fe_domain2 = FEGrid(coord_min=(3., 0., 0.), coord_max=(6., 0., 0.), shape=(3, ), fets_eval=self.fets_eval) self.fe_domain3 = FEGrid(coord_min=(3., 0., 0.), coord_max=(6., 0., 0.), shape=(3, ), fets_eval=self.fets_eval) self.ts = TS( dof_resultants=True, sdomain=[self.fe_domain1, self.fe_domain2, self.fe_domain3], bcond_list=[ BCDof(var='u', dof=0, value=0.), BCDof(var='u', dof=4, link_dofs=[3], link_coeffs=[1.], value=0.), BCDof(var='f', dof=7, value=1, link_dofs=[2], link_coeffs=[2]) ], 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 self.tloop = TLoop(tstepper=self.ts, tline=TLine(min=0.0, step=1, max=1.0)) def test_bar2(self): '''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 ''' self.fe_domain1.set(coord_min=(0, 0, 0), coord_max=(10, 0, 0), shape=(10, )) self.fe_domain2.set(coord_min=(10, 0, 0), coord_max=(20, 0, 0), shape=(10, )) self.ts.set(sdomain=[self.fe_domain1, self.fe_domain2], 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) ]) u = self.tloop.eval() # expected solution u_ex = array([ 0., 1., 2., 3., 4., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 6., 7., 8., 9., 10. ], dtype=float) for u_, u_ex_ in zip(u, u_ex): self.assertAlmostEqual(u_, u_ex_) return # @todo - reactivate this test. # # '---------------------------------------------------------------' # '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 # self.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 = self.tloop.eval() # expected solution u_ex = array([ 0., 1 / 10., 2 / 10., 3 / 10., 4 / 10., 5 / 10., 5 / 10., 5 / 10., 5 / 10., 5 / 10., 5 / 10., 5 / 10., 5 / 10., 5 / 10., 5 / 10., 5 / 10., 5 / 10., 6 / 10., 7 / 10., 8 / 10., 9 / 10., 1. ], dtype=float) for u_, u_ex_ in zip(u, u_ex): self.assertAlmostEqual(u_, u_ex_) # def test_bar4(self): '''Clamped bar 3 domains, each with 2 elems (displ at right end) [0]-[1]-[2] [3]-[4]-[5] [6]-[7]-[8] u[0] = 0, u[2] = u[3], u[5] = u[6], u[8] = 1''' self.fe_domain1.set(coord_min=(0, 0, 0), coord_max=(2, 0, 0), shape=(2, )) self.fe_domain2.set(coord_min=(2, 0, 0), coord_max=(4, 0, 0), shape=(2, )) self.fe_domain3.set(coord_min=(4, 0, 0), coord_max=(6, 0, 0), shape=(2, )) self.ts.set( sdomain=[self.fe_domain1, self.fe_domain2, self.fe_domain3], dof_resultants=True, bcond_list=[ BCDof(var='u', dof=0, value=0.), BCDof(var='u', dof=2, link_dofs=[3], link_coeffs=[1.], value=0.), BCDof(var='u', dof=5, link_dofs=[6], link_coeffs=[1.], value=0.), BCDof(var='u', dof=8, value=1) ], rtrace_list=[ RTraceGraph(name='Fi,right over u_right (iteration)', var_y='F_int', idx_y=0, var_x='U_k', idx_x=1), ]) # system solver u = self.tloop.eval() # expected solution u_ex = array( [0., 1 / 6., 1 / 3., 1 / 3., 1 / 2., 2 / 3., 2 / 3., 5 / 6., 1.], dtype=float) for u_, u_ex_ in zip(u, u_ex): self.assertAlmostEqual(u_, u_ex_) # def test_bar5(self): '''Clamped bar with 4 elements. Elements 2-4 are reinforced with another bar with 3 elements [0]-[1]-[2]-[3]-[4] [5]-[6]-[7] u[0] = 0, u[1] = u[5], u[3] = u[7], u[4] = 1 ''' self.fe_domain1.set(coord_min=(0, 0, 0), coord_max=(4, 0, 0), shape=(4, )) self.fe_domain2.set(coord_min=(1, 0, 0), coord_max=(3, 0, 0), shape=(2, )) self.ts.set(sdomain=[self.fe_domain1, self.fe_domain2], bcond_list=[ BCDof(var='u', dof=0, value=0.), BCDof(var='u', dof=5, link_dofs=[1], link_coeffs=[1.], value=0.), BCDof(var='u', dof=7, link_dofs=[3], link_coeffs=[1.], value=0.), BCDof(var='u', dof=4, value=1) ]) u = self.tloop.eval() # expected solution u_ex = array([0., 1 / 3., 0.5, 2 / 3., 1., 1 / 3., 0.5, 2 / 3.], dtype=float) for u_, u_ex_ in zip(u, u_ex): self.assertAlmostEqual(u_, u_ex_) def test_bar6(self): '''Clamped bar with 4 elements. Elements 2-4 are reinforced with another bar with 1 element linked proportianally [0]-[1]-[2]-[3]-[4] [5]-[6] u[0] = 0, u[1] = u[5], u[3] = u[7], u[4] = 1''' self.fe_domain1.set(coord_min=(0, 0, 0), coord_max=(4, 0, 0), shape=(4, )) self.fe_domain2.set(coord_min=(1.5, 0, 0), coord_max=(2.5, 0, 0), shape=(1, )) self.ts.set(sdomain=[self.fe_domain1, self.fe_domain2], bcond_list=[ BCDof(var='u', dof=0, value=0.), BCDof(var='u', dof=5, link_dofs=[1, 2], link_coeffs=[.5, .5]), BCDof(var='u', dof=6, link_dofs=[2, 3], link_coeffs=[.5, .5]), BCDof(var='u', dof=4, value=1) ]) u = self.tloop.eval() # expected solution u_ex = array([-0., 0.3, 0.5, 0.7, 1., 0.4, 0.6], dtype=float) for u_, u_ex_ in zip(u, u_ex): self.assertAlmostEqual(u_, u_ex_) def test_bar7(self): '''Two clamped beams link in parallel and loaded by force at right end [5]-[6]-[7]-[8]-[9] [0]-[1]-[2]-[3]-[4] u[5] = u[0], u[0] = 0, u[4] = u[9], R[4] = 1''' self.fe_domain1.set(coord_min=(0, 0, 0), coord_max=(4, 0, 0), shape=(4, )) self.fe_domain2.set(coord_min=(0, 0, 0), coord_max=(4, 0, 0), shape=(4, )) self.ts.set(sdomain=[self.fe_domain1, self.fe_domain2], bcond_list=[ BCDof(var='u', dof=0, value=0.), BCDof(var='u', dof=5, link_dofs=[0], link_coeffs=[1.]), BCDof(var='u', dof=4, link_dofs=[9], link_coeffs=[0.5]), BCDof(var='f', dof=4, value=1), BCDof(var='f', dof=9, value=1) ]) u = self.tloop.eval() # expected solution u_ex = array([-0., 0.06, 0.12, 0.18, 0.24, 0., 0.12, 0.24, 0.36, 0.48], dtype=float) for u_, u_ex_ in zip(u, u_ex): self.assertAlmostEqual(u_, u_ex_)
from ibvpy.fets.fets1D.fets1D2l import FETS1D2L from ibvpy.mats.mats1D.mats1D_elastic.mats1D_elastic import MATS1DElastic from ibvpy.mesh.fe_grid import FEGrid if __name__ == '__main__': fets_eval = FETS1D2L(mats_eval=MATS1DElastic(E=10.)) # 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 = [RTraceGraph(name='Fi,right over u_right (iteration)', var_y='F_int', idx_y=3,
ts = TStepper(tse=tseval, bcond_list=[bcond_alpha], rtrace_list=[ RTDofGraph(name='strain 0 - stress 0', var_x='eps_app', idx_x=0, var_y='sig_app', idx_y=0, record_on='update'), RTDofGraph(name='strain 1 - stress 1', var_x='eps_app', idx_x=1, var_y='sig_app', idx_y=1, record_on='update'), RTDofGraph(name='strain 0 - stress 1', var_x='eps_app', idx_x=0, var_y='sig_app', idx_y=1, record_on='update'), RTDofGraph(name='strain 1 - stress 0', var_x='eps_app', idx_x=1, var_y='sig_app', idx_y=0, record_on='update'), RTDofGraph(name='strain 0 - strain 1', var_x='eps_app', idx_x=0, var_y='eps_app', idx_y=1, record_on='update'), ])