当前位置: 首页>>代码示例>>Python>>正文


Python task.OptimizeTask类代码示例

本文整理汇总了Python中ase.tasks.task.OptimizeTask的典型用法代码示例。如果您正苦于以下问题:Python OptimizeTask类的具体用法?Python OptimizeTask怎么用?Python OptimizeTask使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OptimizeTask类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: parse

    def parse(self, opts, args):
        OptimizeTask.parse(self, opts, args)

        if opts.srelax:
            if len(opts.srelax.split(',')) > 1:
                self.sfmax, self.soptimizer = opts.srelax.split(',')
            else:
                self.sfmax = opts.srelax
                self.soptimizer = 'BFGS'
            self.sfmax = float(self.sfmax)

        if opts.srelaxsteps is not None:
            self.ssteps = int(opts.srelaxsteps)
        else:
            # yes, the default number of ASE optimizer steps
            # ase/optimize/optimize.py
            self.ssteps = 100000000

        if opts.fit:
            points, strain = opts.fit.split(',')
            if float(strain) > 0:
                self.fit = (int(points), float(strain) * 0.01)
            else:
                self.fit = (int(points), float(strain))

        self.eos = opts.eos

        self.crystal_structure = opts.crystal_structure
        self.lattice_constant = opts.lattice_constant
        self.c_over_a = opts.c_over_a
        self.orthorhombic = opts.orthorhombic
        self.cubic = opts.cubic
        self.repeat = opts.repeat
开发者ID:jboes,项目名称:ase,代码行数:33,代码来源:bulk.py

示例2: analyse

    def analyse(self):
        OptimizeTask.analyse(self)

        for name, data in self.data.items():
            if 'distances' in data:
                distances = data['distances']
                energies = data['energies']
                fit0 = np.poly1d(np.polyfit(1 / distances, energies, 3))
                fit1 = np.polyder(fit0, 1)
                fit2 = np.polyder(fit1, 1)

                dmin = None
                for t in np.roots(fit1):
                    if t > 0 and fit2(t) > 0:
                        dmin = 1 / t
                        break

                if dmin is None:
                    raise ValueError('No minimum!')

                if abs(dmin) < min(distances) or abs(dmin) > max(distances):
                    raise ValueError('Fit outside of range! ' + \
                                      str(abs(dmin)) + ' not in ' + \
                                      str(distances))

                emin = fit0(t)
                k = fit2(t) * t**4
                m1, m2 = self.create_system(name).get_masses()
                m = m1 * m2 / (m1 + m2)
                hnu = units._hbar * 1e10 * sqrt(k / units._e / units._amu / m)

                data['minimum energy'] = emin
                self.results[name][1:] = [energies[2] - emin, dmin, 1000 * hnu]
            else:
                self.results[name].extend([None, None])

        for name, data in self.data.items():
            atoms = self.create_system(name)
            if len(atoms) == 1:
                self.results[name].extend([None, None])
                continue

            eatoms = 0.0
            for symbol in atoms.get_chemical_symbols():
                if symbol in self.data and symbol != name:
                    eatoms += self.data[symbol]['energy']
                else:
                    eatoms = None
                    break
            ea = None
            ea0 = None
            if eatoms is not None:
                ea = eatoms - data['energy']
                if 'minimum energy' in data:
                    ea0 = eatoms - data['minimum energy']
            self.results[name].extend([ea, ea0])
开发者ID:gjuhasz,项目名称:ase,代码行数:56,代码来源:molecule.py

示例3: parse

    def parse(self, opts, args):
        OptimizeTask.parse(self, opts, args)

        if opts.fit:
            points, strain = opts.fit.split(',')
            self.fit = (int(points), float(strain) * 0.01)

        self.crystal_structure = opts.crystal_structure
        self.lattice_constant = opts.lattice_constant
        self.c_over_a = opts.c_over_a
        self.orthorhombic = opts.orthorhombic
        self.cubic = opts.cubic
        self.repeat = opts.repeat
开发者ID:sr76,项目名称:excitingscripts,代码行数:13,代码来源:bulk.py

示例4: calculate

 def calculate(self, name, atoms):
     if self.fit and len(atoms) == 2:
         return self.fit_bond_length(name, atoms)
     else:
         data = OptimizeTask.calculate(self, name, atoms)
         self.check_occupation_numbers(atoms)
         return data
开发者ID:gjuhasz,项目名称:ase,代码行数:7,代码来源:molecule.py

示例5: parse

    def parse(self, opts, args):
        OptimizeTask.parse(self, opts, args)

        self.vacuum = opts.vacuum
        self.bond_length = opts.bond_length
        self.atomize = opts.atomize

        if opts.fit:
            points, strain = opts.fit.split(',')
            self.fit = (int(points), float(strain) * 0.01)

        if opts.unit_cell:
            if ',' in opts.unit_cell:
                self.unit_cell = [float(x) for x in opts.unit_cell.split(',')]
            else:
                self.unit_cell = [float(opts.unit_cell)] * 3
