dist = ed_cube.field.distance_transform(isoval) exclusion_dist = 0 rand_skim = 1 axes_limits = [[0, 4]] charge_types = {'aim': '.sumviz', # 'aim': 'ACF.dat', 'mulliken': '.log', 'chelpg': '_chelpg.log', 'mk': '_mk.log', 'nbo': '_nbo.log', } # Use the same color span in all plots (true ESP doesn't depend on charges so # common to all charge_types and can be outside of loop): _dist, esp_values = filter_by_dist(exclusion_dist, dist, esp_cube.field) color_span = [np.nanmin(esp_values), np.nanmax(esp_values)] # A symmetric span can also be used: # color_limit = max(abs(np.nanmin(esp_values)), abs(np.nanmax(esp_values))) # color_span = [-color_limit, color_limit] # Note that the y-axis is not set for different charge_types! If this is # desired behaviour, it could be set in a similar manner here. for charge_type in charge_types.keys(): charge_dir = output_path + charge_type # raises OSError if directory exists os.mkdir(charge_dir) if charge_types[charge_type][0] in ['.', '_']: filename = path + molecule_name + charge_types[charge_type] else:
exclusion_dist = 0 rand_skim = 1 axes_limits = [[0, 4]] charge_types = { 'aim': '.sumviz', # 'aim': 'ACF.dat', 'mulliken': '.log', 'chelpg': '_chelpg.log', 'mk': '_mk.log', 'nbo': '_nbo.log', } # Use the same color span in all plots (true ESP doesn't depend on charges so # common to all charge_types and can be outside of loop): _dist, esp_values = filter_by_dist(exclusion_dist, dist, esp_cube.field) color_span = [np.nanmin(esp_values), np.nanmax(esp_values)] # A symmetric span can also be used: # color_limit = max(abs(np.nanmin(esp_values)), abs(np.nanmax(esp_values))) # color_span = [-color_limit, color_limit] # Note that the y-axis is not set for different charge_types! If this is # desired behaviour, it could be set in a similar manner here. for charge_type in charge_types.keys(): charge_dir = output_path + charge_type # raises OSError if directory exists os.mkdir(charge_dir) if charge_types[charge_type][0] in ['.', '_']: filename = path + molecule_name + charge_types[charge_type] else:
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)
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)