Last active
April 29, 2016 02:29
-
-
Save Altoidnerd/516a1a50d7beb7d4b4e5841f1a9a2a57 to your computer and use it in GitHub Desktop.
Parses (kinda) output of gipaw.x for job 'efg' getting NQR frequencies(for 14N and 35Cl only).
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| import numpy as np | |
| import sys | |
| ################################# | |
| ################################# | |
| ## #### | |
| ## working version! tested! #### | |
| ## #### | |
| ################################# | |
| ################################# | |
| def f52(cq, eta=0, verbose=False): | |
| x2 = 1 - 11/54*eta**2 | |
| x1 = 1 + 5/54*eta**2 | |
| return 3 / 10 * cq * np.array( [1/2*x1, x2 ] ) | |
| def f32(cq, eta=0): | |
| return np.sqrt( 1 + (eta**2)/3 ) * cq/2 | |
| def f1(cq, eta=0): | |
| x0 = 2/3 * eta | |
| x1 = 1 - eta/3 | |
| x2 = 1 + eta/3 | |
| return (3/4) * cq * np.array( [x0, x1, x2] ) | |
| def cq32(f, eta=0): | |
| return np.sqrt( 4 * f**2 / (1 + eta**2 / 3) ) | |
| def cq1(freq_arr, eta=0): | |
| f_0, fmin, fmax = np.sort(np.array([x for x in freq_arr])) | |
| cq_0 = 2 * f_0/(eta ) | |
| cq_min = 4 * fmin/( 3 - eta ) | |
| cq_plus = 4 * fmax/( 3 + eta ) | |
| print( """ | |
| "cq_0": {}, | |
| "cq_minus": {}, | |
| "cq_plus": {} | |
| """.format(cq_0, cq_min, cq_plus)) | |
| return np.array([cq_0, cq_min, cq_plus]) | |
| def main(): | |
| infile = open(sys.argv[1],'r').readlines() | |
| relevant_lines = [] | |
| quads = [] | |
| for line in infile: | |
| try: | |
| if line.split()[2] == 'Q=': | |
| relevant_lines.append(line) | |
| except IndexError: | |
| pass | |
| for line in relevant_lines: | |
| quads.append([line.split()[0],line.split()[1],float(line.split()[7]), float(line.split()[10])]) | |
| for quad in quads: | |
| if 'Cl' in quad[0]: | |
| print( | |
| str(quad[0:2])+':\t\t',f32(quad[2],quad[3]) | |
| ) | |
| elif 'N' in quad[0]: | |
| print( | |
| str(quad[0:2])+':\t\t',f1(quad[2],quad[3]) | |
| ) | |
| if __name__ == '__main__': | |
| main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment