本文整理汇总了Python中sfepy.linalg.dot_sequences函数的典型用法代码示例。如果您正苦于以下问题:Python dot_sequences函数的具体用法?Python dot_sequences怎么用?Python dot_sequences使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dot_sequences函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_fargs
def get_fargs(self, mat, var1, var2,
mode=None, term_mode=None, diff_var=None, **kwargs):
vg1, _ = self.get_mapping(var1)
vg2, _ = self.get_mapping(var2)
if diff_var is None:
if self.mode == 'grad_state':
geo = vg1
bf_t = vg1.bf.transpose((0, 1, 3, 2))
val_qp = self.get(var2, 'grad')
out_qp = bf_t * dot_sequences(mat, val_qp, 'ATB')
else:
geo = vg2
val_qp = self.get(var1, 'val')
out_qp = dot_sequences(vg2.bfg, mat, 'ATB') * val_qp
fmode = 0
else:
if self.mode == 'grad_state':
geo = vg1
bf_t = vg1.bf.transpose((0, 1, 3, 2))
out_qp = bf_t * dot_sequences(mat, vg2.bfg, 'ATB')
else:
geo = vg2
out_qp = dot_sequences(vg2.bfg, mat, 'ATB') * vg1.bf
fmode = 1
return out_qp, geo, fmode
示例2: get_fargs
def get_fargs(self, mat, kappa, virtual, state,
mode=None, term_mode=None, diff_var=None, **kwargs):
from sfepy.discrete.variables import create_adof_conn
geo, _ = self.get_mapping(state)
n_fa, n_qp, dim, n_fn, n_c = self.get_data_shape(virtual)
# Expand basis for all components.
bf = geo.bf
ebf = nm.zeros(bf.shape[:2] + (dim, n_fn * dim), dtype=nm.float64)
for ir in range(dim):
ebf[..., ir, ir*n_fn:(ir+1)*n_fn] = bf[..., 0, :]
gmat = _build_wave_strain_op(kappa, ebf)
if diff_var is None:
econn = state.field.get_econn('volume', self.region)
adc = create_adof_conn(nm.arange(state.n_dof, dtype=nm.int32),
econn, n_c, 0)
vals = state()[adc]
# Same as nm.einsum('qij,cj->cqi', gmat[0], vals)[..., None]
aux = dot_sequences(gmat, vals[:, None, :, None])
out_qp = dot_sequences(gmat, dot_sequences(mat, aux), 'ATB')
fmode = 0
else:
out_qp = dot_sequences(gmat, dot_sequences(mat, gmat), 'ATB')
fmode = 1
return out_qp, geo, fmode
示例3: get_fargs
def get_fargs(self, mat, kappa, virtual, state,
mode=None, term_mode=None, diff_var=None, **kwargs):
from sfepy.discrete.variables import create_adof_conn, expand_basis
geo, _ = self.get_mapping(state)
n_el, n_qp, dim, n_en, n_c = self.get_data_shape(virtual)
ebf = expand_basis(geo.bf, dim)
gmat = _build_wave_strain_op(kappa, ebf)
if diff_var is None:
econn = state.field.get_econn('volume', self.region)
adc = create_adof_conn(nm.arange(state.n_dof, dtype=nm.int32),
econn, n_c, 0)
vals = state()[adc]
# Same as nm.einsum('qij,cj->cqi', gmat[0], vals)[..., None]
aux = dot_sequences(gmat, vals[:, None, :, None])
out_qp = dot_sequences(gmat, dot_sequences(mat, aux), 'ATB')
fmode = 0
else:
out_qp = dot_sequences(gmat, dot_sequences(mat, gmat), 'ATB')
fmode = 1
return out_qp, geo, fmode
示例4: function
def function(out, force, normals, fd, geo, fmode):
bf = geo.bf[0]
nbf = bf * normals
nbf.shape = (normals.shape[0], normals.shape[1],
bf.shape[2] * normals.shape[2])
if fmode == 0:
out_qp = force * nbf[..., None]
else:
nbf2 = nbf[..., None] * nbf[..., None, :]
dim = normals.shape[2]
n_ep = bf.shape[2]
bb = bf[:, 0]
vb = nm.zeros((bf.shape[0], dim, dim * n_ep))
for ii in range(dim):
vb[:, ii, ii*n_ep:(ii+1)*n_ep] = bb
ee = nm.eye(3)[None, ...]
eebf2 = dot_sequences(vb, dot_sequences(ee, vb), 'ATB')
out_qp = force * nbf2
if fd is not None:
out_qp -= fd * (eebf2[None, :, :, :] - nbf2)
status = geo.integrate(out, nm.ascontiguousarray(out_qp))
return status
示例5: get_fargs
def get_fargs(self, kappa, virtual, state,
mode=None, term_mode=None, diff_var=None, **kwargs):
from sfepy.discrete.variables import create_adof_conn, expand_basis
geo, _ = self.get_mapping(state)
n_el, n_qp, dim, n_en, n_c = self.get_data_shape(virtual)
ebf = expand_basis(geo.bf, dim)
aux = nm.einsum('i,...ij->...j', kappa, ebf)[0, :, None, :]
kebf = insert_strided_axis(aux, 0, n_el)
if diff_var is None:
econn = state.field.get_econn('volume', self.region)
adc = create_adof_conn(nm.arange(state.n_dof, dtype=nm.int32),
econn, n_c, 0)
vals = state()[adc]
aux = dot_sequences(kebf, vals[:, None, :, None])
out_qp = dot_sequences(kebf, aux, 'ATB')
fmode = 0
else:
out_qp = dot_sequences(kebf, kebf, 'ATB')
fmode = 1
return out_qp, geo, fmode
示例6: get_cauchy_from_2pk
def get_cauchy_from_2pk(self, stress_in):
"""
Get the Cauchy stress given the second Piola-Kirchhoff stress.
.. math::
\sigma_{ij} = J^{-1} F_{ik} S_{kl} F_{jl}
"""
stress_in = nm.asarray(stress_in, dtype=nm.float64)
stress_in_full = stress_in[:,:,self.s2f,0]
val_il = dot_sequences(self.def_grad, stress_in_full)
val_ij = dot_sequences(val_il, self.def_grad, mode='ABT')
stress_out_full = val_ij / self.jacobian
sh = stress_out_full.shape
stress_out_full.shape = (sh[0], sh[1], sh[2] * sh[3])
self._assert_symmetry(stress_out_full)
stress_out = nm.empty_like(stress_in)
stress_out[...,0] = stress_out_full[:,:,self.f2s]
return stress_out
示例7: d_dot
def d_dot(out, mat, val1_qp, val2_qp, geo):
v1, v2 = (val1_qp, val2_qp) if val1_qp.shape[2] > 1 \
else (val2_qp, val1_qp)
aux = dot_sequences(v1, mat, mode='ATB')
vec = dot_sequences(aux, v2, mode='AB')
status = geo.integrate(out, vec)
return status
示例8: function
def function(out, mat, vg, grad, fmode):
bf_t = vg.bf.transpose((0, 1, 3, 2))
if fmode == 0:
out_qp = bf_t * dot_sequences(mat, grad, 'ATB')
else:
bfg = vg.bfg
out_qp = bf_t * dot_sequences(mat, bfg, 'ATB')
status = vg.integrate(out, out_qp)
return status
示例9: get_fargs
def get_fargs(self, mat, par_w, par_u, par_mv,
mode=None, term_mode=None, diff_var=None, **kwargs):
vg, _ = self.get_mapping(par_u)
grad_w = self.get(par_w, 'grad').transpose((0,1,3,2))
grad_u = self.get(par_u, 'grad').transpose((0,1,3,2))
nel, nqp, nr, nc = grad_u.shape
strain_w = grad_w.reshape((nel, nqp, nr * nc, 1))
strain_u = grad_u.reshape((nel, nqp, nr * nc, 1))
mat_map = {1: nm.array([0]),
3: nm.array([0, 2, 2, 1]),
6: nm.array([0, 3, 4, 3, 1, 5, 4, 5, 2])}
mmap = mat_map[mat.shape[-1]]
mat_ns = mat[nm.ix_(nm.arange(nel), nm.arange(nqp),
mmap, mmap)]
div_mv = self.get(par_mv, 'div')
grad_mv = self.get(par_mv, 'grad')
opd_mv = self.op_dv(grad_mv)
aux = dot_sequences(mat_ns, opd_mv)
mat_mv = mat_ns * div_mv - (aux + aux.transpose((0,1,3,2)))
return 1.0, strain_w, strain_u, mat_mv, vg
示例10: __init__
def __init__(self, anchor, normal, bounds):
Struct.__init__(self, anchor=nm.array(anchor, dtype=nm.float64),
bounds=nm.asarray(bounds, dtype=nm.float64))
self.normal = nm.asarray(normal, dtype=nm.float64)
norm = nm.linalg.norm
self.normal /= norm(self.normal)
e3 = [0.0, 0.0, 1.0]
dd = nm.dot(e3, self.normal)
rot_angle = nm.arccos(dd)
if nm.abs(rot_angle) < 1e-14:
mtx = nm.eye(3, dtype=nm.float64)
bounds2d = self.bounds[:, :2]
else:
rot_axis = nm.cross([0.0, 0.0, 1.0], self.normal)
mtx = la.make_axis_rotation_matrix(rot_axis, rot_angle)
mm = la.insert_strided_axis(mtx, 0, self.bounds.shape[0])
rbounds = la.dot_sequences(mm, self.bounds)
bounds2d = rbounds[:, :2]
assert_(nm.allclose(nm.dot(mtx, self.normal), e3,
rtol=0.0, atol=1e-12))
self.adotn = nm.dot(self.anchor, self.normal)
self.rot_angle = rot_angle
self.mtx = mtx
self.bounds2d = bounds2d
示例11: get_homog_mat
def get_homog_mat(ts, coors, mode, term=None, problem=None, **kwargs):
if problem.update_materials_flag == 2 and mode == 'qp':
out = hyperelastic_data['homog_mat']
return {k: nm.array(v) for k, v in six.iteritems(out)}
elif problem.update_materials_flag == 0 or not mode == 'qp':
return
output('get_homog_mat')
dim = problem.domain.mesh.dim
update_var = problem.conf.options.mesh_update_variables[0]
state_u = problem.equations.variables[update_var]
state_u.field.clear_mappings()
family_data = problem.family_data(state_u, term.region,
term.integral, term.integration)
mtx_f = family_data.mtx_f.reshape((coors.shape[0],)
+ family_data.mtx_f.shape[-2:])
out = get_homog_coefs_nonlinear(ts, coors, mode, mtx_f,
term=term, problem=problem,
iteration=problem.iiter, **kwargs)
out['E'] = 0.5 * (la.dot_sequences(mtx_f, mtx_f, 'ATB') - nm.eye(dim))
hyperelastic_data['time'] = ts.step
hyperelastic_data['homog_mat_shape'] = family_data.det_f.shape[:2]
hyperelastic_data['homog_mat'] = \
{k: nm.array(v) for k, v in six.iteritems(out)}
return out
示例12: dw_dot
def dw_dot(out, mat, val_qp, bfve, bfsc, geo, fmode):
nel, nqp, dim, nc = mat.shape
nen = bfve.shape[2]
status1 = 0
if fmode in [0, 1, 3]:
aux = nm.zeros((nel, nqp, dim * nen, nc), dtype=nm.float64)
status1 = terms.actBfT(aux, bfve, mat)
if fmode == 0:
status2 = terms.mulAB_integrate(out, aux, val_qp, geo, 'AB')
if fmode == 1:
status2 = terms.mulAB_integrate(out, aux, bfsc, geo, 'AB')
if fmode == 2:
aux = (bfsc * dot_sequences(mat, val_qp,
mode='ATB')).transpose((0,1,3,2))
status2 = geo.integrate(out, nm.ascontiguousarray(aux))
if fmode == 3:
status2 = terms.mulAB_integrate(out, bfsc, aux, geo, 'ATBT')
return status1 and status2
示例13: function
def function(out, val_qp, ebf, mat, sg, diff_var):
normals = sg.normal
n_fa = out.shape[0]
ebf_t = nm.tile(ebf.transpose((0, 1, 3, 2)), (n_fa, 1, 1, 1))
if diff_var is None:
nu = dot_sequences(normals, val_qp, 'ATB')
nt = dot_sequences(ebf_t, normals)
entnu = mat * nt * nu
status = sg.integrate(out, entnu, 0)
else:
nt = dot_sequences(ebf_t, normals)
entn = mat * dot_sequences(nt, nt, 'ABT')
status = sg.integrate(out, entn, 0)
return status
示例14: get_fargs
def get_fargs(self, mat, parameter,
mode=None, term_mode=None, diff_var=None, **kwargs):
vg, _ = self.get_mapping(parameter)
grad = self.get(parameter, 'grad')
val_qp = dot_sequences(mat, grad, mode='ATB')
fmode = {'eval' : 0, 'el_avg' : 1, 'qp' : 2}.get(mode, 1)
return val_qp, vg, fmode
示例15: d_lin_prestress
def d_lin_prestress(self, out, strain, mat, vg, fmode):
aux = dot_sequences(mat, strain, mode="ATB")
if fmode == 2:
out[:] = aux
status = 0
else:
status = vg.integrate(out, aux, fmode)
return status