コード例 #1
0
ファイル: _coord.py プロジェクト: sofiasanz/sisl
            # error for multiple entries
            return AtomXYZ(**{key: interval}, **new_kwargs)
        elif len(interval) != 0:
            raise ValueError(
                f"{cls.__name__} non-keyword argumest must be 1 tuple, or 2 values"
            )
        return AtomXYZ(**new_kwargs)

    return _new


# Iterate over all directions that deserve an individual class
for key in ("x", "y", "z", "f_x", "f_y", "f_z", "a_x", "a_y", "a_z"):

    # The underscores are just kept for the key that is passed to AtomXYZ,
    # but the name of the category will have no underscore
    name = key.replace("_", "")

    # Create the class for this direction
    # note this is lower case since AtomZ should not interfere with Atomz
    new_cls = AtomXYZMeta(f"Atom{name}", (AtomCategory, ),
                          {"__new__": _new_factory(key)})

    new_cls = set_module("sisl.geom")(new_cls)

    # Set it as an attribute of `AtomXYZ`, so that you can access them from it.
    # Note that the classes are never exposed, so you can not import them, and the way
    # to use them is either through the kw builder in `AtomCategory` or from `AtomXYZ` attributes.
    # This enables AtomXYZ.fz < 0.5, for example.
    setattr(AtomXYZ, name, new_cls)
コード例 #2
0
ファイル: base.py プロジェクト: arsalan-akhtar/sisl
eigvalsh = _partial(sl.eigvalsh, check_finite=False, overwrite_a=False, overwrite_b=False, turbo=True)
eigvalsh_dc = eigvalsh
eigvalsh_qr = _partial(sl.eigvalsh, check_finite=False, overwrite_a=False, overwrite_b=False, turbo=False)
__all__ += _append('eigvalsh', ['', '_dc', '_qr'])

eigvalsh_destroy = _partial(sl.eigvalsh, check_finite=False, overwrite_a=True, overwrite_b=True, turbo=True)
eigvalsh_dc_destroy = eigvalsh_destroy
eigvalsh_qr_destroy = _partial(sl.eigvalsh, check_finite=False, overwrite_a=True, overwrite_b=True, turbo=False)
__all__ += _append('eigvalsh_', ['destroy', 'dc_destroy', 'qr_destroy'])

# SVD problem
svd = _partial(sl.svd, check_finite=False, overwrite_a=False)
svd_destroy = _partial(sl.svd, check_finite=False, overwrite_a=True)
__all__ += _append('svd', ['', '_destroy'])

# Determinants
det = _partial(sl.det, check_finite=False, overwrite_a=False)
det_destroy = _partial(sl.det, check_finite=False, overwrite_a=True)
__all__ += _append('det', ['', '_destroy'])

# Sparse linalg routines

# Solve eigenvalue problem
eigs = set_module("sisl.linalg")(ssl.eigs)
__all__ += ['eigs']

# Solve symmetric/hermitian eigenvalue problem (generic == no overwrite)
eigsh = set_module("sisl.linalg")(ssl.eigsh)
__all__ += ['eigsh']
コード例 #3
0
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
from ..sile import add_sile

from sisl._internal import set_module
from sisl.io.siesta.binaries import _gfSileSiesta

__all__ = ['tbtgfSileTBtrans']

dic = {}
try:
    dic['__doc__'] = _gfSileSiesta.__doc__.replace(_gfSileSiesta.__name__,
                                                   'tbtgfSileTBtrans')
except Exception:
    pass

tbtgfSileTBtrans = set_module("sisl.io.tbtrans")(type("tbtgfSileTBtrans",
                                                      (_gfSileSiesta, ), dic))
del dic

add_sile('TBTGF', tbtgfSileTBtrans)
コード例 #4
0
            return coef * (hist[0] + self.weight * hist[1])
        return reduce(add, map(frac_hist, coefficients, self.history))

    def __call__(self, f, df, delta=None, append=True):
        # Add to history
        if append:
            if delta is None:
                self.history.append(f, df)
            else:
                self.history.append(f, df, delta)

        # Calculate new mixing quantity
        return self.mix(self.coefficients())


PulayMixer = set_module("sisl.mixing")(type("PulayMixer", (DIISMixer, ), {}))


@set_module("sisl.mixing")
class AdaptiveDIISMixer(DIISMixer):
    r""" Adapt the mixing weight according to the Lagrange multiplier

    The Lagrange multiplier calculated in a DIIS/Pulay mixing scheme
    is the squared norm of the residual that is minimized using the
    Lagrange method. It holds information on the closeness of the functional
    to a minimum.

    Thus we can use the Lagrange multiplier to adjust the weight such that
    for large values we know our next guess (:math:`f_{\mathrm{new}}`) will
    be relatively far from the true saddle point, and for small values we
    will be close to the saddle point.