def find_minimum_production(self, coords, opt_param_dict): """ Find the minimum corresponding to the coords. Parameters ---------- coords : np.ndarray Coordinates for which we want to find the corrsponding minima """ nls = Main.NewtonLinesearch(self.interfaced_potential, coords, opt_param_dict["tol"]) mxd = Main.Mixed_Descent( self.interfaced_potential, Main.CVODE_BDF(), nls, coords, opt_param_dict["T"], opt_param_dict["rtol"], opt_param_dict["conv_tol"], opt_param_dict["tol"], ) try: mxd.run_b(mxd, opt_param_dict["n_steps"]) except: return None return ( mxd.optimizer.x0, mxd.converged, mxd.n_g_evals, mxd.iter_number, mxd.n_h_evals, )
def quench_single_mxopt_inverse_power_julia(coord_file_name, foldpath, sub_fold_name, optimizer, opt_param_dict): """ quenches a single system through mxopt Parameters ---------- coord_file_name: string name of the path to the coordinates foldername: str folder definining the run sub_fold_name: name of subfolder where the run data is stored optimizer: optimizer quench opt_param_dict: dict dictionary of parameters for the optimizer """ sysparams = load_params(foldpath) # path to quench coords quench_coords_path = (foldpath + "/" + sub_fold_name + "/" + "ensemble/" + coord_file_name) quench_coords = np.loadtxt(quench_coords_path) radii = get_hs_radii(foldpath, sub_fold_name) box_length = get_box_length(radii, sysparams.ndim.value, sysparams.phi.value) boxv = np.array([box_length] * sysparams.ndim.value) ncellx_scale = get_ncellsx_scale(radii, boxv) # potential = InversePower(sysparams.power.value, # sysparams.eps.value, # use_cell_lists=False, # ndim=sysparams.ndim.value, # radii=radii * 1.0, # boxvec=boxv) pot = Main.pot.InversePower( sysparams.power.value, sysparams.eps.value, radii, ndim=sysparams.ndim.value, boxvec=boxv, use_cell_lists=False, ncellx_scale=ncellx_scale, ) ppot = Main.PythonPotential(pot) nls = Main.NewtonLinesearch(ppot, quench_coords, opt_param_dict["tol"]) mxd = Main.Mixed_Descent( ppot, Main.CVODE_BDF(), nls, quench_coords, opt_param_dict["T"], opt_param_dict["rtol"], opt_param_dict["conv_tol"], opt_param_dict["tol"], ) # Main.run_b(mxd, 10000) try: Main.run_b(mxd, 10000) except: print("exception occured") # if exception occurs, treat as failure. this is for rattlers # not enough failures occur that it would make a difference to not just assume this never happens # but we shoudl switch this out # but jic return (quench_coords, False, 0, 0, 0, 0, 0) results = ( mxd.optimizer.x0, mxd.converged, mxd.n_g_evals, mxd.iter_number, mxd.n_h_evals, 0, 0, ) print(quench_coords_path) return results
def map_binary_inversepower_mxopt_jl( foldername, particle_coords, optimizer, opt_param_dict, random_coord_0=0, random_coord_1=-1, z=0, ): """ Finds whether a point defined by particle_coord on the meshgrid correspond to a minimum or not for a 2d case. """ foldpath = BASE_DIRECTORY + "/" + foldername # import params sysparams = load_params(foldpath) (hs_radii, initial_coords, box_length) = load_secondary_params(foldpath) assert sysparams.ndim.value == 2 minimum_coords = np.loadtxt(foldpath + "/coords_of_minimum.txt", delimiter=",") minimum_coords = np.loadtxt(foldpath + "/coords_of_minimum.txt", delimiter=",") quench_coords = initial_coords.copy() quench_coords = (quench_coords + particle_coords[0] * VEC_16_0 + particle_coords[1] * VEC_16_1 + z * VEC_16_2) # quench_coords = quench_coords + \ # particle_coords[0]*VEC_8_0 + particle_coords[1]*VEC_8_1 + z*VEC_8_2 # print(quench_coords, 'quench coords') # box length box_length = float(box_length) boxv = [box_length] * sysparams.ndim.value ncellx_scale = get_ncellsx_scale(hs_radii, boxv) print(hs_radii, "hs_radii") print(quench_coords, "quench_coords") print(boxv) potential = Main.pot.InversePower( sysparams.power.value, sysparams.eps.value, use_cell_lists=False, ndim=sysparams.ndim.value, radii=hs_radii * 1.0, boxvec=boxv, ) ppot = Main.PythonPotential(potential) nls = Main.NewtonLinesearch(ppot, quench_coords, opt_param_dict["tol"]) mxd = Main.Mixed_Descent( ppot, Main.CVODE_BDF(), nls, quench_coords, opt_param_dict["T"], opt_param_dict["rtol"], opt_param_dict["conv_tol"], opt_param_dict["tol"], ) try: Main.run_b(mxd, 10000) except: print(quench_coords, "failed here") print(initial_coords, "coords") print(len(quench_coords)) # ret = lbfgs_cpp(quench_coords, potential, tol=1e-8, M=1) # This exists because some runs don't have hessian evaluations coordarg = 0 print(mxd.converged, "converged") results = ( mxd.optimizer.x0, mxd.converged, 0, mxd.n_g_evals, mxd.iter_number, mxd.n_h_evals, ) # the reason the potential is being passed is because quench coords needs the potential to figure out what to do return results
2.5, 1.0, radii_arr, ndim=2, boxvec=boxvec, use_cell_lists=False, ncellx_scale=cell_scale, ) pele_wrapped_python_pot = Main.PythonPotential(pele_wrapped_pot) mxd = Main.Mixed_Descent( pele_wrapped_python_pot, Main.solver, Main.nls, coords, 30, 10 ** (-5), 10 ^ (-8), 10 ** (-3), ) Main.run_b(mxd, 2000) print(mxd.integrator.u - coords) print(pele_wrapped_python_pot) print(th) print("yay") # nls = NewtonLinesearch( # lsolve_lsmr!, # p_energy, # p_gradient,