开发者ID:JConwayAWT,项目名称:PGSS14CC,代码行数:16,代码来源:molecule.py

示例6: calculate

 def calculate(self, name, atoms):
     data = OptimizeTask.calculate(self, name, atoms)
     if self.fmax is not None and len(atoms) == 2:
         data['distance'] = atoms.get_distance(0, 1)
     self.check_occupation_numbers(atoms)
     if self.fit and len(atoms) == 2:
         self.fit_bond_length(name, atoms, data)
     return data
开发者ID:JConwayAWT,项目名称:PGSS14CC,代码行数:8,代码来源:molecule.py

示例7: __init__

    def __init__(self, crystal_structure=None, lattice_constant=None,
                 c_over_a=None, cubic=False, orthorhombic=False, fit=None,
                 **kwargs):
        """Bulk task."""

        self.crystal_structure = crystal_structure
        self.lattice_constant = lattice_constant
        self.c_over_a = c_over_a
        self.cubic = cubic
        self.orthorhombic = orthorhombic
        self.fit = fit

        self.repeat = None

        OptimizeTask.__init__(self, **kwargs)

        self.summary_keys = ['energy', 'fitted energy', 'volume', 'B']
开发者ID:sr76,项目名称:excitingscripts,代码行数:17,代码来源:bulk.py

示例8: analyse

 def analyse(self):
     OptimizeTask.analyse(self)
     for name, data in self.data.items():
         if 'strains' in data:
             atoms = self.create_system(name)
             volumes = data['strains']**3 * atoms.get_volume()
             energies = data['energies']
             eos = EquationOfState(volumes, energies)
             try:
                 v, e, B = eos.fit()
             except ValueError:
                 self.results[name].extend([None, None])
             else:
                 self.results[name][1:] = [energies[2] - e, v,
                                           B * 1e24 / units.kJ]
         else:
             self.results[name].extend([None, None])
开发者ID:gjuhasz,项目名称:ase,代码行数:17,代码来源:bulk.py

示例9: __init__

    def __init__(self, crystal_structure=None, lattice_constant=None,
                 c_over_a=None, cubic=False, orthorhombic=False, fit=None,
                 **kwargs):
        """Bulk task."""

        self.crystal_structure = crystal_structure
        self.lattice_constant = lattice_constant
        self.c_over_a = c_over_a
        self.cubic = cubic
        self.orthorhombic = orthorhombic
        self.fit = fit

        self.repeat = None

        OptimizeTask.__init__(self, **kwargs)
        
        self.summary_header += [('V0', 'Ang^3'),
                                ('B', 'GPa')]
开发者ID:gjuhasz,项目名称:ase,代码行数:18,代码来源:bulk.py

示例10: __init__

    def __init__(self, vacuum=3.0, cell=None, atomize=False,
                 bond_length=None, fit=None,
                 **kwargs):
        """Molecule task.

        This task can calculate bond lengths and vibration frequencies
        of dimer molecules."""

        self.vacuum = vacuum
        self.unit_cell = cell
        self.atomize = atomize
        self.bond_length = bond_length
        self.fit = fit

        OptimizeTask.__init__(self, **kwargs)

        self.summary_keys = ['energy', 'relaxed energy', 'distance',
                             'frequency', 'atomic energy']
开发者ID:JConwayAWT,项目名称:PGSS14CC,代码行数:18,代码来源:molecule.py

示例11: add_options

    def add_options(self, parser):
        OptimizeTask.add_options(self, parser)

        mol = optparse.OptionGroup(parser, 'Molecule')
        mol.add_option('-v', '--vacuum', type='float', default=3.0,
                       help='Amount of vacuum to add around isolated systems '
                       '(in Angstrom).')
        mol.add_option('--unit-cell',
                       help='Unit cell.  Examples: "10.0" or "9,10,11" ' +
                       '(in Angstrom).')
        mol.add_option('--bond-length', type='float',
                       help='Bond length of dimer in Angstrom.')
        mol.add_option('-F', '--fit', metavar='N,x',
                       help='Find optimal bondlength and vibration ' +
                       'frequency using N points and displacements from ' +
                       '-x % to +x %.')
        mol.add_option('--atomize', action='store_true',
                       help='Calculate Atomization energies.')
        parser.add_option_group(mol)
开发者ID:JConwayAWT,项目名称:PGSS14CC,代码行数:19,代码来源:molecule.py

