예제 #1
0
파일: average.py 프로젝트: jszopi/repESP
    import sys
    sys.exit(0)

if args.esp_file is not None:
    try:
        averaged_molecule = run_resp(
            args.respin_location, save_resp_to, resp_type='unrest',
            check_ivary=True, esp_fn=args.esp_file)
    except Exception as e:
        shutil.rmtree(save_resp_to)
        raise e
    if args.save_resp_to is None:
        shutil.rmtree(save_resp_to)
else:
    averaged_charges, ivary_list = equivalence(
        molecule, args.input_charge_type, args.respin_location, respin1_fn="",
        respin2_fn="")
    # Check equivalence information from respin:
    _check_ivary(True, molecule, ivary_list)
    # The new molecule and name 'resp' is for consistency with the
    # equivalencing code above
    averaged_molecule = copy.deepcopy(molecule)
    charges._update_molecule_with_charges(averaged_molecule, averaged_charges,
                                          "resp")

message = charges.compare_charges(args.input_charge_type, "resp", molecule,
                                  averaged_molecule, thresh=args.thresh)
thresh_message = " vary by more than the threshold of " + str(args.thresh)

if message:
    print("\nThe following charges" + thresh_message)
예제 #2
0
log_fn = path + molecule_name + "_" + charge_type + ".log"
esp_log_fn = path + molecule_name + "_" + esp_charge_type + ".log"
g = resp_helpers.G09_esp(path + esp_fn)

# Both the Gaussian ESP fitting methods and other charge assignment methods may
# not yield equivalent charges. As equivalent charges make more sense for force
# field development, they will be used. The ESP charges are equivalenced by
# performing unrestrained RESP, which will be used as a reference for the fit
# minimum. Charges from the other method will be equivalenced manually by my
# averaging function `resp.equivalence`. They will be scaled to obtain
# different ratio charges. All the charges are calculated and printed at the
# start for reference.
update_with_charges(esp_charge_type, esp_log_fn, g.molecule)
update_with_charges(charge_type, log_fn, g.molecule)
equiv_charges = resp.equivalence(g.molecule, charge_type, path)[0]
_update_molecule_with_charges(g.molecule, equiv_charges,
                              charge_type + '_equiv')
print("\nRunning unrestrained RESP to fit ESP with equivalence:")
esp_equiv_molecule = resp.run_resp(path,
                                   resp_output_path + 'unrest',
                                   resp_type='unrest',
                                   esp_fn=esp_fn)

charge_rrms = rms_and_rep(g.field, g.molecule, charge_type)[1]
equiv_charge_rrms = rms_and_rep(g.field, g.molecule, charge_type + '_equiv')[1]
esp_charge_rrms = rms_and_rep(g.field, g.molecule, esp_charge_type)[1]
resp_charge_rrms = rms_and_rep(g.field, esp_equiv_molecule, 'resp')[1]

print("\nThe molecule with {0} charges:".format(charge_type.upper()))
print("RRMS: {0:.5f}".format(charge_rrms))
예제 #3
0
# 2 charges: Presentation
if True:
    with open(output_path + "result.p", "rb") as f:
        read_result = pickle.load(f)

    rel_rrms = [
        100 * (elem - read_result.resp_rrms) / read_result.resp_rrms
        for elem in read_result.rrms
    ]
    rel_rrms = np.array(rel_rrms)
    rel_rrms.resize([read_result.sampling_num, read_result.sampling_num])

    # Non-ESP charge and its minimized ratio
    charges.update_with_charges(charge_type, charge_log_fn, molecule)
    equiv_start_charges = resp.equivalence(molecule, charge_type, path)[0]
    charge_type += '_equiv'
    charges._update_molecule_with_charges(molecule, equiv_start_charges,
                                          charge_type)
    os.mkdir(opt_output_path)
    # Scan roughly various ratios to find bracket for minimization
    print("\nScanning roughly various ratios. This shouldn't take long.")
    heavy_args = (g.field, path, opt_output_path, esp_fn, False)
    heavy_result, indicator_charge, ratio_values = resp.eval_ratios(
        'heavy', (0, 2),
        equiv_start_charges,
        10,
        vary_label1,
        heavy_args,
        first_verbose=True)
    # Minimization
예제 #4
0
파일: compromise.py 프로젝트: jszopi/repESP
log_fn = path + molecule_name + "_" + charge_type + ".log"
esp_log_fn = path + molecule_name + "_" + esp_charge_type + ".log"
g = resp_helpers.G09_esp(path + esp_fn)

# Both the Gaussian ESP fitting methods and other charge assignment methods may
# not yield equivalent charges. As equivalent charges make more sense for force
# field development, they will be used. The ESP charges are equivalenced by
# performing unrestrained RESP, which will be used as a reference for the fit
# minimum. Charges from the other method will be equivalenced manually by my
# averaging function `resp.equivalence`. They will be scaled to obtain
# different ratio charges. All the charges are calculated and printed at the
# start for reference.
update_with_charges(esp_charge_type, esp_log_fn, g.molecule)
update_with_charges(charge_type, log_fn, g.molecule)
equiv_charges = resp.equivalence(g.molecule, charge_type, path)[0]
_update_molecule_with_charges(g.molecule, equiv_charges, charge_type+'_equiv')
print("\nRunning unrestrained RESP to fit ESP with equivalence:")
esp_equiv_molecule = resp.run_resp(
    path, resp_output_path + 'unrest', resp_type='unrest', esp_fn=esp_fn)

charge_rrms = rms_and_rep(g.field, g.molecule, charge_type)[1]
equiv_charge_rrms = rms_and_rep(g.field, g.molecule, charge_type + '_equiv')[1]
esp_charge_rrms = rms_and_rep(g.field, g.molecule, esp_charge_type)[1]
resp_charge_rrms = rms_and_rep(g.field, esp_equiv_molecule, 'resp')[1]

print("\nThe molecule with {0} charges:".format(charge_type.upper()))
print("RRMS: {0:.5f}".format(charge_rrms))
for atom in g.molecule:
    atom.print_with_charge(charge_type)
예제 #5
0
if args.esp_file is not None:
    try:
        averaged_molecule = run_resp(args.respin_location,
                                     save_resp_to,
                                     resp_type='unrest',
                                     check_ivary=True,
                                     esp_fn=args.esp_file)
    except Exception as e:
        shutil.rmtree(save_resp_to)
        raise e
    if args.save_resp_to is None:
        shutil.rmtree(save_resp_to)
else:
    averaged_charges, ivary_list = equivalence(molecule,
                                               args.input_charge_type,
                                               args.respin_location,
                                               respin1_fn="",
                                               respin2_fn="")
    # Check equivalence information from respin:
    _check_ivary(True, molecule, ivary_list)
    # The new molecule and name 'resp' is for consistency with the
    # equivalencing code above
    averaged_molecule = copy.deepcopy(molecule)
    charges._update_molecule_with_charges(averaged_molecule, averaged_charges,
                                          "resp")

message = charges.compare_charges(args.input_charge_type,
                                  "resp",
                                  molecule,
                                  averaged_molecule,
                                  thresh=args.thresh)