From 194f58152bb9edad1fbadbded5a4dd6215b4c47a Mon Sep 17 00:00:00 2001 From: hjnpark Date: Wed, 19 Jun 2024 12:23:33 -0700 Subject: [PATCH 1/2] irc update --- geometric/optimize.py | 23 +++++++++++++++-------- geometric/qcf_neb.py | 2 +- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/geometric/optimize.py b/geometric/optimize.py index 45e74f92..99b074db 100644 --- a/geometric/optimize.py +++ b/geometric/optimize.py @@ -575,7 +575,7 @@ def IRC_step(self): logger.info('Half step dy = %.5f \n' % np.linalg.norm(p_prime)) logger.info('Half step mw-dx = %.5f Bohr*sqrt(amu)\n\n' % half_mwdx) logger.info('=> Total step dy = %.5f \n' % dy_norm) - logger.info('=> Total step mw-dx = %.5f Bohr*sqrt(amu)\n' % mwdx) + logger.info('=> Total step mw-dx = %.5f Bohr*sqrt(amu)\n\n\n' % mwdx) self.Iteration += 1 return dy @@ -744,7 +744,7 @@ def evaluate_IRC_step(self, params, step_state, criteria_met, IRC_converged): return True, step_state self.IC_check = False - if step_state in (StepState.Reject, StepState.Poor) and not self.IRC_info.get("opt"): + if step_state in (StepState.Reject, StepState.Poor): step_state = StepState.Reject if np.isclose(self.trust, params.tmin): logger.info("IRC stuck with the minimum step-size and bad quality step. Forcing it to take a step.\n") @@ -759,7 +759,7 @@ def evaluate_IRC_step(self, params, step_state, criteria_met, IRC_converged): self.IC_check = True if self.IRC_info["total_disp"] > 5*self.IRC_init_step: - if criteria_met : + if criteria_met: if self.IRC_info.get("direction") == 1: logger.info("\nIRC forward direction converged\n") logger.info("IRC backward direction starts here\n\n") @@ -778,11 +778,17 @@ def evaluate_IRC_step(self, params, step_state, criteria_met, IRC_converged): return False, step_state - def evaluate_OPT_step(self, params, step_state, criteria_met, Converged_molpro_gmax, Converged_molpro_dmax): + def evaluate_OPT_step(self, params, step_state, criteria_met, Converged_grms, Converged_drms, Converged_energy, + Converged_molpro_gmax, Converged_molpro_dmax): if criteria_met and self.conSatisfied: - self.SortedEigenvalues(self.H) - logger.info("Converged! =D\n") - self.state = OPT_STATE.CONVERGED + if params.irc and self.IRC_info.get("direction") == 1: + logger.info("\nIRC forward direction converged\n") + logger.info("IRC backward direction starts here\n\n") + self.reset_irc() + else: + self.SortedEigenvalues(self.H) + logger.info("Converged! =D\n") + self.state = OPT_STATE.CONVERGED return True, step_state if self.Iteration >= params.maxiter: @@ -881,7 +887,8 @@ def evaluateStep(self): if params.irc and not self.IRC_info.get("opt"): terminate, step_state = self.evaluate_IRC_step(params, step_state, criteria_met, IRC_converged) else: - terminate, step_state = self.evaluate_OPT_step(params, step_state, criteria_met, Converged_molpro_gmax, Converged_molpro_dmax) + terminate, step_state = self.evaluate_OPT_step(params, step_state, criteria_met, Converged_grms, + Converged_drms, Converged_energy, Converged_molpro_gmax, Converged_molpro_dmax) if terminate: return diff --git a/geometric/qcf_neb.py b/geometric/qcf_neb.py index 1852cada..2545367c 100644 --- a/geometric/qcf_neb.py +++ b/geometric/qcf_neb.py @@ -130,7 +130,7 @@ def get_basic_info(info_dict, previous=False): params_dict = {"images": args_dict.get("images"), "maxg": args_dict.get("maximum_force"), "avgg": args_dict.get("average_force"), "nebk": args_dict.get("spring_constant"), "neb_maxcyc": args_dict.get("maximum_cycle"), "plain": args_dict.get("spring_type"), - "skip": not args_dict.get("hessian_reset"), "epsilon": args_dict.get("epsilon")} + "epsilon": args_dict.get("epsilon")} iteration = args_dict.get("iteration") params = NEBParams(**params_dict) From d92ef1bfdeedf35e83710741de35987d84b2696a Mon Sep 17 00:00:00 2001 From: Heejune Park Date: Wed, 19 Jun 2024 15:30:38 -0700 Subject: [PATCH 2/2] verbose option is added for irc --- geometric/optimize.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/geometric/optimize.py b/geometric/optimize.py index 99b074db..323384e7 100644 --- a/geometric/optimize.py +++ b/geometric/optimize.py @@ -450,7 +450,9 @@ def guess_g(self, g, H, disp): def IRC_step(self): self.farConstraints = self.IC.haveConstraints() and self.IC.maxConstraintViolation(self.X) > 1e-1 - logger.info("IRC sub-step 1: Finding the pivot point (q*_{k+1})\n") + + if self.params.verbose: + logger.info("IRC sub-step 1: Finding the pivot point (q*_{k+1})\n") # Need to take a step towards the pivot point self.IC.clearCache() @@ -462,7 +464,7 @@ def IRC_step(self): # Vector to the pivot point if self.Iteration == 0: # If it's the very first step, pick the eigenvector of the imaginary frequency and pick the direction - logger.info('\nFirst, following the imaginary mode vector\n') + logger.info('First, following the imaginary mode vector\n') if self.TSWavenum[1] < 0: raise IRCError("There are more than one imaginary vibrational mode. Please optimize the structure and try again.\n") elif self.TSWavenum[0] > 0: @@ -504,11 +506,13 @@ def IRC_step(self): # Calculating sqrt(mass) weighted Cartesian coordinate MWGMat_sqrt_inv, MWGMat_sqrt = self.IC.GInverse_SVD(X_pivot, sqrt=True, invMW=True) mwdx_1 = np.dot(MWGMat_sqrt_inv, dy_to_pivot) - logger.info("Half step dy = %.5f\n" %np.linalg.norm(dy_to_pivot)) - logger.info("Half step mw-dx = %.5f Bohr*sqrt(amu)\n" %np.linalg.norm(mwdx_1)) + + if self.params.verbose: + logger.info("Half step dy = %.5f\n" %np.linalg.norm(dy_to_pivot)) + logger.info("Half step mw-dx = %.5f Bohr*sqrt(amu)\n" %np.linalg.norm(mwdx_1)) # We are at the pivot point - logger.info('\nIRC sub-step 2: Finding the next point (q_{k+1})\n') + logger.info('\nIRC sub-step 2: Finding the next point (q_{k+1})\n') v1 = v.copy() irc_sub_iteration = 0 irc_reset_iteration = 0 @@ -571,11 +575,12 @@ def IRC_step(self): irc_sub_iteration += 1 p_prime += dq_new - logger.info('Angle between v1 and v2: %2.f \n' % deg) - logger.info('Half step dy = %.5f \n' % np.linalg.norm(p_prime)) - logger.info('Half step mw-dx = %.5f Bohr*sqrt(amu)\n\n' % half_mwdx) + if self.params.verbose: + logger.info('Angle between v1 and v2: %2.f \n' % deg) + logger.info('Half step dy = %.5f \n' % np.linalg.norm(p_prime)) + logger.info('Half step mw-dx = %.5f Bohr*sqrt(amu)\n\n' % half_mwdx) logger.info('=> Total step dy = %.5f \n' % dy_norm) - logger.info('=> Total step mw-dx = %.5f Bohr*sqrt(amu)\n\n\n' % mwdx) + logger.info('=> Total step mw-dx = %.5f Bohr*sqrt(amu)\n\n' % mwdx) self.Iteration += 1 return dy