def demo1d(): # Geometry # length = 1.0 # Material and FE Formulation # from ibvpy.fets.fets1D import FETS1D2L, FETS1D2L3U from ibvpy.mats.mats1D import MATS1DElastic mats_eval = MATS1DElastic(E=100., initial_strain=TemperatureLinFn(length=length, n_dims=1, offset=0.5)) fets_eval = FETS1D2L3U(mats_eval=mats_eval) fets_eval.vtk_r *= 0.99 # Discretization # domain = FEGrid(coord_max=(length, 0., 0.), n_elems=(10, ), fets_eval=fets_eval) bcond_list = [ BCSlice(var='u', dims=[0], slice=domain[0, 0], value=0), #BCSlice( var = 'u', dims = [0], slice = domain[-1, -1], value = 0 ) ] ts = TS(sdomain=domain, bcond_list=bcond_list, rtrace_list=[sig_trace, eps_trace, eps0_trace, eps1t_trace]) # Time integration # tloop = TLoop(tstepper=ts, tline=TLine(min=0.0, step=1, max=1.0)) tloop.eval() # Postprocessing # legend = [] plot_sig(eps_trace, 'eps', legend) plot_sig(eps0_trace, 'eps0', legend) plot_sig(eps1t_trace, 'eps1t', legend) p.legend(legend) p.show()
def _get_explorer_config(self): from ibvpy.api import BCDof, TLine, RTraceGraph return {'bcond_list': [BCDof(var='u', dof=0, value=0.01, time_function=lambda t: t)], 'rtrace_list': [RTraceGraph(name='strain - stress', var_x='eps_app', idx_x=0, var_y='sig_app', idx_y=0, record_on='update'), RTraceGraph(name='strain - strain', var_x='eps_app', idx_x=0, var_y='eps_app', idx_y=1, record_on='update'), RTraceGraph(name='stress - stress', var_x='sig_app', idx_x=0, var_y='sig_app', idx_y=1, record_on='update'), RTraceGraph(name='Stress - Strain', var_x='F_int', idx_x=0, var_y='U_k', idx_y=0, record_on='update'), RTraceGraph(name='Strain - Strain', var_x='U_k', idx_x=0, var_y='U_k', idx_y=1, record_on='update'), RTraceGraph(name='Stress - Stress', var_x='F_int', idx_x=0, var_y='F_int', idx_y=1, record_on='update'), RTraceGraph(name='sig1 - eps1', var_x='F_int', idx_x=0, var_y='U_k', idx_y=0, record_on='update'), RTraceGraph(name='sig2 - sig3', var_x='F_int', idx_x=1, var_y='F_int', idx_y=2, record_on='update'), RTraceGraph(name='eps2 - eps3', var_x='U_k', idx_x=1, var_y='U_k', idx_y=2, record_on='update') ], 'tline': TLine(step=0.1, max=1.0) } def _set_explorer_config(self, value): self._explorer_config = value
def _get_explorer_config(self): from ibvpy.api import TLine, RTraceGraph, BCDof ec = super(MATS1DDamage, self)._get_explorer_config() ec['mats_eval'] = MATS1DDamage(E=1.0, epsilon_0=1.0, epsilon_f=5) ec['bcond_list'] = [ BCDof(var='u', dof=0, value=1.7, time_function=lambda t: (1 + 0.1 * t) * sin(t)) ] ec['tline'] = TLine(step=0.1, max=10) ec['rtrace_list'] = [ RTraceGraph(name='strain - stress', var_x='eps_app', idx_x=0, var_y='sig_app', idx_y=0, record_on='update'), RTraceGraph(name='time - damage', var_x='time', idx_x=0, var_y='omega', idx_y=0, record_on='update') ] return ec
def demo2d(): # Geometry # length = 1.0 from ibvpy.fets.fets2D import FETS2D4Q, FETS2D4Q8U, FETS2D4Q12U from ibvpy.mats.mats2D import MATS2DElastic # Material and FE Formulation # lin_x_temperature = TemperatureLinFn(length=length, n_dims=2) fets_eval = FETS2D4Q12U(mats_eval=MATS2DElastic( E=30e5, nu=0.2, initial_strain=lin_x_temperature)) fets_eval.vtk_r *= 0.99 # Discretization # domain = FEGrid(coord_max=(length, length, 0.), shape=(10, 10), fets_eval=fets_eval) bcond_list = [ BCSlice(var='u', dims=[0, 1], slice=domain[0, 0, 0, 0], value=0), BCSlice(var='u', dims=[1], slice=domain[0, -1, 0, -1], value=0), ] rtrace_list = [sig_trace, eps_trace, eps0_trace, eps1t_trace, u_trace] ts = TS( sdomain=domain, bcond_list=bcond_list, rtrace_list=rtrace_list, ) # Time integration # tloop = TLoop(tstepper=ts, tline=TLine(min=0.0, step=1, max=1.0)) tloop.eval() # Postprocessing # app = IBVPyApp(ibv_resource=tloop) app.main()
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 _tline_default(self): return TLine(min=0.0, step=1.0, max=1.0)
def __demo__(): from ibvpy.api import \ TStepper as TS, RTraceGraph, RTraceDomainListField, TLoop, \ TLine, BCSlice, FEDomain, FERefinementGrid from ibvpy.mats.mats1D.mats1D_elastic.mats1D_elastic import MATS1DElastic fets_eval = FETS1D2L(mats_eval = MATS1DElastic(E = 10.)) from ibvpy.mesh.fe_grid import FEGrid fe_domain = FEDomain() r1 = FERefinementGrid(fets_eval = fets_eval, domain = fe_domain) r2 = FERefinementGrid(fets_eval = fets_eval, domain = fe_domain) # Discretization domain1 = FEGrid(coord_max = (3.,), shape = (3,), fets_eval = fets_eval, level = r1) domain2 = FEGrid(coord_min = (3.,), coord_max = (6.,), shape = (3,), fets_eval = fets_eval, level = r2) ts = TS(dof_resultants = True, sdomain = fe_domain, bcond_list = [BCSlice(var = 'u', dims = [0], value = 0, slice = domain1[0, 0]), BCSlice(var = 'u', dims = [0], value = 0, slice = domain1[-1, -1], link_slice = domain2[0, 0], link_coeffs = [1.]), BCSlice(var = 'f', dims = [0], value = 1, slice = domain2[-1, -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), RTraceDomainListField(name = 'Stress' , var = 'sig_app', idx = 0), RTraceDomainListField(name = 'Displacement' , var = 'u', idx = 0, warp = True), RTraceDomainListField(name = 'N0' , var = 'N_mtx', idx = 0, record_on = 'update') ] ) # Add the time-loop control tloop = TLoop(tstepper = ts, tline = TLine(min = 0.0, step = 0.5, max = 1.0)) print '---- result ----' print tloop.eval() print ts.F_int print ts.rtrace_list[0].trace.ydata # Put the whole stuff into the simulation-framework to map the # individual pieces of definition into the user interface. # from ibvpy.plugins.ibvpy_app import IBVPyApp app = IBVPyApp(ibv_resource = tloop) app.main()
def __demo__(): from ibvpy.api import \ TStepper as TS, RTraceDomainListField, TLoop, \ TLine, BCSlice, FEDomain, FERefinementGrid, FEGrid from ibvpy.mats.mats2D.mats2D_elastic.mats2D_elastic import MATS2DElastic fets_eval = FETS2D4Q8U(mats_eval=MATS2DElastic()) fe_domain = FEDomain() r1 = FERefinementGrid(fets_eval=fets_eval, domain=fe_domain) r2 = FERefinementGrid(fets_eval=fets_eval, domain=fe_domain) # Discretization domain1 = FEGrid(coord_max=(3., 3.), shape=(10, 4), fets_eval=fets_eval, level=r1) domain2 = FEGrid(coord_min=(3., 0.), coord_max=(6., 3), shape=(10, 4), fets_eval=fets_eval, level=r2) ts = TS( dof_resultants=True, sdomain=[domain1, domain2], # fe_domain, bcond_list=[ # Fix the left edge of domain1 BCSlice(var='u', dims=[0, 1], value=0, slice=domain1[0, :, 0, :]), # Link the right edge of domain1 with the left edge of domain2 # # note that following arrays must have the same lengths: # slice and link_slice # dims, link_dims and link_coeffs must have the same lengths # VAR-1: # linking along the complete line between 'domain1' and 'domain2' # all nodes along the y-axis # (used linking of more nodes at once in 'BCSlice') # BCSlice(var='u', dims=[0, 1], value=0.0, slice=domain1[-1, :, -1, :], link_slice=domain2[0, :, 0, :], link_dims=[0, 1], link_coeffs=[1., 1.]), # VAR-2: # linking along individual points between 'domain1' and 'domain2' # (used linking of single nodes in 'BCSlice') # # BCSlice(var='u', dims=[0, 1], value=0.0, # slice=domain1[-1, -1, -1, -1], # link_slice=domain2[0, -1, 0, -1], # link_dims=[0, 1], # link_coeffs=[1., 1.]), # BCSlice(var='u', dims=[0, 1], value=0.0, # slice=domain1[-1, 0, -1, 0], # link_slice=domain2[0, 0, 0, 0], # link_dims=[0, 1], # link_coeffs=[1., 1.]), # Load the right edge of domain2 BCSlice(var='f', dims=[0], value=1, slice=domain2[-1, :, -1, :]) ], rtrace_list=[ RTraceDomainListField(name='Stress', var='sig_app', idx=0), RTraceDomainListField(name='Displacement', var='u', idx=0, warp=True), ]) # Add the time-loop control tloop = TLoop(tstepper=ts, debug=False, tline=TLine(min=0.0, step=1.0, max=1.0)) print '---- result ----' print tloop.eval() # Put the whole stuff into the simulation-framework to map the # individual pieces of definition into the user interface. # from ibvpy.plugins.ibvpy_app import IBVPyApp app = IBVPyApp(ibv_resource=tloop) app.main()
def _tline_default(self): t_max = 1.0 d_t = 0.1 return TLine(min=0.0, step=d_t, max=t_max, time_change_notifier=self.time_changed, )
def example_with_new_domain(): from ibvpy.api import \ TStepper as TS, RTraceDomainListField, TLoop, TLine from ibvpy.tmodel.mats2D5.mats2D5_bond.mats2D_bond import MATS2D5Bond from ibvpy.api import BCDofGroup from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q fets_eval = FETS2DTF(parent_fets=FETS2D4Q(), mats_eval=MATS2D5Bond(E_m=30, nu_m=0.2, E_f=10, nu_f=0.1, G=10.)) from ibvpy.mesh.fe_grid import FEGrid from mathkit.mfn import MFnLineArray # Discretization fe_grid = FEGrid(coord_max=(10., 4., 0.), n_elems=(10, 3), fets_eval=fets_eval) mf = MFnLineArray( # xdata = arange(10), ydata=array([0, 1, 2, 3])) tstepper = TS(sdomain=fe_grid, bcond_list=[BCDofGroup(var='u', value=0., dims=[0, 1], 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], time_function=mf.get_value, get_dof_method=fe_grid.get_right_dofs)], rtrace_list=[ # RTDofGraph(name = 'Fi,right over u_right (iteration)' , # var_y = 'F_int', idx_y = right_dof, # var_x = 'U_k', idx_x = right_dof, # record_on = 'update'), # RTraceDomainListField(name = 'Stress' , # var = 'sig_app', idx = 0, # #position = 'int_pnts', # record_on = 'update'), # RTraceDomainListField(name = 'Damage' , # var = 'omega', idx = 0, # record_on = 'update', # warp = True), RTraceDomainListField(name='Displ matrix', var='u_m', idx=0, record_on='update', warp=True), RTraceDomainListField(name='Displ reinf', var='u_f', idx=0, record_on='update', warp=True), # RTraceDomainListField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ] ) # Add the time-loop control #global tloop tloop = TLoop(tstepper=tstepper, KMAX=300, tolerance=1e-4, tline=TLine(min=0.0, step=1.0, max=1.0)) #import cProfile #cProfile.run('tloop.eval()', 'tloop_prof' ) print(tloop.eval()) #import pstats #p = pstats.Stats('tloop_prof') # p.strip_dirs() # print 'cumulative' # p.sort_stats('cumulative').print_stats(20) # print 'time' # p.sort_stats('time').print_stats(20) # Put the whole thing into the simulation-framework to map the # individual pieces of definition into the user interface. # from ibvpy.plugins.ibvpy_app import IBVPyApp app = IBVPyApp(ibv_resource=tloop) app.main()
def xtest_L_shaped(): '''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''' mp = MATS2DScalarDamage( E=34.e3, nu=0.2, epsilon_0=59.e-6, epsilon_f=3.2e-3, #epsilon_f = 3.2e-1, #stiffness = "algorithmic", strain_norm_type='Mises') # mp = MATS2DElastic( E = 34.e3, # nu = 0.2 ) fets_eval = FETS2D4Q(mats_eval=mp) discr = (10, 10) # Discretization fe_domain1 = FEGrid(coord_min=(0, 0, 0), coord_max=(1., 1., 0.), shape=discr, n_nodal_dofs=fets_eval.n_nodal_dofs, dof_r=fets_eval.dof_r, geo_r=fets_eval.geo_r) fe_domain2 = FEGrid(coord_min=(0., 1., 0), coord_max=(1., 2., 0.), shape=discr, n_nodal_dofs=fets_eval.n_nodal_dofs, dof_r=fets_eval.dof_r, geo_r=fets_eval.geo_r) fe_domain3 = FEGrid(coord_min=(1., 1., 0), coord_max=(2., 2., 0.), shape=discr, n_nodal_dofs=fets_eval.n_nodal_dofs, dof_r=fets_eval.dof_r, geo_r=fets_eval.geo_r) ts = TS( iterms=[(fets_eval, fe_domain1), (fets_eval, fe_domain2), (fets_eval, fe_domain3)], dof_resultants=True, bcond_list=[ BCDofGroup(var='u', value=0., dims=[0, 1], get_dof_method=fe_domain1.get_bottom_dofs), BCDofGroup(var='u', value=0., dims=[0, 1], get_dof_method=fe_domain3.get_left_dofs, get_link_dof_method=fe_domain2.get_right_dofs, link_coeffs=[1.]), BCDofGroup(var='u', value=0., dims=[0, 1], get_dof_method=fe_domain2.get_bottom_dofs, get_link_dof_method=fe_domain1.get_top_dofs, link_coeffs=[1.]), BCDofGroup(var='u', value=0.0004, dims=[1], get_dof_method=fe_domain3.get_right_dofs) ], rtrace_list=[ RTraceDomainListField(name='Displacement', var='u', idx=1), RTraceDomainListField(name='Damage', var='omega', idx=0, record_on='update', warp=True), # RTraceDomainListField(name = 'Stress' , # var = 'sig_app', idx = 0, # record_on = 'update', # warp = False), # RTraceDomainListField(name = 'Strain' , # var = 'eps_app', idx = 0, # record_on = 'update', # warp = False), ]) # Add the time-loop control global tloop tloop = TLoop(tstepper=ts, tolerance=1e-4, KMAX=50, tline=TLine(min=0.0, step=0.2, max=1.0)) tloop.eval() # import cProfile # cProfile.run('tloop.eval()', 'tloop_prof' ) # # import pstats # p = pstats.Stats('tloop_prof') # p.strip_dirs() # print 'cumulative' # p.sort_stats('cumulative').print_stats(20) # print 'time' # p.sort_stats('time').print_stats(20) from ibvpy.plugins.ibvpy_app import IBVPyApp app = IBVPyApp(ibv_resource=tloop) app.main()
def example_with_new_domain(): from ibvpy.api import \ TStepper as TS, RTraceDomainListField, TLoop, \ TLine, BCSlice from ibvpy.fets.fets2D.fets2D4q8u import FETS2D4Q8U from ibvpy.tmodel.mats3D.mats3D_cmdm import \ MATS3DMicroplaneDamage from ibvpy.tmodel.matsXD.matsXD_cmdm import PhiFnStrainSoftening # tmodel = MATS2DElastic(E=2,nu= .2, # stress_state= 'rotational_symetry') mats = MATS3DMicroplaneDamage(model_version='stiffness', E=34e3, nu=0.2, phi_fn=PhiFnStrainSoftening(G_f=0.001117, f_t=2.8968)) fets_eval = FETS2Drotsym(prototype_fets=FETS2D4Q8U(), mats_eval=mats) fets_eval.vtk_r *= 0.9 from ibvpy.mesh.fe_grid import FEGrid radius = sqrt(1. / pi) # f_i = (radius/2.)*2*pi # f_o = (radius)*2*pi # print 'f ',f_i,' ', f_o # Discretization fe_grid = FEGrid( # coord_min = (0.,radius/2.,0.), coord_max=(1., radius, 0.), shape=(20, 20), fets_eval=fets_eval) tstepper = TS(sdomain=fe_grid, bcond_list=[ BCSlice(var='u', value=0., dims=[0], slice=fe_grid[0, :, 0, :]), BCSlice(var='u', value=0., dims=[1], slice=fe_grid[0, 0, 0, 0]), BCSlice(var='u', value=1.e-3, dims=[0], slice=fe_grid[-1, :, -1, :]), ], rtrace_list=[ RTraceDomainListField(name='Stress', var='sig_app', idx=0, warp=True, record_on='update'), RTraceDomainListField(name='fracture_energy', var='fracture_energy', idx=0, warp=True, record_on='update'), RTraceDomainListField(name='Displacement', var='u', idx=0, record_on='update', warp=True), # RTraceDomainListField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ] ) # Add the time-loop control #global tloop tloop = TLoop(tstepper=tstepper, KMAX=300, tolerance=1e-4, tline=TLine(min=0.0, step=1.0, max=1.0)) #import cProfile #cProfile.run('tloop.eval()', 'tloop_prof' ) print(tloop.eval()) #import pstats #p = pstats.Stats('tloop_prof') # p.strip_dirs() # print 'cumulative' # p.sort_stats('cumulative').print_stats(20) # print 'time' # p.sort_stats('time').print_stats(20) # Put the whole thing into the simulation-framework to map the # individual pieces of definition into the user interface. # from ibvpy.plugins.ibvpy_app import IBVPyApp app = IBVPyApp(ibv_resource=tloop) app.main()
idx_y=right_dof, var_x='U_k', idx_x=right_dof), # RTraceDomainListField(name = 'Stress' , # var = 'sig_app', idx = 0, # record_on = 'update'), RTraceDomainListField(name='Displacement', var='u', idx=0), # RTraceDomainListField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ]) # Add the time-loop control global tloop tloop = TLoop(tstepper=ts, DT=0.5, tline=TLine(min=0.0, max=1.0, step=0.1)) import cProfile cProfile.run('tloop.eval()', 'tloop_prof') import pstats p = pstats.Stats('tloop_prof') p.strip_dirs() print 'cumulative' p.sort_stats('cumulative').print_stats(20) print 'time' p.sort_stats('time').print_stats(20) # Put the whole stuff into the simulation-framework to map the # individual pieces of definition into the user interface. #
def eval(self): elem_length = self.length / float(self.shape) flaw_radius = self.flaw_radius mats = MATS1DElasticWithFlaw(E=10., flaw_position=self.flaw_position, flaw_radius=flaw_radius, reduction_factor=self.reduction_factor) #fets_eval = FETS1D2L( mats_eval = mats ) fets_eval = FETS1D2L3U(mats_eval=mats) domain = FEGrid(coord_max=(self.length, 0., 0.), shape=(self.shape, ), fets_eval=fets_eval) avg_processor = RTNonlocalAvg( avg_fn=QuarticAF(radius=self.avg_radius, correction=True)) eps_app = RTraceDomainListField(name='Strain', position='int_pnts', var='eps_app', warp=False) damage = RTraceDomainListField(name='Damage', position='int_pnts', var='omega', warp=False) disp = RTraceDomainListField(name='Displacement', position='int_pnts', var='u', warp=False) sig_app = RTraceDomainListField(name='Stress', position='int_pnts', var='sig_app') right_dof = domain[-1, -1].dofs[0, 0, 0] rt_fu = RTDofGraph(name='Fi,right over u_right (iteration)', var_y='F_int', idx_y=right_dof, var_x='U_k', idx_x=right_dof) ts = TS( u_processor=avg_processor, dof_resultants=True, sdomain=domain, # conversion to list (square brackets) is only necessary for slicing of # single dofs, e.g "get_left_dofs()[0,1]" # bcond_list = [ BCDof(var='u', dof = 0, value = 0.) ] + # [ BCDof(var='u', dof = 2, value = 0.001 ) ]+ # [ ) ], bcond_list=[ BCDof(var='u', dof=0, value=0.), # BCDof(var='u', dof = 1, link_dofs = [2], link_coeffs = [0.5], # value = 0. ), # BCDof(var='u', dof = 2, link_dofs = [3], link_coeffs = [1.], # value = 0. ), BCDof( var='u', dof=right_dof, value=0.01, ) ], rtrace_list=[ rt_fu, eps_app, # damage, sig_app, disp, ]) # Add the time-loop control tloop = TLoop(tstepper=ts, KMAX=100, tolerance=1e-5, verbose_iteration=False, tline=TLine(min=0.0, step=1.0, max=1.0)) U = tloop.eval() p.subplot(221) rt_fu.refresh() rt_fu.trace.plot(p) eps = eps_app.subfields[0] xdata = eps.vtk_X[:, 0] ydata = eps.field_arr[:, 0, 0] idata = argsort(xdata) p.subplot(222) p.plot(xdata[idata], ydata[idata], 'o-') disp = disp.subfields[0] xdata = disp.vtk_X[:, 0] ydata = disp.field_arr[:, 0] idata = argsort(xdata) p.subplot(223) p.plot(xdata[idata], ydata[idata], 'o-') sig = sig_app.subfields[0] xdata = sig.vtk_X[:, 0] ydata = sig.field_arr[:, 0, 0] idata = argsort(xdata) p.subplot(224) p.plot(xdata[idata], ydata[idata], 'o-')
def example_2d(): from ibvpy.api import FEDomain, FERefinementGrid, FEGrid, TStepper as TS, \ BCDofGroup, RTraceDomainListField from ibvpy.api import TLoop, TLine from ibvpy.mesh.xfe_subdomain import XFESubDomain from ibvpy.tmodel.mats2D.mats2D_elastic.mats2D_elastic import MATS2DElastic from ibvpy.tmodel.mats2D import MATS2DPlastic from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q from ibvpy.fets.fets2D import FETS2D9Q from ibvpy.fets.fets2D.fets2D4q8u import FETS2D4Q8U from ibvpy.fets.fets_ls.fets_crack import FETSCrack #fets_eval = FETS2D4Q( mats_eval = MATS2DPlastic( E = 1., nu = 0. ) ) fets_eval = FETS2D4Q8U(mats_eval=MATS2DPlastic(E=1., nu=0.)) xfets_eval = FETSCrack(parent_fets=fets_eval, int_order=5, tri_subdivision=1) # Discretization fe_domain = FEDomain() fe_level1 = FERefinementGrid(domain=fe_domain, fets_eval=fets_eval) fe_grid1 = FEGrid(coord_max=(1., 1.), shape=(8, 8), fets_eval=fets_eval, level=fe_level1) #ls_function = lambda X, Y: X - Y - 0.13 ls_function = lambda X, Y: (X - 0.52)**2 + (Y - 0.72)**2 - 0.51**2 bls_function = lambda X, Y: -((X - 0.5)**2 + (Y - 0.21)**2 - 0.28**2) bls_function2 = lambda X, Y: -((X - 0.5)**2 + (Y - 0.21)**2 - 0.38**2) # design deficits: # - How to define a level set spanned over several fe_grids # (i.e. it is defined over the hierarchy of FESubDomains) # - Patching of subdomains within the FEPatchedGrid (FERefinementGrid) # - What are the compatibility conditions? # - What is the difference between FEGridLeveSetSlice # and FELSDomain? # FELSDomain is associated with a DOTS - Slice is not. # FEGrid has a multidimensional array - elem_grid # it can be accessed through this index. # it is masked by the activity map. The activity map can # be defined using slices and level sets. # the elems array enumerates the elements using the activity map. # in this way, the specialization of grids is available implicitly. # fe_xdomain = FELSDomain( domain=fe_domain, fets_eval=xfets_eval, fe_grid=fe_grid1, ls_function=ls_function, bls_function=bls_function, ) fe_tip_xdomain = FELSDomain( domain=fe_domain, fets_eval=xfets_eval, fe_grid=fe_xdomain, ls_function=bls_function, ) # deactivation must be done only after the dof enumeration has been completed fe_xdomain.deactivate_intg_elems_in_parent() fe_tip_xdomain.deactivate_intg_elems_in_parent() fe_xdomain.bls_function = bls_function2 fe_tip_xdomain.ls_function = bls_function2 # deactivation must be done only after the dof enumeration has been completed fe_xdomain.deactivate_intg_elems_in_parent() fe_tip_xdomain.deactivate_intg_elems_in_parent() # # General procedure: # 1) define the level sets with the boundaries # 2) use the bls to identify the tips of the level set # 3) use independent level sets to introduce indpendently junctions. # # get the extended dofs of the bls_elems and constrain it # cdofs = fe_tip_xdomain.elem_xdof_map.flatten() bc_list = [BCDof(var='u', dof=dof, value=0.0) for dof in cdofs] # construct the time stepper ts = TS( dof_resultants=True, sdomain=fe_domain, bcond_list=[ BCSlice( var='u', value=-0.1, dims=[1], slice=fe_grid1[:, 0, :, 0]), BCSlice( var='u', value=0., dims=[0], slice=fe_grid1[:, 0, :, 0]), BCSlice(var='u', value=0., dims=[0, 1], slice=fe_grid1[:, -1, :, -1]) ] + bc_list, rtrace_list=[ # RTDofGraph(name = 'Fi,right over u_right (iteration)' , # var_y = 'F_int', idx_y = 0, # var_x = 'U_k', idx_x = 1), RTraceDomainListField(name='Stress', var='sig_app', idx=0, warp=True), RTraceDomainListField(name='Displacement', var='u', idx=0, warp=True), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ]) # do = 'print' if do == 'print': p = 'state' if p == 'grids': print('fe_xdomain.ls mask') print(fe_xdomain.ls_mask) print('fe_xdomain.idx mask') print(fe_xdomain.idx_mask) print('fe_xdomain.intg mask') print(fe_xdomain.intg_mask) print('fe_xdomain.xelems_mask') print(fe_xdomain.xelems_mask) print('fe_xdomain.xelems_grid_ix') print(fe_xdomain.xelems_grid_ix) print('fe_xdomain.ls_elem_grid') print(fe_xdomain.ls_elem_grid) print('fe_xdomain.ls_ielem_grid') print(fe_xdomain.ls_ielem_grid) print('fe_xdomain.intg_elem_grid') print(fe_xdomain.intg_elem_grid) print('fe_tip_xdomain.ls_mask`') print(fe_tip_xdomain.ls_mask) print('fe_tip_xdomain.intg_mask`') print(fe_tip_xdomain.intg_mask) print('fe_tip_xdomain.idx_mask`') print(fe_tip_xdomain.idx_mask) print('fe_tip_xdomain.xelems_mask') print(fe_tip_xdomain.xelems_mask) print('fe_tip_xdomain.xelems_grid_ix') print(fe_tip_xdomain.xelems_grid_ix) print('fe_tip_xdomain.ls_elem_grid') print(fe_tip_xdomain.ls_elem_grid) print('fe_tip_xdomain.ls_ielems_grid') print(fe_tip_xdomain.ls_ielem_grid) print('fe_tip_xdomain.intg_elem_grid') print(fe_tip_xdomain.intg_elem_grid) if p == 'maps': print('fe_xdomain.elem_dof_map') print(fe_xdomain.elem_dof_map) print('fe_tip_xdomain.elem_dof_map') print(fe_tip_xdomain.elem_dof_map) print('fe_xdomain.elems') print(fe_xdomain.elems) print('fe_tip_xdomain.elems') print(fe_tip_xdomain.elems) print('fe_xdomain.elem_X_map') print(fe_xdomain.elem_X_map) print('fe_tip_xdomain.elem_X_map') print(fe_tip_xdomain.elem_X_map) if p == 'fields': print("ls_values ", fe_xdomain.dots.dof_node_ls_values) print("tip ls_values ", fe_tip_xdomain.dots.dof_node_ls_values) print('intersection points ', fe_xdomain.ls_intersection_r) print('tip intersection points ', fe_tip_xdomain.ls_intersection_r) print("triangles ", fe_xdomain.dots.rt_triangles) print("vtk points ", fe_xdomain.dots.vtk_X) print("vtk data ", fe_xdomain.dots.get_vtk_cell_data('blabla', 0, 0)) print('ip_triangles', fe_xdomain.dots.int_division) print('ip_coords', fe_xdomain.dots.ip_coords) print('ip_weigths', fe_xdomain.dots.ip_weights) print('ip_offset', fe_xdomain.dots.ip_offset) print('ip_X_coords', fe_xdomain.dots.ip_X) print('ip_ls', fe_xdomain.dots.ip_ls_values) print('vtk_ls', fe_xdomain.dots.vtk_ls_values) print('J_det ', fe_xdomain.dots.J_det_grid) if p == 'state': # Add the time-loop control print('STATE: initial') print('fe_xdomain.old_dots.state_elem grid') print(fe_xdomain.dots.state_start_elem_grid) print('fe_tip_xdomain.old_dots.state_elem grid') print(fe_tip_xdomain.dots.state_start_elem_grid) print('fe_xdomain.old_dots.state_end_elem grid') print(fe_xdomain.dots.state_end_elem_grid) print('fe_tip_xdomain.old_dots.state_end_elem grid') print(fe_tip_xdomain.dots.state_end_elem_grid) fe_xdomain.dots.state_array[:] = 25.5 print('state_array 25', fe_xdomain.dots.state_array) fe_tip_xdomain.dots.state_array[:] = 58 bls_function3 = lambda X, Y: -((X - 0.5)**2 + (Y - 0.21)**2 - 0.58**2) fe_xdomain.bls_function = bls_function3 fe_tip_xdomain.ls_function = bls_function3 print('STATE: changed') print('fe_xdomain.old_dots.state_elem grid') print(fe_xdomain.dots.state_start_elem_grid) print('fe_tip_xdomain.old_dots.state_elem grid') print(fe_tip_xdomain.dots.state_start_elem_grid) print('fe_xdomain.old_dots.state_end_elem grid') print(fe_xdomain.dots.state_end_elem_grid) print('fe_tip_xdomain.old_dots.state_end_elem grid') print(fe_tip_xdomain.dots.state_end_elem_grid) print('state_array 25', fe_xdomain.dots.state_array.shape) print('state_array 25', fe_xdomain.dots.state_array[570:]) print('state_array 58', fe_tip_xdomain.dots.state_array.shape) elif do == 'ui': tloop = TLoop(tstepper=ts, debug=False, tolerance=1e-4, KMAX=3, RESETMAX=0, tline=TLine(min=0.0, step=1, max=1.0)) tloop.eval() from ibvpy.plugins.ibvpy_app import IBVPyApp ibvpy_app = IBVPyApp(ibv_resource=ts) ibvpy_app.main()
def example_1d(): fets_eval = FETS1D2L3U(mats_eval=MATS1DElastic(E=20.)) xfets_eval = FETSCrack(parent_fets=fets_eval, int_order=2) # Discretization fe_domain = FEDomain() fe_level1 = FERefinementGrid(domain=fe_domain, fets_eval=fets_eval) fe_grid1 = FEGrid(coord_max=(2., 0., 0.), shape=(2, ), fets_eval=fets_eval, level=fe_level1) enr = True if enr: fe_xdomain = XFESubDomain( domain=fe_domain, fets_eval=xfets_eval, #fe_grid_idx_slice = fe_grid1[1,0], fe_grid_slice=fe_grid1['X - .75']) fe_xdomain.deactivate_sliced_elems() ts = TS( dof_resultants=True, sdomain=fe_domain, bcond_list=[ BCSlice(var='u', value=-1. / 2., dims=[0], slice=fe_grid1[0, 0]), BCSlice(var='u', value=0., dims=[0], slice=fe_grid1[-1, -1]), ], rtrace_list=[ # RTDofGraph(name = 'Fi,right over u_right (iteration)' , # var_y = 'F_int', idx_y = 0, # var_x = 'U_k', idx_x = 1), RTraceDomainListField(name='Stress', var='eps', idx=0, warp=True), RTraceDomainListField(name='Displacement', var='u', idx=0, warp=True), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ]) # # # Add the time-loop control tloop = TLoop(tstepper=ts, debug=True, tolerance=1e-4, RESETMAX=0, tline=TLine(min=0.0, step=1, max=1.0)) #print "elements ",fe_xdomain.elements[0] if enr: print('parent elems ', fe_xdomain.fe_grid_slice.elems) print('parent dofs ', fe_xdomain.fe_grid_slice.dofs) print("dofmap ", fe_xdomain.elem_dof_map) print("ls_values ", fe_xdomain.dots.dof_node_ls_values) print('intersection points ', fe_xdomain.fe_grid_slice.r_i) # print("triangles ", fe_xdomain.dots.int_division) print('ip_coords', fe_xdomain.dots.ip_coords) print('ip_weigths', fe_xdomain.dots.ip_weights) print('ip_offset ', fe_xdomain.dots.ip_offset) print('ip_X_coords', fe_xdomain.dots.ip_X) print('ip_ls', fe_xdomain.dots.ip_ls_values) print('vtk_X ', fe_xdomain.dots.vtk_X) print('vtk triangles ', fe_xdomain.dots.rt_triangles) print("vtk data ", fe_xdomain.dots.get_vtk_cell_data('blabla', 0, 0)) print('vtk_ls', fe_xdomain.dots.vtk_ls_values) print('J_det ', fe_xdomain.dots.J_det_grid) tloop.eval() from ibvpy.plugins.ibvpy_app import IBVPyApp ibvpy_app = IBVPyApp(ibv_resource=ts) ibvpy_app.main()
def peval( self ): '''Evaluation procedure. ''' #mv = MATS1DDamageView( model = mats_eval ) #mv.configure_traits() self.mats_m.reset_state() # Discretization # length = self.length domain = FEGrid( coord_min = ( 0., length / 5. ), coord_max = ( length, 0. ), shape = ( self.shape, 1 ), fets_eval = self.fets ) right_dofs = domain[-1, -1, -1, :].dofs[0, :, 0] print 'concrete_dofs', id( domain ), domain[:, 0, :, 0].dofs # Response tracers self.stress_strain = RTraceGraph( name = 'Fi,right over u_right (iteration)' , var_y = 'F_int', idx_y = right_dofs[0], var_x = 'U_k', idx_x = right_dofs[0] ) self.eps_m_field = RTraceDomainListField( name = 'eps_m' , position = 'int_pnts', var = 'eps1', idx = 0, warp = True ) self.eps_f_field = RTraceDomainListField( name = 'eps_f' , position = 'int_pnts', var = 'eps2', idx = 0, warp = True ) # Response tracers self.sig_m_field = RTraceDomainListField( name = 'sig_m' , position = 'int_pnts', var = 'mats_phase1_sig_app', idx = 0 ) self.sig_f_field = RTraceDomainListField( name = 'sig_f' , position = 'int_pnts', var = 'mats_phase2_sig_app', idx = 0 ) self.omega_m_field = RTraceDomainListField( name = 'omega_m' , position = 'int_pnts', var = 'mats_phase1_omega', idx = 0, warp = True ) # damage_onset_displ = self.mats_m.epsilon_0 * self.length go_behind = 1.5 finish_displ = go_behind * damage_onset_displ n_steps = 20 step_size = ( finish_displ - damage_onset_displ ) / n_steps tmax = 1 + n_steps def ls( t ): if t <= 1: return t else: return 1.0 + ( t - 1.0 ) / n_steps * ( go_behind - 1 ) ts = TSCrackLoc( dof_resultants = True, on_update = self.plot, sdomain = domain, bcond_list = [# define the left clamping BCSlice( var = 'u', value = 0., dims = [0], slice = domain[ 0, 0, 0, :] ), # loading at the right edge BCSlice( var = 'f', value = 1, dims = [0], slice = domain[-1, -1, -1, 0], time_function = ls ), # BCSlice(var='u', value = finish_displ, dims = [0], slice = domain[-1,-1,-1, 0], # time_function = ls ), # fix horizontal displacement in the top layer BCSlice( var = 'u', value = 0., dims = [0], slice = domain[:, -1, :, -1] ), # fix the vertical displacement all over the domain BCSlice( var = 'u', value = 0., dims = [1], slice = domain[ :, :, :, :] ) ], rtrace_list = [ self.stress_strain, self.eps_m_field, self.eps_f_field, self.sig_m_field, self.sig_f_field, self.omega_m_field ] ) # Add the time-loop control tloop = TLoop( tstepper = ts, KMAX = 200, debug = True, tolerance = 1e-5, tline = TLine( min = 0.0, step = 1.0, max = 1.0 ) ) print ts.rte_dict.keys() U = tloop.eval() self.plot() return array( [ U[right_dofs[-1]] ], dtype = 'float_' )
def combined_fe2D4q_with_fe2D4q8u(): fets_eval_4u_conc = FETS2D4Q(mats_eval=MATS2DElastic(E=28500, nu=0.2)) fets_eval_4u_steel = FETS2D4Q(mats_eval=MATS2DElastic(E=210000, nu=0.25)) fets_eval_8u = FETS2D4Q8U(mats_eval=MATS2DElastic()) # Discretization fe_domain = FEDomain() fe_grid_level1 = FERefinementGrid(name='master grid', fets_eval=fets_eval_4u_conc, domain=fe_domain) fe_grid = FEGrid(level=fe_grid_level1, coord_max=(2., 6., 0.), shape=(11, 30), fets_eval=fets_eval_4u_conc) fe_grid_level2 = FERefinementGrid(name='refinement grid', parent=fe_grid_level1, fets_eval=fets_eval_4u_steel, fine_cell_shape=(1, 1)) # fe_grid_level1[ 5, :5 ].refine_using( fe_grid_level2 ) # 1. first get the slice for the level - distinguish it from the slice at the subgrid # this includes slicing in the subgrids. what if the subgrid does not exist? # # Each subgrid must hold its own slice within the level. The index operator fills # the grid [...] instanciates the whole grid and returns the instance of # FEGridLevelSlice. The expanded subgrid contains its constructor slice. # # 2. If the slice is within an existing slice no change in the FESubgrid is required # only the instance of the slice is returned. The FEGridLevelSlice goes always into # an expanded part of FEGrid. # # 3. If the slice does not fit into any existing slice - all domain with an intersection # of the existing slice must be constructed as well. # # 2. deactivate elements # 3. # BUT how to impose the boundary conditions on the particular refinement? The # slice has an attribute fe_grid_level2.refine_elem((5, 0)) fe_grid_level2.refine_elem((5, 1)) fe_grid_level2.refine_elem((5, 2)) fe_grid_level2.refine_elem((5, 3)) fe_grid_level2.refine_elem((5, 4)) fe_grid_level2.refine_elem((5, 5)) # apply the boundary condition on a subgrid # print fe_grid_level2.fe_subgrids fe_first_grid = fe_grid_level2.fe_subgrids[0] ts = TS( dof_resultants=True, sdomain=fe_domain, bcond_list=[ BCSlice(var='f', value=1., dims=[0], slice=fe_grid[:, -1, :, -1]), BCSlice(var='u', value=0., dims=[0, 1], slice=fe_first_grid[:, 0, :, 0]) ], rtrace_list=[ RTraceGraph(name='Fi,right over u_right (iteration)', var_y='F_int', idx_y=0, var_x='U_k', idx_x=1), RTraceDomainListField(name='Stress', var='sig_app', idx=0, warp=True), # RTraceDomainField(name = 'Displacement' , # var = 'u', idx = 0), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ]) # Add the time-loop control tloop = TLoop(tstepper=ts, tline=TLine(min=0.0, step=1, max=1.0)) print tloop.eval() from ibvpy.plugins.ibvpy_app import IBVPyApp ibvpy_app = IBVPyApp(ibv_resource=tloop) ibvpy_app.main()
def example(): from ibvpy.api import \ TStepper as TS, RTDofGraph, RTraceDomainListField, TLoop, \ TLine, IBVPSolve as IS, DOTSEval, BCSlice from ibvpy.mesh.fe_grid import FEGrid from mathkit.mfn import MFnLineArray stiffness_concrete = 34000 * 0.03 * 0.03 A_fiber = 1. E_fiber = 1. stiffness_fiber = E_fiber * A_fiber d = 2 * sqrt(Pi) tau_max = 0.1 * d * Pi G = 100 u_max = 0.023 f_max = 0.2 mats_eval = MATS1D5Bond(mats_phase1=MATS1DElastic(E=stiffness_fiber), mats_phase2=MATS1DElastic(E=0), mats_ifslip=MATS1DPlastic(E=G, sigma_y=tau_max, K_bar=0., H_bar=0.), mats_ifopen=MATS1DElastic(E=0)) fets_eval = FETS1D52L4ULRH(mats_eval=mats_eval) domain = FEGrid(coord_max=(1., 0.2), shape=(16, 1), fets_eval=fets_eval) end_dof = domain[-1, 0, -1, 0].dofs[0, 0, 0] ts = TS(dof_resultants=True, sdomain=domain, # conversion to list (square brackets) is only necessary for slicing of # single dofs, e.g "get_left_dofs()[0,1]" bcond_list=[ BCSlice(var='u', value=0., dims=[0], slice=domain[:, :, :, -1]), BCSlice(var='u', value=0., dims=[1], slice=domain[:, :, :, :]), BCSlice(var='f', value=f_max, dims=[0], slice=domain[-1, 0, -1, 0]) ], rtrace_list=[RTDofGraph(name='Fi,right over u_right (iteration)', var_y='F_int', idx_y=end_dof, var_x='U_k', idx_x=end_dof), RTraceDomainListField(name='slip', var='slip', idx=0), RTraceDomainListField(name='eps1', var='eps1', idx=0), RTraceDomainListField(name='eps2', var='eps2', idx=0), RTraceDomainListField(name='shear_flow', var='shear_flow', idx=0), RTraceDomainListField(name='sig1', var='sig1', idx=0), RTraceDomainListField(name='sig2', var='sig2', idx=0), RTraceDomainListField(name='Displacement', var='u', idx=0) ]) # Add the time-loop control tloop = TLoop(tstepper=ts, KMAX=30, debug=False, tline=TLine(min=0.0, step=0.1, max=1.0)) print(tloop.eval()) # Put the whole stuff into the simulation-framework to map the # individual pieces of definition into the user interface. # from ibvpy.plugins.ibvpy_app import IBVPyApp app = IBVPyApp(ibv_resource=tloop) app.main()
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)]) print tloop.eval()
def test_bar4(): '''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''' fets_eval = FETS1D2L(mats_eval=MATS1DElastic(E=10., A=1.)) # Discretization fe_domain1 = FEGrid(coord_max=(2., 0., 0.), shape=(2, ), n_nodal_dofs=1, dof_r=fets_eval.dof_r, geo_r=fets_eval.geo_r) fe_domain2 = FEGrid(coord_min=(2., 0., 0.), coord_max=(4., 0., 0.), shape=(2, ), n_nodal_dofs=1, dof_r=fets_eval.dof_r, geo_r=fets_eval.geo_r) fe_domain3 = FEGrid(coord_min=(4., 0., 0.), coord_max=(6., 0., 0.), shape=(2, ), 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), (fets_eval, 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), RTraceDomainListField(name='Displacement', var='u', idx=0) ]) # Add the time-loop control tloop = TLoop(tstepper=ts, tline=TLine(min=0.0, step=1, max=1.0)) print tloop.eval() from ibvpy.plugins.ibvpy_app import IBVPyApp app = IBVPyApp(ibv_resource=tloop) app.main()
RTraceDomainListField( name = 'Displacement' , var = 'u', idx = 0 ), # RTraceDomainListField(name = 'Stress' , # var = 'sig', idx = 0, # record_on = 'update'), # RTraceDomainListField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ] ) # Add the time-loop control # global tloop tloop = TLoop( tstepper = ts, tline = TLine( min = 0.0, step = 0.5, max = .5 ) ) import cProfile cProfile.run( 'tloop.eval()', 'tloop_prof' ) # import pstats # p = pstats.Stats('tloop_prof') # p.strip_dirs() # print 'cumulative' # p.sort_stats('cumulative').print_stats(20) # print 'time' # p.sort_stats('time').print_stats(20) # Put the whole stuff into the simulation-framework to map the # individual pieces of definition into the user interface. #
def app(): avg_radius = 0.03 md = MATS2DScalarDamage(E=20.0e3, nu=0.2, epsilon_0=1.0e-4, epsilon_f=8.0e-4, #epsilon_f = 12.0e-4, #test doubling the e_f stress_state="plane_strain", stiffness="secant", #stiffness = "algorithmic", strain_norm=Rankine()) # me = MATS2DElastic( E = 20.0e3, # nu = 0.2, # stress_state = "plane_strain" ) fets_eval = FETS2D4Q(mats_eval=md)#, ngp_r = 3, ngp_s = 3) n_el_x = 60 # Discretization fe_grid = FEGrid(coord_max=(.6, .15, 0.), shape=(n_el_x, 15), fets_eval=fets_eval) mf = MFnLineArray(xdata=array([0, 1, 2, 7, 8 , 28]), ydata=array([0, 3., 3.2, 3.3, 3.32, 3.72 ])) #averaging function avg_processor = RTNonlocalAvg(avg_fn=QuarticAF(radius=avg_radius, correction=True)) ts = TS(sdomain=fe_grid, u_processor=avg_processor, bcond_list=[ # constraint for all left dofs in y-direction: BCSlice(var='u', slice=fe_grid[0, 0, 0, 0], dims=[0, 1], value=0.), BCSlice(var='u', slice=fe_grid[-1, 0, -1, 0], dims=[1], value=0.), BCSlice(var='u', slice=fe_grid[n_el_x / 2, -1, 0, -1], dims=[1], time_function=mf.get_value, value= -2.0e-5), ], rtrace_list=[ # RTDofGraph(name = 'Fi,right over u_right (iteration)' , # var_y = 'F_int', idx_y = right_dof, # var_x = 'U_k', idx_x = right_dof, # record_on = 'update'), RTraceDomainListField(name='Deformation' , var='eps_app', idx=0, record_on='update'), RTraceDomainListField(name='Displacement' , var='u', idx=1, record_on='update', warp=True), RTraceDomainListField(name='Damage' , var='omega', idx=0, record_on='update', warp=True), # RTraceDomainField(name = 'Stress' , # var = 'sig', idx = 0, # record_on = 'update'), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ] ) # Add the time-loop control # tl = TLoop(tstepper=ts, tolerance=5.0e-4, KMAX=100, tline=TLine(min=0.0, step=.25, max=10.0)) tl.eval() # Put the whole stuff into the simulation-framework to map the # individual pieces of definition into the user interface. # from ibvpy.plugins.ibvpy_app import IBVPyApp ibvpy_app = IBVPyApp(ibv_resource=ts) ibvpy_app.main()
def _get_tloop(self): #-------------------------------------------------------------- # ts #-------------------------------------------------------------- mid_zone_spec = self.mid_zone_specmn_fe_grid load_zone_spec = self.load_zone_specmn_fe_grid outer_zone_spec = self.outer_zone_specmn_fe_grid if self.elstmr_flag: # ELSTRMR TOP SURFACE # dofs at elastomer top surface (used to integrate the force) # elastomer = self.elstmr_fe_grid elstmr_top_dofs_z = elastomer[:, :, -1, :, :, -1].dofs[:, :, 2].flatten() load_dofs_z = np.unique(elstmr_top_dofs_z) print 'load_dofs_z', load_dofs_z else: # LINE LOAD TOP OF LOAD ZONE # dofs at center line of the specmn load zone (used to integrate the force) # note slice index in x-direction is only valid for load_zone_shape_x = 2 ! # load_zone_spec_topline_dofs_z = load_zone_spec[ 0, :, -1, -1, :, -1].dofs[:, :, 2].flatten() load_dofs_z = np.unique(load_zone_spec_topline_dofs_z) print 'load_dofs_z', load_dofs_z # SUPPRT LINE # dofs at support line of the specmn (used to integrate the force) # outer_zone_spec_supprtline_dofs_z = outer_zone_spec[ -1, :, 0, -1, :, 0].dofs[:, :, 2].flatten() supprt_dofs_z = np.unique(outer_zone_spec_supprtline_dofs_z) print 'supprt_dofs_z', supprt_dofs_z # CENTER DOF (used for tracing of the displacement) # center_bottom_dof = mid_zone_spec[0, 0, 0, 0, 0, 0].dofs[0, 0, 2] print 'center_bottom_dof', center_bottom_dof # THIRDPOINT DOF (used for tracing of the displacement) # dofs at center middle of the laod zone at the bottom side # # NOTE: slice index in x-direction is only valid for load_zone_shape_x = 2 ! thirdpoint_bottom_dof = load_zone_spec[0, 0, 0, -1, 0, 0].dofs[0, 0, 2] print 'thirdpoint_bottom_dof', thirdpoint_bottom_dof # force-displacement-diagram (CENTER) # self.f_w_diagram_center = RTraceGraph( name='displacement_elasttop (center) - force', var_x='U_k', idx_x=center_bottom_dof, var_y='F_int', idx_y_arr=load_dofs_z, record_on='update', transform_x='-x * 1000', # %g * x' % ( fabs( w_max ),), # due to symmetry the total force sums up from four parts of the beam (2 symmetry axis): # transform_y='-4000. * y') # force-displacement-diagram_supprt (SUPPRT) # self.f_w_diagram_supprt = RTraceGraph( name='displacement_supprtline (center) - force', var_x='U_k', idx_x=center_bottom_dof, var_y='F_int', idx_y_arr=supprt_dofs_z, record_on='update', transform_x='-x * 1000', # %g * x' % ( fabs( w_max ),), # due to symmetry the total force sums up from four parts of the beam (2 symmetry axis): # transform_y='4000. * y') # force-displacement-diagram (THIRDPOINT) # self.f_w_diagram_thirdpoint = RTraceGraph( name='displacement_elasttop (thirdpoint) - force', var_x='U_k', idx_x=thirdpoint_bottom_dof, var_y='F_int', idx_y_arr=load_dofs_z, record_on='update', transform_x='-x * 1000', # %g * x' % ( fabs( w_max ),), # due to symmetry the total force sums up from four parts of the beam (2 symmetry axis): # transform_y='-4000. * y') ts = TS( sdomain=self.fe_domain, bcond_list=self.bc_list, rtrace_list=[ self.f_w_diagram_center, self.f_w_diagram_thirdpoint, self.f_w_diagram_supprt, RTraceDomainListField(name='Displacement', var='u', idx=0, warp=True), # RTraceDomainListField(name = 'Stress' , # var = 'sig_app', idx = 0, warp = True, # record_on = 'update'), # RTraceDomainListField(name = 'Strain' , # var = 'eps_app', idx = 0, warp = True, # record_on = 'update'), # RTraceDomainListField(name = 'Damage' , # var = 'omega_mtx', idx = 0, warp = True, # record_on = 'update'), RTraceDomainListField(name='max_omega_i', warp=True, var='max_omega_i', idx=0, record_on='update'), # RTraceDomainListField(name = 'IStress' , # position = 'int_pnts', # var = 'sig_app', idx = 0, # record_on = 'update'), # RTraceDomainListField(name = 'IStrain' , # position = 'int_pnts', # var = 'eps_app', idx = 0, # record_on = 'update'), ]) # Add the time-loop control tloop = TLoop(tstepper=ts, KMAX=50, tolerance=self.tolerance, RESETMAX=0, tline=TLine(min=0.0, step=self.tstep, max=self.tmax), ord=self.ord) return tloop
def example_2d(): from ibvpy.mats.mats2D.mats2D_elastic.mats2D_elastic import MATS2DElastic from ibvpy.fets.fets2D.fets2D4q import FETS2D4Q fets_eval = FETS2D4Q(mats_eval=MATS2DElastic(E=2.1e5)) # Discretization fe_domain1 = FEGrid(coord_max=(2., 5., 0.), shape=(10, 10), fets_eval=fets_eval) fe_subgrid1 = FERefinementLevel(parent=fe_domain1, fine_cell_shape=(1, 1)) print('children') print(fe_domain1.children) fe_subgrid1.refine_elem((5, 5)) fe_subgrid1.refine_elem((6, 5)) fe_subgrid1.refine_elem((7, 5)) fe_subgrid1.refine_elem((8, 5)) fe_subgrid1.refine_elem((9, 5)) fe_domain = FEDomain(subdomains=[fe_domain1]) ts = TS( dof_resultants=True, sdomain=fe_domain, bcond_list=[ BCDofGroup(var='f', value=0.1, dims=[0], get_dof_method=fe_domain1.get_top_dofs), BCDofGroup(var='u', value=0., dims=[0, 1], get_dof_method=fe_domain1.get_bottom_dofs), ], rtrace_list=[ RTDofGraph(name='Fi,right over u_right (iteration)', var_y='F_int', idx_y=0, var_x='U_k', idx_x=1), RTraceDomainListField(name='Stress', var='sig_app', idx=0, warp=True), # RTraceDomainField(name = 'Displacement' , # var = 'u', idx = 0), # RTraceDomainField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ]) # Add the time-loop control tloop = TLoop(tstepper=ts, tline=TLine(min=0.0, step=1, max=1.0)) # print(tloop.eval()) from ibvpy.plugins.ibvpy_app import IBVPyApp ibvpy_app = IBVPyApp(ibv_resource=tloop) ibvpy_app.main()
def example_with_new_domain(): from ibvpy.api import \ TStepper as TS, RTraceGraph, RTraceDomainListField, \ RTraceDomainListInteg, TLoop, \ TLine, BCDof, IBVPSolve as IS, DOTSEval from ibvpy.mats.mats2D.mats2D_elastic.mats2D_elastic import MATS2DElastic from ibvpy.mats.mats2D.mats2D_sdamage.mats2D_sdamage import MATS2DScalarDamage from ibvpy.api import BCDofGroup mats_eval = MATS2DElastic() fets_eval = FETS2D4Q(mats_eval=mats_eval) #fets_eval = FETS2D4Q(mats_eval = MATS2DScalarDamage()) 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=(10., 4., 0.), shape=(10, 3), fets_eval=fets_eval) bcg = BCDofGroup(var='u', value=0., dims=[0], get_dof_method=fe_grid.get_left_dofs) bcg.setup(None) print 'labels', bcg._get_labels() print 'points', bcg._get_mvpoints() mf = MFnLineArray( # xdata = arange(10), ydata=array([0, 1, 2, 3])) right_dof = 2 tstepper = TS( sdomain=fe_grid, bcond_list=[ BCDofGroup(var='u', value=0., dims=[0, 1], 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=[1], time_function=mf.get_value, get_dof_method=fe_grid.get_right_dofs) ], rtrace_list=[ RTraceGraph(name='Fi,right over u_right (iteration)', var_y='F_int', idx_y=right_dof, var_x='U_k', idx_x=right_dof, record_on='update'), RTraceDomainListField(name='Stress', var='sig_app', idx=0, position='int_pnts', record_on='update'), # 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='Strain energy', var='strain_energy', idx=0, record_on='update', warp=False), RTraceDomainListInteg(name='Integ strain energy', var='strain_energy', idx=0, record_on='update', warp=False), # RTraceDomainListField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ]) # Add the time-loop control #global tloop tloop = TLoop(tstepper=tstepper, KMAX=300, tolerance=1e-4, tline=TLine(min=0.0, step=1.0, max=1.0)) #import cProfile #cProfile.run('tloop.eval()', 'tloop_prof' ) # print tloop.eval() #import pstats #p = pstats.Stats('tloop_prof') # p.strip_dirs() # print 'cumulative' # p.sort_stats('cumulative').print_stats(20) # print 'time' # p.sort_stats('time').print_stats(20) tloop.eval() # Put the whole thing into the simulation-framework to map the # individual pieces of definition into the user interface. # from ibvpy.plugins.ibvpy_app import IBVPyApp app = IBVPyApp(ibv_resource=tloop) app.main()
# RTraceDomainListField(name = 'Deformation' , # var = 'eps', idx = 0, # record_on = 'update'), RTraceDomainListField(name='Displacement', var='u', idx=0, warp=True), # RTraceDomainListField(name = 'Stress' , # var = 'sig', idx = 0, # record_on = 'update'), # RTraceDomainListField(name = 'N0' , # var = 'N_mtx', idx = 0, # record_on = 'update') ]) # Add the time-loop control tloop = TLoop(tstepper=ts, KMAX=4, RESETMAX=0, tolerance=1e-3, tline=TLine(min=0.0, step=1.0, max=1.0)) print 'u', tloop.eval() # Put the whole stuff into the simulation-framework to map the # individual pieces of definition into the user interface. # from ibvpy.plugins.ibvpy_app import IBVPyApp app = IBVPyApp(ibv_resource=tloop) app.main()
def _get_tloop(self): domain = self.fe_grid_roof #---------------------------------------------------- # loading and boundaries #---------------------------------------------------- #--- LC1: dead load # g = 22.4 kN/m^3 # orientation: global z-direction; material_density_roof = -22.43e-3 # [MN/m^3] #--- LC2 additional dead load # gA = 0,20 kN/m^2 # orientation: global z-direction (following the curved structure); additional_dead_load = -0.20e-3 # [MN/m^2] #--- LC2 additional boundary load # gA = 0,35 kN/m^2 # orientation: global z-direction (following the curved structure); boundary_dead_load = -0.35e-3 # [MN/m] #--- LC3 snow # s = 0,79 kN/m^2 # orientation: global z-direction (projection); surface_load_s = -0.85e-3 # [MN/m^2] #--- LC4 wind (pressure) # w = 0,13 kN/m^2 # orientation: local t-direction (surface normal); surface_load_w = -0.13e-3 # [MN/m^2] # NOTE: additional line-loads at the edge of the roof need to be considered! upper_surface = domain[:, :, -1, :, :, -1] whole_domain = domain[:, :, :, :, :, :] boundary_x1 = domain[-1, :, -1, -1, :, -1] boundary_y1 = domain[:, -1, -1, :, -1, -1] time_fn_load = self.time_fn_load time_fn_permanent_load = MFnLineArray(xdata=[0.0, 1.0], ydata=[0.0, 1.0]) time_fn_snow_load = MFnLineArray(xdata=[0.0, 1.0], ydata=[0.0, 0.0]) force_bc = [ # own weight BCSlice(name='self weight', var='f', value=material_density_roof, dims=[2], integ_domain='global', time_function=time_fn_load.get_value, slice=whole_domain), # LC2: additional dead-load BCSlice(name='additional load', var='f', value=additional_dead_load, dims=[2], integ_domain='global', time_function=time_fn_load.get_value, slice=upper_surface), # LC2: additional boundary-load BCSlice(name='additional boundary load 1', var='f', value=boundary_dead_load, dims=[2], integ_domain='global', time_function=time_fn_load.get_value, slice=boundary_x1), # LC2: additional boundary-load BCSlice(name='additional boundary load 2', var='f', value=boundary_dead_load, dims=[2], integ_domain='global', time_function=time_fn_load.get_value, slice=boundary_y1), # LC3: snow load BCSlice(name='snow load', var='f', value=surface_load_s, dims=[2], integ_domain='global', time_function=time_fn_snow_load.get_value, slice=upper_surface), # # LC3: wind # BCSlice( var = 'f', value = surface_load_w, dims = [2], # integ_domain = 'global', # slice = upper_surface ) ] bc_symplane_yz = BCSlice(var='u', value=0., dims=[0], slice=domain[0, :, :, 0, :, :]) bc_symplane_xz = BCSlice(var='u', value=0., dims=[1], slice=domain[:, 0, :, :, 0, :]) bc_support_000 = BCSlice(var='u', value=0., dims=[2], slice=domain[0, 0, 0, :, :, 0]) # bc_column = [ # BCSlice( var = 'u' , dims = [0, 1, 2], # slice = domain[self.n_elems_xy_quarter - 1, # self.n_elems_xy_quarter - 1, # 0, # 0, -1, 0 ], # value = 0. ), # BCSlice( var = 'u' , dims = [0, 1, 2], # slice = domain[self.n_elems_xy_quarter - 1, # self.n_elems_xy_quarter - 1 , # 0, # - 1, 0, 0], # value = 0. )] # bc_corner_load = BCSlice( var = 'f', value = -nodal_load, dims = [2], slice = domain[-1,-1,-1,-1,-1,-1] ) # bc_topface_load = BCSlice( var = 'f', value = -nodal_load, dims = [2], slice = domain[:,:,-1,:,:,-1] ) # support_z_dofs = domain[0, 0, 0, :, : , 0].dofs[:, :, 2] # support_f_w = RTraceGraph(name='force - corner deflection', # var_x='time', idx_x=0, # transform_x='x * %g' % lambda_failure, # var_y='F_int', idx_y_arr=np.unique(support_z_dofs.flatten()), # transform_y='-y', # record_on='update') rtrace_list = [self.f_w_diagram] + self.rtrace_list ts = TS(sdomain=[domain], dof_resultants=True, bcond_list=[bc_symplane_yz, bc_symplane_xz, bc_support_000] + force_bc, rtrace_list=rtrace_list) step = 1.0 # self.n_steps # Add the time-loop control tloop = TLoop(tstepper=ts, RESETMAX=0, KMAX=70, tolerance=0.5e-3, tline=TLine(min=0.0, step=step, max=1.0)) # self.max_lambda)) return tloop
dims=[1], get_dof_method=domain.get_bottom_left_dofs), BCDofGroup(var='u', value=0.002, dims=[0], get_dof_method=domain.get_right_dofs) ], rtrace_list=[ # RTDofGraph(name = 'Fi,right over u_right (iteration)' , # var_y = 'F_int', idx_y = right_dof, # var_x = 'U_k', idx_x = right_dof), # 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') ]) # Add the time-loop control tl = TLoop(tstepper=ts, tline=TLine(min=0.0, step=0.5, max=1.0)) tl.eval() # Put the whole stuff into the simulation-framework to map the # individual pieces of definition into the user interface. # from ibvpy.plugins.ibvpy_app import IBVPyApp app = IBVPyApp(ibv_resource=tl) app.main()
def example_with_new_domain(): from ibvpy.api import \ TStepper as TS, RTraceGraph, RTraceDomainListField, TLoop, \ TLine, BCDof, IBVPSolve as IS, DOTSEval from ibvpy.mats.mats1D.mats1D_elastic.mats1D_elastic import MATS1DElastic fets_eval = FETS1D2L3U(mats_eval=MATS1DElastic(E=10.)) from ibvpy.mesh.fe_grid import FEGrid # Discretization domain = FEGrid(coord_max=(3., ), shape=(3, ), fets_eval=fets_eval) ts = TS( dof_resultants=True, sdomain=domain, # conversion to list (square brackets) is only necessary for slicing of # single dofs, e.g "get_left_dofs()[0,1]" # bcond_list = [ BCDof(var='u', dof = 0, value = 0.) ] + # [ BCDof(var='u', dof = 2, value = 0.001 ) ]+ # [ ) ], bcond_list=[ BCDof(var='u', dof=0, value=0.), # BCDof(var='u', dof = 1, link_dofs = [2], link_coeffs = [0.5], # value = 0. ), # BCDof(var='u', dof = 2, link_dofs = [3], link_coeffs = [1.], # value = 0. ), BCDof( var='f', dof=6, 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), RTraceDomainListField(name='Stress', var='sig_app', idx=0), RTraceDomainListField(name='Displacement', var='u', idx=0), RTraceDomainListField(name='N0', var='N_mtx', idx=0, record_on='update') ]) # Add the time-loop control tloop = TLoop(tstepper=ts, tline=TLine(min=0.0, step=1, max=1.0)) print '---- result ----' print tloop.eval() print ts.F_int print ts.rtrace_list[0].trace.ydata # Put the whole stuff into the simulation-framework to map the # individual pieces of definition into the user interface. # from ibvpy.plugins.ibvpy_app import IBVPyApp app = IBVPyApp(ibv_resource=tloop) app.main()