Example #1
0
# 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)

print("\nThe molecule with equivalenced {0} charges:".format(
    charge_type.upper()))
print("RRMS: {0:.5f}".format(equiv_charge_rrms))
for atom in g.molecule:
    atom.print_with_charge(charge_type + '_equiv')
Example #2
0
    color_span = []
    error_color_span = []
    for calc in calcs:
        g = resp_helpers.G09_esp(path + calc + '.esp')
        charges.update_with_charges(charge_type, path + calc + '.log',
                                    g.molecule)
        with open(path + calc + "-charges.txt", "a") as fc:
            for atom in g.molecule:
                atom.print_with_charge(charge_type, fc)
                if atom.label in charges_dict:
                    charges_dict[atom.label].append(atom.charges[charge_type])
                else:
                    charges_dict[atom.label] = [atom.charges[charge_type]]

            min_rms, min_rrms, rep_esp_field = rms_and_rep(g.field, g.molecule,
                                                           charge_type)
            rms_list.append(min_rms)
            print("\n", min_rms, file=fc)

        # Default given as extremal values of methane CHelpG
        color_span = check_color_span(g.field.values, color_span,
                                      default=[-0.0045, 0.011])
        diff_field = difference(g.field, rep_esp_field)
        error_color_span = check_color_span(diff_field.values,
                                            error_color_span,
                                            default=[-0.0012, 0.019])

        graphs.plot_points(
            g.field, 2, title=calc, molecule=g.molecule,
            plane_eqn=graphs.plane_through_atoms(g.molecule, 1, 2, 3),
            dist_thresh=0.5, axes_limits=[(-5, 5)]*2, color_span=color_span,
Example #3
0
import resp_parser

import os
import shutil

help_description = """Evaluate the fit quality of the given charges on the
    provided mesh of fitting points."""

parser = argparse.ArgumentParser(
    parents=[charges_parser.parser],
    formatter_class=argparse.ArgumentDefaultsHelpFormatter,
    description=help_description)

parser.add_argument("esp_filename",
                    help=resp_parser.esp_file_help,
                    metavar="ESP_FILE_NAME")

args = parser.parse_args()

esp_file = resp_helpers.G09_esp(args.esp_filename)
molecule = esp_file.molecule

input_type = charges_parser.input_type(args.input_charge_type)
charges._get_charges(args.input_charge_type, args.input_charge_file,
                     input_type, molecule)

rms, rrms = rms_and_rep(esp_file.field, molecule, args.input_charge_type)[:2]
print(" RMS: {0:.5f}".format(rms))
print("RRMS: {0:.5f}".format(rrms))
print("RMSV: {0:.5f}".format(rms / rrms))
Example #4
0
# 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)

print("\nThe molecule with equivalenced {0} charges:".format(
      charge_type.upper()))
print("RRMS: {0:.5f}".format(equiv_charge_rrms))
for atom in g.molecule:
    atom.print_with_charge(charge_type + '_equiv')
Example #5
0
    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)
    # Equivalence alternative charge as well (i.e. unrest RESP on its own grid)
    alt_esp_equiv_molecule = resp.run_resp(path,
                                           resp_output_path + 'alt_unrest',
                                           resp_type='unrest',
                                           esp_fn=alt_esp_fn,
                                           check_ivary=False)

    charges.update_with_charges(esp_charge_type, log_fn, g.molecule)
    # This should actually be called esp_charge_rms
    charge_rms, charge_rrms = rms_and_rep(g.field, g.molecule,
                                          esp_charge_type)[:2]
    resp_rms, resp_rrms = rms_and_rep(g.field, esp_equiv_molecule, 'resp')[:2]
    # Note that, crucially, the equivalenced alternative charges are evaluated
    # on the same grid as the original charges, i.e. `g.field`
    alt_resp_rms, alt_resp_rrms = rms_and_rep(g.field, alt_esp_equiv_molecule,
                                              'resp')[:2]

    print("\nThe molecule with {0} charges:".format(esp_charge_type.upper()))
    print(" RMS: {0:.5f}".format(charge_rms))
    print("RRMS: {0:.5f}".format(charge_rrms))
    print("RMSV: {0:.5f}".format(charge_rms / charge_rrms))
    for atom in g.molecule:
        atom.print_with_charge(esp_charge_type)

    print("\nThe molecule with equivalenced {0} charges (unrestrained RESP):".
          format(esp_charge_type.upper()))
Example #6
0
    color_span = []
    error_color_span = []
    for calc in calcs:
        g = resp_helpers.G09_esp(path + calc + '.esp')
        charges.update_with_charges(charge_type, path + calc + '.log',
                                    g.molecule)
        with open(path + calc + "-charges.txt", "a") as fc:
            for atom in g.molecule:
                atom.print_with_charge(charge_type, fc)
                if atom.label in charges_dict:
                    charges_dict[atom.label].append(atom.charges[charge_type])
                else:
                    charges_dict[atom.label] = [atom.charges[charge_type]]

            min_rms, min_rrms, rep_esp_field = rms_and_rep(g.field, g.molecule,
                                                           charge_type)
            rms_list.append(min_rms)
            print("\n", min_rms, file=fc)

        # Default given as extremal values of methane CHelpG
        color_span = check_color_span(g.field.values, color_span,
                                      default=[-0.0045, 0.011])
        diff_field = difference(g.field, rep_esp_field)
        error_color_span = check_color_span(diff_field.values,
                                            error_color_span,
                                            default=[-0.0012, 0.019])

        graphs.plot_points(
            g.field, 2, title=calc, molecule=g.molecule,
            plane_eqn=graphs.plane_through_atoms(g.molecule, 1, 2, 3),
            dist_thresh=0.5, axes_limits=[(-5, 5)]*2, color_span=color_span,
Example #7
0
import resp_parser

import os
import shutil

help_description = """Evaluate the fit quality of the given charges on the
    provided mesh of fitting points."""

parser = argparse.ArgumentParser(
    parents=[charges_parser.parser],
    formatter_class=argparse.ArgumentDefaultsHelpFormatter,
    description=help_description)

parser.add_argument("esp_filename",
                    help=resp_parser.esp_file_help,
                    metavar="ESP_FILE_NAME")

args = parser.parse_args()

esp_file = resp_helpers.G09_esp(args.esp_filename)
molecule = esp_file.molecule

input_type = charges_parser.input_type(args.input_charge_type)
charges._get_charges(args.input_charge_type, args.input_charge_file,
                     input_type, molecule)

rms, rrms = rms_and_rep(esp_file.field, molecule, args.input_charge_type)[:2]
print(" RMS: {0:.5f}".format(rms))
print("RRMS: {0:.5f}".format(rrms))
print("RMSV: {0:.5f}".format(rms/rrms))