Esempio n. 1
0
    def __init__(self, symbol, configuration = None, xc = LDA, 
                 maxiter = 200, mixing = 0.4, tol = 1e-6, output = None, 
                 write = None):
        """
        DFT atomic calculation.

        Parameters:
        symbol          chemical symbol
        configuration   '[He] 2s2 2p2', overrides default from table
        xc              XC functional (LDA default)
        """
        # store parameters
        self.element = Element(symbol)
        if configuration == None:
            self.configuration = self.element.get_configuration()
        else:
            self.configuration = configuration
        self.xc = xc
        self.maxiter = maxiter
        self.mixing = mixing
        self.tol = tol
        self.write = write
        self.set_output(output)

        # initialize grid, orbitals, energies
        self.grid = RadialGrid(self.element.get_atomic_number())
        self.setup_orbitals()
        
        # print header
        self.print_header()
Esempio n. 2
0
def inertia(atoms, xyz):
    ## This function calculate principal axis

    xyz = np.array([i for i in xyz])  # copy the array to avoid changing it
    mass = []
    for i in atoms:
        m = Element(i).getMass()
        mass.append(m)
    mass = np.array(mass)
    xyz -= np.average(xyz, weights=mass, axis=0)
    xx = 0.0
    yy = 0.0
    zz = 0.0
    xy = 0.0
    xz = 0.0
    yz = 0.0
    for n, i in enumerate(xyz):
        xx += mass[n] * (i[1]**2 + i[2]**2)
        yy += mass[n] * (i[0]**2 + i[2]**2)
        zz += mass[n] * (i[0]**2 + i[1]**2)
        xy += -mass[n] * i[0] * i[1]
        xz += -mass[n] * i[0] * i[2]
        yz += -mass[n] * i[1] * i[2]

    I = np.array([[xx, xy, xz], [xy, yy, yz], [xz, yz, zz]])
    eigval, eigvec = np.linalg.eig(I)

    return eigvec[np.argmax(eigval)]
Esempio n. 3
0
 def _read_coord(self, xyz):
     xyz = np.array(xyz)
     natom = len(xyz)
     T = xyz[:, 0]
     R = xyz[:, 1:].astype(float)
     M = np.array([Element(x).getMass() * 1822.8852
                   for x in T]).reshape([-1, 1])
     return T, R, M
Esempio n. 4
0
def Readinitcond(trvm):
    ## This function read coordinates from sampled initial condition
    ## This function return coordinates in a numpy array
    ## The elements are presented by the nuclear number
    ## This function also return a list of atomic mass in amu
    ## 1 g/mol = 1822.8852 amu
    natom = len(trvm)
    xyz = []
    velo = np.zeros((natom, 3))
    mass = np.zeros((natom, 1))
    for i, line in enumerate(trvm):
        e, x, y, z, vx, vy, vz, m, chrg = line
        xyz.append([e, x, y, z])
        m = Element(e).getMass()
        velo[i, 0:3] = float(vx), float(vy), float(vz)
        mass[i, 0:1] = float(m) * 1822.8852

    return xyz, mass, velo
Esempio n. 5
0
def Readcoord(title):
    ## This function read coordinates from a xyz file
    ## This function return coordinates in a numpy array
    ## The elements are presented by the nuclear number
    ## This function also return a list of atomic mass in amu
    ## 1 g/mol = 1822.8852 amu

    file = open('%s.xyz' % (title)).read().splitlines()
    natom = int(file[0])
    xyz = []
    mass = np.zeros((natom, 1))
    for i, line in enumerate(file[2:2 + natom]):
        e, x, y, z = line.split()
        xyz.append([e, x, y, z])
        m = Element(e).getMass()
        mass[i, 0:1] = m * 1822.8852

    return xyz, mass