本文整理汇总了Python中sfepy.base.conf.ProblemConf.from_dict方法的典型用法代码示例。如果您正苦于以下问题:Python ProblemConf.from_dict方法的具体用法?Python ProblemConf.from_dict怎么用?Python ProblemConf.from_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfepy.base.conf.ProblemConf
的用法示例。
在下文中一共展示了ProblemConf.from_dict方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: assemble_matrices
# 需要导入模块: from sfepy.base.conf import ProblemConf [as 别名]
# 或者: from sfepy.base.conf.ProblemConf import from_dict [as 别名]
def assemble_matrices(define, mod, pars, set_wave_dir, options):
"""
Assemble the blocks of dispersion eigenvalue problem matrices.
"""
define_problem = functools.partial(define,
filename_mesh=options.mesh_filename,
pars=pars,
approx_order=options.order,
refinement_level=options.refine,
solver_conf=options.solver_conf,
plane=options.plane,
post_process=options.post_process)
conf = ProblemConf.from_dict(define_problem(), mod)
pb = Problem.from_conf(conf)
pb.dispersion_options = options
pb.set_output_dir(options.output_dir)
dim = pb.domain.shape.dim
# Set the normalized wave vector direction to the material(s).
wdir = nm.asarray(options.wave_dir[:dim], dtype=nm.float64)
wdir = wdir / nm.linalg.norm(wdir)
set_wave_dir(pb, wdir)
bbox = pb.domain.mesh.get_bounding_box()
size = (bbox[1] - bbox[0]).max()
scaling0 = apply_unit_multipliers([1.0], ['length'],
options.unit_multipliers)[0]
scaling = scaling0
if options.mesh_size is not None:
scaling *= options.mesh_size / size
output('scaling factor of periodic cell mesh coordinates:', scaling)
output('new mesh size with applied unit multipliers:', scaling * size)
pb.domain.mesh.coors[:] *= scaling
pb.set_mesh_coors(pb.domain.mesh.coors, update_fields=True)
bzone = 2.0 * nm.pi / (scaling * size)
output('1. Brillouin zone size:', bzone * scaling0)
output('1. Brillouin zone size with applied unit multipliers:', bzone)
pb.time_update()
pb.update_materials()
# Assemble the matrices.
mtxs = {}
for key, eq in pb.equations.iteritems():
mtxs[key] = mtx = pb.mtx_a.copy()
mtx = eq.evaluate(mode='weak', dw_mode='matrix', asm_obj=mtx)
mtx.eliminate_zeros()
output_array_stats(mtx.data, 'nonzeros in %s' % key)
output('symmetry checks:')
output('%s - %s^T:' % (key, key), max_diff_csr(mtx, mtx.T))
output('%s - %s^H:' % (key, key), max_diff_csr(mtx, mtx.H))
return pb, wdir, bzone, mtxs
示例2: eval_homogenized_coefs
# 需要导入模块: from sfepy.base.conf import ProblemConf [as 别名]
# 或者: from sfepy.base.conf.ProblemConf import from_dict [as 别名]
def eval_homogenized_coefs( self ):
if self.cached_coefs is not None:
return self.cached_coefs
opts = self.app_options
if opts.homogeneous:
rtm = opts.region_to_material
mat_region = rtm.keys()[0]
mat_name = rtm[mat_region]
self.problem.update_materials()
mat = self.problem.materials[mat_name]
coefs = mat.get_data( mat_region, 0, opts.tensor_names )
else:
dc = opts.dispersion_conf
dconf = ProblemConf.from_dict( dc['input'], dc['module'] )
dconf.materials = self.conf.materials
dconf.fe = self.conf.fe
dconf.regions.update( self.conf.regions )
dconf.options['output_dir'] = self.problem.output_dir
volume = opts.volume(self.problem, 'Y')
problem = ProblemDefinition.from_conf(dconf, init_equations=False)
he = HomogenizationEngine( problem, self.options, volume = volume )
coefs = he()
## print coefs
## pause()
output.prefix = self.output_prefix
self.cached_coefs = coefs
return coefs
示例3: __call__
# 需要导入模块: from sfepy.base.conf import ProblemConf [as 别名]
# 或者: from sfepy.base.conf.ProblemConf import from_dict [as 别名]
def __call__(self):
return ProblemConf.from_dict(self.conf.__dict__,
import_file(__file__))