示例12: calculate

 def calculate(self, name, atoms):
     if self.fmax is not None:
         # this performs relaxation of internal degrees of freedom
         data = OptimizeTask.calculate(self, name, atoms)
         data['distance'] = atoms.get_distance(0, -1)
     else:
         # no optimization
         if self.fit is None or len(atoms) != 2:
             # for dimers: only calculate single-point energy if no fit follows
             data = OptimizeTask.calculate(self, name, atoms)
     if self.fit is not None and len(atoms) == 2:
         if self.fmax is not None:
             # fit after optimization
             self.fit_bond_length(name, atoms, data)
         else:
             # fit is the only task performed
             data = self.fit_bond_length(name, atoms)
     self.check_occupation_numbers(atoms)
     return data
开发者ID:PHOTOX,项目名称:fuase,代码行数:19,代码来源:molecule.py

示例13: __init__

    def __init__(self, vacuum=3.0, cell=None, atomize=False,
                 bond_length=None, fit=None,
                 **kwargs):
        """Molecule task.

        This task can calculate bond lengths and vibration frequencies
        of dimer molecules."""

        self.vacuum = vacuum
        self.unit_cell = cell
        self.atomize = atomize
        self.bond_length = bond_length
        self.fit = fit

        OptimizeTask.__init__(self, **kwargs)

        self.summary_header += [('d0', 'Ang'),
                                ('hnu', 'meV'),
                                ('Ea', 'eV'),
                                ('Ea0', 'eV')]
开发者ID:gjuhasz,项目名称:ase,代码行数:20,代码来源:molecule.py

示例14: add_options

    def add_options(self, parser):
        OptimizeTask.add_options(self, parser)

        bulk = optparse.OptionGroup(parser, 'Bulk')
        bulk.add_option('-F', '--fit', metavar='N,x',
                        help='Find optimal volume and bulk modulus ' +
                        'using odd N points and variations of the lattice ' +
                        'constant a from -x % to +x %, i.e. in the interval '
                        '<a - a * x * 100, ..., a, ..., a + a * x * 100>. ' +
                        'This method gives non-equidistant sampling of volume. ' +
                        'With x negative (in Angstrom**3) the sampling of ' +
                        'the cell volume (v) in the interval ' +
                        '<(1 + x /v), ..., 1, ..., (1 - x /v)> is used. ' +
                        'This method gives equidistant sampling of volume.')
        bulk.add_option('--eos', type='str',
                        metavar='eos',
                        help='Selects the type of eos.')
        bulk.add_option('--srelax', metavar='SFMAX[,SOPTIMIZER]',
                        help='Relax cell by minimizing stress using StranFilter '
                        'with SOPTIMIZER algorithm. The SOPTIMIZER keyword is '
                        'optional, and if omitted BFGS is used by default.')
        bulk.add_option('--srelaxsteps', type='int',
                        metavar='ssteps',
                        help='Limit the number of SF optimizer steps.')
        bulk.add_option('-x', '--crystal-structure',
                        help='Crystal structure.',
                        choices=['sc', 'fcc', 'bcc', 'hcp', 'diamond',
                                 'zincblende', 'rocksalt', 'cesiumchloride',
                                 'fluorite'])
        bulk.add_option('-a', '--lattice-constant', type='float',
                        help='Lattice constant in Angstrom.')
        bulk.add_option('--c-over-a', type='float',
                        help='c/a ratio.')
        bulk.add_option('-O', '--orthorhombic', action='store_true',
                        help='Use orthorhombic unit cell.')
        bulk.add_option('-C', '--cubic', action='store_true',
                        help='Use cubic unit cell.')
        bulk.add_option('-r', '--repeat',
                        help='Repeat unit cell.  Use "-r 2" or "-r 2,3,1".')
        parser.add_option_group(bulk)
开发者ID:jboes,项目名称:ase,代码行数:40,代码来源:bulk.py

示例15: __init__

    def __init__(self, crystal_structure=None, lattice_constant=None,
                 c_over_a=None, cubic=False, orthorhombic=False, fit=None,
                 eos=None, sfmax=None, soptimizer='BFGS', ssteps=100000000,
                 **kwargs):
        """Bulk task."""

        self.crystal_structure = crystal_structure
        self.lattice_constant = lattice_constant
        self.c_over_a = c_over_a
        self.cubic = cubic
        self.orthorhombic = orthorhombic
        self.eos = eos
        self.fit = fit
        self.sfmax = sfmax
        self.soptimizer = soptimizer
        self.ssteps = ssteps

        self.repeat = None

        OptimizeTask.__init__(self, **kwargs)

        self.summary_keys = ['energy', 'fitted energy', 'volume', 'B']
开发者ID:jboes,项目名称:ase,代码行数:22,代码来源:bulk.py


注:本文中的ase.tasks.task.OptimizeTask类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。