def update_material_properties(self, material_properties=None): if material_properties is not None: self.material_properties = material_properties for s in [self.data_manager.s0, self.data_manager.s1]: for (key, value) in self.material_properties.items(): if type(value) in [int, float]: mgis_bv.setMaterialProperty(s, key, value) else: if isinstance(value, dolfin.Function): value = value.vector().get_local() mgis_bv.setMaterialProperty(s, key, value, mgis_bv.MaterialStateManagerStorageMode.LocalStorage)
def __updateMaterialData(self,res): self.__materData = mgis_bv.MaterialDataManager(behaviour, self.__npts) for s in [self.__materData.s0, self.__materData.s1]: # material initialization mgis_bv.setMaterialProperty(s,"YoungModulus",self.mater['young']) mgis_bv.setMaterialProperty(s,"PoissonRatio",self.mater['poisson']) mgis_bv.setMaterialProperty(s,"InitYieldStress",self.mater['tau0']) mgis_bv.setMaterialProperty(s,"ResidualYieldStress",self.mater['taur']) mgis_bv.setMaterialProperty(s,"SoftenExponent",self.mater['b']) mgis_bv.setExternalStateVariable(s,"Temperature",293.15) s.internal_state_variables[:,:] = res[:,:5] #s.thermodynamic_forces[:,:] = res[:,5:9] s.gradients[:,:] = res[:,5:] mgis_bv.integrate(pool, self.__materData, intType, self.__dt) mgis_bv.update(self.__materData)
def update_material_properties(self, degree, mesh, material_properties=None): if material_properties is not None: self.material_properties = material_properties for s in [self.data_manager.s0, self.data_manager.s1]: for (key, value) in self.material_properties.items(): if type(value) in [int, float]: mgis_bv.setMaterialProperty(s, key, value) else: values = compute_on_quadrature( value, mesh, degree).vector().get_local() mgis_bv.setMaterialProperty( s, key, values, mgis_bv.MaterialStateManagerStorageMode.LocalStorage)
def __init__(self, pts, mater=None, sigma=None, gravity=[0., 0.], charlen=1.): """ :var pts: type numpy ndarray, shape = (npts, 2), points coordinates :var mater: type structure, material properties :var sigma: type numpy ndarray, initial stress, shape = (4,) or (npts, 4) :var gravity: type vector, size = 2, gravity constant :var charlen: type double, characteristic spacing :var limlen: type double, minimum spacing """ self.__npts = len(pts) # no. of nodes self.__pts = pts self.__spfem = SPFEM( ) # SPFEM module with C++ backend and Python binding through compiled shared library self.__materData = mgis_bv.MaterialDataManager( behaviour, self.__npts) # material data container for s in [self.__materData.s0, self.__materData.s1]: # material initialization mgis_bv.setMaterialProperty(s, "YoungModulus", mater['young']) mgis_bv.setMaterialProperty(s, "PoissonRatio", mater['poisson']) mgis_bv.setExternalStateVariable(s, "Temperature", 293.15) self.__wavespeed = numpy.sqrt(mater['young'] * (1 - mater['poisson']) / mater['rho'] / (1 + mater['poisson']) / (1 - 2 * mater['poisson'])) print('wave speed:', self.__wavespeed) self.__acc = numpy.zeros(self.__npts * 2) self.__vel = numpy.zeros(self.__npts * 2) self.__disp = numpy.zeros(self.__npts * 2) self.__T = 0. # total elapsed time self.__charlen = charlen self.__dt = self.__updateMeshBmatrixFint( ) # update the triangulation and internal force vector print(self.__dt) mass = numpy.multiply( self.__area, mater['rho'] ) # after initialization, mass will not change to guarantee mass conservation self.__fbody = numpy.outer(mass, gravity).reshape( -1) # body force due to gravity self.__mass = numpy.repeat(mass, 2)
def test_behaviour_data(self): eps = 1.e-14 e = numpy.asarray([1.3e-2, 1.2e-2, 1.4e-2, 0., 0., 0.], dtype=numpy.float64) e2 = numpy.asarray([1.2e-2, 1.3e-2, 1.4e-2, 0., 0., 0.], dtype=numpy.float64) h = mgis_bv.Hypothesis.Tridimensional b = self.__get_behaviour(h) m = mgis_bv.MaterialDataManager(b, 2) mgis_bv.setMaterialProperty(m.s1, "YoungModulus", 150e9) mgis_bv.setMaterialProperty(m.s1, "PoissonRatio", 0.3) mgis_bv.setExternalStateVariable(m.s1, "Temperature", 293.15) mgis_bv.update(m) m.s1.gradients[0:] = e m.s1.gradients[1:] = e outputs = numpy.empty(shape=(2, 3), dtype=numpy.float64) mgis_bv.executePostProcessing(outputs.reshape(6), m, "PrincipalStrain") for i in range(0, 3): self.assertTrue( abs(outputs[0, i] - e2[i]) < eps, "invalid output value") self.assertTrue( abs(outputs[1, i] - e2[i]) < eps, "invalid output value")
def __init__(self,pts,mater,sigma=None,gravity=[0.,0.],charlen=1.): """ pts: type numpy ndarray, shape = (npts, 2), points coordinates mater: type structure, material properties sigma: type numpy ndarray, initial stress, shape = (4,) or (npts, 4) gravity: type vector, size = 2, gravity constant charlen: type double, characteristic spacing """ self.__npts = len(pts) self.__pts = pts self.__spfem = SPFEM() #SPFEM module with C++ backend and Python binding through compiled shared library compliance = 1. / mater['young'] * numpy.array([[1.,-mater['poisson'],-mater['poisson'],0.], \ [-mater['poisson'],1.,-mater['poisson'],0.], \ [-mater['poisson'],-mater['poisson'],1.,0.], \ [0.,0.,0.,numpy.sqrt(2)*(1+mater['poisson'])]]) if sigma is None: sigma = numpy.zeros(4) epsilon = numpy.dot(compliance, sigma.T).T self.__materData = mgis_bv.MaterialDataManager(behaviour, self.__npts) #material data container self.mater = mater for s in [self.__materData.s0, self.__materData.s1]: #material initialization mgis_bv.setMaterialProperty(s,"YoungModulus",mater['young']) mgis_bv.setMaterialProperty(s,"PoissonRatio",mater['poisson']) mgis_bv.setMaterialProperty(s,"InitYieldStress",mater['tau0']) mgis_bv.setMaterialProperty(s,"ResidualYieldStress",mater['taur']) mgis_bv.setMaterialProperty(s,"SoftenExponent",mater['b']) mgis_bv.setExternalStateVariable(s,"Temperature",293.15) s.internal_state_variables[:,:4] = epsilon s.thermodynamic_forces[:] = sigma self.__charlen = charlen self.__dt = self.__updateMeshBmatrixFint() self.__wavespeed = numpy.sqrt(mater['young']/mater['rho']) self.__acc = numpy.zeros(self.__npts*2) #acceleration self.__vel = numpy.zeros(self.__npts*2) #velocity self.__disp = numpy.zeros(self.__npts*2) #displacement self.__T = 0. #total elapsed time mass = numpy.multiply(self.__area, mater['rho']) #after initialization, mass will not change to guarantee mass conservation self.__fbody = numpy.outer(mass, gravity).reshape(-1) #gravity force self.__mass = numpy.repeat(mass, 2) #nodal mass
alpha = 0. # In [MPa] beta = 30e3 gamma = 30e3 # yield strength sig0 = 800. Et = E/100. # hardening slope H = E*Et/(E-Et) # Cosserat plasticity coupling modules a_1 = 1.0 a_2 = 1.0 b_1 = 1.0 b_2 = 1.0 for s in [m.s0, m.s1]: mgis_bv.setMaterialProperty(s, "lambda", llambda) mgis_bv.setMaterialProperty(s, "mu", mu) mgis_bv.setMaterialProperty(s, "mu_c", mu_c) mgis_bv.setMaterialProperty(s, "alpha", alpha) mgis_bv.setMaterialProperty(s, "beta", beta) mgis_bv.setMaterialProperty(s, "gamma", gamma) mgis_bv.setMaterialProperty(s, "a_1", a_1) mgis_bv.setMaterialProperty(s, "a_2", a_2) mgis_bv.setMaterialProperty(s, "b_1", b_1) mgis_bv.setMaterialProperty(s, "b_2", b_2) mgis_bv.setMaterialProperty(s, "HardeningSlope", H) mgis_bv.setMaterialProperty(s, "YieldStrength", sig0) mgis_bv.setExternalStateVariable(s, "Temperature", 293.15) # Boundary conditions and external loading are defined as before along with the # analytical limit load solution::
# Loading the behaviour b = mgis_bv.load('src/libBehaviour.so', 'IsotropicLinearHardeningPlasticity', h) # Setting the material data manager m = mgis_bv.MaterialDataManager(b, ngauss) # elastic parameters E = 107e3 # In [MPa] nu = 0.31 # yield strength sig0 = 800. Et = E / 100. # hardening slope H = E * Et / (E - Et) for s in [m.s0, m.s1]: mgis_bv.setMaterialProperty(s, "YoungModulus", E) mgis_bv.setMaterialProperty(s, "PoissonRatio", nu) mgis_bv.setMaterialProperty(s, "HardeningSlope", H) mgis_bv.setMaterialProperty(s, "YieldStrength", sig0) mgis_bv.setExternalStateVariable(s, "Temperature", 293.15) # Boundary conditions and external loading are defined as before along with the # analytical limit load solution:: bc = [ DirichletBC(V.sub(0), 0, boundary_L), DirichletBC(V.sub(1), 0, boundary_L), DirichletBC(V.sub(2), 0, boundary_L) ] #bc = [DirichletBC(V.sub(0), 0, facets, 38), DirichletBC(V.sub(1), 0, facets, 38), DirichletBC(V.sub(2), 0, facets, 38)] #bc = [DirichletBC(V, as_vector((0.0,0.0,0.0)), facets, 1)]
def test_material_data_manager(self): eps = 1.e-14 dt = 0.1 h = mgis_bv.Hypothesis.Tridimensional b = self.__get_behaviour(h) d = mgis_bv.MaterialDataManager(b, 2) mgis_bv.setMaterialProperty(d.s0, "YoungModulus", 150e9) mgis_bv.setMaterialProperty(d.s0, "PoissonRatio", 0.3) mgis_bv.setMaterialProperty(d.s1, "YoungModulus", 150e9) mgis_bv.setMaterialProperty(d.s1, "PoissonRatio", 0.3) # zeros = numpy.zeros(9) # v_esv is uniform v_esv_values = numpy.asarray([1, 2, 3], dtype=numpy.float64) mgis_bv.setExternalStateVariable(d.s0, "v_esv", zeros[0:3], mgis_bv.MaterialStateManagerStorageMode.EXTERNAL_STORAGE) mgis_bv.setExternalStateVariable(d.s1, "v_esv", v_esv_values, mgis_bv.MaterialStateManagerStorageMode.LOCAL_STORAGE) # v2_esv[0] is not uniform v2_esv0_values = numpy.asarray([1, 2, 3, 7, 6, 5], dtype=numpy.float64) mgis_bv.setExternalStateVariable(d.s0, "v2_esv[0]",zeros[0:3], mgis_bv.MaterialStateManagerStorageMode.EXTERNAL_STORAGE) mgis_bv.setExternalStateVariable(d.s1, "v2_esv[0]", v2_esv0_values, mgis_bv.MaterialStateManagerStorageMode.EXTERNAL_STORAGE) v2_esv1_values = numpy.asarray([9, 8, 2, 3, 6, 4], dtype=numpy.float64) mgis_bv.setExternalStateVariable(d.s0, "v2_esv[1]", zeros[0:3], mgis_bv.MaterialStateManagerStorageMode.EXTERNAL_STORAGE) mgis_bv.setExternalStateVariable(d.s1, "v2_esv[1]", v2_esv1_values, mgis_bv.MaterialStateManagerStorageMode.EXTERNAL_STORAGE) for s in [d.s0, d.s1]: mgis_bv.setExternalStateVariable(s, "Temperature", zeros[0:1], mgis_bv.MaterialStateManagerStorageMode.EXTERNAL_STORAGE) mgis_bv.setExternalStateVariable(s, "s_esv", zeros[0:6], mgis_bv.MaterialStateManagerStorageMode.EXTERNAL_STORAGE) mgis_bv.setExternalStateVariable(s, "s2_esv[0]", zeros[0:6], mgis_bv.MaterialStateManagerStorageMode.EXTERNAL_STORAGE) mgis_bv.setExternalStateVariable(s, "s2_esv[1]", zeros[0:6], mgis_bv.MaterialStateManagerStorageMode.EXTERNAL_STORAGE) mgis_bv.setExternalStateVariable(s, "t_esv", zeros[0:9], mgis_bv.MaterialStateManagerStorageMode.EXTERNAL_STORAGE) mgis_bv.setExternalStateVariable(s, "t2_esv[0]", zeros[0:9], mgis_bv.MaterialStateManagerStorageMode.EXTERNAL_STORAGE) mgis_bv.setExternalStateVariable(s, "t2_esv[1]", zeros[0:9], mgis_bv.MaterialStateManagerStorageMode.EXTERNAL_STORAGE) # checking if the external storage do work as expected v2_esv1_values[3] = -1 mgis_bv.integrate(d, mgis_bv.IntegrationType.INTEGRATION_NO_TANGENT_OPERATOR, dt, 0, 2) for i in range (0, 3): self.assertTrue(abs(d.s1.internal_state_variables[0, i] - v_esv_values[i]) < eps, "invalid internal state variable value") self.assertTrue(abs(d.s1.internal_state_variables[1, i] - v_esv_values[i]) < eps, "invalid internal state variable value") self.assertTrue(abs(d.s1.internal_state_variables[0, i + 3] - v2_esv0_values[i]) < eps, "invalid internal state variable value") self.assertTrue(abs(d.s1.internal_state_variables[1, i + 3] - v2_esv0_values[i + 3]) < eps, "invalid internal state variable value") self.assertTrue(abs(d.s1.internal_state_variables[0, i + 6] - v2_esv1_values[i]) < eps, "invalid internal state variable value") self.assertTrue(abs(d.s1.internal_state_variables[1, i + 6] - v2_esv1_values[i + 3]) < eps, "invalid internal state variable value")