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.
Files changed (246) hide show
  1. multioptpy/Calculator/__init__.py +0 -0
  2. multioptpy/Calculator/ase_calculation_tools.py +424 -0
  3. multioptpy/Calculator/ase_tools/__init__.py +0 -0
  4. multioptpy/Calculator/ase_tools/fairchem.py +28 -0
  5. multioptpy/Calculator/ase_tools/gamess.py +19 -0
  6. multioptpy/Calculator/ase_tools/gaussian.py +165 -0
  7. multioptpy/Calculator/ase_tools/mace.py +28 -0
  8. multioptpy/Calculator/ase_tools/mopac.py +19 -0
  9. multioptpy/Calculator/ase_tools/nwchem.py +31 -0
  10. multioptpy/Calculator/ase_tools/orca.py +22 -0
  11. multioptpy/Calculator/ase_tools/pygfn0.py +37 -0
  12. multioptpy/Calculator/dxtb_calculation_tools.py +344 -0
  13. multioptpy/Calculator/emt_calculation_tools.py +458 -0
  14. multioptpy/Calculator/gpaw_calculation_tools.py +183 -0
  15. multioptpy/Calculator/lj_calculation_tools.py +314 -0
  16. multioptpy/Calculator/psi4_calculation_tools.py +334 -0
  17. multioptpy/Calculator/pwscf_calculation_tools.py +189 -0
  18. multioptpy/Calculator/pyscf_calculation_tools.py +327 -0
  19. multioptpy/Calculator/sqm1_calculation_tools.py +611 -0
  20. multioptpy/Calculator/sqm2_calculation_tools.py +376 -0
  21. multioptpy/Calculator/tblite_calculation_tools.py +352 -0
  22. multioptpy/Calculator/tersoff_calculation_tools.py +818 -0
  23. multioptpy/Constraint/__init__.py +0 -0
  24. multioptpy/Constraint/constraint_condition.py +834 -0
  25. multioptpy/Coordinate/__init__.py +0 -0
  26. multioptpy/Coordinate/polar_coordinate.py +199 -0
  27. multioptpy/Coordinate/redundant_coordinate.py +638 -0
  28. multioptpy/IRC/__init__.py +0 -0
  29. multioptpy/IRC/converge_criteria.py +28 -0
  30. multioptpy/IRC/dvv.py +544 -0
  31. multioptpy/IRC/euler.py +439 -0
  32. multioptpy/IRC/hpc.py +564 -0
  33. multioptpy/IRC/lqa.py +540 -0
  34. multioptpy/IRC/modekill.py +662 -0
  35. multioptpy/IRC/rk4.py +579 -0
  36. multioptpy/Interpolation/__init__.py +0 -0
  37. multioptpy/Interpolation/adaptive_interpolation.py +283 -0
  38. multioptpy/Interpolation/binomial_interpolation.py +179 -0
  39. multioptpy/Interpolation/geodesic_interpolation.py +785 -0
  40. multioptpy/Interpolation/interpolation.py +156 -0
  41. multioptpy/Interpolation/linear_interpolation.py +473 -0
  42. multioptpy/Interpolation/savitzky_golay_interpolation.py +252 -0
  43. multioptpy/Interpolation/spline_interpolation.py +353 -0
  44. multioptpy/MD/__init__.py +0 -0
  45. multioptpy/MD/thermostat.py +185 -0
  46. multioptpy/MEP/__init__.py +0 -0
  47. multioptpy/MEP/pathopt_bneb_force.py +443 -0
  48. multioptpy/MEP/pathopt_dmf_force.py +448 -0
  49. multioptpy/MEP/pathopt_dneb_force.py +130 -0
  50. multioptpy/MEP/pathopt_ewbneb_force.py +207 -0
  51. multioptpy/MEP/pathopt_gpneb_force.py +512 -0
  52. multioptpy/MEP/pathopt_lup_force.py +113 -0
  53. multioptpy/MEP/pathopt_neb_force.py +225 -0
  54. multioptpy/MEP/pathopt_nesb_force.py +205 -0
  55. multioptpy/MEP/pathopt_om_force.py +153 -0
  56. multioptpy/MEP/pathopt_qsm_force.py +174 -0
  57. multioptpy/MEP/pathopt_qsmv2_force.py +304 -0
  58. multioptpy/ModelFunction/__init__.py +7 -0
  59. multioptpy/ModelFunction/avoiding_model_function.py +29 -0
  60. multioptpy/ModelFunction/binary_image_ts_search_model_function.py +47 -0
  61. multioptpy/ModelFunction/conical_model_function.py +26 -0
  62. multioptpy/ModelFunction/opt_meci.py +50 -0
  63. multioptpy/ModelFunction/opt_mesx.py +47 -0
  64. multioptpy/ModelFunction/opt_mesx_2.py +49 -0
  65. multioptpy/ModelFunction/seam_model_function.py +27 -0
  66. multioptpy/ModelHessian/__init__.py +0 -0
  67. multioptpy/ModelHessian/approx_hessian.py +147 -0
  68. multioptpy/ModelHessian/calc_params.py +227 -0
  69. multioptpy/ModelHessian/fischer.py +236 -0
  70. multioptpy/ModelHessian/fischerd3.py +360 -0
  71. multioptpy/ModelHessian/fischerd4.py +398 -0
  72. multioptpy/ModelHessian/gfn0xtb.py +633 -0
  73. multioptpy/ModelHessian/gfnff.py +709 -0
  74. multioptpy/ModelHessian/lindh.py +165 -0
  75. multioptpy/ModelHessian/lindh2007d2.py +707 -0
  76. multioptpy/ModelHessian/lindh2007d3.py +822 -0
  77. multioptpy/ModelHessian/lindh2007d4.py +1030 -0
  78. multioptpy/ModelHessian/morse.py +106 -0
  79. multioptpy/ModelHessian/schlegel.py +144 -0
  80. multioptpy/ModelHessian/schlegeld3.py +322 -0
  81. multioptpy/ModelHessian/schlegeld4.py +559 -0
  82. multioptpy/ModelHessian/shortrange.py +346 -0
  83. multioptpy/ModelHessian/swartd2.py +496 -0
  84. multioptpy/ModelHessian/swartd3.py +706 -0
  85. multioptpy/ModelHessian/swartd4.py +918 -0
  86. multioptpy/ModelHessian/tshess.py +40 -0
  87. multioptpy/Optimizer/QHAdam.py +61 -0
  88. multioptpy/Optimizer/__init__.py +0 -0
  89. multioptpy/Optimizer/abc_fire.py +83 -0
  90. multioptpy/Optimizer/adabelief.py +58 -0
  91. multioptpy/Optimizer/adabound.py +68 -0
  92. multioptpy/Optimizer/adadelta.py +65 -0
  93. multioptpy/Optimizer/adaderivative.py +56 -0
  94. multioptpy/Optimizer/adadiff.py +68 -0
  95. multioptpy/Optimizer/adafactor.py +70 -0
  96. multioptpy/Optimizer/adam.py +65 -0
  97. multioptpy/Optimizer/adamax.py +62 -0
  98. multioptpy/Optimizer/adamod.py +83 -0
  99. multioptpy/Optimizer/adamw.py +65 -0
  100. multioptpy/Optimizer/adiis.py +523 -0
  101. multioptpy/Optimizer/afire_neb.py +282 -0
  102. multioptpy/Optimizer/block_hessian_update.py +709 -0
  103. multioptpy/Optimizer/c2diis.py +491 -0
  104. multioptpy/Optimizer/component_wise_scaling.py +405 -0
  105. multioptpy/Optimizer/conjugate_gradient.py +82 -0
  106. multioptpy/Optimizer/conjugate_gradient_neb.py +345 -0
  107. multioptpy/Optimizer/coordinate_locking.py +405 -0
  108. multioptpy/Optimizer/dic_rsirfo.py +1015 -0
  109. multioptpy/Optimizer/ediis.py +417 -0
  110. multioptpy/Optimizer/eve.py +76 -0
  111. multioptpy/Optimizer/fastadabelief.py +61 -0
  112. multioptpy/Optimizer/fire.py +77 -0
  113. multioptpy/Optimizer/fire2.py +249 -0
  114. multioptpy/Optimizer/fire_neb.py +92 -0
  115. multioptpy/Optimizer/gan_step.py +486 -0
  116. multioptpy/Optimizer/gdiis.py +609 -0
  117. multioptpy/Optimizer/gediis.py +203 -0
  118. multioptpy/Optimizer/geodesic_step.py +433 -0
  119. multioptpy/Optimizer/gpmin.py +633 -0
  120. multioptpy/Optimizer/gpr_step.py +364 -0
  121. multioptpy/Optimizer/gradientdescent.py +78 -0
  122. multioptpy/Optimizer/gradientdescent_neb.py +52 -0
  123. multioptpy/Optimizer/hessian_update.py +433 -0
  124. multioptpy/Optimizer/hybrid_rfo.py +998 -0
  125. multioptpy/Optimizer/kdiis.py +625 -0
  126. multioptpy/Optimizer/lars.py +21 -0
  127. multioptpy/Optimizer/lbfgs.py +253 -0
  128. multioptpy/Optimizer/lbfgs_neb.py +355 -0
  129. multioptpy/Optimizer/linesearch.py +236 -0
  130. multioptpy/Optimizer/lookahead.py +40 -0
  131. multioptpy/Optimizer/nadam.py +64 -0
  132. multioptpy/Optimizer/newton.py +200 -0
  133. multioptpy/Optimizer/prodigy.py +70 -0
  134. multioptpy/Optimizer/purtubation.py +16 -0
  135. multioptpy/Optimizer/quickmin_neb.py +245 -0
  136. multioptpy/Optimizer/radam.py +75 -0
  137. multioptpy/Optimizer/rfo_neb.py +302 -0
  138. multioptpy/Optimizer/ric_rfo.py +842 -0
  139. multioptpy/Optimizer/rl_step.py +627 -0
  140. multioptpy/Optimizer/rmspropgrave.py +65 -0
  141. multioptpy/Optimizer/rsirfo.py +1647 -0
  142. multioptpy/Optimizer/rsprfo.py +1056 -0
  143. multioptpy/Optimizer/sadam.py +60 -0
  144. multioptpy/Optimizer/samsgrad.py +63 -0
  145. multioptpy/Optimizer/tr_lbfgs.py +678 -0
  146. multioptpy/Optimizer/trim.py +273 -0
  147. multioptpy/Optimizer/trust_radius.py +207 -0
  148. multioptpy/Optimizer/trust_radius_neb.py +121 -0
  149. multioptpy/Optimizer/yogi.py +60 -0
  150. multioptpy/OtherMethod/__init__.py +0 -0
  151. multioptpy/OtherMethod/addf.py +1150 -0
  152. multioptpy/OtherMethod/dimer.py +895 -0
  153. multioptpy/OtherMethod/elastic_image_pair.py +629 -0
  154. multioptpy/OtherMethod/modelfunction.py +456 -0
  155. multioptpy/OtherMethod/newton_traj.py +454 -0
  156. multioptpy/OtherMethod/twopshs.py +1095 -0
  157. multioptpy/PESAnalyzer/__init__.py +0 -0
  158. multioptpy/PESAnalyzer/calc_irc_curvature.py +125 -0
  159. multioptpy/PESAnalyzer/cmds_analysis.py +152 -0
  160. multioptpy/PESAnalyzer/koopman_analysis.py +268 -0
  161. multioptpy/PESAnalyzer/pca_analysis.py +314 -0
  162. multioptpy/Parameters/__init__.py +0 -0
  163. multioptpy/Parameters/atomic_mass.py +20 -0
  164. multioptpy/Parameters/atomic_number.py +22 -0
  165. multioptpy/Parameters/covalent_radii.py +44 -0
  166. multioptpy/Parameters/d2.py +61 -0
  167. multioptpy/Parameters/d3.py +63 -0
  168. multioptpy/Parameters/d4.py +103 -0
  169. multioptpy/Parameters/dreiding.py +34 -0
  170. multioptpy/Parameters/gfn0xtb_param.py +137 -0
  171. multioptpy/Parameters/gfnff_param.py +315 -0
  172. multioptpy/Parameters/gnb.py +104 -0
  173. multioptpy/Parameters/parameter.py +22 -0
  174. multioptpy/Parameters/uff.py +72 -0
  175. multioptpy/Parameters/unit_values.py +20 -0
  176. multioptpy/Potential/AFIR_potential.py +55 -0
  177. multioptpy/Potential/LJ_repulsive_potential.py +345 -0
  178. multioptpy/Potential/__init__.py +0 -0
  179. multioptpy/Potential/anharmonic_keep_potential.py +28 -0
  180. multioptpy/Potential/asym_elllipsoidal_potential.py +718 -0
  181. multioptpy/Potential/electrostatic_potential.py +69 -0
  182. multioptpy/Potential/flux_potential.py +30 -0
  183. multioptpy/Potential/gaussian_potential.py +101 -0
  184. multioptpy/Potential/idpp.py +516 -0
  185. multioptpy/Potential/keep_angle_potential.py +146 -0
  186. multioptpy/Potential/keep_dihedral_angle_potential.py +105 -0
  187. multioptpy/Potential/keep_outofplain_angle_potential.py +70 -0
  188. multioptpy/Potential/keep_potential.py +99 -0
  189. multioptpy/Potential/mechano_force_potential.py +74 -0
  190. multioptpy/Potential/nanoreactor_potential.py +52 -0
  191. multioptpy/Potential/potential.py +896 -0
  192. multioptpy/Potential/spacer_model_potential.py +221 -0
  193. multioptpy/Potential/switching_potential.py +258 -0
  194. multioptpy/Potential/universal_potential.py +34 -0
  195. multioptpy/Potential/value_range_potential.py +36 -0
  196. multioptpy/Potential/void_point_potential.py +25 -0
  197. multioptpy/SQM/__init__.py +0 -0
  198. multioptpy/SQM/sqm1/__init__.py +0 -0
  199. multioptpy/SQM/sqm1/sqm1_core.py +1792 -0
  200. multioptpy/SQM/sqm2/__init__.py +0 -0
  201. multioptpy/SQM/sqm2/calc_tools.py +95 -0
  202. multioptpy/SQM/sqm2/sqm2_basis.py +850 -0
  203. multioptpy/SQM/sqm2/sqm2_bond.py +119 -0
  204. multioptpy/SQM/sqm2/sqm2_core.py +303 -0
  205. multioptpy/SQM/sqm2/sqm2_data.py +1229 -0
  206. multioptpy/SQM/sqm2/sqm2_disp.py +65 -0
  207. multioptpy/SQM/sqm2/sqm2_eeq.py +243 -0
  208. multioptpy/SQM/sqm2/sqm2_overlapint.py +704 -0
  209. multioptpy/SQM/sqm2/sqm2_qm.py +578 -0
  210. multioptpy/SQM/sqm2/sqm2_rep.py +66 -0
  211. multioptpy/SQM/sqm2/sqm2_srb.py +70 -0
  212. multioptpy/Thermo/__init__.py +0 -0
  213. multioptpy/Thermo/normal_mode_analyzer.py +865 -0
  214. multioptpy/Utils/__init__.py +0 -0
  215. multioptpy/Utils/bond_connectivity.py +264 -0
  216. multioptpy/Utils/calc_tools.py +884 -0
  217. multioptpy/Utils/oniom.py +96 -0
  218. multioptpy/Utils/pbc.py +48 -0
  219. multioptpy/Utils/riemann_curvature.py +208 -0
  220. multioptpy/Utils/symmetry_analyzer.py +482 -0
  221. multioptpy/Visualization/__init__.py +0 -0
  222. multioptpy/Visualization/visualization.py +156 -0
  223. multioptpy/WFAnalyzer/MO_analysis.py +104 -0
  224. multioptpy/WFAnalyzer/__init__.py +0 -0
  225. multioptpy/Wrapper/__init__.py +0 -0
  226. multioptpy/Wrapper/autots.py +1239 -0
  227. multioptpy/Wrapper/ieip_wrapper.py +93 -0
  228. multioptpy/Wrapper/md_wrapper.py +92 -0
  229. multioptpy/Wrapper/neb_wrapper.py +94 -0
  230. multioptpy/Wrapper/optimize_wrapper.py +76 -0
  231. multioptpy/__init__.py +5 -0
  232. multioptpy/entrypoints.py +916 -0
  233. multioptpy/fileio.py +660 -0
  234. multioptpy/ieip.py +340 -0
  235. multioptpy/interface.py +1086 -0
  236. multioptpy/irc.py +529 -0
  237. multioptpy/moleculardynamics.py +432 -0
  238. multioptpy/neb.py +1267 -0
  239. multioptpy/optimization.py +1553 -0
  240. multioptpy/optimizer.py +709 -0
  241. multioptpy-1.20.2.dist-info/METADATA +438 -0
  242. multioptpy-1.20.2.dist-info/RECORD +246 -0
  243. multioptpy-1.20.2.dist-info/WHEEL +5 -0
  244. multioptpy-1.20.2.dist-info/entry_points.txt +9 -0
  245. multioptpy-1.20.2.dist-info/licenses/LICENSE +674 -0
  246. multioptpy-1.20.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,896 @@
