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,221 @@
|
|
|
1
|
+
|
|
2
|
+
from multioptpy.Parameters.parameter import UnitValueLib, UFF_VDW_distance_lib, UFF_VDW_well_depth_lib
|
|
3
|
+
from multioptpy.Optimizer.fire import FIRE
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
import torch
|
|
7
|
+
import copy
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class SpacerModelPotential:
|
|
11
|
+
def __init__(self, mm_pot_type="UFF", **kwarg):
|
|
12
|
+
if mm_pot_type == "UFF":
|
|
13
|
+
self.VDW_distance_lib = UFF_VDW_distance_lib #function
|
|
14
|
+
self.VDW_well_depth_lib = UFF_VDW_well_depth_lib #function
|
|
15
|
+
else:
|
|
16
|
+
raise "Unexpected MM potential type"
|
|
17
|
+
self.config = kwarg
|
|
18
|
+
|
|
19
|
+
UVL = UnitValueLib()
|
|
20
|
+
self.hartree2kcalmol = UVL.hartree2kcalmol
|
|
21
|
+
self.bohr2angstroms = UVL.bohr2angstroms
|
|
22
|
+
self.hartree2kjmol = UVL.hartree2kjmol
|
|
23
|
+
|
|
24
|
+
self.a = 1.0
|
|
25
|
+
self.num2tgtatomlabel = {}
|
|
26
|
+
for num, tgt_atom_num in enumerate(self.config["spacer_model_potential_target"]):
|
|
27
|
+
self.num2tgtatomlabel[num] = tgt_atom_num - 1
|
|
28
|
+
|
|
29
|
+
self.nparticle = self.config["spacer_model_potential_particle_number"]
|
|
30
|
+
self.element_list = self.config["element_list"]
|
|
31
|
+
self.natom = len(self.element_list)
|
|
32
|
+
self.particle_num_list = None
|
|
33
|
+
|
|
34
|
+
self.file_directory = self.config["directory"]
|
|
35
|
+
self.lj_repulsive_order = 12.0
|
|
36
|
+
self.lj_attractive_order = 6.0
|
|
37
|
+
|
|
38
|
+
self.micro_iteration = 5000 * self.config["spacer_model_potential_particle_number"]
|
|
39
|
+
self.rand_search_iteration = 250 * self.config["spacer_model_potential_particle_number"]
|
|
40
|
+
self.threshold = 2e-6
|
|
41
|
+
self.init = True
|
|
42
|
+
return
|
|
43
|
+
|
|
44
|
+
def save_state(self):
|
|
45
|
+
with open(self.file_directory + "/spacer.xyz", "a") as f:
|
|
46
|
+
f.write(str(len(self.tmp_geom_num_list_for_save)) + "\n")
|
|
47
|
+
f.write("spacer\n")
|
|
48
|
+
for i in range(len(self.tmp_geom_num_list_for_save)):
|
|
49
|
+
f.write(self.tmp_element_list_for_save[i] + " " + str(self.tmp_geom_num_list_for_save[i][0].item()) + " " + str(self.tmp_geom_num_list_for_save[i][1].item()) + " " + str(self.tmp_geom_num_list_for_save[i][2].item()) + "\n")
|
|
50
|
+
|
|
51
|
+
return
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def lennard_johns_potential(self, distance, sigma, epsilon):
|
|
55
|
+
ene = epsilon * ((sigma/distance) ** self.lj_repulsive_order -2 * (sigma/distance) ** self.lj_attractive_order)
|
|
56
|
+
return ene
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def morse_potential(self, distance, sigma, epsilon):
|
|
60
|
+
ene = epsilon * (torch.exp(-2 * self.a * (distance - sigma)) -2 * torch.exp(-1 * self.a * (distance - sigma)))
|
|
61
|
+
return ene
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def barrier_switching_potential(self, distance, sigma):
|
|
65
|
+
normalized_distance = distance / sigma
|
|
66
|
+
min_norm_dist = 0.9
|
|
67
|
+
max_norm_dist = 1.0
|
|
68
|
+
const = 0.5
|
|
69
|
+
|
|
70
|
+
in_range = (normalized_distance >= min_norm_dist) & (normalized_distance < max_norm_dist)
|
|
71
|
+
out_of_range = normalized_distance >= max_norm_dist
|
|
72
|
+
ene = torch.zeros_like(normalized_distance)
|
|
73
|
+
|
|
74
|
+
normalized_diff = (normalized_distance - min_norm_dist) / (max_norm_dist - min_norm_dist)
|
|
75
|
+
ene[in_range] = -const * (
|
|
76
|
+
1 - 10 * normalized_diff[in_range]**3
|
|
77
|
+
+ 15 * normalized_diff[in_range]**4
|
|
78
|
+
- 6 * normalized_diff[in_range]**5
|
|
79
|
+
) + const
|
|
80
|
+
|
|
81
|
+
ene[out_of_range] = const * normalized_distance[out_of_range]
|
|
82
|
+
ene = torch.sum(ene)
|
|
83
|
+
return ene
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def calc_potential(self, geom_num_list, particle_num_list, bias_pot_params):
|
|
87
|
+
energy = 0.0
|
|
88
|
+
particle_sigma = self.config["spacer_model_potential_distance"] / self.bohr2angstroms
|
|
89
|
+
particle_epsilon = self.config["spacer_model_potential_well_depth"] / self.hartree2kjmol
|
|
90
|
+
#atom-particle interactions
|
|
91
|
+
spacer_indices = torch.tensor([i for i in range(len(self.config["element_list"]))])
|
|
92
|
+
geom_particles = geom_num_list[spacer_indices] # shape: (M, 3), M = len(spacer_model_potential_target)
|
|
93
|
+
atom_sigmas = torch.tensor([self.VDW_distance_lib(self.config["element_list"][idx]) for idx in spacer_indices])
|
|
94
|
+
atom_epsilons = torch.tensor([self.VDW_well_depth_lib(self.config["element_list"][idx]) for idx in spacer_indices])
|
|
95
|
+
sigma = particle_sigma + atom_sigmas.unsqueeze(1) # shape: (M, 1) + (1, N) -> (M, N)
|
|
96
|
+
epsilon = torch.sqrt(particle_epsilon * atom_epsilons.unsqueeze(1)) # shape: (M, 1)
|
|
97
|
+
diffs = geom_particles.unsqueeze(1) - particle_num_list.unsqueeze(0) # shape: (M, N, 3)
|
|
98
|
+
distances = torch.linalg.norm(diffs, dim=-1) # shape: (M, N)
|
|
99
|
+
pairwise_energies = self.lennard_johns_potential(distances, sigma, epsilon)
|
|
100
|
+
energy = energy + pairwise_energies.sum()
|
|
101
|
+
|
|
102
|
+
#particle-particle interactions
|
|
103
|
+
diffs = particle_num_list.unsqueeze(1) - particle_num_list.unsqueeze(0) # shape: (N, N, 3)
|
|
104
|
+
distances = torch.linalg.norm(diffs, dim=-1) # shape: (N, N), diagonal is 0 (self distance)
|
|
105
|
+
i, j = torch.triu_indices(distances.shape[0], distances.shape[1], offset=1)
|
|
106
|
+
pairwise_distances = distances[i, j]
|
|
107
|
+
pairwise_energies = self.lennard_johns_potential(pairwise_distances, 2 * particle_sigma, particle_epsilon)
|
|
108
|
+
energy = energy + pairwise_energies.sum()
|
|
109
|
+
|
|
110
|
+
#avoid scattering particle to outside of cavity
|
|
111
|
+
target_geom = geom_num_list[np.array(self.config["spacer_model_potential_target"]) - 1]
|
|
112
|
+
|
|
113
|
+
norm_diff = torch.abs(torch.linalg.norm(target_geom, dim=1).unsqueeze(1) - torch.linalg.norm(particle_num_list, dim=1).unsqueeze(0))
|
|
114
|
+
min_dist, min_idx = torch.min(norm_diff, dim=0)
|
|
115
|
+
|
|
116
|
+
element_indices = [self.num2tgtatomlabel[idx.item()] for idx in min_idx]
|
|
117
|
+
atom_sigmas = self.config["spacer_model_potential_cavity_scaling"] * torch.tensor(
|
|
118
|
+
[self.VDW_distance_lib(self.config["element_list"][idx]) for idx in element_indices]
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
energy = energy + self.barrier_switching_potential(min_dist, atom_sigmas)
|
|
122
|
+
|
|
123
|
+
self.tmp_geom_num_list_for_save = torch.cat([geom_num_list, particle_num_list], dim=0) * self.bohr2angstroms
|
|
124
|
+
self.tmp_element_list_for_save = self.config["element_list"] + ["He"] * len(particle_num_list)
|
|
125
|
+
|
|
126
|
+
return energy
|
|
127
|
+
|
|
128
|
+
def rand_search(self, geom_num_list, bias_pot_params):
|
|
129
|
+
max_energy = 1e+10
|
|
130
|
+
print("rand_search")
|
|
131
|
+
for i in range(self.rand_search_iteration):
|
|
132
|
+
center = torch.mean(geom_num_list[np.array(self.config["spacer_model_potential_target"])-1], dim=0)
|
|
133
|
+
tmp_particle_num_list = torch.normal(mean=0, std=100, size=(self.config["spacer_model_potential_particle_number"], 3)) + center
|
|
134
|
+
energy = self.calc_potential(geom_num_list, tmp_particle_num_list, bias_pot_params)
|
|
135
|
+
if energy < max_energy:
|
|
136
|
+
max_energy = energy
|
|
137
|
+
self.particle_num_list = tmp_particle_num_list
|
|
138
|
+
print("rand_search done")
|
|
139
|
+
print("max_energy: ", max_energy.item())
|
|
140
|
+
return
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def microiteration(self, geom_num_list, bias_pot_params):
|
|
144
|
+
nparticle = self.config["spacer_model_potential_particle_number"]
|
|
145
|
+
if self.init:
|
|
146
|
+
self.rand_search(geom_num_list, bias_pot_params)
|
|
147
|
+
self.init = False
|
|
148
|
+
|
|
149
|
+
prev_particle_grad = torch.zeros_like(self.particle_num_list)
|
|
150
|
+
Opt = FIRE()
|
|
151
|
+
Opt.display_flag = False
|
|
152
|
+
|
|
153
|
+
for j in range(self.micro_iteration):
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
particle_grad = torch.func.jacrev(self.calc_potential, argnums=1)(geom_num_list, self.particle_num_list, bias_pot_params)
|
|
157
|
+
if torch.linalg.norm(particle_grad) < self.threshold:
|
|
158
|
+
print("Converged!")
|
|
159
|
+
print("M. itr: ", j)
|
|
160
|
+
break
|
|
161
|
+
if j == self.micro_iteration - 1:
|
|
162
|
+
print("Not converged!")
|
|
163
|
+
break
|
|
164
|
+
|
|
165
|
+
tmp_particle_list = copy.copy(self.particle_num_list.clone().detach().numpy()).reshape(3*nparticle, 1)
|
|
166
|
+
tmp_particle_grad = copy.copy(particle_grad.clone().detach().numpy()).reshape(3*nparticle, 1)
|
|
167
|
+
tmp_prev_particle_grad = copy.copy(prev_particle_grad.clone().detach().numpy()).reshape(3*nparticle, 1)
|
|
168
|
+
|
|
169
|
+
move_vector = Opt.run(tmp_particle_list, tmp_particle_grad, tmp_prev_particle_grad, pre_geom=[], B_e=0.0, pre_B_e=0.0, pre_move_vector=[], initial_geom_num_list=[], g=[], pre_g=[])
|
|
170
|
+
move_vector = torch.tensor(move_vector, dtype=torch.float64).reshape(nparticle, 3)
|
|
171
|
+
self.particle_num_list = self.particle_num_list - 0.5 * move_vector
|
|
172
|
+
# update rot_angle_list
|
|
173
|
+
if j % 100 == 0:
|
|
174
|
+
print("M. itr: ", j)
|
|
175
|
+
print("energy: ", self.calc_potential(geom_num_list, self.particle_num_list, bias_pot_params).item())
|
|
176
|
+
print("particle_grad: ", np.linalg.norm(particle_grad.detach().numpy()))
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
prev_particle_grad = particle_grad
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
energy = self.calc_potential(geom_num_list, self.particle_num_list, bias_pot_params)
|
|
183
|
+
print("energy: ", self.calc_potential(geom_num_list, self.particle_num_list, bias_pot_params).item())
|
|
184
|
+
return energy
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def calc_energy(self, geom_num_list, bias_pot_params=[]):
|
|
188
|
+
"""
|
|
189
|
+
# required variables:self.config["spacer_model_potential_target"]
|
|
190
|
+
self.config["spacer_model_potential_distance"]
|
|
191
|
+
self.config["spacer_model_potential_well_depth"]
|
|
192
|
+
self.config["spacer_model_potential_cavity_scaling"]
|
|
193
|
+
self.config["spacer_model_potential_particle_number"]
|
|
194
|
+
self.config["element_list"]
|
|
195
|
+
self.config["directory"]
|
|
196
|
+
|
|
197
|
+
"""
|
|
198
|
+
energy = self.microiteration(geom_num_list, bias_pot_params)
|
|
199
|
+
|
|
200
|
+
return energy
|
|
201
|
+
|
|
202
|
+
def calc_pot_for_eff_hess(self, coord_and_ell_angle, bias_pot_params):
|
|
203
|
+
geom_num_list = coord_and_ell_angle[:len(self.element_list)*3].reshape(-1, 3)
|
|
204
|
+
particle_num_list = coord_and_ell_angle[len(self.element_list)*3:].reshape(self.nparticle, 3)
|
|
205
|
+
energy = self.calc_potential(geom_num_list, particle_num_list, bias_pot_params)
|
|
206
|
+
return energy
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def calc_eff_hessian(self, geom_num_list, bias_pot_params):
|
|
210
|
+
transformed_geom_num_list = geom_num_list.reshape(-1, 1)
|
|
211
|
+
transformed_particle_num_list = self.particle_num_list.reshape(-1, 1)
|
|
212
|
+
coord_and_particle = torch.cat((transformed_geom_num_list, transformed_particle_num_list), dim=0)
|
|
213
|
+
combined_hess = torch.func.hessian(self.calc_pot_for_eff_hess, argnums=0)(coord_and_particle, bias_pot_params).reshape(len(self.element_list)*3+self.nparticle*3, len(self.element_list)*3+self.nparticle*3)
|
|
214
|
+
coupling_hess_1 = combined_hess[:len(self.element_list)*3, len(self.element_list)*3:]
|
|
215
|
+
coupling_hess_2 = combined_hess[len(self.element_list)*3:, :len(self.element_list)*3]
|
|
216
|
+
angle_hess = combined_hess[len(self.element_list)*3:, len(self.element_list)*3:]
|
|
217
|
+
eff_hess = -1 * torch.matmul(torch.matmul(coupling_hess_1, torch.linalg.inv(angle_hess)), coupling_hess_2)
|
|
218
|
+
return eff_hess
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
#[[solvent particle well depth (kJ/mol)] [solvent particle e.q. distance (ang.)] [scaling of cavity (2.0)] [number of particles] [target atoms (2,3-5)] ...]
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
|
|
2
|
+
from multioptpy.Parameters.parameter import UnitValueLib
|
|
3
|
+
import torch
|
|
4
|
+
|
|
5
|
+
class WellPotential:
|
|
6
|
+
def __init__(self, **kwarg):
|
|
7
|
+
self.config = kwarg
|
|
8
|
+
UVL = UnitValueLib()
|
|
9
|
+
self.hartree2kcalmol = UVL.hartree2kcalmol
|
|
10
|
+
self.bohr2angstroms = UVL.bohr2angstroms
|
|
11
|
+
self.hartree2kjmol = UVL.hartree2kjmol
|
|
12
|
+
return
|
|
13
|
+
|
|
14
|
+
def calc_energy(self, geom_num_list, bias_pot_params=[]):
|
|
15
|
+
"""
|
|
16
|
+
# required variables: self.config["well_pot_wall_energy"]
|
|
17
|
+
self.config["well_pot_fragm_1"]
|
|
18
|
+
self.config["well_pot_fragm_2"]
|
|
19
|
+
self.config["well_pot_limit_dist"]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
"""
|
|
23
|
+
fragm_1_center = torch.tensor([0.0, 0.0, 0.0], dtype=torch.float32, requires_grad=True)
|
|
24
|
+
for i in self.config["well_pot_fragm_1"]:
|
|
25
|
+
fragm_1_center = fragm_1_center + geom_num_list[i-1]
|
|
26
|
+
|
|
27
|
+
fragm_1_center = fragm_1_center / len(self.config["well_pot_fragm_1"])
|
|
28
|
+
|
|
29
|
+
fragm_2_center = torch.tensor([0.0, 0.0, 0.0], dtype=torch.float32, requires_grad=True)
|
|
30
|
+
for i in self.config["well_pot_fragm_2"]:
|
|
31
|
+
fragm_2_center = fragm_2_center + geom_num_list[i-1]
|
|
32
|
+
|
|
33
|
+
fragm_2_center = fragm_2_center / len(self.config["well_pot_fragm_2"])
|
|
34
|
+
|
|
35
|
+
vec_norm = torch.linalg.norm(fragm_1_center - fragm_2_center)
|
|
36
|
+
a = float(self.config["well_pot_limit_dist"][0]) / self.bohr2angstroms
|
|
37
|
+
b = float(self.config["well_pot_limit_dist"][1]) / self.bohr2angstroms
|
|
38
|
+
c = float(self.config["well_pot_limit_dist"][2]) / self.bohr2angstroms
|
|
39
|
+
d = float(self.config["well_pot_limit_dist"][3]) / self.bohr2angstroms
|
|
40
|
+
short_dist_linear_func_slope = 0.5 / (b - a)
|
|
41
|
+
short_dist_linear_func_intercept = 1.0 - 0.5 * b / (b - a)
|
|
42
|
+
long_dist_linear_func_slope = 0.5 / (c - d)
|
|
43
|
+
long_dist_linear_func_intercept = 1.0 - 0.5 * c / (c - d)
|
|
44
|
+
|
|
45
|
+
x_short = short_dist_linear_func_slope * vec_norm + short_dist_linear_func_intercept
|
|
46
|
+
x_long = long_dist_linear_func_slope * vec_norm + long_dist_linear_func_intercept
|
|
47
|
+
|
|
48
|
+
if vec_norm <= a:
|
|
49
|
+
energy = (self.config["well_pot_wall_energy"] / self.hartree2kjmol) * (-3.75 * x_short + 2.875)
|
|
50
|
+
|
|
51
|
+
elif a < vec_norm and vec_norm <= b:
|
|
52
|
+
energy = (self.config["well_pot_wall_energy"] / self.hartree2kjmol) * (2.0 - 20.0 * x_short ** 3 + 30.0 * x_short ** 4 - 12.0 * x_short ** 5)
|
|
53
|
+
|
|
54
|
+
elif b < vec_norm and vec_norm < c:
|
|
55
|
+
energy = torch.tensor(0.0, requires_grad=True, dtype=torch.float32)
|
|
56
|
+
|
|
57
|
+
elif c <= vec_norm and vec_norm < d:
|
|
58
|
+
energy = (self.config["well_pot_wall_energy"] / self.hartree2kjmol) * (2.0 - 20.0 * x_long ** 3 + 30.0 * x_long ** 4 - 12.0 * x_long ** 5)
|
|
59
|
+
|
|
60
|
+
elif d <= vec_norm:
|
|
61
|
+
energy = (self.config["well_pot_wall_energy"] / self.hartree2kjmol) * (-3.75 * x_long + 2.875)
|
|
62
|
+
|
|
63
|
+
else:
|
|
64
|
+
print("well pot error")
|
|
65
|
+
raise "well pot error"
|
|
66
|
+
#print(energy)
|
|
67
|
+
return energy
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class WellPotentialWall:
|
|
71
|
+
def __init__(self, **kwarg):
|
|
72
|
+
self.config = kwarg
|
|
73
|
+
UVL = UnitValueLib()
|
|
74
|
+
self.hartree2kcalmol = UVL.hartree2kcalmol
|
|
75
|
+
self.bohr2angstroms = UVL.bohr2angstroms
|
|
76
|
+
self.hartree2kjmol = UVL.hartree2kjmol
|
|
77
|
+
return
|
|
78
|
+
|
|
79
|
+
def calc_energy(self, geom_num_list, bias_pot_params=[]):
|
|
80
|
+
"""
|
|
81
|
+
# required variables: self.config["wall_well_pot_wall_energy"]
|
|
82
|
+
self.config["wall_well_pot_direction"]
|
|
83
|
+
self.config["wall_well_pot_limit_dist"]
|
|
84
|
+
self.config["wall_well_pot_target"]
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
if self.config["wall_well_pot_direction"] == "x":
|
|
90
|
+
direction_num = 0
|
|
91
|
+
elif self.config["wall_well_pot_direction"] == "y":
|
|
92
|
+
direction_num = 1
|
|
93
|
+
elif self.config["wall_well_pot_direction"] == "z":
|
|
94
|
+
direction_num = 2
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
energy = 0.0
|
|
99
|
+
for i in self.config["wall_well_pot_target"]:
|
|
100
|
+
|
|
101
|
+
vec_norm = abs(torch.linalg.norm(geom_num_list[i-1][direction_num]))
|
|
102
|
+
|
|
103
|
+
a = float(self.config["wall_well_pot_limit_dist"][0]) / self.bohr2angstroms
|
|
104
|
+
b = float(self.config["wall_well_pot_limit_dist"][1]) / self.bohr2angstroms
|
|
105
|
+
c = float(self.config["wall_well_pot_limit_dist"][2]) / self.bohr2angstroms
|
|
106
|
+
d = float(self.config["wall_well_pot_limit_dist"][3]) / self.bohr2angstroms
|
|
107
|
+
short_dist_linear_func_slope = 0.5 / (b - a)
|
|
108
|
+
short_dist_linear_func_intercept = 1.0 - 0.5 * b / (b - a)
|
|
109
|
+
long_dist_linear_func_slope = 0.5 / (c - d)
|
|
110
|
+
long_dist_linear_func_intercept = 1.0 - 0.5 * c / (c - d)
|
|
111
|
+
|
|
112
|
+
x_short = short_dist_linear_func_slope * vec_norm + short_dist_linear_func_intercept
|
|
113
|
+
x_long = long_dist_linear_func_slope * vec_norm + long_dist_linear_func_intercept
|
|
114
|
+
|
|
115
|
+
if vec_norm <= a:
|
|
116
|
+
energy += (self.config["wall_well_pot_wall_energy"] / self.hartree2kjmol) * (-3.75 * x_short + 2.875)
|
|
117
|
+
|
|
118
|
+
elif a < vec_norm and vec_norm <= b:
|
|
119
|
+
energy += (self.config["wall_well_pot_wall_energy"] / self.hartree2kjmol) * (2.0 - 20.0 * x_short ** 3 + 30.0 * x_short ** 4 - 12.0 * x_short ** 5)
|
|
120
|
+
|
|
121
|
+
elif b < vec_norm and vec_norm < c:
|
|
122
|
+
energy += torch.tensor(0.0, requires_grad=True, dtype=torch.float32)
|
|
123
|
+
|
|
124
|
+
elif c <= vec_norm and vec_norm < d:
|
|
125
|
+
energy += (self.config["wall_well_pot_wall_energy"] / self.hartree2kjmol) * (2.0 - 20.0 * x_long ** 3 + 30.0 * x_long ** 4 - 12.0 * x_long ** 5)
|
|
126
|
+
|
|
127
|
+
elif d <= vec_norm:
|
|
128
|
+
energy += (self.config["wall_well_pot_wall_energy"] / self.hartree2kjmol) * (-3.75 * x_long + 2.875)
|
|
129
|
+
|
|
130
|
+
else:
|
|
131
|
+
print("well pot error")
|
|
132
|
+
raise "well pot error"
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
#print(energy)
|
|
136
|
+
return energy
|
|
137
|
+
|
|
138
|
+
class WellPotentialVP:
|
|
139
|
+
def __init__(self, **kwarg):
|
|
140
|
+
self.config = kwarg
|
|
141
|
+
UVL = UnitValueLib()
|
|
142
|
+
self.hartree2kcalmol = UVL.hartree2kcalmol
|
|
143
|
+
self.bohr2angstroms = UVL.bohr2angstroms
|
|
144
|
+
self.hartree2kjmol = UVL.hartree2kjmol
|
|
145
|
+
return
|
|
146
|
+
def calc_energy(self, geom_num_list, bias_pot_params=[]):
|
|
147
|
+
"""
|
|
148
|
+
# required variables: self.config["void_point_well_pot_wall_energy"]
|
|
149
|
+
self.config["void_point_well_pot_coordinate"]
|
|
150
|
+
self.config["void_point_well_pot_limit_dist"]
|
|
151
|
+
self.config["void_point_well_pot_target"]
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
"""
|
|
155
|
+
self.config["void_point_well_pot_coordinate"] = torch.tensor(self.config["void_point_well_pot_coordinate"], dtype=torch.float32)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
energy = 0.0
|
|
159
|
+
for i in self.config["void_point_well_pot_target"]:
|
|
160
|
+
|
|
161
|
+
vec_norm = torch.linalg.norm(geom_num_list[i-1] - self.config["void_point_well_pot_coordinate"])
|
|
162
|
+
|
|
163
|
+
a = float(self.config["void_point_well_pot_limit_dist"][0]) / self.bohr2angstroms
|
|
164
|
+
b = float(self.config["void_point_well_pot_limit_dist"][1]) / self.bohr2angstroms
|
|
165
|
+
c = float(self.config["void_point_well_pot_limit_dist"][2]) / self.bohr2angstroms
|
|
166
|
+
d = float(self.config["void_point_well_pot_limit_dist"][3]) / self.bohr2angstroms
|
|
167
|
+
short_dist_linear_func_slope = 0.5 / (b - a)
|
|
168
|
+
short_dist_linear_func_intercept = 1.0 - 0.5 * b / (b - a)
|
|
169
|
+
long_dist_linear_func_slope = 0.5 / (c - d)
|
|
170
|
+
long_dist_linear_func_intercept = 1.0 - 0.5 * c / (c - d)
|
|
171
|
+
|
|
172
|
+
x_short = short_dist_linear_func_slope * vec_norm + short_dist_linear_func_intercept
|
|
173
|
+
x_long = long_dist_linear_func_slope * vec_norm + long_dist_linear_func_intercept
|
|
174
|
+
|
|
175
|
+
if vec_norm <= a:
|
|
176
|
+
energy += (self.config["void_point_well_pot_wall_energy"] / self.hartree2kjmol) * (-3.75 * x_short + 2.875)
|
|
177
|
+
|
|
178
|
+
elif a < vec_norm and vec_norm <= b:
|
|
179
|
+
energy += (self.config["void_point_well_pot_wall_energy"] / self.hartree2kjmol) * (2.0 - 20.0 * x_short ** 3 + 30.0 * x_short ** 4 - 12.0 * x_short ** 5)
|
|
180
|
+
|
|
181
|
+
elif b < vec_norm and vec_norm < c:
|
|
182
|
+
energy += torch.tensor(0.0, requires_grad=True, dtype=torch.float32)
|
|
183
|
+
|
|
184
|
+
elif c <= vec_norm and vec_norm < d:
|
|
185
|
+
energy += (self.config["void_point_well_pot_wall_energy"] / self.hartree2kjmol) * (2.0 - 20.0 * x_long ** 3 + 30.0 * x_long ** 4 - 12.0 * x_long ** 5)
|
|
186
|
+
|
|
187
|
+
elif d <= vec_norm:
|
|
188
|
+
energy += (self.config["void_point_well_pot_wall_energy"] / self.hartree2kjmol) * (-3.75 * x_long + 2.875)
|
|
189
|
+
|
|
190
|
+
else:
|
|
191
|
+
print("well pot error")
|
|
192
|
+
raise "well pot error"
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
#print(energy)
|
|
196
|
+
return energy
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
class WellPotentialAround:
|
|
200
|
+
def __init__(self, **kwarg):
|
|
201
|
+
self.config = kwarg
|
|
202
|
+
UVL = UnitValueLib()
|
|
203
|
+
self.hartree2kcalmol = UVL.hartree2kcalmol
|
|
204
|
+
self.bohr2angstroms = UVL.bohr2angstroms
|
|
205
|
+
self.hartree2kjmol = UVL.hartree2kjmol
|
|
206
|
+
return
|
|
207
|
+
def calc_energy(self, geom_num_list, bias_pot_params=[]):
|
|
208
|
+
"""
|
|
209
|
+
# required variables: self.config["around_well_pot_wall_energy"]
|
|
210
|
+
self.config["around_well_pot_center"]
|
|
211
|
+
self.config["around_well_pot_limit_dist"]
|
|
212
|
+
self.config["around_well_pot_target"]
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
"""
|
|
216
|
+
geom_center_coord = torch.tensor([0.0, 0.0, 0.0], dtype=torch.float32, requires_grad=True)
|
|
217
|
+
for i in self.config["around_well_pot_center"]:
|
|
218
|
+
geom_center_coord = geom_center_coord + geom_num_list[i-1]
|
|
219
|
+
geom_center_coord = geom_center_coord/len(self.config["around_well_pot_center"])
|
|
220
|
+
energy = 0.0
|
|
221
|
+
for i in self.config["around_well_pot_target"]:
|
|
222
|
+
|
|
223
|
+
vec_norm = torch.linalg.norm(geom_num_list[i-1] - geom_center_coord)
|
|
224
|
+
|
|
225
|
+
a = float(self.config["around_well_pot_limit_dist"][0]) / self.bohr2angstroms
|
|
226
|
+
b = float(self.config["around_well_pot_limit_dist"][1]) / self.bohr2angstroms
|
|
227
|
+
c = float(self.config["around_well_pot_limit_dist"][2]) / self.bohr2angstroms
|
|
228
|
+
d = float(self.config["around_well_pot_limit_dist"][3]) / self.bohr2angstroms
|
|
229
|
+
short_dist_linear_func_slope = 0.5 / (b - a)
|
|
230
|
+
short_dist_linear_func_intercept = 1.0 - 0.5 * b / (b - a)
|
|
231
|
+
long_dist_linear_func_slope = 0.5 / (c - d)
|
|
232
|
+
long_dist_linear_func_intercept = 1.0 - 0.5 * c / (c - d)
|
|
233
|
+
|
|
234
|
+
x_short = short_dist_linear_func_slope * vec_norm + short_dist_linear_func_intercept
|
|
235
|
+
x_long = long_dist_linear_func_slope * vec_norm + long_dist_linear_func_intercept
|
|
236
|
+
|
|
237
|
+
if vec_norm <= a:
|
|
238
|
+
energy += (self.config["around_well_pot_wall_energy"] / self.hartree2kjmol) * (-3.75 * x_short + 2.875)
|
|
239
|
+
|
|
240
|
+
elif a < vec_norm and vec_norm <= b:
|
|
241
|
+
energy += (self.config["around_well_pot_wall_energy"] / self.hartree2kjmol) * (2.0 - 20.0 * x_short ** 3 + 30.0 * x_short ** 4 - 12.0 * x_short ** 5)
|
|
242
|
+
|
|
243
|
+
elif b < vec_norm and vec_norm < c:
|
|
244
|
+
energy += torch.tensor(0.0, requires_grad=True, dtype=torch.float32)
|
|
245
|
+
|
|
246
|
+
elif c <= vec_norm and vec_norm < d:
|
|
247
|
+
energy += (self.config["around_well_pot_wall_energy"] / self.hartree2kjmol) * (2.0 - 20.0 * x_long ** 3 + 30.0 * x_long ** 4 - 12.0 * x_long ** 5)
|
|
248
|
+
|
|
249
|
+
elif d <= vec_norm:
|
|
250
|
+
energy += (self.config["around_well_pot_wall_energy"] / self.hartree2kjmol) * (-3.75 * x_long + 2.875)
|
|
251
|
+
|
|
252
|
+
else:
|
|
253
|
+
print("well pot error")
|
|
254
|
+
raise "well pot error"
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
#print(energy)
|
|
258
|
+
return energy
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
from multioptpy.Parameters.parameter import UnitValueLib
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
import torch
|
|
6
|
+
import itertools
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class UniversalPotential:
|
|
10
|
+
def __init__(self, **kwarg):
|
|
11
|
+
self.config = kwarg
|
|
12
|
+
UVL = UnitValueLib()
|
|
13
|
+
self.hartree2kcalmol = UVL.hartree2kcalmol
|
|
14
|
+
self.bohr2angstroms = UVL.bohr2angstroms
|
|
15
|
+
self.hartree2kjmol = UVL.hartree2kjmol
|
|
16
|
+
return
|
|
17
|
+
|
|
18
|
+
def calc_energy(self, geom_num_list, bias_pot_params=[]):
|
|
19
|
+
"""
|
|
20
|
+
# required variables: self.config["universal_pot_const"],
|
|
21
|
+
self.config["universal_pot_target"],
|
|
22
|
+
"""
|
|
23
|
+
energy = 0.0
|
|
24
|
+
|
|
25
|
+
point = geom_num_list[self.config["universal_pot_target"][0]-1]
|
|
26
|
+
for i in range(1, len(self.config["universal_pot_target"])):
|
|
27
|
+
point = point + geom_num_list[self.config["universal_pot_target"][i]-1]
|
|
28
|
+
|
|
29
|
+
point = point / len(self.config["universal_pot_target"])
|
|
30
|
+
|
|
31
|
+
for i in self.config["universal_pot_target"]:
|
|
32
|
+
energy = energy + self.config["universal_pot_const"] / self.hartree2kjmol / len(list(itertools.combinations(self.config["universal_pot_target"], 2))) * torch.linalg.norm(geom_num_list[i-1] - point)
|
|
33
|
+
|
|
34
|
+
return energy
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
from multioptpy.Parameters.parameter import UnitValueLib
|
|
3
|
+
from multioptpy.Utils.calc_tools import torch_calc_partial_center
|
|
4
|
+
|
|
5
|
+
import torch
|
|
6
|
+
|
|
7
|
+
class ValueRangePotential:
|
|
8
|
+
def __init__(self, **kwarg):
|
|
9
|
+
self.config = kwarg
|
|
10
|
+
UVL = UnitValueLib()
|
|
11
|
+
self.hartree2kcalmol = UVL.hartree2kcalmol
|
|
12
|
+
self.bohr2angstroms = UVL.bohr2angstroms
|
|
13
|
+
self.hartree2kjmol = UVL.hartree2kjmol
|
|
14
|
+
return
|
|
15
|
+
|
|
16
|
+
def calc_energy(self, geom_num_list, bias_pot_params=[]):
|
|
17
|
+
# ref.:https://doi.org/10.1063/5.0197592 (bond range potential)
|
|
18
|
+
"""
|
|
19
|
+
# required variables: self.config["value_range_upper_const"]
|
|
20
|
+
self.config["value_range_lower_const"]
|
|
21
|
+
self.config["value_range_upper_distance"]
|
|
22
|
+
self.config["value_range_lower_distance"]
|
|
23
|
+
self.config["value_range_fragm_1"]
|
|
24
|
+
self.config["value_range_fragm_2"]
|
|
25
|
+
"""
|
|
26
|
+
fragm_1_center = torch_calc_partial_center(geom_num_list, self.config["value_range_fragm_1"])
|
|
27
|
+
fragm_2_center = torch_calc_partial_center(geom_num_list, self.config["value_range_fragm_2"])
|
|
28
|
+
|
|
29
|
+
distance = torch.linalg.norm(fragm_1_center - fragm_2_center)
|
|
30
|
+
|
|
31
|
+
upper_distance = self.config["value_range_upper_distance"] / self.bohr2angstroms
|
|
32
|
+
lower_distance = self.config["value_range_lower_distance"] / self.bohr2angstroms
|
|
33
|
+
upper_const = self.config["value_range_upper_const"]
|
|
34
|
+
lower_const = self.config["value_range_lower_const"]
|
|
35
|
+
energy = torch.log((1 + torch.exp(upper_const * (distance - upper_distance))) * (1 + torch.exp(lower_const * (lower_distance - distance))))
|
|
36
|
+
return energy
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
from multioptpy.Parameters.parameter import UnitValueLib
|
|
3
|
+
import torch
|
|
4
|
+
|
|
5
|
+
class VoidPointPotential:
|
|
6
|
+
def __init__(self, **kwarg):
|
|
7
|
+
self.config = kwarg
|
|
8
|
+
UVL = UnitValueLib()
|
|
9
|
+
self.hartree2kcalmol = UVL.hartree2kcalmol
|
|
10
|
+
self.bohr2angstroms = UVL.bohr2angstroms
|
|
11
|
+
self.hartree2kjmol = UVL.hartree2kjmol
|
|
12
|
+
return
|
|
13
|
+
def calc_energy(self, geom_num_list, bias_pot_params=[]):
|
|
14
|
+
"""
|
|
15
|
+
# required variables: self.config["void_point_pot_spring_const"],
|
|
16
|
+
self.config["void_point_pot_atoms"]
|
|
17
|
+
self.config["void_point_pot_coord"] #need to convert tensor type
|
|
18
|
+
|
|
19
|
+
self.config["void_point_pot_distance"]
|
|
20
|
+
self.config["void_point_pot_order"]
|
|
21
|
+
|
|
22
|
+
"""
|
|
23
|
+
vector = torch.linalg.norm((geom_num_list[self.config["void_point_pot_atoms"]-1] - self.config["void_point_pot_coord"]), ord=2)
|
|
24
|
+
energy = (1 / self.config["void_point_pot_order"]) * self.config["void_point_pot_spring_const"] * (vector - self.config["void_point_pot_distance"]/self.bohr2angstroms) ** self.config["void_point_pot_order"]
|
|
25
|
+
return energy #hartree
|
|
File without changes
|
|
File without changes
|