def map_pointset_loop_xy(
    foldname,
    pointset,
    optimizer,
    parameter_dict,
    ctol=1e-2,
    ndim=2,
    use_minima_database=True,
    minima_database_path=None,
    coord_arg_0=0,
    coord_arg_1=1,
    z=0,
):
    """ Checks a bunch of points if they match to a minimum by using a for loop
    """
    is_same_minimum_list = []
    resultlist = []
    foldpath = BASE_DIRECTORY + "/" + foldname

    sysparams = load_params(foldpath)
    (hs_radii, initial_coords, box_length) = load_secondary_params(foldpath)
    minimum_coords = np.loadtxt(foldpath + "/coords_of_minimum.txt", delimiter=",")

    # Initialize CheckSameMinimum
    potential = InversePower(
        sysparams.power.value,
        sysparams.eps.value,
        use_cell_lists=False,
        ndim=sysparams.ndim.value,
        radii=hs_radii * 1.0,
        boxvec=[box_length, box_length],
    )
    minima_container = CheckSameMinimum(
        ctol,
        ndim,
        boxl=box_length,
        minimalist_max_len=200000,
        minima_database_location=minima_database_path,
        update_database=True,
        rattler_check=True,
        potential=potential,
        hs_radii=hs_radii,
    )

    if use_minima_database == True:
        try:
            minima_container.minimalist = [
                minima_container.box_reshape_coords(x)
                for x in np.load(minima_database_path)
            ]
        except:
            print("warning no minima data found. generating")
            minima_container.minimalist = [
                # minima_container.box_reshape_coords(minimum_coords)
            ]
    nfevlist = []
    nstepslist = []
    nhevlist = []
    for index, point in enumerate(pointset):
        res = map_binary_inversepower(
            foldname,
            point,
            optimizer,
            parameter_dict,
            random_coord_0=coord_arg_0,
            random_coord_1=coord_arg_1,
            z=z,
        )
        minima_container.add_minimum(res[0], point, res[2])
        # print(index)
        # print(minima_container.nrattlermin, 'nrattlermin')
        # print(minima_container.nfluidstates, 'nfluidstates')
        nfevlist.append(res[3])
        nstepslist.append(res[4])
        nhevlist.append(res[5])

    # print(np.average(nfevlist), 'number of function evaluations')
    # print(np.average(nstepslist), 'number of steps')
    # print(np.average(nstepslist), 'number of steps')
    # print(np.average(nhevlist), "number of hessian evaluations")

    # print(minima_container.orderparamlist)

    foldpathdata = foldpath + "/" + QUENCH_FOLDER_NAME + "/z_data_30_l6/" + str(z)
    os.makedirs(foldpathdata, exist_ok=True)
    minima_container.dump_map(foldpathdata)

    run_diagnostics = {}
    run_diagnostics["nfev"] = float(np.average(nfevlist))
    run_diagnostics["nhev"] = float(np.average(nhevlist))
    run_diagnostics["nsteps"] = float(np.average(nstepslist))

    # print(minima_container.initial_coords_list)
    # print(minima_container.orderparamlist)
    # print(minima_container.orderparamlist)
    return run_diagnostics, is_same_minimum_list, resultlist
Exemple #2
0
def compare_runs_2d(fnames, foldpath, subfoldname, run_a, run_b, ctol):
    """ compares runs on points with names fnames between
        runs done with 2 minima find routines run_a and run_b

    Args:
       fnames filenames
       run_a run a 
       run_b run b

    Returns:
        percentage of minima that are the same

    """
    # TODO: replace this
    sysparams = load_params(foldpath)
    radii = get_hs_radii(foldpath, subfoldname)
    box_length = get_box_length(radii, sysparams.ndim.value,
                                sysparams.phi.value)

    subfoldpath = foldpath + "/" + subfoldname
    data_path_a = subfoldpath + "/" + run_a
    data_path_b = subfoldpath + "/" + run_b
    potential = InversePower(
        sysparams.power.value,
        sysparams.eps.value,
        use_cell_lists=False,
        ndim=sysparams.ndim.value,
        radii=radii * 1.0,
        boxvec=[box_length, box_length],
    )
    minima_checker = CheckSameMinimum(ctol,
                                      dim=2,
                                      boxl=box_length,
                                      hs_radii=radii,
                                      potential=potential)

    same_minimum_check_l = []
    for fname in fnames:
        print(fname)
        minimum_a = np.loadtxt(data_path_a + "/" + fname, delimiter=",")
        minimum_b = np.loadtxt(data_path_b + "/" + fname, delimiter=",")
        boxed_minimum_a = minima_checker.box_reshape_coords(minimum_a)
        boxed_minimum_b = minima_checker.box_reshape_coords(minimum_b)
        # get first index that is not a rattler
        rattlers_exist, rattlers = minima_checker._find_rattlers(minimum_a)
        print(rattlers)
        # number of non rattlers to ensure we're not in a fluid state
        n_non_rattlers = np.count_nonzero(rattlers)
        # only do calculations if all particles aren't rattlers
        if n_non_rattlers != 0:
            first_non_rattler = (np.argwhere(rattlers != 0).T)[0, 0]
            # TODO: rewrite the CheckSameMinimum function
            # load and make sure the particle being aligned is not a rattler later
            # we're choosing -1 because that's always going to be of radius 1.4
            #  particle
            aligned_minimum_b = minima_checker.align_structures(
                boxed_minimum_a, boxed_minimum_b, part_ind=first_non_rattler)
            same_minimum_check = minima_checker.check_same_structure(
                aligned_minimum_b, boxed_minimum_a, rattlers)
            same_minimum_check_l.append(same_minimum_check)

    fraction_same_minimum = np.mean(same_minimum_check_l)
    print(fraction_same_minimum)
    return fraction_same_minimum
Exemple #3
0
minima_container = CheckSameMinimum(
    ctol,
    ndim,
    boxl=box_length,
    minimalist_max_len=2000,
    minima_database_location=minima_database_path,
    update_database=True,
    rattler_check=True,
    potential=potential,
    hs_radii=hs_radii,
)
print(box_length, "box_length")

box_length = float(box_length)
minimum_coords = np.loadtxt(foldpath + "/coords_of_minimum.txt", delimiter=",")
m1 = minima_container.box_reshape_coords(th[m1_arg])
m2 = minima_container.box_reshape_coords(th[m2_arg])
m3 = minima_container.box_reshape_coords(th[m3_arg])
m4 = minima_container.box_reshape_coords(th[m4_arg])
print(minima_container.boxl)

# print(th)
# print(m1)
# print(m2)
# print(m3)
# print(m4)
print(m3)
print(m4)
dv = m3 - m4
print(dv)
print(np.where(dv > box_length / 2, box_length - dv, dv))