Example #1
0
    def __init__(self,
                 calc,
                 charge_density='Gaussian',
                 solver=None,
                 accuracy_goal=12):
        self.calc = proxy(calc)
        self.norb = calc.el.get_nr_orbitals()
        self.SCC = calc.get('SCC')
        self.N = len(calc.el)
        self.dq = np.zeros((self.N))
        self.G = np.zeros((self.N, self.N))
        self.dG = np.zeros((self.N, self.N, 3))

        self.accuracy_goal = accuracy_goal

        if not charge_density in _gamma_correction_dict.keys():
            raise RuntimeError("Unknown charge density type: %s." %
                               charge_density)

        self.gamma_correction = _gamma_correction_dict[charge_density]

        if solver is None:
            cut = self.calc.get('gamma_cut')
            if self.SCC and cut == None and np.any(
                    self.calc.el.atoms.get_pbc()):
                raise AssertionError(
                    'gamma_cut must be provided for periodic calculations and with DirectCoulomb'
                )
            self.solver = DirectCoulomb(cut)
        else:
            self.solver = solver