-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
5,521 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import numpy as np | ||
from cosymlib.file_io import read_generic_structure_file, get_file_xyz_txt | ||
from cosymlib.molecule.geometry import Geometry | ||
|
||
|
||
def read_normal_modes_gaussian(file_name): | ||
read = False | ||
frequencies = [] | ||
normal_modes_matrices = [] | ||
with open(file_name, mode='r') as lines: | ||
for line in lines: | ||
if read: | ||
if len(line.split()) == 3 or not line.strip(): | ||
read = False | ||
else: | ||
for i in range(int(len(line.split()[2:])/3)): | ||
atom_vibration = line.split()[2 + 3*i:3 + 2 + 3*i] | ||
normal_modes_matrices[-3+i].append([float(x)for x in atom_vibration]) | ||
|
||
if 'Atom AN' in line: | ||
read = True | ||
for _ in range(line.split()[2:].count('X')): | ||
normal_modes_matrices.append([]) | ||
if 'Frequencies --' in line: | ||
frequencies.append(line.split()[2:]) | ||
frequencies = [float(frequency) for sublist in frequencies for frequency in sublist] | ||
|
||
return frequencies, normal_modes_matrices | ||
|
||
|
||
def get_nm_vibration_path(geometry, normal_mode, points=10, backward=False, k=1.5): | ||
|
||
nm_np_matrix = np.array(normal_mode) | ||
geom_np = np.array(geometry) | ||
if backward: | ||
x = np.linspace(-k, k, points) | ||
else: | ||
x = np.linspace(k/points, k, points) | ||
|
||
structures_path = [] | ||
for dx in x: | ||
structures_path.append(geom_np + dx*nm_np_matrix) | ||
|
||
return structures_path | ||
|
||
|
||
molecule = read_generic_structure_file('sf6.fchk') | ||
freq, nm_martices = read_normal_modes_gaussian('sf6_freq.out') | ||
k_points = 1.5 | ||
n_freq = 0 | ||
path = get_nm_vibration_path(molecule.geometry.get_positions(), nm_martices[0], k=k_points) | ||
|
||
x = np.linspace(k_points/10, k_points, 10) | ||
output = open('sf6_freq{}.xyz'.format(n_freq+1), 'w') | ||
for ids, structure in enumerate(path): | ||
xi = '{:.2f}'.format(x[ids]).replace('.', '') | ||
txt = get_file_xyz_txt(Geometry(structure, symbols=molecule.geometry.get_symbols(), name='freq : ' + str(freq[0]) + | ||
' ' + str(xi))) | ||
output.write(txt) |
Oops, something went wrong.