Ejemplo n.º 1
0
 def setUp(self):
     h2_xyz_file = 'tmp.xyz'
     with open(h2_xyz_file, 'w') as ftemp:
         ftemp.write("   %d\n" % 2)
         ftemp.write("  \n")
         ftemp.write("H 0.0 0.0 0.0\n")
         ftemp.write("H 0.0 0.0 0.7\n")
         mopac_inst = mopac.Mopac(h2_xyz_file)
         mopac_inst.prepare_input(keyword="PM7")
Ejemplo n.º 2
0
 def make_monomers(self, mers_list):
     n_of_molecules = len(mers_list)
     energy_list = []
     for i in range(n_of_molecules):
         mer_i = "mer_" + str(i) + ".xyz"
         with open(mer_i, 'w') as fp:
             fp.write("  %d\n" % len(mers_list[i]))
             fp.write("xyz for cooperativity\n")
             for j in mers_list[i]:
                 fp.write("%s %f %f %f\n" % (j[0], j[1], j[2], j[3]))
         mopac_inst = mopac.Mopac(mer_i)
         prepare_input_status = mopac_inst.prepare_input(keyword="PM7 1SCF")
         optimize = mopac_inst.optimize()
         energy = mopac_inst.get_energy()
         energy_list.append([mer_i, energy])
     return energy_list
Ejemplo n.º 3
0
def run_cluster(fragment_1_all_set, fragment_2_all_set, tabu_file, xyz_file_adder, no_of_orientation, aggregates, atoms_name,\
                translational_vector_range, tvector_dimension, rvector_dimension):
    print "Running the Cluster calculation"
    tot_atoms = len(atoms_name)
    dict_struct_energy = {}
    for orientation in range(no_of_orientation):
        xaxis = [translational_vector_range[0], translational_vector_range[1], 1]
        yaxis = [translational_vector_range[0], translational_vector_range[1], 1]
        zaxis = [translational_vector_range[0], translational_vector_range[1], 1]
        all_trans = [xaxis, yaxis, zaxis]
        all_rot = [[0, 360, 12], [0, 180, 6], [0, 360, 12]]
        start_xyz_file_name = "start_"+str(aggregates)+"_"+xyz_file_adder+"_"+str(orientation)+".xyz"
        vectors = vector_generator.vector_generator(tvector_dimension, rvector_dimension)
        tvectors, rvectors = vectors.trans_rot_vector_generator(tabu_file, all_trans, all_rot, 0.1, 30.0)
        new_rot_coords_of_frag_2 = species.rotate_euler(fragment_2_all_set, rvectors[:])
        final_coords_of_frag_2 = species.translate(atoms_name, fragment_1_all_set, new_rot_coords_of_frag_2[:], tvectors[:])
        all_coords = np.concatenate((fragment_1_all_set, final_coords_of_frag_2), axis=0)
        fstart = open(start_xyz_file_name, 'w')
        fstart.write("%d\n" % tot_atoms)
        fstart.write("    \n")
        for n in range(len(all_coords)):
            fstart.write("%-5s %17.10f %17.10f %17.10f \n" % (atoms_name[n], all_coords[n][0], all_coords[n][1], all_coords[n][2]))
        fstart.close()
        mopac_inst = mopac.Mopac(start_xyz_file_name)
        xyz_file_result_name = "result_"+str(aggregates)+"_"+xyz_file_adder+"_"+str(orientation)
        prepare_input_status = mopac_inst.prepare_input(keyword="PM7 PRECISE SINGLET LET DDMIN=0.0 CYCLES=10000 THREADS=8")
        optimize_status = mopac_inst.optimize()
        if optimize_status != 0:
            print "optimize status: ", optimize_status
            print "The optimization for geometry:", start_xyz_file_name, "has failed."
            print "New geometry will be optimized and it will be discarded."
            continue
        #if files_dirs.file_exists_check_with_return_status("start_"+str(aggregates)+"_"+str(orientation)+".arc"):
        #    energies = mopac_inst.get_energy()
        #else:
        #    continue
        energies = mopac_inst.get_energy()
        en_kcal = energies[0]
        en_kj = energies[1]
        print "xyz_file_result_name is: ", xyz_file_result_name
        mopac_inst.extract_xyz(xyz_file_result_name+".xyz")
        dict_struct_energy[xyz_file_result_name] = en_kcal
    pprint.pprint(dict_struct_energy)
    return
Ejemplo n.º 4
0
 def make_dimers(self, mers_list):
     n_of_molecules = len(mers_list)
     no_of_atoms_in_each_mer = len(mers_list[0])
     energy_list = []
     for i in range(n_of_molecules - 1):
         for j in range(i + 1, n_of_molecules):
             mer_ij = "mer_" + str(i) + "_" + str(j) + ".xyz"
             with open(mer_ij, 'w') as fp:
                 fp.write("  %d\n" % (2 * no_of_atoms_in_each_mer))
                 fp.write("xyz for cooperativity\n")
                 for k in mers_list[i]:
                     fp.write("%s %f %f %f\n" % (k[0], k[1], k[2], k[3]))
                 for l in mers_list[j]:
                     fp.write("%s %f %f %f\n" % (l[0], l[1], l[2], l[3]))
             mopac_inst = mopac.Mopac(mer_ij)
             prepare_input_status = mopac_inst.prepare_input(
                 keyword="PM7 1SCF")
             optimize = mopac_inst.optimize()
             energy = mopac_inst.get_energy()
             energy_list.append([mer_ij, energy])
     return energy_list
Ejemplo n.º 5
0
 def test_return_status(self):
     mopac_inst = mopac.Mopac(self.h2_xyz_file)
     status = mopac_inst.prepare_input(keyword="PM7")
     self.assertEqual(status, 0)
Ejemplo n.º 6
0
 def single_point_nmer(self, xyz_file):
     mopac_inst = mopac.Mopac(xyz_file)
     prepare_input_status = mopac_inst.prepare_input(keyword="PM7 1SCF")
     optimize_status = mopac_inst.optimize()
     energy = mopac_inst.get_energy()
     return energy