def __init__(self, nalpha, nbeta=None, temperature=300, eps=1e-8): ''' **Arguments:** nalpha The number of alpha electrons **Optional arguments:** nbeta The number of beta electrons. Default is equal to nalpha. temperature Controls the width of the distribution (derivative) eps The error on the sum of the occupation number when searching for the right Fermi level. ''' FermiBase.__init__(self, temperature, eps) if nbeta is None: nbeta = nalpha if nalpha < 0 or nbeta < 0: raise ElectronCountError( 'Negative number of electrons is not allowed.') if nalpha == 0 and nbeta == 0: raise ElectronCountError( 'At least one alpha or beta electron is required.') self.nalpha = nalpha self.nbeta = nbeta
def __init__(self, *noccs): ''' **Arguments:** nalpha, nbeta, ... The number of electrons in each channel. ''' for nocc in noccs: if nocc < 0: raise ElectronCountError('Negative number of electrons is not allowed.') if sum(noccs) == 0: raise ElectronCountError('At least one electron is required.') self.noccs = noccs
def assign(self, exp_alpha, exp_beta=None): '''Assign occupation numbers to the expansion objects **Arguments:** exp_alpha An alpha DenseExpansion object **Optional arguments:** exp_beta A beta DenseExpansion object ''' exps = [(exp_alpha, self.nalpha)] if exp_beta is not None: exps.append((exp_beta, self.nbeta)) for exp, nocc in exps: if exp.nfn < nocc: raise ElectronCountError( 'The number of orbitals must not be lower than the number of alpha or beta electrons.' ) # It is assumed that the orbitals are sorted from low to high energy. if nocc == int(nocc): exp.occupations[:nocc] = 1.0 exp.occupations[nocc:] = 0.0 else: exp.occupations[:int(np.floor(nocc))] = 1.0 exp.occupations[int(np.floor(nocc))] = nocc - np.floor(nocc) exp.occupations[int(np.ceil(nocc)):] = 0.0
def __init__(self, nel): ''' **Arguments:** nel The total number of electrons (alpha + beta) ''' if nel <= 0: raise ElectronCountError('The number of electron must be positive.') self.nel = nel
def assign(self, *exps): if len(exps) != len(self.noccs): raise TypeError('Expected %i expansion objects, got %i.' % (len(self.nocc), len(exps))) for exp, nocc in zip(exps, self.noccs): if exp.nfn < nocc: raise ElectronCountError('The number of orbitals must not be lower than the number of alpha or beta electrons.') # It is assumed that the orbitals are sorted from low to high energy. if nocc == int(nocc): exp.occupations[:nocc] = 1.0 exp.occupations[nocc:] = 0.0 else: exp.occupations[:int(np.floor(nocc))] = 1.0 exp.occupations[int(np.floor(nocc))] = nocc - np.floor(nocc) exp.occupations[int(np.ceil(nocc)):] = 0.0
def __init__(self, nalpha, nbeta=None): ''' **Arguments:** nalpha The number of alpha electrons **Optional arguments:** nbeta The number of beta electrons. Default is equal to nalpha. ''' if nbeta is None: nbeta = nalpha if nalpha < 0 or nbeta < 0: raise ElectronCountError( 'Negative number of electrons is not allowed.') if nalpha == 0 and nbeta == 0: raise ElectronCountError( 'At least one alpha or beta electron is required.') self.nalpha = nalpha self.nbeta = nbeta