1
+
2
+ from multioptpy.Parameters.parameter import UnitValueLib
3
+ from multioptpy.fileio import save_bias_pot_info, save_bias_param_grad_info
4
+
5
+ import numpy as np
6
+ import copy
7
+ import random
8
+ import torch
9
+ import re
10
+
11
+ from multioptpy.Potential.LJ_repulsive_potential import LJRepulsivePotentialCone, LJRepulsivePotentialGaussian, LJRepulsivePotentialv2Value, LJRepulsivePotentialv2Scale, LJRepulsivePotentialValue, LJRepulsivePotentialScale
12
+ from multioptpy.Potential.AFIR_potential import AFIRPotential
13
+ from multioptpy.Potential.keep_potential import StructKeepPotential, StructKeepPotentialv2
14
+ from multioptpy.Potential.anharmonic_keep_potential import StructAnharmonicKeepPotential
15
+ from multioptpy.Potential.keep_angle_potential import StructKeepAnglePotential, StructKeepAnglePotentialv2
16
+ from multioptpy.Potential.keep_dihedral_angle_potential import StructKeepDihedralAnglePotential, StructKeepDihedralAnglePotentialv2, StructKeepDihedralAnglePotentialCos
17
+ from multioptpy.Potential.keep_outofplain_angle_potential import StructKeepOutofPlainAnglePotential, StructKeepOutofPlainAnglePotentialv2
18
+ from multioptpy.Potential.void_point_potential import VoidPointPotential
19
+ from multioptpy.Potential.switching_potential import WellPotential, WellPotentialAround, WellPotentialVP, WellPotentialWall
20
+ from multioptpy.Potential.gaussian_potential import GaussianPotential
21
+ from multioptpy.Potential.spacer_model_potential import SpacerModelPotential
22
+ from multioptpy.Potential.universal_potential import UniversalPotential
23
+ from multioptpy.Potential.flux_potential import FluxPotential
24
+ from multioptpy.Potential.value_range_potential import ValueRangePotential
25
+ from multioptpy.Potential.mechano_force_potential import LinearMechanoForcePotential, LinearMechanoForcePotentialv2
26
+ from multioptpy.Potential.asym_elllipsoidal_potential import AsymmetricEllipsoidalLJPotential, AsymmetricEllipsoidalLJPotentialv2
27
+ from multioptpy.Potential.nanoreactor_potential import NanoReactorPotential
28
+
29
+ class BiasPotentialCalculation:
30
+ def __init__(self, FOLDER_DIRECTORY="./"):
31
+ torch.set_printoptions(precision=12)
32
+ UVL = UnitValueLib()
33
+ self.hartree2kcalmol = UVL.hartree2kcalmol #
34
+ self.bohr2angstroms = UVL.bohr2angstroms #
35
+ self.hartree2kjmol = UVL.hartree2kjmol #
36
+ self.JOBID = random.randint(0, 1000000)
37
+ self.microiteration_num = 300
38
+ self.rand_search_num = 800
39
+ self.BPA_FOLDER_DIRECTORY = FOLDER_DIRECTORY
40
+ self.metaD_history_list = None
41
+ self.miter_delta = 1.0
42
+ self.mi_bias_pot_obj_list = []
43
+ self.mi_bias_pot_obj_id_list = []
44
+ self.mi_bias_pot_params_list = []
45
+ self.bias_pot_params_grad_list = None
46
+ self.bias_pot_params_grad_name_list = None
47
+ self.bias_pot_prev_ene_list = []
48
+ self.bias_pot_obj_list = []
49
+ self.bias_pot_obj_id_list = []
50
+ self.bias_pot_params_list = []
51
+ self.numerical_derivative_delta = 1e-5 #unit:Bohr
52
+
53
+ def main(self, e, g, geom_num_list, element_list, force_data, pre_B_g="", iter="", initial_geom_num_list=""):
54
+ #g:hartree/Bohr
55
+ #e:hartree
56
+ #geom_num_list:Bohr
57
+ tmp_bias_pot_params_grad_list = []
58
+ tmp_bias_pot_params_grad_name_list = []
59
+ change_param_flag = []
60
+ #--------------------------------------------------
61
+ B_e = torch.tensor(0.0, dtype=torch.float64)
62
+ BPA_grad_list = g*0.0
63
+ BPA_hessian = np.zeros((3*len(g), 3*len(g)))
64
+ geom_num_list = ndarray2tensor(geom_num_list)
65
+ #------------------------------------------------
66
+
67
+ if iter == 0 or iter == "":
68
+ self.bias_pot_obj_list, self.bias_pot_obj_id_list, self.bias_pot_params_list = make_bias_pot_obj_list(force_data, element_list, self.BPA_FOLDER_DIRECTORY, self.JOBID, geom_num_list, iter)
69
+ self.mi_bias_pot_obj_list, self.mi_bias_pot_obj_id_list, self.mi_bias_pot_params_list = make_micro_iter_bias_pot_obj_list(force_data, element_list, self.BPA_FOLDER_DIRECTORY, self.JOBID, geom_num_list, iter)
70
+ self.bias_pot_prev_ene_list = [np.inf for i in range(len(self.bias_pot_obj_id_list))]
71
+
72
+
73
+ ####------------------
74
+ # For meta-dynamics
75
+ ####------------------
76
+ # caution : This potential is not for geometry optimization.
77
+ if len(force_data["gaussian_potential_target"]) > 0:
78
+ if self.metaD_history_list is None:
79
+ self.metaD_history_list = [[] for i in range(len(force_data["gaussian_potential_target"]))]
80
+ prev_metaD_history_list = self.metaD_history_list
81
+ METAD = GaussianPotential(gaussian_potential_target=force_data["gaussian_potential_target"],
82
+ gaussian_potential_height=force_data["gaussian_potential_height"],
83
+ gaussian_potential_width=force_data["gaussian_potential_width"],
84
+ gaussian_potential_tgt_atom=force_data["gaussian_potential_tgt_atom"])
85
+ METAD.history_list = prev_metaD_history_list
86
+
87
+ B_e += METAD.calc_energy_for_metadyn(geom_num_list)
88
+
89
+ tensor_BPA_grad = torch.func.jacfwd(METAD.calc_energy_for_metadyn)(geom_num_list)
90
+ BPA_grad_list += tensor2ndarray(tensor_BPA_grad)
91
+
92
+ tensor_BPA_hessian = torch.func.hessian(METAD.calc_energy_for_metadyn)(geom_num_list)
93
+ tensor_BPA_hessian = torch.reshape(tensor_BPA_hessian, (len(geom_num_list)*3, len(geom_num_list)*3))
94
+ BPA_hessian += tensor2ndarray(tensor_BPA_hessian)
95
+
96
+ self.metaD_history_list = METAD.history_list
97
+
98
+
99
+
100
+ ###-----------------
101
+ # For ab initio nano-reactor (ref.:https://doi.org/10.1038/nchem.2099, https://doi.org/10.1021/acs.jctc.4c00826)
102
+ ###-----------------
103
+ # caution : This potential is not for geometry optimization.
104
+ if len(force_data["nano_reactor_potential"]) > 0:
105
+ time = torch.tensor([iter], dtype=torch.float64)
106
+ NRP = NanoReactorPotential(inner_wall=force_data["nano_reactor_potential"][0][0],
107
+ outer_wall=force_data["nano_reactor_potential"][0][1],
108
+ contraction_time=force_data["nano_reactor_potential"][0][2],
109
+ expansion_time=force_data["nano_reactor_potential"][0][3],
110
+ contraction_force_const=force_data["nano_reactor_potential"][0][4],
111
+ expansion_force_const=force_data["nano_reactor_potential"][0][5],
112
+ element_list=element_list,)
113
+ B_e += NRP.calc_energy(geom_num_list, time)
114
+
115
+ tensor_BPA_grad = torch.func.jacfwd(NRP.calc_energy)(geom_num_list, time)
116
+ BPA_grad_list += tensor2ndarray(tensor_BPA_grad)
117
+
118
+ tensor_BPA_hessian = torch.func.hessian(NRP.calc_energy)(geom_num_list, time)
119
+ tensor_BPA_hessian = torch.reshape(tensor_BPA_hessian, (len(geom_num_list)*3, len(geom_num_list)*3))
120
+ BPA_hessian += tensor2ndarray(tensor_BPA_hessian)
121
+
122
+
123
+
124
+ ###-----------------
125
+ # combine almost all the bias potentials
126
+ ###-----------------
127
+ for j in range(len(self.bias_pot_obj_list)):
128
+ tmp_bias_pot_params = self.bias_pot_params_list[j]
129
+
130
+ tmp_B_e = self.bias_pot_obj_list[j].calc_energy(geom_num_list, tmp_bias_pot_params)
131
+ tmp_tensor_BPA_grad = torch.func.jacrev(self.bias_pot_obj_list[j].calc_energy, argnums=0)(geom_num_list, tmp_bias_pot_params)
132
+ tmp_tensor_BPA_grad = tensor2ndarray(tmp_tensor_BPA_grad)
133
+ tmp_tensor_BPA_hessian = torch.func.hessian(self.bias_pot_obj_list[j].calc_energy, argnums=0)(geom_num_list, tmp_bias_pot_params)
134
+ tmp_tensor_BPA_hessian = torch.reshape(tmp_tensor_BPA_hessian, (len(geom_num_list)*3, len(geom_num_list)*3))
135
+ tmp_tensor_BPA_hessian = tensor2ndarray(tmp_tensor_BPA_hessian)
136
+ if len(tmp_bias_pot_params) > 0:
137
+ results = torch.func.jacrev(self.bias_pot_obj_list[j].calc_energy, argnums=1)(geom_num_list, tmp_bias_pot_params)
138
+ results = tensor2ndarray(results)
139
+ print(self.bias_pot_obj_id_list[j],":dE_bias_pot/d_param: ", results)
140
+ save_bias_param_grad_info(self.BPA_FOLDER_DIRECTORY, results, self.bias_pot_obj_id_list[j])
141
+ tmp_bias_pot_params_grad_list.append(results)
142
+ tmp_bias_pot_params_grad_name_list.append(self.bias_pot_obj_id_list[j])
143
+
144
+ save_bias_pot_info(self.BPA_FOLDER_DIRECTORY, tmp_B_e.item(), tmp_tensor_BPA_grad, self.bias_pot_obj_id_list[j])
145
+
146
+ change_param_flag.append(False)
147
+
148
+ self.bias_pot_prev_ene_list[j] = tmp_B_e.item()
149
+
150
+ B_e = B_e + tmp_B_e
151
+ BPA_grad_list = BPA_grad_list + tmp_tensor_BPA_grad
152
+ BPA_hessian = BPA_hessian + tmp_tensor_BPA_hessian
153
+
154
+
155
+ self.bias_pot_obj_list, self.bias_pot_obj_id_list, self.bias_pot_params_list = change_bias_pot_params(force_data, self.bias_pot_obj_list, self.bias_pot_obj_id_list, self.bias_pot_params_list, geom_num_list, iter, change_param_flag, tmp_bias_pot_params_grad_list)
156
+
157
+ ###-----------------
158
+ # combine the bias potentials using microiteration
159
+ ###-----------------
160
+ for j in range(len(self.mi_bias_pot_obj_list)):
161
+ tmp_bias_pot_params = self.mi_bias_pot_params_list[j]
162
+
163
+ tmp_B_e = self.mi_bias_pot_obj_list[j].calc_energy(geom_num_list, tmp_bias_pot_params)
164
+ tmp_tensor_BPA_grad = torch.func.jacrev(self.mi_bias_pot_obj_list[j].calc_energy, argnums=0)(geom_num_list, tmp_bias_pot_params)
165
+ tmp_tensor_BPA_grad = tensor2ndarray(tmp_tensor_BPA_grad)
166
+ tmp_tensor_BPA_hessian = torch.func.hessian(self.mi_bias_pot_obj_list[j].calc_energy, argnums=0)(geom_num_list, tmp_bias_pot_params)
167
+ tmp_tensor_BPA_hessian = torch.reshape(tmp_tensor_BPA_hessian, (len(geom_num_list)*3, len(geom_num_list)*3))
168
+ tmp_tensor_BPA_hessian = tensor2ndarray(tmp_tensor_BPA_hessian)
169
+ if len(tmp_bias_pot_params) > 0:
170
+ results = torch.func.jacrev(self.mi_bias_pot_obj_list[j].calc_energy, argnums=1)(geom_num_list, tmp_bias_pot_params)
171
+ results = tensor2ndarray(results)
172
+ print(self.mi_bias_pot_obj_id_list[j],":dE_bias_pot/d_param: ", results)
173
+ save_bias_param_grad_info(self.BPA_FOLDER_DIRECTORY, results, self.mi_bias_pot_obj_id_list[j])
174
+ tmp_bias_pot_params_grad_list.append(results)
175
+ tmp_bias_pot_params_grad_name_list.append(self.mi_bias_pot_obj_id_list[j])
176
+
177
+ save_bias_pot_info(self.BPA_FOLDER_DIRECTORY, tmp_B_e.item(), tmp_tensor_BPA_grad, self.mi_bias_pot_obj_id_list[j])
178
+
179
+
180
+ #self.mi_bias_pot_obj_list, self.mi_bias_pot_obj_id_list, self.mi_bias_pot_params_list = change_bias_pot_params(force_data, self.mi_bias_pot_obj_list, self.mi_bias_pot_obj_id_list, self.mi_bias_pot_params_list, geom_num_list, iter)
181
+ B_e = B_e + tmp_B_e
182
+ BPA_grad_list = BPA_grad_list + tmp_tensor_BPA_grad
183
+ BPA_hessian = BPA_hessian + tmp_tensor_BPA_hessian
184
+ # calculate effective hessian (ref.: https://doi.org/10.1021/ct9003383)
185
+ eff_hess = self.mi_bias_pot_obj_list[j].calc_eff_hessian(geom_num_list, tmp_bias_pot_params)
186
+ eff_hess = tensor2ndarray(eff_hess)
187
+ BPA_hessian = BPA_hessian + eff_hess
188
+ self.mi_bias_pot_obj_list[j].save_state()
189
+
190
+
191
+
192
+
193
+ B_g = g + BPA_grad_list
194
+ B_e = B_e.item() + e
195
+ #new_geometry:ang.
196
+ #B_e:hartree
197
+
198
+ self.bias_pot_params_grad_list = tmp_bias_pot_params_grad_list
199
+ self.bias_pot_params_grad_name_list = tmp_bias_pot_params_grad_name_list
200
+
201
+ return BPA_grad_list, B_e, B_g, BPA_hessian
202
+
203
+ def ndarray2tensor(ndarray):
204
+ tensor = copy.copy(torch.tensor(ndarray, dtype=torch.float64, requires_grad=True))
205
+
206
+ return tensor
207
+
208
+ def ndarray2nogradtensor(ndarray):
209
+ tensor = copy.copy(torch.tensor(ndarray, dtype=torch.float64))
210
+
211
+ return tensor
212
+
213
+ def tensor2ndarray(tensor):
214
+ ndarray = copy.copy(tensor.detach().numpy())
215
+ return ndarray
216
+
217
+ def gradually_change_param(param_1, param_2, iter):
218
+ partition = 300
219
+ parameter = param_1 + ((param_2 - param_1)/partition) * int(iter)
220
+ if param_1 < param_2:
221
+ return min(parameter, param_2)
222
+ elif param_1 > param_2:
223
+ return max(parameter, param_2)
224
+ else:
225
+ return parameter
226
+
227
+ def make_micro_iter_bias_pot_obj_list(force_data, element_list, file_directory, JOBID, geom_num_list, iter):
228
+ bias_pot_obj_list = []
229
+ bias_pot_obj_id_list = []
230
+ bias_pot_params_list = []
231
+ if len(force_data["asymmetric_ellipsoidal_repulsive_potential_eps"]) > 0:
232
+ AERP = AsymmetricEllipsoidalLJPotential(asymmetric_ellipsoidal_repulsive_potential_eps=force_data["asymmetric_ellipsoidal_repulsive_potential_eps"],
233
+ asymmetric_ellipsoidal_repulsive_potential_sig=force_data["asymmetric_ellipsoidal_repulsive_potential_sig"],
234
+ asymmetric_ellipsoidal_repulsive_potential_dist=force_data["asymmetric_ellipsoidal_repulsive_potential_dist"],
235
+ asymmetric_ellipsoidal_repulsive_potential_atoms=force_data["asymmetric_ellipsoidal_repulsive_potential_atoms"],
236
+ asymmetric_ellipsoidal_repulsive_potential_offtgt=force_data["asymmetric_ellipsoidal_repulsive_potential_offtgt"],
237
+ element_list=element_list,
238
+ file_directory=file_directory)
239
+
240
+ bias_pot_params = []
241
+
242
+ for j in range(len(force_data["asymmetric_ellipsoidal_repulsive_potential_eps"])):
243
+ tmp_list = [force_data["asymmetric_ellipsoidal_repulsive_potential_eps"][j]] + force_data["asymmetric_ellipsoidal_repulsive_potential_sig"][j] + [force_data["asymmetric_ellipsoidal_repulsive_potential_dist"][j]]
244
+ bias_pot_params.append(tmp_list)
245
+
246
+
247
+ bias_pot_params = torch.tensor(bias_pot_params, requires_grad=True, dtype=torch.float64)
248
+
249
+ bias_pot_obj_list.append(AERP)
250
+ bias_pot_obj_id_list.append("asymmetric_ellipsoidal_repulsive_potential")
251
+ bias_pot_params_list.append(bias_pot_params)
252
+
253
+ if len(force_data["asymmetric_ellipsoidal_repulsive_potential_v2_eps"]) > 0:
254
+ AERP2 = AsymmetricEllipsoidalLJPotentialv2(asymmetric_ellipsoidal_repulsive_potential_v2_eps=force_data["asymmetric_ellipsoidal_repulsive_potential_v2_eps"],
255
+ asymmetric_ellipsoidal_repulsive_potential_v2_sig=force_data["asymmetric_ellipsoidal_repulsive_potential_v2_sig"],
256
+ asymmetric_ellipsoidal_repulsive_potential_v2_dist=force_data["asymmetric_ellipsoidal_repulsive_potential_v2_dist"],
257
+ asymmetric_ellipsoidal_repulsive_potential_v2_atoms=force_data["asymmetric_ellipsoidal_repulsive_potential_v2_atoms"],
258
+ asymmetric_ellipsoidal_repulsive_potential_v2_offtgt=force_data["asymmetric_ellipsoidal_repulsive_potential_v2_offtgt"],
259
+ element_list=element_list,
260
+ file_directory=file_directory)
261
+
262
+ bias_pot_params = []
263
+
264
+ for j in range(len(force_data["asymmetric_ellipsoidal_repulsive_potential_v2_eps"])):
265
+ tmp_list = [force_data["asymmetric_ellipsoidal_repulsive_potential_v2_eps"][j]] + force_data["asymmetric_ellipsoidal_repulsive_potential_v2_sig"][j] + [force_data["asymmetric_ellipsoidal_repulsive_potential_v2_dist"][j]]
266
+ bias_pot_params.append(tmp_list)
267
+
268
+
269
+ bias_pot_params = torch.tensor(bias_pot_params, requires_grad=True, dtype=torch.float64)
270
+
271
+ bias_pot_obj_list.append(AERP2)
272
+ bias_pot_obj_id_list.append("asymmetric_ellipsoidal_repulsive_potential_v2")
273
+ bias_pot_params_list.append(bias_pot_params)
274
+
275
+
276
+ for i in range(len(force_data["spacer_model_potential_well_depth"])):
277
+
278
+ if force_data["spacer_model_potential_well_depth"][i] != 0.0:
279
+ SMP = SpacerModelPotential(spacer_model_potential_target=force_data["spacer_model_potential_target"][i],
280
+ spacer_model_potential_distance=force_data["spacer_model_potential_distance"][i],
281
+ spacer_model_potential_well_depth=force_data["spacer_model_potential_well_depth"][i],
282
+ spacer_model_potential_cavity_scaling=force_data["spacer_model_potential_cavity_scaling"][i],
283
+ spacer_model_potential_particle_number=force_data["spacer_model_potential_particle_number"][i],
284
+ element_list=element_list,
285
+ directory=file_directory)
286
+ bias_pot_params = []
287
+ bias_pot_obj_list.append(SMP)
288
+ bias_pot_obj_id_list.append("spacer_model_potential_"+str(i))
289
+ bias_pot_params_list.append(bias_pot_params)
290
+
291
+
292
+ return bias_pot_obj_list, bias_pot_obj_id_list, bias_pot_params_list
293
+
294
+
295
+ def change_bias_pot_params(force_data, bias_pot_obj_list, bias_pot_obj_id_list, bias_pot_params_list, geom_num_list, iter, change_param_flag, tmp_bias_pot_params_grad_list):
296
+ def process_AFIR_pot(k):
297
+
298
+ gamma_data = force_data["AFIR_gamma"][k]
299
+ AFIR_gamma_tmp = (
300
+ gradually_change_param(gamma_data[0], gamma_data[1], iter)
301
+ if len(gamma_data) == 2 and iter != ""
302
+ else gamma_data[0]
303
+ )
304
+
305
+ print(AFIR_gamma_tmp)
306
+
307
+ return torch.tensor([AFIR_gamma_tmp], requires_grad=True, dtype=torch.float64)
308
+
309
+ def process_keep_pot_v2(k):
310
+ spring_data = force_data["keep_pot_v2_spring_const"][k]
311
+ distance_data = force_data["keep_pot_v2_distance"][k]
312
+
313
+ spring_const_tmp = (
314
+ gradually_change_param(spring_data[0], spring_data[1], iter)
315
+ if len(spring_data) == 2 and iter != ""
316
+ else spring_data[0]
317
+ )
318
+ dist_tmp = (
319
+ gradually_change_param(distance_data[0], distance_data[1], iter)
320
+ if len(distance_data) == 2 and iter != ""
321
+ else distance_data[0]
322
+ )
323
+
324
+ print(spring_const_tmp, dist_tmp)
325
+ return torch.tensor([spring_const_tmp, dist_tmp], requires_grad=True, dtype=torch.float64)
326
+
327
+ def process_keep_angle_v2(k):
328
+ spring_data = force_data["keep_angle_v2_spring_const"][k]
329
+ angle_data = force_data["keep_angle_v2_angle"][k]
330
+
331
+ spring_const_tmp = (
332
+ gradually_change_param(spring_data[0], spring_data[1], iter)
333
+ if len(spring_data) == 2 and iter != ""
334
+ else spring_data[0]
335
+ )
336
+ angle_tmp = (
337
+ gradually_change_param(angle_data[0], angle_data[1], iter)
338
+ if len(angle_data) == 2 and iter != ""
339
+ else angle_data[0]
340
+ )
341
+
342
+ print(spring_const_tmp, angle_tmp)
343
+ return torch.tensor([spring_const_tmp, angle_tmp], requires_grad=True, dtype=torch.float64)
344
+
345
+ def process_keep_dihedral_angle_v2(k):
346
+ spring_data = force_data["keep_dihedral_angle_v2_spring_const"][k]
347
+ angle_data = force_data["keep_dihedral_angle_v2_angle"][k]
348
+
349
+ spring_const_tmp = (
350
+ gradually_change_param(spring_data[0], spring_data[1], iter)
351
+ if len(spring_data) == 2 and iter != ""
352
+ else spring_data[0]
353
+ )
354
+ angle_tmp = (
355
+ gradually_change_param(angle_data[0], angle_data[1], iter)
356
+ if len(angle_data) == 2 and iter != ""
357
+ else angle_data[0]
358
+ )
359
+
360
+ print(spring_const_tmp, angle_tmp)
361
+ return torch.tensor([spring_const_tmp, angle_tmp], requires_grad=True, dtype=torch.float64)
362
+
363
+ def process_keep_dihedral_angle_cos(k):
364
+ potential_const_data = force_data["keep_dihedral_angle_cos_potential_const"][k]
365
+ angle_const_data = force_data["keep_dihedral_angle_cos_angle_const"][k]
366
+ angle_data = force_data["keep_dihedral_angle_cos_angle"][k]
367
+
368
+ potential_const_tmp = (
369
+ gradually_change_param(potential_const_data[0], potential_const_data[1], iter)
370
+ if len(potential_const_data) == 2 and iter != ""
371
+ else potential_const_data[0]
372
+ )
373
+ angle_const_tmp = (
374
+ gradually_change_param(angle_const_data[0], angle_const_data[1], iter)
375
+ if len(angle_const_data) == 2 and iter != ""
376
+ else angle_const_data[0]
377
+ )
378
+ angle_tmp = (
379
+ gradually_change_param(angle_data[0], angle_data[1], iter)
380
+ if len(angle_data) == 2 and iter != ""
381
+ else angle_data[0]
382
+ )
383
+
384
+ print(potential_const_tmp, angle_const_tmp, angle_tmp)
385
+ return torch.tensor([potential_const_tmp, angle_const_tmp, angle_tmp], requires_grad=True, dtype=torch.float64)
386
+
387
+ def process_keep_out_of_plain_angle_v2(k):
388
+ spring_data = force_data["keep_out_of_plain_angle_v2_spring_const"][k]
389
+ angle_data = force_data["keep_out_of_plain_angle_v2_angle"][k]
390
+
391
+ spring_const_tmp = (
392
+ gradually_change_param(spring_data[0], spring_data[1], iter)
393
+ if len(spring_data) == 2 and iter != ""
394
+ else spring_data[0]
395
+ )
396
+ angle_tmp = (
397
+ gradually_change_param(angle_data[0], angle_data[1], iter)
398
+ if len(angle_data) == 2 and iter != ""
399
+ else angle_data[0]
400
+ )
401
+
402
+ print(spring_const_tmp, angle_tmp)
403
+ return torch.tensor([spring_const_tmp, angle_tmp], requires_grad=True, dtype=torch.float64)
404
+
405
+ def process_default():
406
+ pass # Do nothing for unsupported patterns
407
+
408
+ pattern_to_function = {
409
+ r"AFIR_pot_\d+": process_AFIR_pot,
410
+ r"keep_pot_v2_\d+": process_keep_pot_v2,
411
+ r"keep_angle_v2_\d+": process_keep_angle_v2,
412
+ r"keep_dihedral_angle_v2_\d+": process_keep_dihedral_angle_v2,
413
+ r"keep_dihedral_angle_cos_\d+": process_keep_dihedral_angle_cos,
414
+ r"keep_out_of_plain_angle_v2_\d+": process_keep_out_of_plain_angle_v2,
415
+ # Add patterns here for other types if needed
416
+ }
417
+
418
+ for i, bias_pot_obj_id in enumerate(bias_pot_obj_id_list):
419
+ matched = False
420
+ for pattern, func in pattern_to_function.items():
421
+ if re.match(pattern, bias_pot_obj_id):
422
+ extracted = re.findall(r'_[0-9]+', bias_pot_obj_id)[0]
423
+ num = int(extracted[1:])
424
+ bias_pot_params_list[i] = func(num)
425
+ matched = True
426
+ break
427
+ if not matched:
428
+ process_default()
429
+
430
+ return bias_pot_obj_list, bias_pot_obj_id_list, bias_pot_params_list
431
+
432
+
433
+ def make_bias_pot_obj_list(force_data, element_list, file_directory, JOBID, geom_num_list, iter):
434
+ bias_pot_obj_list = []
435
+ bias_pot_obj_id_list = []
436
+ bias_pot_params_list = []
437
+
438
+
439
+ for i in range(len(force_data["linear_mechano_force"])):
440
+ if force_data["linear_mechano_force"][i] != 0.0:
441
+ LMF = LinearMechanoForcePotential(linear_mechano_force=force_data["linear_mechano_force"][i],
442
+ linear_mechano_force_atoms_1=force_data["linear_mechano_force_atoms_1"][i],
443
+ linear_mechano_force_atoms_2=force_data["linear_mechano_force_atoms_2"][i],
444
+ element_list=element_list)
445
+ bias_pot_params = torch.tensor([force_data["linear_mechano_force"][i]], requires_grad=True, dtype=torch.float64)
446
+ bias_pot_obj_list.append(LMF)
447
+ bias_pot_obj_id_list.append("linear_mechano_force_"+str(i))
448
+ bias_pot_params_list.append(bias_pot_params)
449
+
450
+ else:
451
+ pass
452
+
453
+ for i in range(len(force_data["linear_mechano_force_v2"])):
454
+ if force_data["linear_mechano_force_v2"][i] != 0.0:
455
+ LMF2 = LinearMechanoForcePotentialv2(linear_mechano_force_v2=force_data["linear_mechano_force_v2"][i],
456
+ linear_mechano_force_atom_v2=force_data["linear_mechano_force_atom_v2"][i],
457
+ element_list=element_list)
458
+ bias_pot_params = torch.tensor([force_data["linear_mechano_force_v2"][i]], requires_grad=True, dtype=torch.float64)
459
+ bias_pot_obj_list.append(LMF2)
460
+ bias_pot_obj_id_list.append("linear_mechano_force_v2_"+str(i))
461
+ bias_pot_params_list.append(bias_pot_params)
462
+
463
+ else:
464
+ pass
465
+
466
+
467
+ for i in range(len(force_data["AFIR_gamma"])):
468
+ if not 0.0 in force_data["AFIR_gamma"][i]:
469
+ if len(force_data["AFIR_gamma"][i]) == 2 and iter != "":
470
+ AFIR_gamma_tmp = gradually_change_param(force_data["AFIR_gamma"][i][0], force_data["AFIR_gamma"][i][1], iter)
471
+ print(AFIR_gamma_tmp)
472
+ else:
473
+ AFIR_gamma_tmp = force_data["AFIR_gamma"][i][0]
474
+
475
+ bias_pot_params = torch.tensor([AFIR_gamma_tmp], requires_grad=True, dtype=torch.float64)
476
+
477
+ AP = AFIRPotential(AFIR_Fragm_1=force_data["AFIR_Fragm_1"][i],
478
+ AFIR_Fragm_2=force_data["AFIR_Fragm_2"][i],
479
+ element_list=element_list)
480
+ bias_pot_obj_list.append(AP)
481
+ bias_pot_obj_id_list.append("AFIR_pot_"+str(i))
482
+ bias_pot_params_list.append(bias_pot_params)
483
+
484
+ for i in range(len(force_data["flux_pot_const"])):
485
+
486
+ FP = FluxPotential(flux_pot_const=force_data["flux_pot_const"][i],
487
+ flux_pot_target=force_data["flux_pot_target"][i],
488
+ flux_pot_order=force_data["flux_pot_order"][i],
489
+ flux_pot_direction=force_data["flux_pot_direction"][i],
490
+ element_list=element_list,
491
+ directory=file_directory)
492
+
493
+ bias_pot_obj_list.append(FP)
494
+ bias_pot_obj_id_list.append("flux_pot_"+str(i))
495
+ bias_pot_params_list.append([])
496
+
497
+ for i in range(len(force_data["value_range_upper_const"])):
498
+ if force_data["value_range_upper_const"][i] != 0.0:
499
+ VRP = ValueRangePotential(value_range_upper_const=force_data["value_range_upper_const"][i],
500
+ value_range_lower_const=force_data["value_range_lower_const"][i],
501
+ value_range_upper_distance=force_data["value_range_upper_distance"][i],
502
+ value_range_lower_distance=force_data["value_range_lower_distance"][i],
503
+ value_range_fragm_1=force_data["value_range_fragm_1"][i],
504
+ value_range_fragm_2=force_data["value_range_fragm_2"][i],
505
+ element_list=element_list,
506
+ directory=file_directory)
507
+
508
+
509
+ bias_pot_obj_list.append(VRP)
510
+ bias_pot_obj_id_list.append("value_range_pot_"+str(i))
511
+ bias_pot_params_list.append([])
512
+ else:
513
+ pass
514
+
515
+ for i in range(len(force_data["universal_pot_const"])):
516
+ if force_data["universal_pot_const"][i] != 0.0:
517
+ UP = UniversalPotential(universal_pot_const=force_data["universal_pot_const"][i],
518
+ universal_pot_target=force_data["universal_pot_target"][i],
519
+ element_list=element_list,
520
+ directory=file_directory)
521
+
522
+
523
+ bias_pot_obj_list.append(UP)
524
+ bias_pot_obj_id_list.append("universal_pot_"+str(i))
525
+ bias_pot_params_list.append([])
526
+ else:
527
+ pass
528
+
529
+ for i in range(len(force_data["repulsive_potential_v2_well_scale"])):
530
+ if force_data["repulsive_potential_v2_well_scale"][i] != 0.0:
531
+ if force_data["repulsive_potential_v2_unit"][i] == "scale":
532
+ LJRP = LJRepulsivePotentialv2Scale(repulsive_potential_v2_well_scale=force_data["repulsive_potential_v2_well_scale"][i],
533
+ repulsive_potential_v2_dist_scale=force_data["repulsive_potential_v2_dist_scale"][i],
534
+ repulsive_potential_v2_length=force_data["repulsive_potential_v2_length"][i],
535
+ repulsive_potential_v2_const_rep=force_data["repulsive_potential_v2_const_rep"][i],
536
+ repulsive_potential_v2_const_attr=force_data["repulsive_potential_v2_const_attr"][i],
537
+ repulsive_potential_v2_order_rep=force_data["repulsive_potential_v2_order_rep"][i],
538
+ repulsive_potential_v2_order_attr=force_data["repulsive_potential_v2_order_attr"][i],
539
+ repulsive_potential_v2_center=force_data["repulsive_potential_v2_center"][i],
540
+ repulsive_potential_v2_target=force_data["repulsive_potential_v2_target"][i],
541
+ element_list=element_list,
542
+ jobid=JOBID)
543
+
544
+
545
+ bias_pot_obj_list.append(LJRP)
546
+ bias_pot_obj_id_list.append("repulsive_pot_v2_scale_"+str(i))
547
+ bias_pot_params_list.append([])
548
+
549
+ elif force_data["repulsive_potential_v2_unit"][i] == "value":
550
+ LJRP = LJRepulsivePotentialv2Value(repulsive_potential_v2_well_value=force_data["repulsive_potential_v2_well_scale"][i],
551
+ repulsive_potential_v2_dist_value=force_data["repulsive_potential_v2_dist_scale"][i],
552
+ repulsive_potential_v2_length=force_data["repulsive_potential_v2_length"][i],
553
+ repulsive_potential_v2_const_rep=force_data["repulsive_potential_v2_const_rep"][i],
554
+ repulsive_potential_v2_const_attr=force_data["repulsive_potential_v2_const_attr"][i],
555
+ repulsive_potential_v2_order_rep=force_data["repulsive_potential_v2_order_rep"][i],
556
+ repulsive_potential_v2_order_attr=force_data["repulsive_potential_v2_order_attr"][i],
557
+ repulsive_potential_v2_center=force_data["repulsive_potential_v2_center"][i],
558
+ repulsive_potential_v2_target=force_data["repulsive_potential_v2_target"][i],
559
+ element_list=element_list,
560
+ jobid=JOBID)
561
+
562
+
563
+ bias_pot_obj_list.append(LJRP)
564
+ bias_pot_obj_id_list.append("repulsive_pot_v2_value_"+str(i))
565
+ bias_pot_params_list.append([])
566
+
567
+ else:
568
+ print("error -rpv2")
569
+ raise "error -rpv2"
570
+ else:
571
+ pass
572
+
573
+ for i in range(len(force_data["repulsive_potential_dist_scale"])):
574
+ if force_data["repulsive_potential_well_scale"][i] != 0.0:
575
+ if force_data["repulsive_potential_unit"][i] == "scale":
576
+ LJRP = LJRepulsivePotentialScale(repulsive_potential_well_scale=force_data["repulsive_potential_well_scale"][i],
577
+ repulsive_potential_dist_scale=force_data["repulsive_potential_dist_scale"][i],
578
+ repulsive_potential_Fragm_1=force_data["repulsive_potential_Fragm_1"][i],
579
+ repulsive_potential_Fragm_2=force_data["repulsive_potential_Fragm_2"][i],
580
+ element_list=element_list,
581
+ jobid=JOBID)
582
+
583
+
584
+ bias_pot_obj_list.append(LJRP)
585
+ bias_pot_obj_id_list.append("repulsive_pot_scale_"+str(i))
586
+ bias_pot_params_list.append([])
587
+
588
+ elif force_data["repulsive_potential_unit"][i] == "value":
589
+ LJRP = LJRepulsivePotentialValue(repulsive_potential_well_value=force_data["repulsive_potential_well_scale"][i],
590
+ repulsive_potential_dist_value=force_data["repulsive_potential_dist_scale"][i],
591
+ repulsive_potential_Fragm_1=force_data["repulsive_potential_Fragm_1"][i],
592
+ repulsive_potential_Fragm_2=force_data["repulsive_potential_Fragm_2"][i],
593
+ element_list=element_list,
594
+ jobid=JOBID)
595
+
596
+ bias_pot_obj_list.append(LJRP)
597
+ bias_pot_obj_id_list.append("repulsive_pot_value_"+str(i))
598
+ bias_pot_params_list.append([])
599
+ else:
600
+ print("error -rpv2")
601
+ raise "error -rpv2"
602
+ else:
603
+ pass
604
+
605
+ for i in range(len(force_data["repulsive_potential_gaussian_LJ_well_depth"])):
606
+
607
+ if force_data["repulsive_potential_gaussian_LJ_well_depth"][i] != 0.0 or force_data["repulsive_potential_gaussian_gau_well_depth"][i] != 0.0:
608
+
609
+ LJRP = LJRepulsivePotentialGaussian(repulsive_potential_gaussian_LJ_well_depth=force_data["repulsive_potential_gaussian_LJ_well_depth"][i],
610
+ repulsive_potential_gaussian_LJ_dist=force_data["repulsive_potential_gaussian_LJ_dist"][i],
611
+ repulsive_potential_gaussian_gau_well_depth=force_data["repulsive_potential_gaussian_gau_well_depth"][i],
612
+ repulsive_potential_gaussian_gau_dist=force_data["repulsive_potential_gaussian_gau_dist"][i],
613
+ repulsive_potential_gaussian_gau_range=force_data["repulsive_potential_gaussian_gau_range"][i],
614
+ repulsive_potential_gaussian_fragm_1=force_data["repulsive_potential_gaussian_fragm_1"][i],
615
+ repulsive_potential_gaussian_fragm_2=force_data["repulsive_potential_gaussian_fragm_2"][i],
616
+ element_list=element_list,
617
+ jobid=JOBID)
618
+
619
+ bias_pot_obj_list.append(LJRP)
620
+ bias_pot_obj_id_list.append("repulsive_gaussian_pot_"+str(i))
621
+ bias_pot_params_list.append([])
622
+
623
+ for i in range(len(force_data["cone_potential_well_value"])):
624
+ if force_data["cone_potential_well_value"][i] != 0.0:
625
+
626
+ LJRP = LJRepulsivePotentialCone(cone_potential_well_value=force_data["cone_potential_well_value"][i],
627
+ cone_potential_dist_value=force_data["cone_potential_dist_value"][i],
628
+ cone_potential_cone_angle=force_data["cone_potential_cone_angle"][i],
629
+ cone_potential_center=force_data["cone_potential_center"][i],
630
+ cone_potential_three_atoms=force_data["cone_potential_three_atoms"][i],
631
+ cone_potential_target=force_data["cone_potential_target"][i],
632
+ element_list=element_list
633
+ )
634
+
635
+ bias_pot_obj_list.append(LJRP)
636
+ bias_pot_obj_id_list.append("repulsive_cone_pot_"+str(i))
637
+ bias_pot_params_list.append([])
638
+
639
+ for i in range(len(force_data["keep_pot_spring_const"])):
640
+ if force_data["keep_pot_spring_const"][i] != 0.0:
641
+ SKP = StructKeepPotential(keep_pot_spring_const=force_data["keep_pot_spring_const"][i],
642
+ keep_pot_distance=force_data["keep_pot_distance"][i],
643
+ keep_pot_atom_pairs=force_data["keep_pot_atom_pairs"][i])
644
+
645
+ bias_pot_params = torch.tensor([force_data["keep_pot_spring_const"][i], force_data["keep_pot_distance"][i]], requires_grad=True, dtype=torch.float64)
646
+
647
+ bias_pot_obj_list.append(SKP)
648
+ bias_pot_obj_id_list.append("keep_pot_"+str(i))
649
+ bias_pot_params_list.append(bias_pot_params)
650
+ else:
651
+ pass
652
+
653
+
654
+ for i in range(len(force_data["keep_pot_v2_spring_const"])):
655
+ if not 0.0 in force_data["keep_pot_v2_spring_const"][i]:
656
+ spring_const_tmp = force_data["keep_pot_v2_spring_const"][i][0]
657
+ dist_tmp = force_data["keep_pot_v2_distance"][i][0]
658
+ SKP = StructKeepPotentialv2(keep_pot_v2_spring_const=spring_const_tmp,
659
+ keep_pot_v2_distance=dist_tmp,
660
+ keep_pot_v2_fragm1=force_data["keep_pot_v2_fragm1"][i],
661
+ keep_pot_v2_fragm2=force_data["keep_pot_v2_fragm2"][i]
662
+ )
663
+ bias_pot_params = torch.tensor([spring_const_tmp, dist_tmp], requires_grad=True, dtype=torch.float64)
664
+
665
+ bias_pot_obj_list.append(SKP)
666
+ bias_pot_obj_id_list.append("keep_pot_v2_"+str(i))
667
+ bias_pot_params_list.append(bias_pot_params)
668
+ else:
669
+ pass
670
+
671
+
672
+ for i in range(len(force_data["anharmonic_keep_pot_spring_const"])):
673
+ if force_data["anharmonic_keep_pot_spring_const"][i] != 0.0:
674
+ SAKP = StructAnharmonicKeepPotential(anharmonic_keep_pot_spring_const=force_data["anharmonic_keep_pot_spring_const"][i],
675
+ anharmonic_keep_pot_potential_well_depth=force_data["anharmonic_keep_pot_potential_well_depth"][i],
676
+ anharmonic_keep_pot_atom_pairs=force_data["anharmonic_keep_pot_atom_pairs"][i],
677
+ anharmonic_keep_pot_distance=force_data["anharmonic_keep_pot_distance"][i])
678
+
679
+ bias_pot_obj_list.append(SAKP)
680
+ bias_pot_obj_id_list.append("anharmonic_keep_pot_"+str(i))
681
+ bias_pot_params_list.append([])
682
+
683
+ else:
684
+ pass
685
+
686
+ for i in range(len(force_data["well_pot_wall_energy"])):
687
+ if force_data["well_pot_wall_energy"][i] != 0.0:
688
+ WP = WellPotential(well_pot_wall_energy=force_data["well_pot_wall_energy"][i],
689
+ well_pot_fragm_1=force_data["well_pot_fragm_1"][i],
690
+ well_pot_fragm_2=force_data["well_pot_fragm_2"][i],
691
+ well_pot_limit_dist=force_data["well_pot_limit_dist"][i])
692
+
693
+ bias_pot_obj_list.append(WP)
694
+ bias_pot_obj_id_list.append("well_pot_wall_"+str(i))
695
+ bias_pot_params_list.append([])
696
+ else:
697
+ pass
698
+
699
+ for i in range(len(force_data["wall_well_pot_wall_energy"])):
700
+ if force_data["wall_well_pot_wall_energy"][i] != 0.0:
701
+ WP = WellPotentialWall(wall_well_pot_wall_energy=force_data["wall_well_pot_wall_energy"][i],
702
+ wall_well_pot_direction=force_data["wall_well_pot_direction"][i],
703
+ wall_well_pot_limit_dist=force_data["wall_well_pot_limit_dist"][i],
704
+ wall_well_pot_target=force_data["wall_well_pot_target"][i])
705
+
706
+ bias_pot_obj_list.append(WP)
707
+ bias_pot_obj_id_list.append("wall_well_pot_wall_"+str(i))
708
+ bias_pot_params_list.append([])
709
+ else:
710
+ pass
711
+
712
+ for i in range(len(force_data["void_point_well_pot_wall_energy"])):
713
+ if force_data["void_point_well_pot_wall_energy"][i] != 0.0:
714
+ WP = WellPotentialVP(void_point_well_pot_wall_energy=force_data["void_point_well_pot_wall_energy"][i],
715
+ void_point_well_pot_coordinate=force_data["void_point_well_pot_coordinate"][i],
716
+ void_point_well_pot_limit_dist=force_data["void_point_well_pot_limit_dist"][i],
717
+ void_point_well_pot_target=force_data["void_point_well_pot_target"][i])
718
+
719
+ bias_pot_obj_list.append(WP)
720
+ bias_pot_obj_id_list.append("void_point_well_pot_wall_"+str(i))
721
+ bias_pot_params_list.append([])
722
+
723
+ else:
724
+ pass
725
+
726
+ for i in range(len(force_data["around_well_pot_wall_energy"])):
727
+ if force_data["around_well_pot_wall_energy"][i] != 0.0:
728
+ WP = WellPotentialAround(around_well_pot_wall_energy=force_data["around_well_pot_wall_energy"][i],
729
+ around_well_pot_center=force_data["around_well_pot_center"][i],
730
+ around_well_pot_limit_dist=force_data["around_well_pot_limit_dist"][i],
731
+ around_well_pot_target=force_data["around_well_pot_target"][i])
732
+
733
+ bias_pot_obj_list.append(WP)
734
+ bias_pot_obj_id_list.append("around_well_pot_wall_"+str(i))
735
+ bias_pot_params_list.append([])
736
+
737
+ else:
738
+ pass
739
+
740
+ if len(geom_num_list) > 2:
741
+ for i in range(len(force_data["keep_angle_spring_const"])):
742
+ if force_data["keep_angle_spring_const"][i] != 0.0:
743
+ SKAngleP = StructKeepAnglePotential(keep_angle_atom_pairs=force_data["keep_angle_atom_pairs"][i],
744
+ keep_angle_spring_const=force_data["keep_angle_spring_const"][i],
745
+ keep_angle_angle=force_data["keep_angle_angle"][i])
746
+
747
+ bias_pot_params = torch.tensor([force_data["keep_angle_spring_const"][i], force_data["keep_angle_angle"][i]], requires_grad=True, dtype=torch.float64)
748
+ bias_pot_obj_list.append(SKAngleP)
749
+ bias_pot_obj_id_list.append("keep_angle_pot_"+str(i))
750
+ bias_pot_params_list.append(bias_pot_params)
751
+
752
+ else:
753
+ pass
754
+
755
+
756
+ if len(geom_num_list) > 2:
757
+ for i in range(len(force_data["keep_angle_v2_spring_const"])):
758
+ if not 0.0 in force_data["keep_angle_v2_spring_const"][i]:
759
+
760
+ spring_const_tmp = force_data["keep_angle_v2_spring_const"][i][0]
761
+ angle_tmp = force_data["keep_angle_v2_angle"][i][0]
762
+ bias_pot_params = torch.tensor([spring_const_tmp, angle_tmp], requires_grad=True, dtype=torch.float64)
763
+ SKAngleP = StructKeepAnglePotentialv2(
764
+ keep_angle_v2_fragm1=force_data["keep_angle_v2_fragm1"][i],
765
+ keep_angle_v2_fragm2=force_data["keep_angle_v2_fragm2"][i],
766
+ keep_angle_v2_fragm3=force_data["keep_angle_v2_fragm3"][i],
767
+ keep_angle_v2_spring_const=spring_const_tmp,
768
+ keep_angle_v2_angle=angle_tmp)
769
+
770
+ bias_pot_obj_list.append(SKAngleP)
771
+ bias_pot_obj_id_list.append("keep_angle_v2_"+str(i))
772
+ bias_pot_params_list.append(bias_pot_params)
773
+
774
+ else:
775
+ pass
776
+
777
+
778
+ if len(geom_num_list) > 3:
779
+ for i in range(len(force_data["keep_dihedral_angle_spring_const"])):
780
+ if force_data["keep_dihedral_angle_spring_const"][i] != 0.0:
781
+ SKDAP = StructKeepDihedralAnglePotential(keep_dihedral_angle_spring_const=force_data["keep_dihedral_angle_spring_const"][i],
782
+ keep_dihedral_angle_atom_pairs=force_data["keep_dihedral_angle_atom_pairs"][i],
783
+ keep_dihedral_angle_angle=force_data["keep_dihedral_angle_angle"][i])
784
+
785
+
786
+ bias_pot_params = torch.tensor([force_data["keep_dihedral_angle_spring_const"][i], force_data["keep_dihedral_angle_angle"][i]], requires_grad=True, dtype=torch.float64)
787
+ bias_pot_obj_list.append(SKDAP)
788
+ bias_pot_obj_id_list.append("keep_dihedral_angle_"+str(i))
789
+ bias_pot_params_list.append(bias_pot_params)
790
+ else:
791
+ pass
792
+ else:
793
+ pass
794
+
795
+ if len(geom_num_list) > 3:
796
+ for i in range(len(force_data["keep_out_of_plain_angle_spring_const"])):
797
+ if force_data["keep_out_of_plain_angle_spring_const"][i] != 0.0:
798
+ SKOPAP = StructKeepOutofPlainAnglePotential(keep_out_of_plain_angle_spring_const=force_data["keep_out_of_plain_angle_spring_const"][i],
799
+ keep_out_of_plain_angle_atom_pairs=force_data["keep_out_of_plain_angle_atom_pairs"][i],
800
+ keep_out_of_plain_angle_angle=force_data["keep_out_of_plain_angle_angle"][i])
801
+ bias_pot_params = torch.tensor([force_data["keep_out_of_plain_angle_spring_const"][i], force_data["keep_out_of_plain_angle_angle"][i]], requires_grad=True, dtype=torch.float64)
802
+ bias_pot_obj_list.append(SKOPAP)
803
+ bias_pot_obj_id_list.append("keep_out_of_plain_angle_"+str(i))
804
+ bias_pot_params_list.append(bias_pot_params)
805
+ else:
806
+ pass
807
+ else:
808
+ pass
809
+
810
+ if len(geom_num_list) > 3:
811
+ for i in range(len(force_data["keep_dihedral_angle_v2_spring_const"])):
812
+ if not 0.0 in force_data["keep_dihedral_angle_v2_spring_const"][i]:
813
+
814
+ spring_const_tmp = force_data["keep_dihedral_angle_v2_spring_const"][i][0]
815
+ angle_tmp = force_data["keep_dihedral_angle_v2_angle"][i][0]
816
+
817
+ SKDAP = StructKeepDihedralAnglePotentialv2(keep_dihedral_angle_v2_spring_const=spring_const_tmp,
818
+ keep_dihedral_angle_v2_fragm1=force_data["keep_dihedral_angle_v2_fragm1"][i],
819
+ keep_dihedral_angle_v2_fragm2=force_data["keep_dihedral_angle_v2_fragm2"][i],
820
+ keep_dihedral_angle_v2_fragm3=force_data["keep_dihedral_angle_v2_fragm3"][i],
821
+ keep_dihedral_angle_v2_fragm4=force_data["keep_dihedral_angle_v2_fragm4"][i],
822
+ keep_dihedral_angle_v2_angle=angle_tmp)
823
+ bias_pot_params = torch.tensor([spring_const_tmp, angle_tmp], requires_grad=True, dtype=torch.float64)
824
+
825
+ bias_pot_obj_list.append(SKDAP)
826
+ bias_pot_obj_id_list.append("keep_dihedral_angle_v2_"+str(i))
827
+ bias_pot_params_list.append(bias_pot_params)
828
+
829
+ else:
830
+ pass
831
+ else:
832
+ pass
833
+
834
+ if len(geom_num_list) > 3:
835
+ for i in range(len(force_data["keep_dihedral_angle_cos_potential_const"])):
836
+ if not 0.0 in force_data["keep_dihedral_angle_cos_potential_const"][i]:
837
+
838
+ potential_const_tmp = force_data["keep_dihedral_angle_cos_potential_const"][i][0]
839
+
840
+ angle_const_tmp = force_data["keep_dihedral_angle_cos_angle_const"][i][0]
841
+
842
+ angle_tmp = force_data["keep_dihedral_angle_cos_angle"][i][0]
843
+
844
+
845
+ SKDAP = StructKeepDihedralAnglePotentialCos(keep_dihedral_angle_cos_potential_const=potential_const_tmp,
846
+ keep_dihedral_angle_cos_angle_const=angle_const_tmp,
847
+ keep_dihedral_angle_cos_fragm1=force_data["keep_dihedral_angle_cos_fragm1"][i],
848
+ keep_dihedral_angle_cos_fragm2=force_data["keep_dihedral_angle_cos_fragm2"][i],
849
+ keep_dihedral_angle_cos_fragm3=force_data["keep_dihedral_angle_cos_fragm3"][i],
850
+ keep_dihedral_angle_cos_fragm4=force_data["keep_dihedral_angle_cos_fragm4"][i],
851
+ keep_dihedral_angle_cos_angle=angle_tmp)
852
+ bias_pot_obj_list.append(SKDAP)
853
+ bias_pot_obj_id_list.append("keep_dihedral_angle_cos_"+str(i))
854
+ bias_pot_params_list.append([])
855
+ else:
856
+ pass
857
+ else:
858
+ pass
859
+
860
+ if len(geom_num_list) > 3:
861
+ for i in range(len(force_data["keep_out_of_plain_angle_v2_spring_const"])):
862
+ if not 0.0 in force_data["keep_out_of_plain_angle_v2_spring_const"][i]:
863
+
864
+ spring_const_tmp = force_data["keep_out_of_plain_angle_v2_spring_const"][i][0]
865
+ angle_tmp = force_data["keep_out_of_plain_angle_v2_angle"][i][0]
866
+ bias_pot_params = torch.tensor([spring_const_tmp, angle_tmp], requires_grad=True, dtype=torch.float64)
867
+ SKOPAP = StructKeepOutofPlainAnglePotentialv2(keep_out_of_plain_angle_v2_spring_const=spring_const_tmp,
868
+ keep_out_of_plain_angle_v2_fragm1=force_data["keep_out_of_plain_angle_v2_fragm1"][i],
869
+ keep_out_of_plain_angle_v2_fragm2=force_data["keep_out_of_plain_angle_v2_fragm2"][i],
870
+ keep_out_of_plain_angle_v2_fragm3=force_data["keep_out_of_plain_angle_v2_fragm3"][i],
871
+ keep_out_of_plain_angle_v2_fragm4=force_data["keep_out_of_plain_angle_v2_fragm4"][i],
872
+ keep_out_of_plain_angle_v2_angle=angle_tmp)
873
+
874
+ bias_pot_obj_list.append(SKOPAP)
875
+ bias_pot_obj_id_list.append("keep_out_of_plain_angle_v2_"+str(i))
876
+ bias_pot_params_list.append(bias_pot_params)
877
+ else:
878
+ pass
879
+ else:
880
+ pass
881
+
882
+ for i in range(len(force_data["void_point_pot_spring_const"])):
883
+ if force_data["void_point_pot_spring_const"][i] != 0.0:
884
+ for j in force_data["void_point_pot_atoms"][i]:
885
+ VPP = VoidPointPotential(void_point_pot_spring_const=force_data["void_point_pot_spring_const"][i],
886
+ void_point_pot_atoms=j,
887
+ void_point_pot_coord=ndarray2tensor(np.array(force_data["void_point_pot_coord"][i], dtype="float64")),
888
+ void_point_pot_distance=force_data["void_point_pot_distance"][i],
889
+ void_point_pot_order=force_data["void_point_pot_order"][i])
890
+ bias_pot_obj_list.append(VPP)
891
+ bias_pot_obj_id_list.append("void_point_pot_"+str(i))
892
+ bias_pot_params_list.append([])
893
+ else:
894
+ pass
895
+
896
+ return bias_pot_obj_list, bias_pot_obj_id_list, bias_pot_params_list