本文整理汇总了Python中sfepy.mechanics.matcoefs.stiffness_from_lame函数的典型用法代码示例。如果您正苦于以下问题:Python stiffness_from_lame函数的具体用法?Python stiffness_from_lame怎么用?Python stiffness_from_lame使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stiffness_from_lame函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_stiffness_tensors
def test_stiffness_tensors(self):
import numpy as nm
from sfepy.base.base import assert_
import sfepy.mechanics.matcoefs as mc
ok = True
lam = 1.0
mu = 4.0
lam = nm.array([lam] * 3)
mu = nm.array([mu] * 3)
d = nm.array([[ 9., 1., 1., 0., 0., 0.],
[ 1., 9., 1., 0., 0., 0.],
[ 1., 1., 9., 0., 0., 0.],
[ 0., 0., 0., 4., 0., 0.],
[ 0., 0., 0., 0., 4., 0.],
[ 0., 0., 0., 0., 0., 4.]])
_ds = mc.stiffness_from_lame(3, lam, mu)
assert_(_ds.shape == (3, 6, 6))
_ok = True
for _d in _ds:
__ok = nm.allclose(_d, d, rtol=0.0, atol=1e-14)
_ok = _ok and __ok
self.report('stiffness_from_lame():', _ok)
ok = ok and _ok
d = nm.array([[ 6., -2., -2., 0., 0., 0.],
[-2., 6., -2., 0., 0., 0.],
[-2., -2., 6., 0., 0., 0.],
[ 0., 0., 0., 4., 0., 0.],
[ 0., 0., 0., 0., 4., 0.],
[ 0., 0., 0., 0., 0., 4.]])
_ds = mc.stiffness_from_lame_mixed(3, lam, mu)
assert_(_ds.shape == (3, 6, 6))
_ok = True
for _d in _ds:
__ok = nm.allclose(_d, d, rtol=0.0, atol=1e-14)
_ok = _ok and __ok
self.report('stiffness_from_lame_mixed():', _ok)
ok = ok and _ok
blam = 2.0 / 3.0 * (lam - mu)
_ds = mc.stiffness_from_lame(3, blam, mu)
assert_(_ds.shape == (3, 6, 6))
_ok = True
for _d in _ds:
__ok = nm.allclose(_d, d, rtol=0.0, atol=1e-14)
_ok = _ok and __ok
self.report('stiffness_from_lame() with modified lambda:', _ok)
ok = ok and _ok
return ok
示例2: get_inclusion_pars
def get_inclusion_pars(ts, coor, mode=None, **kwargs):
"""TODO: implement proper 3D -> 2D transformation of constitutive
matrices."""
if mode == 'qp':
n_nod, dim = coor.shape
sym = (dim + 1) * dim // 2
dielectric = nm.eye(dim, dtype=nm.float64)
# !!!
coupling = nm.ones((dim, sym), dtype=nm.float64)
# coupling[0,1] = 0.2
out = {
# Lame coefficients in 1e+10 Pa.
'D' : stiffness_from_lame(dim=2, lam=0.1798, mu=0.148),
# dielectric tensor
'dielectric' : dielectric,
# piezoelectric coupling
'coupling' : coupling,
'density' : 0.1142, # in 1e4 kg/m3
}
for key, val in six.iteritems(out):
out[key] = nm.tile(val, (coor.shape[0], 1, 1))
return out
示例3: get_pars
def get_pars(ts, coors, mode='qp',
equations=None, term=None, problem=None, **kwargs):
"""
The material nonlinearity function - the Lamé coefficient `mu`
depends on the strain.
"""
if mode != 'qp': return
val = nm.empty((coors.shape[0], 1, 1), dtype=nm.float64)
val.fill(1e0)
order = term.integral.order
uvar = equations.variables['u']
strain = problem.evaluate('ev_cauchy_strain.%d.Omega(u)' % order,
u=uvar, mode='qp')
if ts.step > 0:
strain0 = strains[-1]
else:
strain0 = strain
dstrain = (strain - strain0) / ts.dt
dstrain.shape = (strain.shape[0] * strain.shape[1], strain.shape[2])
norm = norm_l2_along_axis(dstrain)
val += norm[:, None, None]
# Store history.
strains[0] = strain
return {'D': stiffness_from_lame(dim=3, lam=1e1, mu=val), 'mu': val}
示例4: test_solving
def test_solving(self):
from sfepy.base.base import IndexedStruct
from sfepy.discrete import (FieldVariable, Material, Problem, Function,
Equation, Equations, Integral)
from sfepy.discrete.conditions import Conditions, EssentialBC
from sfepy.terms import Term
from sfepy.solvers.ls import ScipyDirect
from sfepy.solvers.nls import Newton
from sfepy.mechanics.matcoefs import stiffness_from_lame
u = FieldVariable('u', 'unknown', self.field)
v = FieldVariable('v', 'test', self.field, primary_var_name='u')
m = Material('m', D=stiffness_from_lame(self.dim, 1.0, 1.0))
f = Material('f', val=[[0.02], [0.01]])
bc_fun = Function('fix_u_fun', fix_u_fun,
extra_args={'extra_arg' : 'hello'})
fix_u = EssentialBC('fix_u', self.gamma1, {'u.all' : bc_fun})
shift_u = EssentialBC('shift_u', self.gamma2, {'u.0' : 0.1})
integral = Integral('i', order=3)
t1 = Term.new('dw_lin_elastic(m.D, v, u)',
integral, self.omega, m=m, v=v, u=u)
t2 = Term.new('dw_volume_lvf(f.val, v)', integral, self.omega, f=f, v=v)
eq = Equation('balance', t1 + t2)
eqs = Equations([eq])
ls = ScipyDirect({})
nls_status = IndexedStruct()
nls = Newton({}, lin_solver=ls, status=nls_status)
pb = Problem('elasticity', equations=eqs)
## pb.save_regions_as_groups('regions')
pb.set_bcs(ebcs=Conditions([fix_u, shift_u]))
pb.set_solver(nls)
state = pb.solve()
name = op.join(self.options.out_dir, 'test_high_level_solving.vtk')
pb.save_state(name, state)
ok = nls_status.condition == 0
if not ok:
self.report('solver did not converge!')
_ok = state.has_ebc()
if not _ok:
self.report('EBCs violated!')
ok = ok and _ok
return ok
示例5: get_fargs
def get_fargs(self, lam, mu, virtual, state,
mode=None, term_mode=None, diff_var=None, **kwargs):
from sfepy.mechanics.matcoefs import stiffness_from_lame
mat = stiffness_from_lame(self.region.dim, lam, mu)
return LinearElasticTerm.get_fargs(self, mat, virtual, state,
mode=mode, term_mode=term_mode,
diff_var=diff_var, **kwargs)
示例6: get_pars
def get_pars(dim, lam, mu):
c = stiffness_from_lame(3, lam, mu)
if dim == 2:
tr = TransformToPlane()
try:
c = tr.tensor_plane_stress(c3=c)
except:
sym = (dim + 1) * dim / 2
c = nm.zeros((sym, sym), dtype=nm.float64)
return c
示例7: get_pars
def get_pars(lam, mu, dim, full=False):
from sfepy.mechanics.matcoefs import stiffness_from_lame, TransformToPlane
if full:
c = stiffness_from_lame(3, lam, mu)
if dim == 2:
tr = TransformToPlane()
try:
c = tr.tensor_plane_stress(c3=c)
except:
sym = (dim + 1) * dim / 2
c = nm.zeros((sym, sym), dtype=nm.float64)
return c
else:
return lam, mu
示例8: _material_func_
def _material_func_(ts, coors, mode=None, **kwargs):
if mode == 'qp':
ijk_out = np.empty_like(coors, dtype=int)
ijk = np.floor((coors - min_xyz[None]) / self.dx,
ijk_out, casting="unsafe")
ijk_tuple = tuple(ijk.swapaxes(0, 1))
property_array_qp = property_array[ijk_tuple]
lam = property_array_qp[..., 0]
mu = property_array_qp[..., 1]
lam = np.ascontiguousarray(lam.reshape((lam.shape[0], 1, 1)))
mu = np.ascontiguousarray(mu.reshape((mu.shape[0], 1, 1)))
from sfepy.mechanics.matcoefs import stiffness_from_lame
stiffness = stiffness_from_lame(dims, lam=lam, mu=mu)
return {'lam': lam, 'mu': mu, 'D': stiffness}
else:
return
示例9: get_pars
def get_pars(ts, coor, mode, output_dir=".", **kwargs):
if mode == "qp":
n_nod, dim = coor.shape
sym = (dim + 1) * dim / 2
out = {}
out["D"] = nm.tile(stiffness_from_lame(dim, lam=1.7, mu=0.3), (coor.shape[0], 1, 1))
aa = nm.zeros((sym, 1), dtype=nm.float64)
aa[:dim] = 0.132
aa[dim:sym] = 0.092
out["alpha"] = nm.tile(aa, (coor.shape[0], 1, 1))
perm = nm.eye(dim, dtype=nm.float64)
out["K"] = nm.tile(perm, (coor.shape[0], 1, 1))
return out
示例10: stress_strain
def stress_strain(out, pb, state,lam,mu, extend=False):
"""
Calculate and output strain and stress for given displacements.
"""
from sfepy.base.base import Struct
D = stiffness_from_lame(3,lam, mu)
#asphalt = Material('Asphalt', D=D)
mat = Material('Mat', D=D)
ev = pb.evaluate
strain = ev('ev_cauchy_strain.2.Omega(u)', mode='el_avg')
stress = ev('ev_cauchy_stress.2.Omega(Mat.D, u)', mode='el_avg',
copy_materials=False)
out['cauchy_strain'] = Struct(name='output_data', mode='cell',
data=strain, dofs=None)
out['cauchy_stress'] = Struct(name='output_data', mode='cell',
data=stress, dofs=None)
return out
示例11: get_pars
def get_pars(ts, coor, mode, **kwargs):
"""
Define the material parameters.
"""
if mode == 'qp':
n_nod, dim = coor.shape
out = {}
out['D'] = nm.tile(stiffness_from_lame(dim, lam=1.7, mu=0.3),
(coor.shape[0], 1, 1))
alpha = [[0.132, 0.092],
[0.052, 0.132]]
out['alpha'] = nm.tile(alpha, (coor.shape[0], 1, 1))
perm = nm.eye(dim, dtype=nm.float64)
out['K'] = nm.tile(perm, (coor.shape[0], 1, 1))
out['np_eps'] = nm.tile(1e5, (coor.shape[0], 1, 1))
return out
示例12: deepcopy
from sfepy.postprocess.probes_vtk import Probe
from sfepy.mechanics.matcoefs import stiffness_from_lame
# Define options.
options = {
'output_dir' : '.',
'post_process_hook' : 'post_process',
}
# Update materials, as ev_cauchy_stress below needs the elastic constants in
# the tensor form.
materials = deepcopy(materials)
solid = materials['solid'][0]
lam, mu = solid['lam'], solid['mu']
solid.update({
'D' : stiffness_from_lame(3, lam=lam, mu=mu),
})
# The function returning the probe parametrization.
def par_fun(idx):
return nm.log(idx + 1) / nm.log(20) * 0.04
# Define the function post_process, that will be called after the problem is
# solved.
def post_process(out, problem, state, extend=False):
"""
This will be called after the problem is solved.
Parameters
----------
out : dict
示例13: in
import numpy as nm
from sfepy.mechanics.matcoefs import stiffness_from_lame
from sfepy import data_dir
filename_mesh = data_dir + '/meshes/3d/block.mesh'
regions = {
'Omega' : 'all',
'Left' : ('vertices in (x < -4.99)', 'facet'),
'Omega1' : 'vertices in (x < 0.001)',
'Omega2' : 'vertices in (x > -0.001)',
}
materials = {
'solid' : ({
'D' : stiffness_from_lame(3, lam=1e2, mu=1e1),
'prestress' : 0.1 * nm.array([[1.0], [1.0], [1.0],
[0.5], [0.5], [0.5]],
dtype=nm.float64),
'DF' : stiffness_from_lame(3, lam=8e0, mu=8e-1),
'nu' : nm.array([[-0.5], [0.0], [0.5]], dtype=nm.float64),
},),
}
fields = {
'displacement': ('real', 'vector', 'Omega', 1),
}
variables = {
'u' : ('unknown field', 'displacement', 0),
'v' : ('test field', 'displacement', 'u'),
示例14: get_exp_fading_kernel
t0 = 0.0
t1 = 20.0
n_step = 21
# Fading memory times.
f_t0 = 0.0
f_t1 = 5.0
f_n_step = 6
decay = 0.8
mode = 'eth'
## Configure above. ##
times = nm.linspace(f_t0, f_t1, f_n_step)
kernel = get_exp_fading_kernel(stiffness_from_lame(3, lam=1.0, mu=1.0),
decay, times)
dt = (t1 - t0) / (n_step - 1)
fading_memory_length = min(int((f_t1 - f_t0) / dt) + 1, n_step)
output('fading memory length:', fading_memory_length)
def post_process(out, pb, state, extend=False):
"""
Calculate and output strain and stress for given displacements.
"""
from sfepy.base.base import Struct
ev = pb.evaluate
strain = ev('ev_cauchy_strain.2.Omega(u)', mode='el_avg')
out['cauchy_strain'] = Struct(name='output_data', mode='cell',
示例15: in
region_10 = {
'name' : 'Bottom',
'select' : 'vertices in (y < %f)' % -wy,
'kind' : 'facet',
}
region_11 = {
'name' : 'Top',
'select' : 'vertices in (y > %f)' % wy,
'kind' : 'facet',
}
material_1 = {
'name' : 'solid',
'values' : {
'D' : stiffness_from_lame(2, 1e1, 1e0),
'density' : 1e-1,
},
}
field_1 = {
'name' : '2_displacement',
'dtype' : 'real',
'shape' : 'vector',
'region' : 'Y',
'approx_order' : 2,
}
variable_1 = {
'name' : 'u',
'kind' : 'unknown field',