MultiOptPy 1.20.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- multioptpy/Calculator/__init__.py +0 -0
- multioptpy/Calculator/ase_calculation_tools.py +424 -0
- multioptpy/Calculator/ase_tools/__init__.py +0 -0
- multioptpy/Calculator/ase_tools/fairchem.py +28 -0
- multioptpy/Calculator/ase_tools/gamess.py +19 -0
- multioptpy/Calculator/ase_tools/gaussian.py +165 -0
- multioptpy/Calculator/ase_tools/mace.py +28 -0
- multioptpy/Calculator/ase_tools/mopac.py +19 -0
- multioptpy/Calculator/ase_tools/nwchem.py +31 -0
- multioptpy/Calculator/ase_tools/orca.py +22 -0
- multioptpy/Calculator/ase_tools/pygfn0.py +37 -0
- multioptpy/Calculator/dxtb_calculation_tools.py +344 -0
- multioptpy/Calculator/emt_calculation_tools.py +458 -0
- multioptpy/Calculator/gpaw_calculation_tools.py +183 -0
- multioptpy/Calculator/lj_calculation_tools.py +314 -0
- multioptpy/Calculator/psi4_calculation_tools.py +334 -0
- multioptpy/Calculator/pwscf_calculation_tools.py +189 -0
- multioptpy/Calculator/pyscf_calculation_tools.py +327 -0
- multioptpy/Calculator/sqm1_calculation_tools.py +611 -0
- multioptpy/Calculator/sqm2_calculation_tools.py +376 -0
- multioptpy/Calculator/tblite_calculation_tools.py +352 -0
- multioptpy/Calculator/tersoff_calculation_tools.py +818 -0
- multioptpy/Constraint/__init__.py +0 -0
- multioptpy/Constraint/constraint_condition.py +834 -0
- multioptpy/Coordinate/__init__.py +0 -0
- multioptpy/Coordinate/polar_coordinate.py +199 -0
- multioptpy/Coordinate/redundant_coordinate.py +638 -0
- multioptpy/IRC/__init__.py +0 -0
- multioptpy/IRC/converge_criteria.py +28 -0
- multioptpy/IRC/dvv.py +544 -0
- multioptpy/IRC/euler.py +439 -0
- multioptpy/IRC/hpc.py +564 -0
- multioptpy/IRC/lqa.py +540 -0
- multioptpy/IRC/modekill.py +662 -0
- multioptpy/IRC/rk4.py +579 -0
- multioptpy/Interpolation/__init__.py +0 -0
- multioptpy/Interpolation/adaptive_interpolation.py +283 -0
- multioptpy/Interpolation/binomial_interpolation.py +179 -0
- multioptpy/Interpolation/geodesic_interpolation.py +785 -0
- multioptpy/Interpolation/interpolation.py +156 -0
- multioptpy/Interpolation/linear_interpolation.py +473 -0
- multioptpy/Interpolation/savitzky_golay_interpolation.py +252 -0
- multioptpy/Interpolation/spline_interpolation.py +353 -0
- multioptpy/MD/__init__.py +0 -0
- multioptpy/MD/thermostat.py +185 -0
- multioptpy/MEP/__init__.py +0 -0
- multioptpy/MEP/pathopt_bneb_force.py +443 -0
- multioptpy/MEP/pathopt_dmf_force.py +448 -0
- multioptpy/MEP/pathopt_dneb_force.py +130 -0
- multioptpy/MEP/pathopt_ewbneb_force.py +207 -0
- multioptpy/MEP/pathopt_gpneb_force.py +512 -0
- multioptpy/MEP/pathopt_lup_force.py +113 -0
- multioptpy/MEP/pathopt_neb_force.py +225 -0
- multioptpy/MEP/pathopt_nesb_force.py +205 -0
- multioptpy/MEP/pathopt_om_force.py +153 -0
- multioptpy/MEP/pathopt_qsm_force.py +174 -0
- multioptpy/MEP/pathopt_qsmv2_force.py +304 -0
- multioptpy/ModelFunction/__init__.py +7 -0
- multioptpy/ModelFunction/avoiding_model_function.py +29 -0
- multioptpy/ModelFunction/binary_image_ts_search_model_function.py +47 -0
- multioptpy/ModelFunction/conical_model_function.py +26 -0
- multioptpy/ModelFunction/opt_meci.py +50 -0
- multioptpy/ModelFunction/opt_mesx.py +47 -0
- multioptpy/ModelFunction/opt_mesx_2.py +49 -0
- multioptpy/ModelFunction/seam_model_function.py +27 -0
- multioptpy/ModelHessian/__init__.py +0 -0
- multioptpy/ModelHessian/approx_hessian.py +147 -0
- multioptpy/ModelHessian/calc_params.py +227 -0
- multioptpy/ModelHessian/fischer.py +236 -0
- multioptpy/ModelHessian/fischerd3.py +360 -0
- multioptpy/ModelHessian/fischerd4.py +398 -0
- multioptpy/ModelHessian/gfn0xtb.py +633 -0
- multioptpy/ModelHessian/gfnff.py +709 -0
- multioptpy/ModelHessian/lindh.py +165 -0
- multioptpy/ModelHessian/lindh2007d2.py +707 -0
- multioptpy/ModelHessian/lindh2007d3.py +822 -0
- multioptpy/ModelHessian/lindh2007d4.py +1030 -0
- multioptpy/ModelHessian/morse.py +106 -0
- multioptpy/ModelHessian/schlegel.py +144 -0
- multioptpy/ModelHessian/schlegeld3.py +322 -0
- multioptpy/ModelHessian/schlegeld4.py +559 -0
- multioptpy/ModelHessian/shortrange.py +346 -0
- multioptpy/ModelHessian/swartd2.py +496 -0
- multioptpy/ModelHessian/swartd3.py +706 -0
- multioptpy/ModelHessian/swartd4.py +918 -0
- multioptpy/ModelHessian/tshess.py +40 -0
- multioptpy/Optimizer/QHAdam.py +61 -0
- multioptpy/Optimizer/__init__.py +0 -0
- multioptpy/Optimizer/abc_fire.py +83 -0
- multioptpy/Optimizer/adabelief.py +58 -0
- multioptpy/Optimizer/adabound.py +68 -0
- multioptpy/Optimizer/adadelta.py +65 -0
- multioptpy/Optimizer/adaderivative.py +56 -0
- multioptpy/Optimizer/adadiff.py +68 -0
- multioptpy/Optimizer/adafactor.py +70 -0
- multioptpy/Optimizer/adam.py +65 -0
- multioptpy/Optimizer/adamax.py +62 -0
- multioptpy/Optimizer/adamod.py +83 -0
- multioptpy/Optimizer/adamw.py +65 -0
- multioptpy/Optimizer/adiis.py +523 -0
- multioptpy/Optimizer/afire_neb.py +282 -0
- multioptpy/Optimizer/block_hessian_update.py +709 -0
- multioptpy/Optimizer/c2diis.py +491 -0
- multioptpy/Optimizer/component_wise_scaling.py +405 -0
- multioptpy/Optimizer/conjugate_gradient.py +82 -0
- multioptpy/Optimizer/conjugate_gradient_neb.py +345 -0
- multioptpy/Optimizer/coordinate_locking.py +405 -0
- multioptpy/Optimizer/dic_rsirfo.py +1015 -0
- multioptpy/Optimizer/ediis.py +417 -0
- multioptpy/Optimizer/eve.py +76 -0
- multioptpy/Optimizer/fastadabelief.py +61 -0
- multioptpy/Optimizer/fire.py +77 -0
- multioptpy/Optimizer/fire2.py +249 -0
- multioptpy/Optimizer/fire_neb.py +92 -0
- multioptpy/Optimizer/gan_step.py +486 -0
- multioptpy/Optimizer/gdiis.py +609 -0
- multioptpy/Optimizer/gediis.py +203 -0
- multioptpy/Optimizer/geodesic_step.py +433 -0
- multioptpy/Optimizer/gpmin.py +633 -0
- multioptpy/Optimizer/gpr_step.py +364 -0
- multioptpy/Optimizer/gradientdescent.py +78 -0
- multioptpy/Optimizer/gradientdescent_neb.py +52 -0
- multioptpy/Optimizer/hessian_update.py +433 -0
- multioptpy/Optimizer/hybrid_rfo.py +998 -0
- multioptpy/Optimizer/kdiis.py +625 -0
- multioptpy/Optimizer/lars.py +21 -0
- multioptpy/Optimizer/lbfgs.py +253 -0
- multioptpy/Optimizer/lbfgs_neb.py +355 -0
- multioptpy/Optimizer/linesearch.py +236 -0
- multioptpy/Optimizer/lookahead.py +40 -0
- multioptpy/Optimizer/nadam.py +64 -0
- multioptpy/Optimizer/newton.py +200 -0
- multioptpy/Optimizer/prodigy.py +70 -0
- multioptpy/Optimizer/purtubation.py +16 -0
- multioptpy/Optimizer/quickmin_neb.py +245 -0
- multioptpy/Optimizer/radam.py +75 -0
- multioptpy/Optimizer/rfo_neb.py +302 -0
- multioptpy/Optimizer/ric_rfo.py +842 -0
- multioptpy/Optimizer/rl_step.py +627 -0
- multioptpy/Optimizer/rmspropgrave.py +65 -0
- multioptpy/Optimizer/rsirfo.py +1647 -0
- multioptpy/Optimizer/rsprfo.py +1056 -0
- multioptpy/Optimizer/sadam.py +60 -0
- multioptpy/Optimizer/samsgrad.py +63 -0
- multioptpy/Optimizer/tr_lbfgs.py +678 -0
- multioptpy/Optimizer/trim.py +273 -0
- multioptpy/Optimizer/trust_radius.py +207 -0
- multioptpy/Optimizer/trust_radius_neb.py +121 -0
- multioptpy/Optimizer/yogi.py +60 -0
- multioptpy/OtherMethod/__init__.py +0 -0
- multioptpy/OtherMethod/addf.py +1150 -0
- multioptpy/OtherMethod/dimer.py +895 -0
- multioptpy/OtherMethod/elastic_image_pair.py +629 -0
- multioptpy/OtherMethod/modelfunction.py +456 -0
- multioptpy/OtherMethod/newton_traj.py +454 -0
- multioptpy/OtherMethod/twopshs.py +1095 -0
- multioptpy/PESAnalyzer/__init__.py +0 -0
- multioptpy/PESAnalyzer/calc_irc_curvature.py +125 -0
- multioptpy/PESAnalyzer/cmds_analysis.py +152 -0
- multioptpy/PESAnalyzer/koopman_analysis.py +268 -0
- multioptpy/PESAnalyzer/pca_analysis.py +314 -0
- multioptpy/Parameters/__init__.py +0 -0
- multioptpy/Parameters/atomic_mass.py +20 -0
- multioptpy/Parameters/atomic_number.py +22 -0
- multioptpy/Parameters/covalent_radii.py +44 -0
- multioptpy/Parameters/d2.py +61 -0
- multioptpy/Parameters/d3.py +63 -0
- multioptpy/Parameters/d4.py +103 -0
- multioptpy/Parameters/dreiding.py +34 -0
- multioptpy/Parameters/gfn0xtb_param.py +137 -0
- multioptpy/Parameters/gfnff_param.py +315 -0
- multioptpy/Parameters/gnb.py +104 -0
- multioptpy/Parameters/parameter.py +22 -0
- multioptpy/Parameters/uff.py +72 -0
- multioptpy/Parameters/unit_values.py +20 -0
- multioptpy/Potential/AFIR_potential.py +55 -0
- multioptpy/Potential/LJ_repulsive_potential.py +345 -0
- multioptpy/Potential/__init__.py +0 -0
- multioptpy/Potential/anharmonic_keep_potential.py +28 -0
- multioptpy/Potential/asym_elllipsoidal_potential.py +718 -0
- multioptpy/Potential/electrostatic_potential.py +69 -0
- multioptpy/Potential/flux_potential.py +30 -0
- multioptpy/Potential/gaussian_potential.py +101 -0
- multioptpy/Potential/idpp.py +516 -0
- multioptpy/Potential/keep_angle_potential.py +146 -0
- multioptpy/Potential/keep_dihedral_angle_potential.py +105 -0
- multioptpy/Potential/keep_outofplain_angle_potential.py +70 -0
- multioptpy/Potential/keep_potential.py +99 -0
- multioptpy/Potential/mechano_force_potential.py +74 -0
- multioptpy/Potential/nanoreactor_potential.py +52 -0
- multioptpy/Potential/potential.py +896 -0
- multioptpy/Potential/spacer_model_potential.py +221 -0
- multioptpy/Potential/switching_potential.py +258 -0
- multioptpy/Potential/universal_potential.py +34 -0
- multioptpy/Potential/value_range_potential.py +36 -0
- multioptpy/Potential/void_point_potential.py +25 -0
- multioptpy/SQM/__init__.py +0 -0
- multioptpy/SQM/sqm1/__init__.py +0 -0
- multioptpy/SQM/sqm1/sqm1_core.py +1792 -0
- multioptpy/SQM/sqm2/__init__.py +0 -0
- multioptpy/SQM/sqm2/calc_tools.py +95 -0
- multioptpy/SQM/sqm2/sqm2_basis.py +850 -0
- multioptpy/SQM/sqm2/sqm2_bond.py +119 -0
- multioptpy/SQM/sqm2/sqm2_core.py +303 -0
- multioptpy/SQM/sqm2/sqm2_data.py +1229 -0
- multioptpy/SQM/sqm2/sqm2_disp.py +65 -0
- multioptpy/SQM/sqm2/sqm2_eeq.py +243 -0
- multioptpy/SQM/sqm2/sqm2_overlapint.py +704 -0
- multioptpy/SQM/sqm2/sqm2_qm.py +578 -0
- multioptpy/SQM/sqm2/sqm2_rep.py +66 -0
- multioptpy/SQM/sqm2/sqm2_srb.py +70 -0
- multioptpy/Thermo/__init__.py +0 -0
- multioptpy/Thermo/normal_mode_analyzer.py +865 -0
- multioptpy/Utils/__init__.py +0 -0
- multioptpy/Utils/bond_connectivity.py +264 -0
- multioptpy/Utils/calc_tools.py +884 -0
- multioptpy/Utils/oniom.py +96 -0
- multioptpy/Utils/pbc.py +48 -0
- multioptpy/Utils/riemann_curvature.py +208 -0
- multioptpy/Utils/symmetry_analyzer.py +482 -0
- multioptpy/Visualization/__init__.py +0 -0
- multioptpy/Visualization/visualization.py +156 -0
- multioptpy/WFAnalyzer/MO_analysis.py +104 -0
- multioptpy/WFAnalyzer/__init__.py +0 -0
- multioptpy/Wrapper/__init__.py +0 -0
- multioptpy/Wrapper/autots.py +1239 -0
- multioptpy/Wrapper/ieip_wrapper.py +93 -0
- multioptpy/Wrapper/md_wrapper.py +92 -0
- multioptpy/Wrapper/neb_wrapper.py +94 -0
- multioptpy/Wrapper/optimize_wrapper.py +76 -0
- multioptpy/__init__.py +5 -0
- multioptpy/entrypoints.py +916 -0
- multioptpy/fileio.py +660 -0
- multioptpy/ieip.py +340 -0
- multioptpy/interface.py +1086 -0
- multioptpy/irc.py +529 -0
- multioptpy/moleculardynamics.py +432 -0
- multioptpy/neb.py +1267 -0
- multioptpy/optimization.py +1553 -0
- multioptpy/optimizer.py +709 -0
- multioptpy-1.20.2.dist-info/METADATA +438 -0
- multioptpy-1.20.2.dist-info/RECORD +246 -0
- multioptpy-1.20.2.dist-info/WHEEL +5 -0
- multioptpy-1.20.2.dist-info/entry_points.txt +9 -0
- multioptpy-1.20.2.dist-info/licenses/LICENSE +674 -0
- multioptpy-1.20.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from scipy.signal import argrelextrema
|
|
3
|
+
|
|
4
|
+
def extremum_list_index(energy_list):
|
|
5
|
+
local_max_energy_list_index = argrelextrema(energy_list, np.greater)
|
|
6
|
+
inverse_energy_list = (-1)*energy_list
|
|
7
|
+
local_min_energy_list_index = argrelextrema(inverse_energy_list, np.greater)
|
|
8
|
+
|
|
9
|
+
local_max_energy_list_index = local_max_energy_list_index[0].tolist()
|
|
10
|
+
local_min_energy_list_index = local_min_energy_list_index[0].tolist()
|
|
11
|
+
local_max_energy_list_index.append(0)
|
|
12
|
+
local_min_energy_list_index.append(0)
|
|
13
|
+
local_max_energy_list_index.append(0)
|
|
14
|
+
local_min_energy_list_index.append(0)
|
|
15
|
+
return local_max_energy_list_index, local_min_energy_list_index
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class CaluculationNEB2:
|
|
19
|
+
def __init__(self, APPLY_CI_NEB=99999):
|
|
20
|
+
self.spring_constant_k = 1e-6
|
|
21
|
+
self.APPLY_CI_NEB = APPLY_CI_NEB
|
|
22
|
+
self.force_const_for_cineb = 0.01
|
|
23
|
+
|
|
24
|
+
def calc_force(self, geometry_num_list, energy_list, gradient_list, optimize_num, element_list):
|
|
25
|
+
print("NEB2NEB2NEB2NEB2NEB2NEB2NEB2NEB2NEB2NEB2NEB2NEB2NEB2NEB2NEB2NEB2NEB2")
|
|
26
|
+
local_max_energy_list_index, local_min_energy_list_index = extremum_list_index(energy_list)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
total_force_list = [((-1)*np.array(gradient_list[0], dtype = "float64")).tolist()]
|
|
30
|
+
for i in range(1,len(energy_list)-1):
|
|
31
|
+
tau_plus, tau_minus, tau = [], [], []
|
|
32
|
+
|
|
33
|
+
delta_max_energy = np.array(max([(energy_list[i+1]-energy_list[i]),(energy_list[i-1]-energy_list[i])]), dtype = "float64")
|
|
34
|
+
delta_min_energy = np.array(min([(energy_list[i+1]-energy_list[i]),(energy_list[i-1]-energy_list[i])]), dtype = "float64")
|
|
35
|
+
|
|
36
|
+
if (energy_list[i-1] < energy_list[i]) and (energy_list[i] < energy_list[i+1]):
|
|
37
|
+
for t in range(len(geometry_num_list[i])):
|
|
38
|
+
tau_vector = geometry_num_list[i+1][t]-geometry_num_list[i][t]
|
|
39
|
+
tau_norm = np.linalg.norm(geometry_num_list[i+1][t]-geometry_num_list[i][t], ord=2)
|
|
40
|
+
tau.append(np.divide(tau_vector, tau_norm, out=np.zeros_like(geometry_num_list[i][t]) ,where=np.linalg.norm(geometry_num_list[i+1][t]-geometry_num_list[i][t], ord=2)!=0).tolist())
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
elif (energy_list[i-1] > energy_list[i]) and (energy_list[i] > energy_list[i+1]):
|
|
44
|
+
for t in range(len(geometry_num_list[i])):
|
|
45
|
+
tau_vector = geometry_num_list[i][t]-geometry_num_list[i-1][t]
|
|
46
|
+
tau_norm = np.linalg.norm(geometry_num_list[i][t]-geometry_num_list[i-1][t], ord=2)
|
|
47
|
+
tau.append(np.divide(tau_vector, tau_norm, out=np.zeros_like(geometry_num_list[i][t]), where=np.linalg.norm(geometry_num_list[i][t]-geometry_num_list[i-1][t], ord=2)!=0).tolist())
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
else: #((energy_list[i-1] >= energy_list[i]) and (energy_list[i] <= energy_list[i+1])) or ((energy_list[i-1] <= energy_list[i]) and (energy_list[i] >= energy_list[i+1])):
|
|
52
|
+
for t in range(len(geometry_num_list[i])):
|
|
53
|
+
tau_minus_vector = geometry_num_list[i][t]-geometry_num_list[i-1][t]
|
|
54
|
+
tau_minus_norm = np.linalg.norm(geometry_num_list[i][t]-geometry_num_list[i-1][t], ord=2) + 1e-15
|
|
55
|
+
tau_minus.append((tau_minus_vector / tau_minus_norm).tolist())
|
|
56
|
+
|
|
57
|
+
for t in range(len(geometry_num_list[i])):
|
|
58
|
+
tau_plus_vector = geometry_num_list[i+1][t]-geometry_num_list[i][t]
|
|
59
|
+
tau_plus_norm = np.linalg.norm(geometry_num_list[i+1][t]-geometry_num_list[i][t], ord=2) + 1e-15
|
|
60
|
+
tau_plus.append((tau_plus_vector / tau_plus_norm).tolist())
|
|
61
|
+
|
|
62
|
+
if energy_list[i-1] > energy_list[i+1]:
|
|
63
|
+
for t in range(len(geometry_num_list[i])):
|
|
64
|
+
tau_vector = (tau_plus[t]*delta_min_energy+tau_minus[t]*delta_max_energy)
|
|
65
|
+
tau_norm = np.linalg.norm(tau_plus[t]*delta_min_energy+tau_minus[t]*delta_max_energy, ord=2) + 1e-15
|
|
66
|
+
tau.append((tau_vector / tau_norm).tolist())
|
|
67
|
+
else:
|
|
68
|
+
for t in range(len(geometry_num_list[i])):
|
|
69
|
+
tau_vector = (tau_plus[t]*delta_max_energy+tau_minus[t]*delta_min_energy)
|
|
70
|
+
tau_norm = np.linalg.norm(tau_plus[t]*delta_min_energy+tau_minus[t]*delta_max_energy, ord=2) + 1e-15
|
|
71
|
+
tau.append((tau_vector / tau_norm).tolist())
|
|
72
|
+
|
|
73
|
+
tau_plus, tau_minus, tau = np.array(tau_plus, dtype = "float64"), np.array(tau_minus, dtype = "float64"), np.array(tau, dtype = "float64")
|
|
74
|
+
#print("tau_minus:\n",tau_minus)
|
|
75
|
+
#print("tau_plus:\n",tau_plus)
|
|
76
|
+
#print("tau:\n",str(tau))
|
|
77
|
+
force_perpendicularity, force_parallelism = [], []
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
if energy_list[i] == energy_list[local_max_energy_list_index[0]] and self.APPLY_CI_NEB < optimize_num: #CI-NEB
|
|
81
|
+
for f in range(len(geometry_num_list[i])):
|
|
82
|
+
force_perpendicularity.append(np.array((-1)*self.force_const_for_cineb*(gradient_list[i][f]-2.0*(np.dot(gradient_list[i][f], tau[f]))*tau[f]), dtype = "float64"))
|
|
83
|
+
#print(str(force_perpendicularity))
|
|
84
|
+
total_force = np.array(force_perpendicularity, dtype="float64")
|
|
85
|
+
del local_max_energy_list_index[0]
|
|
86
|
+
else:
|
|
87
|
+
tau_x = []
|
|
88
|
+
tau_y = []
|
|
89
|
+
tau_z = []
|
|
90
|
+
for i in range(len(tau)):
|
|
91
|
+
tau_x.extend([tau[i][0], 0.0, 0.0])
|
|
92
|
+
tau_y.extend([0.0, tau[i][1], 0.0])
|
|
93
|
+
tau_z.extend([0.0, 0.0, tau[i][2]])
|
|
94
|
+
tau_x = np.array(tau_x, dtype = "float64")
|
|
95
|
+
tau_y = np.array(tau_y, dtype = "float64")
|
|
96
|
+
tau_z = np.array(tau_z, dtype = "float64")
|
|
97
|
+
|
|
98
|
+
orthogonal_normalized_tau, _ = np.linalg.qr(np.array([tau_x, tau_y, tau_z], dtype = "float64").T)
|
|
99
|
+
|
|
100
|
+
projection_operator = np.dot(orthogonal_normalized_tau, orthogonal_normalized_tau.T)
|
|
101
|
+
tmp_gradient = np.array(gradient_list[i], dtype = "float64").reshape(len(gradient_list[i]) * 3, 1)
|
|
102
|
+
|
|
103
|
+
force_perpendicularity = (np.eye(len(gradient_list[i]) * 3) - projection_operator).dot(tmp_gradient).reshape(len(gradient_list[i]), 3)
|
|
104
|
+
force_parallelism = projection_operator.dot(tmp_gradient).reshape(len(gradient_list[i]), 3) * self.spring_constant_k
|
|
105
|
+
|
|
106
|
+
total_force = np.array((-1)*force_perpendicularity - force_parallelism, dtype = "float64")
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
total_force_list.append(total_force.tolist())
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
total_force_list.append(((-1)*np.array(gradient_list[-1], dtype = "float64")).tolist())
|
|
113
|
+
|
|
114
|
+
return np.array(total_force_list, dtype = "float64")
|
|
115
|
+
|
|
116
|
+
class CaluculationNEB:
|
|
117
|
+
def __init__(self, APPLY_CI_NEB=99999):
|
|
118
|
+
self.spring_constant_k = 0.01
|
|
119
|
+
self.APPLY_CI_NEB = APPLY_CI_NEB
|
|
120
|
+
self.force_const_for_cineb = 0.01
|
|
121
|
+
|
|
122
|
+
def calc_force(self, geometry_num_list, energy_list, gradient_list, optimize_num, element_list):
|
|
123
|
+
print("NEBNEBNEBNEBNEBNEBNEBNEBNEBNEBNEBNEBNEBNEBNEBNEBNEB")
|
|
124
|
+
local_max_energy_list_index, local_min_energy_list_index = extremum_list_index(energy_list)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
total_force_list = [((-1)*np.array(gradient_list[0], dtype = "float64")).tolist()]
|
|
128
|
+
for i in range(1,len(energy_list)-1):
|
|
129
|
+
tau_plus, tau_minus, tau = [], [], []
|
|
130
|
+
|
|
131
|
+
delta_max_energy = np.array(max([(energy_list[i+1]-energy_list[i]),(energy_list[i-1]-energy_list[i])]), dtype = "float64")
|
|
132
|
+
delta_min_energy = np.array(min([(energy_list[i+1]-energy_list[i]),(energy_list[i-1]-energy_list[i])]), dtype = "float64")
|
|
133
|
+
|
|
134
|
+
if (energy_list[i-1] < energy_list[i]) and (energy_list[i] < energy_list[i+1]):
|
|
135
|
+
for t in range(len(geometry_num_list[i])):
|
|
136
|
+
tau_vector = geometry_num_list[i+1][t]-geometry_num_list[i][t]
|
|
137
|
+
tau_norm = np.linalg.norm(geometry_num_list[i+1][t]-geometry_num_list[i][t], ord=2)
|
|
138
|
+
tau.append(np.divide(tau_vector, tau_norm, out=np.zeros_like(geometry_num_list[i][t]) ,where=np.linalg.norm(geometry_num_list[i+1][t]-geometry_num_list[i][t], ord=2)!=0).tolist())
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
elif (energy_list[i-1] > energy_list[i]) and (energy_list[i] > energy_list[i+1]):
|
|
142
|
+
for t in range(len(geometry_num_list[i])):
|
|
143
|
+
tau_vector = geometry_num_list[i][t]-geometry_num_list[i-1][t]
|
|
144
|
+
tau_norm = np.linalg.norm(geometry_num_list[i][t]-geometry_num_list[i-1][t], ord=2)
|
|
145
|
+
tau.append(np.divide(tau_vector, tau_norm, out=np.zeros_like(geometry_num_list[i][t]), where=np.linalg.norm(geometry_num_list[i][t]-geometry_num_list[i-1][t], ord=2)!=0).tolist())
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
else: #((energy_list[i-1] >= energy_list[i]) and (energy_list[i] <= energy_list[i+1])) or ((energy_list[i-1] <= energy_list[i]) and (energy_list[i] >= energy_list[i+1])):
|
|
150
|
+
for t in range(len(geometry_num_list[i])):
|
|
151
|
+
tau_minus_vector = geometry_num_list[i][t]-geometry_num_list[i-1][t]
|
|
152
|
+
tau_minus_norm = np.linalg.norm(geometry_num_list[i][t]-geometry_num_list[i-1][t], ord=2)
|
|
153
|
+
tau_minus.append(np.divide(tau_minus_vector, tau_minus_norm
|
|
154
|
+
,out=np.zeros_like(geometry_num_list[i][t]),
|
|
155
|
+
where=np.linalg.norm(geometry_num_list[i][t]-geometry_num_list[i-1][t], ord=2)!=0).tolist())
|
|
156
|
+
|
|
157
|
+
for t in range(len(geometry_num_list[i])):
|
|
158
|
+
tau_plus_vector = geometry_num_list[i+1][t]-geometry_num_list[i][t]
|
|
159
|
+
tau_plus_norm = np.linalg.norm(geometry_num_list[i+1][t]-geometry_num_list[i][t], ord=2)
|
|
160
|
+
tau_plus.append(np.divide(tau_plus_vector, tau_plus_norm, out=np.zeros_like(geometry_num_list[i][t]), where=np.linalg.norm(geometry_num_list[i+1][t]-geometry_num_list[i][t], ord=2)!=0).tolist())
|
|
161
|
+
|
|
162
|
+
if energy_list[i-1] > energy_list[i+1]:
|
|
163
|
+
for t in range(len(geometry_num_list[i])):
|
|
164
|
+
tau_vector = (tau_plus[t]*delta_min_energy+tau_minus[t]*delta_max_energy)
|
|
165
|
+
tau_norm = np.linalg.norm(tau_plus[t]*delta_min_energy+tau_minus[t]*delta_max_energy, ord=2)
|
|
166
|
+
tau.append(np.divide(tau_vector,tau_norm, out=np.zeros_like(tau_plus[0]) ,where=np.linalg.norm(tau_plus[t]*delta_min_energy+tau_minus[t]*delta_max_energy!=0)).tolist())
|
|
167
|
+
else:
|
|
168
|
+
for t in range(len(geometry_num_list[i])):
|
|
169
|
+
tau_vector = (tau_plus[t]*delta_max_energy+tau_minus[t]*delta_min_energy)
|
|
170
|
+
tau_norm = np.linalg.norm(tau_plus[t]*delta_min_energy+tau_minus[t]*delta_max_energy, ord=2)
|
|
171
|
+
tau.append(np.divide(tau_vector, tau_norm,out=np.zeros_like(tau_minus[0]) ,where=np.linalg.norm(tau_plus[t]*delta_min_energy+tau_minus[t]*delta_max_energy, ord=2)!=0 ).tolist())
|
|
172
|
+
|
|
173
|
+
tau_plus, tau_minus, tau = np.array(tau_plus, dtype = "float64"), np.array(tau_minus, dtype = "float64"), np.array(tau, dtype = "float64")
|
|
174
|
+
#print("tau_minus:\n",tau_minus)
|
|
175
|
+
#print("tau_plus:\n",tau_plus)
|
|
176
|
+
#print("tau:\n",str(tau))
|
|
177
|
+
force_perpendicularity, force_parallelism = [], []
|
|
178
|
+
|
|
179
|
+
if energy_list[i] == energy_list[local_max_energy_list_index[0]] and self.APPLY_CI_NEB < optimize_num: #CI-NEB
|
|
180
|
+
for f in range(len(geometry_num_list[i])):
|
|
181
|
+
force_perpendicularity.append(np.array((-1)*self.force_const_for_cineb*(gradient_list[i][f]-2.0*(np.dot(gradient_list[i][f], tau[f]))*tau[f]), dtype = "float64"))
|
|
182
|
+
#print(str(force_perpendicularity))
|
|
183
|
+
total_force = np.array(force_perpendicularity, dtype="float64")
|
|
184
|
+
del local_max_energy_list_index[0]
|
|
185
|
+
#print(str(total_force))
|
|
186
|
+
#elif energy_list[i] == energy_list[local_min_energy_list_index[0]]: #for discovering intermidiate
|
|
187
|
+
# for f in range(len(geometry_num_list[i])):
|
|
188
|
+
# force_perpendicularity.append(np.array(((-1)*(gradient_list[i][f])), dtype = "float64"))
|
|
189
|
+
# #print(str(force_perpendicularity))
|
|
190
|
+
# total_force = np.array(force_perpendicularity, dtype="float64")
|
|
191
|
+
# del local_min_energy_list_index[0]
|
|
192
|
+
else:
|
|
193
|
+
for f in range(len(geometry_num_list[i])):
|
|
194
|
+
grad = 0.0
|
|
195
|
+
|
|
196
|
+
for gg in range(len(gradient_list[i])):
|
|
197
|
+
grad += np.linalg.norm(gradient_list[i][gg], ord=2)
|
|
198
|
+
|
|
199
|
+
grad = grad/len(gradient_list[i])
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
#print("spring_constant:",self.spring_constant_k)
|
|
203
|
+
|
|
204
|
+
force_parallelism.append(np.array((self.spring_constant_k*(np.linalg.norm(geometry_num_list[i+1][f]-geometry_num_list[i][f], ord=2))+(-1.0)*self.spring_constant_k*(np.linalg.norm(geometry_num_list[i][f]-geometry_num_list[i-1][f], ord=2)))*tau[f], dtype = "float64"))
|
|
205
|
+
|
|
206
|
+
force_perpendicularity.append(np.array(gradient_list[i][f]-(np.dot(gradient_list[i][f], tau[f]))*tau[f], dtype = "float64"))
|
|
207
|
+
#doubly nudged elastic band method :https://doi.org/10.1063/1.1636455
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
force_perpendicularity, force_parallelism = np.array(force_perpendicularity, dtype = "float64"), np.array(force_parallelism, dtype = "float64")
|
|
213
|
+
total_force = np.array((-1)*force_perpendicularity - force_parallelism, dtype = "float64")
|
|
214
|
+
|
|
215
|
+
if np.nanmean(np.nanmean(total_force)) > 10:
|
|
216
|
+
total_force = total_force / np.nanmean(np.nanmean(total_force))
|
|
217
|
+
|
|
218
|
+
total_force_list.append(total_force.tolist())
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
total_force_list.append(((-1)*np.array(gradient_list[-1], dtype = "float64")).tolist())
|
|
224
|
+
|
|
225
|
+
return np.array(total_force_list, dtype = "float64")
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from scipy.signal import argrelextrema
|
|
3
|
+
|
|
4
|
+
def extremum_list_index(energy_list):
|
|
5
|
+
local_max_energy_list_index = argrelextrema(energy_list, np.greater)
|
|
6
|
+
inverse_energy_list = (-1)*energy_list
|
|
7
|
+
local_min_energy_list_index = argrelextrema(inverse_energy_list, np.greater)
|
|
8
|
+
|
|
9
|
+
local_max_energy_list_index = local_max_energy_list_index[0].tolist()
|
|
10
|
+
local_min_energy_list_index = local_min_energy_list_index[0].tolist()
|
|
11
|
+
local_max_energy_list_index.append(0)
|
|
12
|
+
local_min_energy_list_index.append(0)
|
|
13
|
+
local_max_energy_list_index.append(0)
|
|
14
|
+
local_min_energy_list_index.append(0)
|
|
15
|
+
return local_max_energy_list_index, local_min_energy_list_index
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class CaluculationNESB:
|
|
22
|
+
def __init__(self, APPLY_CI_NEB=99999):
|
|
23
|
+
self.spring_constant_k = 0.01
|
|
24
|
+
self.APPLY_CI_NEB = APPLY_CI_NEB
|
|
25
|
+
self.force_const_for_cineb = 0.01
|
|
26
|
+
self.NESB_band_width = 0.1
|
|
27
|
+
|
|
28
|
+
def calc_force(self, geometry_num_list, energy_list, gradient_list, optimize_num, element_list):
|
|
29
|
+
#Nudged elastic stiffness band method
|
|
30
|
+
#ref.: J Comput Chem. 2023;44:1884–1897. https://doi.org/10.1002/jcc.27169
|
|
31
|
+
print("NESBNESBNESBNESBNESBNESBNESBNESBNESBNESBNESBNESBNESBNESB")
|
|
32
|
+
local_max_energy_list_index, local_min_energy_list_index = extremum_list_index(energy_list)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
tau_list = [np.array(gradient_list[0], dtype = "float64") * 0.0]
|
|
36
|
+
total_force_list = [((-1)*np.array(gradient_list[0], dtype = "float64")).tolist()]
|
|
37
|
+
for i in range(1,len(energy_list)-1):
|
|
38
|
+
tau_plus, tau_minus, tau = [], [], []
|
|
39
|
+
|
|
40
|
+
delta_max_energy = np.array(max([(energy_list[i+1]-energy_list[i]),(energy_list[i-1]-energy_list[i])]), dtype = "float64")
|
|
41
|
+
delta_min_energy = np.array(min([(energy_list[i+1]-energy_list[i]),(energy_list[i-1]-energy_list[i])]), dtype = "float64")
|
|
42
|
+
|
|
43
|
+
if (energy_list[i-1] < energy_list[i]) and (energy_list[i] < energy_list[i+1]):
|
|
44
|
+
for t in range(len(geometry_num_list[i])):
|
|
45
|
+
tau_vector = geometry_num_list[i+1][t]-geometry_num_list[i][t]
|
|
46
|
+
tau_norm = np.linalg.norm(geometry_num_list[i+1][t]-geometry_num_list[i][t], ord=2)
|
|
47
|
+
tau.append(np.divide(tau_vector, tau_norm, out=np.zeros_like(geometry_num_list[i][t]) ,where=np.linalg.norm(geometry_num_list[i+1][t]-geometry_num_list[i][t], ord=2)!=0).tolist())
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
elif (energy_list[i-1] > energy_list[i]) and (energy_list[i] > energy_list[i+1]):
|
|
51
|
+
for t in range(len(geometry_num_list[i])):
|
|
52
|
+
tau_vector = geometry_num_list[i][t]-geometry_num_list[i-1][t]
|
|
53
|
+
tau_norm = np.linalg.norm(geometry_num_list[i][t]-geometry_num_list[i-1][t], ord=2)
|
|
54
|
+
tau.append(np.divide(tau_vector, tau_norm, out=np.zeros_like(geometry_num_list[i][t]), where=np.linalg.norm(geometry_num_list[i][t]-geometry_num_list[i-1][t], ord=2)!=0).tolist())
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
else: #((energy_list[i-1] >= energy_list[i]) and (energy_list[i] <= energy_list[i+1])) or ((energy_list[i-1] <= energy_list[i]) and (energy_list[i] >= energy_list[i+1])):
|
|
59
|
+
for t in range(len(geometry_num_list[i])):
|
|
60
|
+
tau_minus_vector = geometry_num_list[i][t]-geometry_num_list[i-1][t]
|
|
61
|
+
tau_minus_norm = np.linalg.norm(geometry_num_list[i][t]-geometry_num_list[i-1][t], ord=2)
|
|
62
|
+
tau_minus.append(np.divide(tau_minus_vector, tau_minus_norm
|
|
63
|
+
,out=np.zeros_like(geometry_num_list[i][t]),
|
|
64
|
+
where=np.linalg.norm(geometry_num_list[i][t]-geometry_num_list[i-1][t], ord=2)!=0).tolist())
|
|
65
|
+
|
|
66
|
+
for t in range(len(geometry_num_list[i])):
|
|
67
|
+
tau_plus_vector = geometry_num_list[i+1][t]-geometry_num_list[i][t]
|
|
68
|
+
tau_plus_norm = np.linalg.norm(geometry_num_list[i+1][t]-geometry_num_list[i][t], ord=2)
|
|
69
|
+
tau_plus.append(np.divide(tau_plus_vector, tau_plus_norm, out=np.zeros_like(geometry_num_list[i][t]), where=np.linalg.norm(geometry_num_list[i+1][t]-geometry_num_list[i][t], ord=2)!=0).tolist())
|
|
70
|
+
|
|
71
|
+
if energy_list[i-1] > energy_list[i+1]:
|
|
72
|
+
for t in range(len(geometry_num_list[i])):
|
|
73
|
+
tau_vector = (tau_plus[t]*delta_min_energy+tau_minus[t]*delta_max_energy)
|
|
74
|
+
tau_norm = np.linalg.norm(tau_plus[t]*delta_min_energy+tau_minus[t]*delta_max_energy, ord=2)
|
|
75
|
+
tau.append(np.divide(tau_vector,tau_norm, out=np.zeros_like(tau_plus[0]) ,where=np.linalg.norm(tau_plus[t]*delta_min_energy+tau_minus[t]*delta_max_energy!=0)).tolist())
|
|
76
|
+
else:
|
|
77
|
+
for t in range(len(geometry_num_list[i])):
|
|
78
|
+
tau_vector = (tau_plus[t]*delta_max_energy+tau_minus[t]*delta_min_energy)
|
|
79
|
+
tau_norm = np.linalg.norm(tau_plus[t]*delta_min_energy+tau_minus[t]*delta_max_energy, ord=2)
|
|
80
|
+
tau.append(np.divide(tau_vector, tau_norm,out=np.zeros_like(tau_minus[0]) ,where=np.linalg.norm(tau_plus[t]*delta_min_energy+tau_minus[t]*delta_max_energy, ord=2)!=0 ).tolist())
|
|
81
|
+
|
|
82
|
+
tau_plus, tau_minus, tau = np.array(tau_plus, dtype = "float64"), np.array(tau_minus, dtype = "float64"), np.array(tau, dtype = "float64")
|
|
83
|
+
#print("tau_minus:\n",tau_minus)
|
|
84
|
+
#print("tau_plus:\n",tau_plus)
|
|
85
|
+
#print("tau:\n",str(tau))
|
|
86
|
+
tau_list.append(tau)
|
|
87
|
+
#-----------------------------------
|
|
88
|
+
tau_list.append(np.array(gradient_list[0], dtype = "float64") * 0.0)
|
|
89
|
+
tangent_tau_list = [np.array(gradient_list[0], dtype = "float64") * 0.0]
|
|
90
|
+
for i in range(1,len(energy_list)-1):
|
|
91
|
+
#NESB
|
|
92
|
+
|
|
93
|
+
tangent_tau = []
|
|
94
|
+
|
|
95
|
+
v_1 = geometry_num_list[i-1] - geometry_num_list[i]
|
|
96
|
+
v_2 = geometry_num_list[i+1] - geometry_num_list[i]
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
for l in range(len(geometry_num_list[i])):
|
|
100
|
+
|
|
101
|
+
v_1_tau = np.dot(v_1[l], tau_list[i][l].T)
|
|
102
|
+
v_2_tau = np.dot(v_2[l], tau_list[i][l].T)
|
|
103
|
+
if abs(v_1_tau) < 1e-8 and abs(v_2_tau) < 1e-8:
|
|
104
|
+
tangent_tau.append(v_1[l])
|
|
105
|
+
|
|
106
|
+
elif abs(v_1_tau) < 1e-8:
|
|
107
|
+
tmp_a = -1 * (v_1_tau / v_2_tau)
|
|
108
|
+
tangent_tau.append(v_1[l]+v_2[l]*tmp_a)
|
|
109
|
+
|
|
110
|
+
elif abs(v_1_tau) > 0.9 and abs(v_2_tau) > 0.9:
|
|
111
|
+
|
|
112
|
+
tmp_a = -1 * (np.dot(tangent_tau_list[i-1][l], tau_list[i][l].T) / np.dot(tau_list[i][l], tau_list[i][l].T))
|
|
113
|
+
tangent_tau.append(tmp_a*tau_list[i][l]+tangent_tau_list[i-1][l])
|
|
114
|
+
|
|
115
|
+
else:
|
|
116
|
+
tmp_a = -1 * (v_2_tau / v_1_tau)
|
|
117
|
+
tangent_tau.append(v_2[l]+v_1[l]*tmp_a)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
tangent_tau = np.array(tangent_tau, dtype="float64")
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
if i > 1:
|
|
124
|
+
check_direction = np.sum(np.dot(tangent_tau, tangent_tau_list[i-1].T))
|
|
125
|
+
if check_direction <= 0:
|
|
126
|
+
tangent_tau *= -1
|
|
127
|
+
tangent_tau = tangent_tau/(np.linalg.norm(tangent_tau)+1e-8)
|
|
128
|
+
|
|
129
|
+
tangent_tau_list.append(tangent_tau)
|
|
130
|
+
#force_stiff
|
|
131
|
+
|
|
132
|
+
tangent_tau_list.append(np.array(gradient_list[0], dtype = "float64") * 0.0)
|
|
133
|
+
|
|
134
|
+
#-------------------------------------
|
|
135
|
+
force_stiff_list = [np.array(gradient_list[0], dtype = "float64") * 0.0, np.array(gradient_list[0], dtype = "float64") * 0.0]
|
|
136
|
+
for i in range(2,len(energy_list)-2):
|
|
137
|
+
virtual_image_in_geometry_num_list = geometry_num_list[i] + 0.5 * self.NESB_band_width * tangent_tau_list[i]
|
|
138
|
+
virtual_image_out_geometry_num_list = geometry_num_list[i] - 0.5 * self.NESB_band_width * tangent_tau_list[i]
|
|
139
|
+
next_virtual_image_in_geometry_num_list = geometry_num_list[i+1] + 0.5 * self.NESB_band_width * tangent_tau_list[i+1]
|
|
140
|
+
next_virtual_image_out_geometry_num_list = geometry_num_list[i+1] - 0.5 * self.NESB_band_width * tangent_tau_list[i+1]
|
|
141
|
+
vi_in_geom_dist = np.linalg.norm(virtual_image_in_geometry_num_list)
|
|
142
|
+
vi_out_geom_dist = np.linalg.norm(virtual_image_out_geometry_num_list)
|
|
143
|
+
next_vi_in_geom_dist = np.linalg.norm(next_virtual_image_in_geometry_num_list)
|
|
144
|
+
next_vi_out_geom_dist = np.linalg.norm(next_virtual_image_out_geometry_num_list)
|
|
145
|
+
force_stiff_plus = 0.5 * (next_vi_out_geom_dist - next_vi_in_geom_dist) * tangent_tau_list[i+1]
|
|
146
|
+
force_stiff_minus = 0.5 * (vi_out_geom_dist - vi_in_geom_dist) * tangent_tau_list[i]
|
|
147
|
+
force_stiff = force_stiff_minus + force_stiff_plus
|
|
148
|
+
force_stiff_list.append(force_stiff)
|
|
149
|
+
|
|
150
|
+
force_stiff_list.append(np.array(gradient_list[0], dtype = "float64") * 0.0)
|
|
151
|
+
force_stiff_list.append(np.array(gradient_list[0], dtype = "float64") * 0.0)
|
|
152
|
+
|
|
153
|
+
for i in range(1,len(energy_list)-1):
|
|
154
|
+
force_perpendicularity, force_parallelism = [], []
|
|
155
|
+
|
|
156
|
+
if energy_list[i] == energy_list[local_max_energy_list_index[0]] and self.APPLY_CI_NEB < optimize_num: #CI-NEB
|
|
157
|
+
for f in range(len(geometry_num_list[i])):
|
|
158
|
+
force_perpendicularity.append(np.array((-1)*self.force_const_for_cineb*(gradient_list[i][f]-2.0*(np.dot(gradient_list[i][f], tau_list[i][f]))*tau_list[i][f]), dtype = "float64"))
|
|
159
|
+
#print(str(force_perpendicularity))
|
|
160
|
+
total_force = np.array(force_perpendicularity, dtype="float64")
|
|
161
|
+
del local_max_energy_list_index[0]
|
|
162
|
+
#print(str(total_force))
|
|
163
|
+
#elif energy_list[i] == energy_list[local_min_energy_list_index[0]]: #for discovering intermidiate
|
|
164
|
+
# for f in range(len(geometry_num_list[i])):
|
|
165
|
+
# force_perpendicularity.append(np.array(((-1)*(gradient_list[i][f])), dtype = "float64"))
|
|
166
|
+
# #print(str(force_perpendicularity))
|
|
167
|
+
# total_force = np.array(force_perpendicularity, dtype="float64")
|
|
168
|
+
# del local_min_energy_list_index[0]
|
|
169
|
+
else:
|
|
170
|
+
for f in range(len(geometry_num_list[i])):
|
|
171
|
+
grad = 0.0
|
|
172
|
+
|
|
173
|
+
for gg in range(len(gradient_list[i])):
|
|
174
|
+
grad += np.linalg.norm(gradient_list[i][gg], ord=2)
|
|
175
|
+
|
|
176
|
+
grad = grad/len(gradient_list[i])
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
#print("spring_constant:",self.spring_constant_k)
|
|
180
|
+
|
|
181
|
+
force_parallelism.append(np.array((self.spring_constant_k*(np.linalg.norm(geometry_num_list[i+1][f]-geometry_num_list[i][f], ord=2))+(-1.0)*self.spring_constant_k*(np.linalg.norm(geometry_num_list[i][f]-geometry_num_list[i-1][f], ord=2)))*tau[f], dtype = "float64"))
|
|
182
|
+
|
|
183
|
+
force_perpendicularity.append(np.array(gradient_list[i][f]-(np.dot(gradient_list[i][f], tau_list[i][f]))*tau_list[i][f], dtype = "float64"))
|
|
184
|
+
#doubly nudged elastic band method :https://doi.org/10.1063/1.1636455
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
force_perpendicularity, force_parallelism = np.array(force_perpendicularity, dtype = "float64"), np.array(force_parallelism, dtype = "float64")
|
|
190
|
+
if np.sum(np.dot(force_parallelism, force_stiff_list[i].T)) > 0:
|
|
191
|
+
force_stiff_list[i] *= -1
|
|
192
|
+
|
|
193
|
+
total_force = np.array((-1)*force_perpendicularity - force_parallelism + force_stiff_list[i], dtype = "float64")
|
|
194
|
+
|
|
195
|
+
if np.nanmean(np.nanmean(total_force)) > 10:
|
|
196
|
+
total_force = total_force / np.nanmean(np.nanmean(total_force))
|
|
197
|
+
|
|
198
|
+
total_force_list.append(total_force.tolist())
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
total_force_list.append(((-1)*np.array(gradient_list[-1], dtype = "float64")).tolist())
|
|
204
|
+
|
|
205
|
+
return np.array(total_force_list, dtype = "float64")
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from scipy.signal import argrelextrema
|
|
3
|
+
from multioptpy.Parameters.parameter import atomic_mass
|
|
4
|
+
|
|
5
|
+
def extremum_list_index(energy_list):
|
|
6
|
+
local_max_energy_list_index = argrelextrema(energy_list, np.greater)
|
|
7
|
+
inverse_energy_list = (-1)*energy_list
|
|
8
|
+
local_min_energy_list_index = argrelextrema(inverse_energy_list, np.greater)
|
|
9
|
+
|
|
10
|
+
local_max_energy_list_index = local_max_energy_list_index[0].tolist()
|
|
11
|
+
local_min_energy_list_index = local_min_energy_list_index[0].tolist()
|
|
12
|
+
local_max_energy_list_index.append(0)
|
|
13
|
+
local_min_energy_list_index.append(0)
|
|
14
|
+
local_max_energy_list_index.append(0)
|
|
15
|
+
local_min_energy_list_index.append(0)
|
|
16
|
+
return local_max_energy_list_index, local_min_energy_list_index
|
|
17
|
+
|
|
18
|
+
class CaluculationOM:
|
|
19
|
+
def __init__(self, APPLY_CI_NEB=99999):
|
|
20
|
+
self.spring_constant_k = 0.01
|
|
21
|
+
self.APPLY_CI_NEB = APPLY_CI_NEB
|
|
22
|
+
self.force_const_for_cineb = 0.01
|
|
23
|
+
|
|
24
|
+
def calc_force(self, geometry_num_list, energy_list, gradient_list, optimize_num, element_list):#J. Chem. Phys. 155, 074103 (2021) doi:https://doi.org/10.1063/5.0059593
|
|
25
|
+
#This improved NEB method is inspired by the Onsager-Machlup (OM) action.
|
|
26
|
+
print("OMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOMOM")
|
|
27
|
+
local_max_energy_list_index, local_min_energy_list_index = extremum_list_index(energy_list)
|
|
28
|
+
delta_t = 1
|
|
29
|
+
damping_const = 1
|
|
30
|
+
OM_spring_const = 0.001
|
|
31
|
+
|
|
32
|
+
total_force_list = [((-1)*np.array(gradient_list[0], dtype = "float64")).tolist()]
|
|
33
|
+
|
|
34
|
+
for i in range(1,len(energy_list)-1):
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
tau_plus, tau_minus, tau = [], [], []
|
|
39
|
+
|
|
40
|
+
delta_max_energy = np.array(max([(energy_list[i+1]-energy_list[i]),(energy_list[i-1]-energy_list[i])]), dtype = "float64")
|
|
41
|
+
delta_min_energy = np.array(min([(energy_list[i+1]-energy_list[i]),(energy_list[i-1]-energy_list[i])]), dtype = "float64")
|
|
42
|
+
|
|
43
|
+
if (energy_list[i-1] < energy_list[i]) and (energy_list[i] < energy_list[i+1]):
|
|
44
|
+
for t in range(len(geometry_num_list[i])):
|
|
45
|
+
tau_vector = geometry_num_list[i+1][t]-geometry_num_list[i][t]
|
|
46
|
+
tau_norm = np.linalg.norm(geometry_num_list[i+1][t]-geometry_num_list[i][t], ord=2)
|
|
47
|
+
tau.append(np.divide(tau_vector, tau_norm, out=np.zeros_like(geometry_num_list[i][t]) ,where=np.linalg.norm(geometry_num_list[i+1][t]-geometry_num_list[i][t], ord=2)!=0).tolist())
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
elif (energy_list[i-1] > energy_list[i]) and (energy_list[i] > energy_list[i+1]):
|
|
51
|
+
for t in range(len(geometry_num_list[i])):
|
|
52
|
+
tau_vector = geometry_num_list[i][t]-geometry_num_list[i-1][t]
|
|
53
|
+
tau_norm = np.linalg.norm(geometry_num_list[i][t]-geometry_num_list[i-1][t], ord=2)
|
|
54
|
+
tau.append(np.divide(tau_vector, tau_norm, out=np.zeros_like(geometry_num_list[i][t]), where=np.linalg.norm(geometry_num_list[i][t]-geometry_num_list[i-1][t], ord=2)!=0).tolist())
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
else: #((energy_list[i-1] >= energy_list[i]) and (energy_list[i] <= energy_list[i+1])) or ((energy_list[i-1] <= energy_list[i]) and (energy_list[i] >= energy_list[i+1])):
|
|
59
|
+
for t in range(len(geometry_num_list[i])):
|
|
60
|
+
tau_minus_vector = geometry_num_list[i][t]-geometry_num_list[i-1][t]
|
|
61
|
+
tau_minus_norm = np.linalg.norm(geometry_num_list[i][t]-geometry_num_list[i-1][t], ord=2)
|
|
62
|
+
tau_minus.append(np.divide(tau_minus_vector, tau_minus_norm
|
|
63
|
+
,out=np.zeros_like(geometry_num_list[i][t]),
|
|
64
|
+
where=np.linalg.norm(geometry_num_list[i][t]-geometry_num_list[i-1][t], ord=2)!=0).tolist())
|
|
65
|
+
|
|
66
|
+
for t in range(len(geometry_num_list[i])):
|
|
67
|
+
tau_plus_vector = geometry_num_list[i+1][t]-geometry_num_list[i][t]
|
|
68
|
+
tau_plus_norm = np.linalg.norm(geometry_num_list[i+1][t]-geometry_num_list[i][t], ord=2)
|
|
69
|
+
tau_plus.append(np.divide(tau_plus_vector, tau_plus_norm, out=np.zeros_like(geometry_num_list[i][t]), where=np.linalg.norm(geometry_num_list[i+1][t]-geometry_num_list[i][t], ord=2)!=0).tolist())
|
|
70
|
+
|
|
71
|
+
if energy_list[i-1] > energy_list[i+1]:
|
|
72
|
+
for t in range(len(geometry_num_list[i])):
|
|
73
|
+
tau_vector = (tau_plus[t]*delta_min_energy+tau_minus[t]*delta_max_energy)
|
|
74
|
+
tau_norm = np.linalg.norm(tau_plus[t]*delta_min_energy+tau_minus[t]*delta_max_energy, ord=2)
|
|
75
|
+
tau.append(np.divide(tau_vector,tau_norm, out=np.zeros_like(tau_plus[0]) ,where=np.linalg.norm(tau_plus[t]*delta_min_energy+tau_minus[t]*delta_max_energy!=0)).tolist())
|
|
76
|
+
else:
|
|
77
|
+
for t in range(len(geometry_num_list[i])):
|
|
78
|
+
tau_vector = (tau_plus[t]*delta_max_energy+tau_minus[t]*delta_min_energy)
|
|
79
|
+
tau_norm = np.linalg.norm(tau_plus[t]*delta_min_energy+tau_minus[t]*delta_max_energy, ord=2)
|
|
80
|
+
tau.append(np.divide(tau_vector, tau_norm,out=np.zeros_like(tau_minus[0]) ,where=np.linalg.norm(tau_plus[t]*delta_min_energy+tau_minus[t]*delta_max_energy, ord=2)!=0 ).tolist())
|
|
81
|
+
|
|
82
|
+
tau_plus, tau_minus, tau = np.array(tau_plus, dtype = "float64"), np.array(tau_minus, dtype = "float64"), np.array(tau, dtype = "float64")
|
|
83
|
+
|
|
84
|
+
L_minus = []
|
|
85
|
+
L_neutral = []
|
|
86
|
+
for t in range(len(geometry_num_list[i])):
|
|
87
|
+
atom_mass = atomic_mass(element_list[t])
|
|
88
|
+
L_minus.append(-(delta_t/(atom_mass * damping_const)) * gradient_list[i-1][t])
|
|
89
|
+
L_neutral.append(-(delta_t/(atom_mass * damping_const)) * gradient_list[i][t])
|
|
90
|
+
L_minus = np.array(L_minus, dtype="float64")
|
|
91
|
+
L_neutral = np.array(L_neutral, dtype="float64")
|
|
92
|
+
|
|
93
|
+
OM_action_force = OM_spring_const * (geometry_num_list[i+1] + geometry_num_list[i-1] - 2 * geometry_num_list[i] + L_minus - L_neutral)
|
|
94
|
+
|
|
95
|
+
cos_phi = np.sum((geometry_num_list[i+1]-geometry_num_list[i]) * (geometry_num_list[i]-geometry_num_list[i-1])) /(np.linalg.norm(geometry_num_list[i+1]-geometry_num_list[i]) * np.linalg.norm(geometry_num_list[i]-geometry_num_list[i-1]))
|
|
96
|
+
phi = np.arccos(cos_phi)
|
|
97
|
+
|
|
98
|
+
if 0 <= phi and phi <= np.pi/2:
|
|
99
|
+
f_phi = 0.5 * (1 + np.cos(np.pi * cos_phi))
|
|
100
|
+
else:
|
|
101
|
+
f_phi = 1.0
|
|
102
|
+
OM_action_force_perpendicularity, OM_action_force_parallelism = [], []
|
|
103
|
+
|
|
104
|
+
force_perpendicularity, force_parallelism = [], []
|
|
105
|
+
|
|
106
|
+
if energy_list[i] == energy_list[local_max_energy_list_index[0]] and self.APPLY_CI_NEB < optimize_num: #CI-NEB
|
|
107
|
+
for f in range(len(geometry_num_list[i])):
|
|
108
|
+
force_perpendicularity.append(np.array((-1)*self.force_const_for_cineb*(gradient_list[i][f]-2.0*(np.dot(gradient_list[i][f], tau[f]))*tau[f]), dtype = "float64"))
|
|
109
|
+
#print(str(force_perpendicularity))
|
|
110
|
+
total_force = np.array(force_perpendicularity, dtype="float64")
|
|
111
|
+
del local_max_energy_list_index[0]
|
|
112
|
+
|
|
113
|
+
else:
|
|
114
|
+
for f in range(len(geometry_num_list[i])):
|
|
115
|
+
grad = 0.0
|
|
116
|
+
|
|
117
|
+
for gg in range(len(gradient_list[i])):
|
|
118
|
+
grad += np.linalg.norm(gradient_list[i][gg], ord=2)
|
|
119
|
+
|
|
120
|
+
grad = grad/len(gradient_list[i])
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
#print("spring_constant:",self.spring_constant_k)
|
|
124
|
+
|
|
125
|
+
force_parallelism.append(np.array((self.spring_constant_k*(np.linalg.norm(geometry_num_list[i+1][f]-geometry_num_list[i][f], ord=2))+(-1.0)*self.spring_constant_k*(np.linalg.norm(geometry_num_list[i][f]-geometry_num_list[i-1][f], ord=2)))*tau[f], dtype = "float64"))
|
|
126
|
+
OM_action_force_parallelism.append(np.array(OM_action_force[f] * np.dot(tau[f], tau[f]), dtype = "float64"))
|
|
127
|
+
|
|
128
|
+
force_perpendicularity.append(np.array(gradient_list[i][f]-(np.dot(gradient_list[i][f], tau[f]))*tau[f], dtype = "float64"))
|
|
129
|
+
OM_action_force_perpendicularity.append(f_phi * np.array(OM_action_force[f]-(np.dot(OM_action_force[f], tau[f]))*tau[f], dtype = "float64"))
|
|
130
|
+
#doubly nudged elastic band method :https://doi.org/10.1063/1.1636455
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
force_perpendicularity, force_parallelism = np.array(force_perpendicularity, dtype = "float64"), np.array(force_parallelism, dtype = "float64")
|
|
134
|
+
|
|
135
|
+
OM_action_force_perpendicularity, OM_action_force_parallelism = np.array(OM_action_force_perpendicularity, dtype = "float64"), np.array(OM_action_force_parallelism, dtype = "float64")
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
total_force = np.array((-1)*force_perpendicularity - force_parallelism + OM_action_force_parallelism + OM_action_force_perpendicularity, dtype = "float64")
|
|
141
|
+
|
|
142
|
+
if np.nanmean(np.nanmean(total_force)) > 10:
|
|
143
|
+
total_force = total_force / np.nanmean(np.nanmean(total_force))
|
|
144
|
+
|
|
145
|
+
total_force_list.append(total_force.tolist())
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
total_force_list.append(((-1)*np.array(gradient_list[-1], dtype = "float64")).tolist())
|
|
150
|
+
|
|
151
|
+
return np.array(total_force_list, dtype = "float64")
|
|
152
|
+
|
|
153
|
+
|