Ejemplo n.º 1
0
            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,
            save_to=path + calc[-6:] + '_V.pdf')

        graphs.plot_points(
            diff_field, 2, title=calc + " Errors", 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=error_color_span, save_to=path + calc[-6:] + '_E.pdf')
Ejemplo n.º 2
0
    update_with_charges(charge_type, filename, molecule)

    print("\n{0} charges:".format(charge_type.upper()))
    for atom in molecule:
        atom.print_with_charge(charge_type)
    # The same but to file (would be better with my Tee class from featsel)
    with open(charge_dir + '/charges.txt', 'w') as f:
        for atom in esp_cube.molecule:
            atom.print_with_charge(charge_type, f=f)

    # This is costly but was designed to be easy for many charge types, so
    # should be moved outside of the loop
    rep = calc_grid_field(esp_cube.molecule, esp_cube.field.grid, 'rep_esp',
                          [charge_type])[0]
    # Change details of calculating difference here (absolute, relative)
    diff = difference(esp_cube.field, rep)

    # Write cube
    diff.write_cube(charge_dir + '/diff.cub', molecule, charge_type)
    # and with elements within the ED isosurface excluded
    diff_filtered = copy.deepcopy(diff)
    diff_filtered.check_nans = False
    _dist, diff_filtered.values = filter_by_dist(exclusion_dist, dist, diff)
    diff_filtered.write_cube(charge_dir + '/diff_filtered-iso_' + str(isoval) +
                             '.cub', molecule, charge_type)

    rep_filtered = copy.deepcopy(rep)
    rep_filtered.check_nans = False
    _dist, rep_filtered.values = filter_by_dist(exclusion_dist, dist, rep)
    rms_val, rrms_val = rms_and_rrms(esp_cube.field, rep_filtered,
                                     ignore_nans=True)
Ejemplo n.º 3
0
            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,
            save_to=path + calc[-6:] + '_V.pdf')

        graphs.plot_points(
            diff_field, 2, title=calc + " Errors", 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=error_color_span, save_to=path + calc[-6:] + '_E.pdf')
Ejemplo n.º 4
0
charges = [atom.charges['nbo_equiv'] for atom in pickled_mol]
_update_molecule_with_charges(molecule, charges, 'nbo_equiv')

all_charges = [
    'chelpg_equiv', 'mk_equiv', 'nbo_equiv', 'compr_chelpg', 'compr_mk'
]

for charge_type in all_charges:

    print('\n', charge_type.upper())
    for atom in molecule:
        atom.print_with_charge(charge_type)
    sys.stdout.flush()

    rep = calc_grid_field(molecule, esp_cube.field.grid, 'rep_esp',
                          [charge_type])[0]
    # Change details of calculating difference here (absolute, relative)
    diff = difference(esp_cube.field, rep)

    # Write cube
    diff.write_cube(output_path + charge_type + '_diff.cub', molecule,
                    charge_type)
    # and with elements within the ED isosurface excluded
    diff_filtered = copy.deepcopy(diff)
    diff_filtered.check_nans = False
    _dist, diff_filtered.values = filter_by_dist(exclusion_dist, dist, diff)
    diff_filtered.write_cube(
        output_path + charge_type + '_diff_filtered-iso_' + str(isoval) +
        '.cub', molecule, charge_type)
Ejemplo n.º 5
0
        ed_cube, isoval, excl_dist = args.exclude
        ed_cube = Cube(ed_cube)
        isoval = float(isoval)
        excl_dist = float(excl_dist)
elif filetype == '.esp':
    esp_file1 = resp_helpers.G09_esp(args.field1)
    esp_file2 = resp_helpers.G09_esp(args.field2)
    # TODO: Molecules not cross-checked. They should be because .esp files in
    # Antechamber format produced by repESP will have no identitity info. This
    # is fine for now for the difference (actual - reproduced), because actual
    # will be Gaussian .esp but not the other way round.
    molecule = esp_file1.molecule
    field1 = esp_file1.field
    field2 = esp_file2.field

diff = difference(field1, field2, relative=args.relative,
                  absolute=args.absolute)

if filetype == '.cub':
    if args.exclude:
        diff.check_nans = False
        dist = ed_cube.field.distance_transform(isoval)
        assign_val = 0 if args.exclusion_as_zero else None
        _dist, diff.values = filter_by_dist(excl_dist, dist, diff,
                                            assign_val=assign_val)

    diff.write_cube(args.output + '.cub', molecule)

elif filetype == '.esp':
    diff.write_to_file(args.output + '.esp', molecule)