Beispiel #1
0
def parse_FORCE_SETS( num_atom,
                      is_translational_invariance = False,
                      filename = "FORCE_SETS" ):
    set_of_forces = []
    file = open(filename, 'r')
    natom_from_disp_yaml = int( get_line_ignore_blank( file ) )
    if not num_atom==natom_from_disp_yaml:
        return None

    num_displacements = int( get_line_ignore_blank( file ) )

    for i in range(num_displacements):
        line = get_line_ignore_blank( file )
        atom_number = int( line )
        line = get_line_ignore_blank( file ).split()
        displacement = np.array([ float(x) for x in line ])
        forces_tmp = []
        for j in range( num_atom ):
            line = get_line_ignore_blank( file ).split()
            forces_tmp.append(np.array( [ float(x) for x in line ] ) )
        forces = Forces( atom_number-1, displacement, forces_tmp )
        if is_translational_invariance:
            forces.set_translational_invariance()
        set_of_forces.append(forces)

    return set_of_forces
Beispiel #2
0
def parse_FORCES(cell, is_translational_invariance=False, filename="FORCES"):
    set_of_forces = []
    f = open(filename, 'r')
    num_displacements = int(f.readline().strip())
    for i in range(num_displacements):
        line = f.readline().strip().split()
        atom_number = int(line[0])
        displacement = np.array([float(line[x]) for x in (1, 2, 3)])
        displacement = np.dot(displacement, cell.get_cell())
        forces_tmp = []
        for j in range(cell.get_number_of_atoms()):
            forces_tmp.append(
                np.array([float(x) for x in f.readline().strip().split()]))
        forces = Forces(atom_number - 1, displacement, forces_tmp)
        if is_translational_invariance:
            forces.set_translational_invariance()
        set_of_forces.append(forces)

    return set_of_forces
Beispiel #3
0
def parse_FORCES( cell,
                  is_translational_invariance = False,
                  filename = "FORCES" ):
    set_of_forces = []
    file = open(filename, 'r')
    num_displacements = int(file.readline().strip())
    for i in range(num_displacements):
        line = file.readline().strip().split()
        atom_number = int( line[0] )
        displacement = np.array([ float(line[x]) for x in (1,2,3)])
        displacement = np.dot( displacement, cell.get_cell() )
        forces_tmp = []
        for j in range(cell.get_number_of_atoms()):
            forces_tmp.append(np.array(
                    [ float(x) for x in file.readline().strip().split() ]))
        forces = Forces( atom_number-1, displacement, forces_tmp )
        if is_translational_invariance:
            forces.set_translational_invariance()
        set_of_forces.append(forces)

    return set_of_forces
Beispiel #4
0
def get_set_of_forces(f, num_atom, is_translational_invariance):
    set_of_forces = []
    natom_from_disp_yaml = int(get_line_ignore_blank(f))
    if not num_atom==natom_from_disp_yaml:
        return None

    num_displacements = int(get_line_ignore_blank(f))

    for i in range(num_displacements):
        line = get_line_ignore_blank(f)
        atom_number = int(line)
        line = get_line_ignore_blank(f).split()
        displacement = np.array([float(x) for x in line])
        forces_tmp = []
        for j in range(num_atom):
            line = get_line_ignore_blank(f).split()
            forces_tmp.append(np.array([float(x) for x in line]))
        forces = Forces(atom_number-1, displacement, forces_tmp)
        if is_translational_invariance:
            forces.set_translational_invariance()
        set_of_forces.append(forces)

    return set_of_forces
Beispiel #5
0
def get_set_of_forces(f, num_atom, is_translational_invariance):
    set_of_forces = []
    natom_from_disp_yaml = int(get_line_ignore_blank(f))
    if not num_atom == natom_from_disp_yaml:
        return None

    num_displacements = int(get_line_ignore_blank(f))

    for i in range(num_displacements):
        line = get_line_ignore_blank(f)
        atom_number = int(line)
        line = get_line_ignore_blank(f).split()
        displacement = np.array([float(x) for x in line])
        forces_tmp = []
        for j in range(num_atom):
            line = get_line_ignore_blank(f).split()
            forces_tmp.append(np.array([float(x) for x in line]))
        forces = Forces(atom_number - 1, displacement, forces_tmp)
        if is_translational_invariance:
            forces.set_translational_invariance()
        set_of_forces.append(forces)

    return set_of_forces
Beispiel #6
0
 def set_forces(self, sets_of_forces):
     forces = []
     for i, disp in enumerate(self._displacements):
         forces.append(Forces(disp[0], disp[1:4], sets_of_forces[i]))
     self._set_of_forces_objects = forces