Пример #1
0
    # long as the indicator charge is on a heavy atom. TODO
    result = resp.eval_ratios('regular',
                              ratio_limits,
                              start_charges,
                              num,
                              indicator_label,
                              regular_args,
                              first_verbose=True)[0]

# RATIO MINIMIZATION

print("\nMinimizing HEAVY ratio. This shouldn't take long.")
# Most arguments here are the same as in the loop with minor changes specific
# to an optimization run (output directory, verbosity)
heavy_args = (start_charges, g.field, path, min_resp_output_path, esp_fn, True)
heavy_min_ratio, heavy_min_ratio_rrms, heavy_charges = resp.minimize_ratio(
    'heavy', ratio_values, heavy_result, heavy_args)

if zero_net_charge:
    print("Minimizing REGULAR ratio. This shouldn't take long.")
    regular_args = (start_charges, g.molecule, g.field)
    reg_min_ratio, reg_min_ratio_rrms, reg_charges = resp.minimize_ratio(
        'regular', ratio_values, result, regular_args)

shutil.rmtree(min_resp_output_path)


def plot(result_list, heavy, min_ratio, min_ratio_rrms):
    fig, ax1 = plt.subplots()
    ax1.plot(ratio_values, result_list)
    ax2 = ax1.twiny()
    ax2.plot(indicator_charge, result_list)
Пример #2
0
    print("\nEvaluating REGULAR ratios. This may take a while.")
    regular_args = (g.molecule, g.field)
    # Note that indicator charge and ratio values are re-used from the heavy
    # version. This is fine for ratio_values. For indicator_charge it's fine as
    # long as the indicator charge is on a heavy atom. TODO
    result = resp.eval_ratios('regular', ratio_limits, start_charges, num,
                              indicator_label, regular_args,
                              first_verbose=True)[0]

# RATIO MINIMIZATION

print("\nMinimizing HEAVY ratio. This shouldn't take long.")
# Most arguments here are the same as in the loop with minor changes specific
# to an optimization run (output directory, verbosity)
heavy_args = (start_charges, g.field, path, min_resp_output_path, esp_fn, True)
heavy_min_ratio, heavy_min_ratio_rrms, heavy_charges = resp.minimize_ratio(
    'heavy', ratio_values, heavy_result, heavy_args)

if zero_net_charge:
    print("Minimizing REGULAR ratio. This shouldn't take long.")
    regular_args = (start_charges, g.molecule, g.field)
    reg_min_ratio, reg_min_ratio_rrms, reg_charges = resp.minimize_ratio(
        'regular', ratio_values, result, regular_args)

shutil.rmtree(min_resp_output_path)


def plot(result_list, heavy, min_ratio, min_ratio_rrms):
    fig, ax1 = plt.subplots()
    ax1.plot(ratio_values, result_list)
    ax2 = ax1.twiny()
    ax2.plot(indicator_charge, result_list)
Пример #3
0
        result, indicator_charge, ratio_values = eval_ratios(
            'heavy',
            args.limits,
            start_charges,
            args.sampling,
            args.indicator,
            func_args,
            first_verbose=True)
    except Exception as e:
        shutil.rmtree(save_resp_to)
        raise e

print("\nOptimizing fit quality...")
if args.scale_all:
    regular_args = (start_charges, molecule, esp_file.field)
    reg_min_ratio, reg_min_ratio_rrms, compr_charges = minimize_ratio(
        'regular', ratio_values, result, regular_args)
else:
    func_args = (start_charges, esp_file.field, args.respin_location,
                 min_resp_calc_dir, args.esp_filename, True)
    try:
        min_ratio, min_ratio_rrms, compr_charges = minimize_ratio(
            'heavy', ratio_values, result, func_args)
    except Exception as e:
        shutil.rmtree(save_resp_to)
        raise e
    shutil.rmtree(min_resp_calc_dir)

if not args.scale_all and args.save_resp_to is None:
    shutil.rmtree(save_resp_to)

# TODO: plotting requires information about other charges. This would make this
Пример #4
0
    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
    print("\nStarting minimization of charge ratio.")
    heavy_args = (equiv_start_charges, g.field, path, opt_output_path, esp_fn,
                  True)  # True for optimization
    heavy_min_ratio, heavy_min_ratio_rrms, compr_charges = resp.minimize_ratio(
        'heavy', ratio_values, heavy_result, heavy_args)
    shutil.rmtree(opt_output_path)

    # Presentation: 3D
    if False:
        fig = plt.figure()
        ax = fig.gca(projection='3d')
        surf = ax.plot_surface(read_result.inp1,
                               read_result.inp2,
                               read_result.rrms,
                               cmap=cm.plasma,
                               rstride=1,
                               cstride=1)
        fig.colorbar(surf, label="RRMS at fitting points")
        title = molecule_name + " " + esp_charge_type.upper()
        plot_common(vary_label1, vary_label2, molecule, title)
Пример #5
0
        regular_args, first_verbose=True)
else:
    func_args = (esp_file.field, args.respin_location, save_resp_to,
                 args.esp_filename, False)
    try:
        result, indicator_charge, ratio_values = eval_ratios(
            'heavy', args.limits, start_charges, args.sampling, args.indicator,
            func_args, first_verbose=True)
    except Exception as e:
        shutil.rmtree(save_resp_to)
        raise e

print("\nOptimizing fit quality...")
if args.scale_all:
    regular_args = (start_charges, molecule, esp_file.field)
    reg_min_ratio, reg_min_ratio_rrms, compr_charges = minimize_ratio(
        'regular', ratio_values, result, regular_args)
else:
    func_args = (start_charges, esp_file.field, args.respin_location,
                 min_resp_calc_dir, args.esp_filename, True)
    try:
        min_ratio, min_ratio_rrms, compr_charges = minimize_ratio(
            'heavy', ratio_values, result, func_args)
    except Exception as e:
        shutil.rmtree(save_resp_to)
        raise e
    shutil.rmtree(min_resp_calc_dir)

if not args.scale_all and args.save_resp_to is None:
    shutil.rmtree(save_resp_to)

# TODO: plotting requires information about other charges. This would make this