本文整理汇总了Python中sfepy.terms.terms.Term类的典型用法代码示例。如果您正苦于以下问题:Python Term类的具体用法?Python Term怎么用?Python Term使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Term类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_term_arithmetics
def test_term_arithmetics(self):
from sfepy.discrete import FieldVariable, Integral
from sfepy.terms.terms import Term
integral = Integral('i', order=3)
u = FieldVariable('u', 'parameter', self.field,
primary_var_name='(set-to-None)')
t1 = Term.new('d_volume(u)', integral, self.omega, u=u)
t2 = Term.new('d_surface(u)', integral, self.gamma1, u=u)
expr = 2.2j * (t1 * 5.5 - 3j * t2) * 0.25
ok = len(expr) == 2
if not ok:
self.report('wrong expression length!')
_ok = nm.allclose(expr[0].sign, 3.025j, rtol=1e-15, atol=0)
if not _ok:
self.report('wrong sign of the first term!')
ok = ok and _ok
_ok = nm.allclose(expr[1].sign, 1.65, rtol=1e-15, atol=0)
if not _ok:
self.report('wrong sign of the second term!')
ok = ok and _ok
return ok
开发者ID:snilek,项目名称:sfepy,代码行数:29,代码来源:test_high_level.py
示例2: __init__
def __init__(self, *args, **kwargs):
Term.__init__(self, *args, **kwargs)
igs = self.region.igs
self.mtx_t = {}.fromkeys(igs, None)
self.membrane_geo = {}.fromkeys(igs, None)
self.bfg = {}.fromkeys(igs, None)
开发者ID:taldcroft,项目名称:sfepy,代码行数:7,代码来源:terms_membrane.py
示例3: test_solving
def test_solving(self):
from sfepy.base.base import IndexedStruct
from sfepy.fem \
import FieldVariable, Material, ProblemDefinition, \
Function, Equation, Equations, Integral
from sfepy.fem.conditions import Conditions, EssentialBC
from sfepy.terms import Term
from sfepy.solvers.ls import ScipyDirect
from sfepy.solvers.nls import Newton
u = FieldVariable('u', 'unknown', self.field, self.dim)
v = FieldVariable('v', 'test', self.field, self.dim,
primary_var_name='u')
m = Material('m', lam=1.0, mu=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_iso(m.lam, m.mu, 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 = ProblemDefinition('elasticity', equations=eqs, nls=nls, ls=ls)
## pb.save_regions_as_groups('regions')
pb.time_update(ebcs=Conditions([fix_u, shift_u]))
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
开发者ID:akshaydolas09,项目名称:sfepy,代码行数:59,代码来源:test_high_level.py
示例4: set_integral
def set_integral(self, integral):
"""
Set the term integral.
"""
if (integral.mode != 'custom') or (integral.coors.shape[1] != 3):
raise ValueError("dw_shell10x term requires 'custom' 3D integral!")
Term.set_integral(self, integral)
开发者ID:Gkdnz,项目名称:sfepy,代码行数:8,代码来源:terms_shells.py
示例5: test_term_evaluation
def test_term_evaluation(self):
from sfepy.discrete import Integral, FieldVariable
from sfepy.terms.terms import Term
integral = Integral('i', order=3)
u = FieldVariable('u', 'parameter', self.field,
primary_var_name='(set-to-None)')
term = Term.new('d_volume(u)', integral, self.omega, u=u)
term *= 10.0
term.setup()
vol = term.evaluate()
self.report('volume: %.8f == 2000.0' % vol)
ok = nm.allclose(vol, 2000.0, rtol=1e-15, atol=0)
## vec = t1.evaluate() # Returns vector.
## vec = t1.evaluate(u=u_vec) # Returns the same vector.
## mtx = t1.evaluate(diff_var='u') # Returns matrix.
## val = t1.evaluate(v=u_vec, u=u_vec) # Forbidden - virtual variable
## # cannot have value.
return ok
开发者ID:snilek,项目名称:sfepy,代码行数:26,代码来源:test_high_level.py
示例6: eval_real
def eval_real(self, shape, fargs, mode='eval', term_mode=None,
diff_var=None, **kwargs):
if diff_var is None:
if mode == 'eval':
out = 0.0
else:
out = nm.zeros(shape, dtype=nm.float64)
iter_kernel = fargs
for ii, fargs in iter_kernel():
out1, status = Term.eval_real(self, shape, fargs, mode=mode,
term_mode=term_mode,
diff_var=diff_var, **kwargs)
out += out1
else:
out, status = Term.eval_real(self, shape, fargs, mode=mode,
term_mode=term_mode,
diff_var=diff_var, **kwargs)
return out, status
开发者ID:AshitaPrasad,项目名称:sfepy,代码行数:23,代码来源:terms_th.py
示例7: __init__
def __init__(self, *args, **kwargs):
Term.__init__(self, *args, **kwargs)
self.cs = None
开发者ID:ZJLi2013,项目名称:sfepy,代码行数:4,代码来源:termsSurface.py
示例8: __init__
def __init__(self, *args, **kwargs):
Term.__init__(self, *args, **kwargs)
self.stress_cache = None
开发者ID:iostanin,项目名称:sfepy,代码行数:4,代码来源:terms_hyperelastic_base.py
示例9: __init__
def __init__(self, *args, **kwargs):
Term.__init__(self, *args, **kwargs)
self.detect = 2
self.ci = None
开发者ID:rc,项目名称:sfepy,代码行数:5,代码来源:terms_contact.py
示例10: __init__
def __init__(self, *args, **kwargs):
Term.__init__(self, *args, **kwargs)
igs = self.region.igs
self.stress_cache = {}.fromkeys(igs, None)
开发者ID:taldcroft,项目名称:sfepy,代码行数:5,代码来源:terms_hyperelastic_base.py
示例11: __init__
def __init__(self, *args, **kwargs):
Term.__init__(self, *args, **kwargs)
self.mtx_t = None
self.membrane_geo = None
self.bfg = None
开发者ID:Nasrollah,项目名称:sfepy,代码行数:6,代码来源:terms_membrane.py
注:本文中的sfepy.terms.terms.Term类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论