def get_coords_CO2(xyzfilename): _, _, atoms, coords = read_xyz(xyzfilename) # CO2 is always the last 3 atoms in each file. coords_CO2 = np.array(coords[-3:]) return coords_CO2
'find /home/eric/Chemistry/calc.sgr/paper_02_CD_SC/NewXYZFiles/ -name "*.xyz" | sort', shell=True ).decode() xyzfilenames = sorted(find_output.splitlines()) dim = 1001 assert len(xyzfilenames) == dim possible_n_qm = list(range(1, 64 + 1)) dropnums = {n_qm: [] for n_qm in possible_n_qm} n_qm_to_distance_from_COM_COM_combined = {n_qm: [] for n_qm in possible_n_qm} n_qm_to_distance_from_COM_COM_cation = {n_qm: [] for n_qm in possible_n_qm} n_qm_to_distance_from_COM_COM_anion = {n_qm: [] for n_qm in possible_n_qm} for xyzfilename in xyzfilenames: dropnum = os.path.splitext(xyzfilename.split("_")[-1])[0] print(dropnum) _, _, elements, coords = read_xyz(xyzfilename) assert elements[-3:] == ["C", "O", "O"] grouping_anions, grouping_cations, grouping_CO2 = determine_fragment_grouping(elements) fragments_anions = make_fragments_from_grouping(elements, coords, grouping_anions) fragments_cations = make_fragments_from_grouping(elements, coords, grouping_cations) fragment_CO2 = make_fragments_from_grouping(elements, coords, grouping_CO2) fragments = fragments_anions + fragments_cations + fragment_CO2 assert len(fragment_CO2) == 1 fragment_CO2 = fragment_CO2[0] for n_qm in possible_n_qm: # Wouldn't it be nice if we didn't calculate the distance twice? closest_cations = get_n_closest_fragments(n_qm, fragment_CO2, fragments_cations, method="centerofmass") closest_anions = get_n_closest_fragments(n_qm, fragment_CO2, fragments_anions, method="centerofmass") max_distance_from_COM_COM_combined = -1.0e30 max_distance_from_COM_COM_cation = -1.0e30 max_distance_from_COM_COM_anion = -1.0e30
parser.add_argument('--alpha-slope', type=float, default=-3415.3) parser.add_argument('--alpha-intercept', type=float, default=9523.8) parser.add_argument('--beta-slope', type=float, default=1.12) parser.add_argument('--beta-intercept', type=float, default=-515.7) args = parser.parse_args() alpha_slope = args.alpha_slope alpha_intercept = args.alpha_intercept beta_slope = args.beta_slope beta_intercept = args.beta_intercept l_lower = [] l_upper = [] for xyzfilename in args.xyzfilename: _, _, atoms, coords = read_xyz(xyzfilename) coords_CO2 = np.array(coords[-3:]) # Carbon is the first atom! l12 = distance(coords_CO2[0], coords_CO2[1]) + distance(coords_CO2[0], coords_CO2[2]) angle = bond_angle(coords_CO2[1], coords_CO2[0], coords_CO2[2]) theta = 180.0 - angle alpha = (alpha_slope * l12) + alpha_intercept beta = (beta_slope * theta) + beta_intercept hamiltonian = np.array( [[alpha, beta], [beta, alpha]] )