def test_bar1(self): '''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''' self.domain.coord_max = (10, 0, 0) self.domain.shape = (10, ) self.ts.bcond_list = [ BCDof(var='u', dof=0, value=0.), BCDof(var='u', dof=10, value=1.) ] self.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 = self.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)) self.assertAlmostEqual(difference, 0) # compare the reaction at the left end F = self.ts.F_int[0] self.assertAlmostEqual(F, -1)
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 example_1d(): from ibvpy.mats.mats1D.mats1D_elastic.mats1D_elastic import MATS1DElastic from ibvpy.fets.fets1D.fets1D2l import FETS1D2L fets_eval = FETS1D2L(mats_eval=MATS1DElastic()) # Discretization fe_domain = FEDomain() fe_level1 = FERefinementGrid(domain=fe_domain, fets_eval=fets_eval) fe_domain1 = FEGrid(coord_max=(3., 0., 0.), shape=(3, ), level=fe_level1, fets_eval=fets_eval) fe_child_domain = FERefinementGrid(parent_domain=fe_level1, fine_cell_shape=(2, )) fe_child_domain.refine_elem((1, )) ts = TS(domain=fe_domain, dof_resultants=True, sdomain=fe_domain, bcond_list=[ BCDof(var='u', dof=0, value=0.), BCDof(var='f', dof=3, value=1.) ]) # Add the time-loop control tloop = TLoop(tstepper=ts, debug=True, tline=TLine(min=0.0, step=1, max=1.0)) print tloop.eval()
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_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_)
def example_with_new_domain(): from ibvpy.api import \ TStepper as TS, RTDofGraph, 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=[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), 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()
def predict(L_x, u, slip, bond): tl.ts.bc_list = [BCDof(var='u', dof=n_dofs - 2, value=0.0), BCDof(var='u', dof=n_dofs - 1, value=u)] tl.ts.L_x = L_x tl.ts.mats_eval.slip = slip.tolist() tl.ts.mats_eval.bond = bond.tolist() U_record, F_record, sig_record = tl.eval() return U_record, F_record, sig_record
def _get_bc_list(self): '''List of boundary concditions ''' right_dof = self.fe_grid[-1, -1].dofs[0, 0, 0] bcond_list = [ BCDof(var='u', dof=0, value=0.), BCDof(var='u', dof=right_dof, value=self.final_displ, time_function=self.time_function ) ] return bcond_list
def __demo__(): from ibvpy.api import \ TStepper as TS, RTDofGraph, RTraceDomainListField, TLoop, \ TLine, BCDof from ibvpy.tmodel.mats1D.mats1D_elastic.mats1D_elastic import MATS1DElastic fets_eval = FETS1D2L(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, bcond_list=[ BCDof(var='u', dof=0, value=0.), BCDof( var='f', dof=3, value=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='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. # app = IBVPyApp(ibv_resource=tloop) app.main()
def _tree_node_list_default(self): loading_scenario = LoadingScenario() bc_list = [ BCDof(var='u', dof=0, value=0.0), BCDof(var='f', dof=-1, time_function=loading_scenario.time_func) ] geometry = Geometry() model = PullOutSimulation(geometry=geometry, loading_scenario=loading_scenario) model.time_stepper.bc_list = bc_list return [model]
def test_bar3(self): '''Clamped bar with recursive constraints (load at right end) [0]-[1]-[2]-[3] u[1] = 0.2 * u[2], u[2] = 0.2 * u[3], R[3] = 10 ''' self.domain.coord_max = (3, 0, 0) self.domain.shape = (3, ) self.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 = self.tloop.eval() # expected solution u_ex = array([-0., 0.1, 0.2, 0.2], dtype=float) difference = sqrt(norm(u - u_ex)) self.assertAlmostEqual(difference, 0) return # # '---------------------------------------------------------------' # 'Clamped bar with recursive constraints (displ at right end)' # 'u[1] = 0.5 * u[2], u[2] = 1.0 * u[3], u[3] = 1' self.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) ] u = self.tloop.eval() # expected solution u_ex = array([0., 0.5, 1, 1], dtype=float) difference = sqrt(norm(u - u_ex)) self.assertAlmostEqual(difference, 0)
def _get_explorer_config(self): from ibvpy.api import TLine, BCDof, RTraceGraph c = super(MATS1DPlastic, self)._get_explorer_config() # overload the default configuration c['bcond_list'] = [ BCDof(var='u', dof=0, value=2.0, time_function=lambda t: sin(t)) ] c['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 - plastic_strain', var_x='time', idx_x=0, var_y='eps_p', idx_y=0, record_on='update'), RTraceGraph(name='time - back stress', var_x='time', idx_x=0, var_y='q', idx_y=0, record_on='update'), RTraceGraph(name='time - hardening', var_x='time', idx_x=0, var_y='alpha', idx_y=0, record_on='update') ] c['tline'] = TLine(step=0.3, max=10) return c
def _get_control_bc_list(self): return [ BCDof(node_name='control dof %d' % dof, var=self.control_variable, dof=dof, value=self.w_max,) for dof in self.control_dofs ]
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 _get_control_bc(self): cvar = self.control_variable return BCDof(node_name='pull-out displacement', var=cvar, dof=self.controlled_dof, value=self.w_max, time_function=self.loading_scenario)
def _get_link_right_x(self): top = self.fe_grid[-1, -1, -1, -1] bot = self.fe_grid[-1, 0, -1, 0] linked = self.fe_grid[-1, 1:, -1, 0] print('SHAPE', top.dof_X.shape) Ty = top.dof_X[0, 0, 1] By = bot.dof_X[0, 0, 1] Ly = linked.dof_X[:, :, 1].flatten() H = Ty - By link_ratios = Ly / H top_dof = top.dofs[0, 0, 0] bot_dof = bot.dofs[0, 0, 0] linked_dofs = linked.dofs[:, :, 0].flatten() bcdof_list = [] for linked_dof, link_ratio in zip(linked_dofs, link_ratios): link_bc = BCDof(var='u', dof=linked_dof, value=0, link_dofs=[bot_dof, top_dof], link_coeffs=[1 - link_ratio, link_ratio] ) bcdof_list.append(link_bc) return bcdof_list
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 _get_control_bc_list(self): return [ BCDof(node_name='control dof %d' % dof, var=self.control_variable, dof=dof, value=self.w_max, time_function=self.loading_scenario) for dof in self.control_dofs ]
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(): '''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 _get_interps(self): interps_m = [] interps_f = [] print 'preparing interploaters...' for L in self.BC_list: w = self.max_w_p / \ (self.tstepper.mats_eval.E_f * self.tstepper.fets_eval.A_f) * L \ + self.tstepper.mats_eval.slack * L # Number of degrees of freedom n_dofs = self.tstepper.domain.n_dofs self.tstepper.bc_list = [ BCDof(var='u', dof=0, value=0.0), BCDof(var='u', dof=1, value=0.0), BCDof(var='u', dof=n_dofs - 1, value=w) ] self.tstepper.L_x = L U_record, F_record, tau_record, sig_m, eps_f = self.tloop.eval() sig_m = self.avg_sig(sig_m) eps_f = self.avg_eps(eps_f) X = np.linspace(0, L, self.tstepper.n_e_x + 1) sig_c = F_record[:, -1] / self.A_c interp_m = interp2d(X[::-1], sig_c, sig_m) interps_m.append(interp_m) interp_f = interp2d(X[::-1], sig_c, eps_f) interps_f.append(interp_f) print 'complete' return [interps_m, interps_f]
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 _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'), ], 'tline': TLine(step=0.1, max=1.0) } def _set_explorer_config(self, value): self._explorer_config = value
def calib(w_arr, pf_arr, l): mat = MATSEval(E_m=2000., # MPa E_f=71000.) # MPa fet = FETS1D52ULRH(A_m=20000., # mm2 A_f=6.91) # mm2 ts = TStepper(mats_eval=mat, fets_eval=fet, L_x=l, # speciment length n_e_x=20 # number of elements ) n_dofs = ts.domain.n_dofs ts.bc_list = [BCDof(var='u', dof=n_dofs - 2, value=0.0), # the fixed DOF BCDof(var='u', dof=n_dofs - 1, value=1.0)] # the DOF on which the displacement is applied tl = TLoop(ts=ts, w_arr=w_arr, pf_arr=pf_arr) slip, bond = tl.eval() return bond, slip
def _get_fixed_bc(self): return BCDof(node_name='fixed left end', var='u', dof=self.fixed_dof, value=0.0)
def _get_control_bc(self): return BCDof(node_name='pull-out displacement', var='u', dof=self.controlled_dof, value=self.u_f0_max, time_function=self.loading_scenario)
def construct_fail_envelope(): elastic_debug = False # Tseval for a material model # tseval = MACMDM( elastic_debug = elastic_debug ) value, coeff = get_value_and_coeff( 1., 0.0 ) bcond_alpha = BCDof(var='u', dof = 0, value = value, link_dofs = [1], link_coeffs = [coeff], time_function = lambda t: t ) ts = TS( tse = tseval, bcond_list = [ bcond_alpha ], rtrace_list = [ RTraceGraph(name = 'strain 0 - stress 0', var_x = 'eps_app', idx_x = 0, var_y = 'sig_app', idx_y = 0, record_on = 'update' ), RTraceGraph(name = 'strain 1 - stress 1', var_x = 'eps_app', idx_x = 1, var_y = 'sig_app', idx_y = 1, record_on = 'update' ), RTraceGraph(name = 'strain 0 - stress 1', var_x = 'eps_app', idx_x = 0, var_y = 'sig_app', idx_y = 1, record_on = 'update' ), RTraceGraph(name = 'strain 1 - stress 0', var_x = 'eps_app', idx_x = 1, var_y = 'sig_app', idx_y = 0, record_on = 'update' ), RTraceGraph(name = 'strain 0 - strain 1', var_x = 'eps_app', idx_x = 0, var_y = 'eps_app', idx_y = 1, record_on = 'update' ), ] ) # Put the time-stepper into the time-loop # if elastic_debug: tmax = 1. n_steps = 1 else: tmax = 0.001 # tmax = 0.0006 n_steps = 60 tl = TLoop( tstepper = ts, DT=tmax/n_steps, KMAX = 100, RESETMAX = 0, tline = TLine( min = 0.0, max = tmax ) ) from numpy import argmax alpha_arr = linspace( - Pi/2 * 1.05, 2*(Pi/2.) + Pi/2.*0.05, 20 ) sig0_m_list = [] sig1_m_list = [] eps0_m_list = [] eps1_m_list = [] for alpha in alpha_arr: value, coeff = get_value_and_coeff( 1., alpha ) bcond_alpha.value = value bcond_alpha.link_coeffs[0] = coeff tl.eval() eps0_sig0 = tl.rtrace_mngr.rtrace_list[0] eps1_sig1 = tl.rtrace_mngr.rtrace_list[1] sig0_midx = argmax( fabs( eps0_sig0.trace.ydata ) ) sig1_midx = argmax( fabs( eps1_sig1.trace.ydata ) ) sig0_m = eps0_sig0.trace.ydata[ sig0_midx ] sig1_m = eps1_sig1.trace.ydata[ sig1_midx ] eps0_m = eps0_sig0.trace.xdata[ sig0_midx ] eps1_m = eps1_sig1.trace.xdata[ sig1_midx ] sig0_m_list.append( sig0_m ) sig1_m_list.append( sig1_m ) eps0_m_list.append( eps0_m ) eps1_m_list.append( eps1_m ) from mfn_line import MFnLineArray sig_plot = MFnLineArray( xdata = sig0_m_list, ydata = sig1_m_list ) eps_plot = MFnLineArray( xdata = eps0_m_list, ydata = eps1_m_list ) sig_plot.configure_traits()
if __name__ == '__main__': #========================================================================= # nonlinear solver #========================================================================= # initialization ts = TStepper() n_dofs = ts.domain.n_dofs # tf = lambda t: 1 - np.abs(t - 1) ts.bc_list = [ BCDof(var='u', dof=n_dofs - 2, value=0.0), BCDof(var='u', dof=n_dofs - 1, value=10.0) ] # w_arr, pf_arr = np.loadtxt('D:\\1.txt') fpath = 'D:\\data\\pull_out\\all\\DPO-30cm-0-3300SBR-V3_R3_f.asc' x, y = np.loadtxt(fpath, delimiter=';') x[0] = 0. interp = interp1d(x / 2., y) w_arr = np.linspace(0, 10.0001, 501) pf_arr = interp(w_arr) * 1000.
return def get_time_idx_arr(self, vot): '''Get the index corresponding to visual time ''' x = self.t_record idx = np.array(np.arange(len(x)), dtype=np.float_) t_idx = np.interp(vot, x, idx) return np.array(t_idx + 0.5, np.int_) def get_time_idx(self, vot): return int(self.get_time_idx_arr(vot)) if __name__ == '__main__': from ibvpy.api import BCDof ts = TStepper() n_dofs = ts.sdomain.n_dofs ts.bc_list = [ BCDof(var='u', dof=0, value=0.0), BCDof(var='f', dof=n_dofs - 1, value=5) ] tl = TLoop(ts=ts) tl.eval()
x = self.t_record idx = np.array(np.arange(len(x)), dtype=np.float_) t_idx = np.interp(vot, x, idx) return np.array(t_idx + 0.5, np.int_) def get_time_idx(self, vot): return int(self.get_time_idx_arr(vot)) if __name__ == '__main__': from ibvpy.api import BCDof from ibvpy.tmodel.mats3D.mats3D_elastic.mats3D_elastic import \ MATS3DElastic from ibvpy.tmodel.mats3D.mats3D_plastic.mats3D_desmorat import \ MATS3DDesmorat from ibvpy.tmodel.mats3D import \ MATS3DMplCSDEEQ ts = MATS3DExplore(mats_eval=MATS3DDesmorat()) ts.bcond_mngr.bcond_list = [BCDof(var='u', dof=0, value=0.001)] tl = TLoop(ts=ts, tline=TLine(step=0.1)) tl.init() U_k = tl.eval() print(U_k) print('U', tl.U_record) print('F', tl.F_record)
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)