HTPolyNet 2.10.1__py3-none-any.whl → 2.10.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.
- htpolynet/core/molecule.py +75 -18
- {htpolynet-2.10.1.dist-info → htpolynet-2.10.2.dist-info}/METADATA +1 -1
- {htpolynet-2.10.1.dist-info → htpolynet-2.10.2.dist-info}/RECORD +6 -6
- {htpolynet-2.10.1.dist-info → htpolynet-2.10.2.dist-info}/WHEEL +0 -0
- {htpolynet-2.10.1.dist-info → htpolynet-2.10.2.dist-info}/entry_points.txt +0 -0
- {htpolynet-2.10.1.dist-info → htpolynet-2.10.2.dist-info}/licenses/LICENSE +0 -0
htpolynet/core/molecule.py
CHANGED
|
@@ -51,6 +51,46 @@ def _yield_bonds_as_df(R: Reaction, TC: TopoCoord, resid_mapper) -> pd.DataFrame
|
|
|
51
51
|
'order': bondrec['order'], 'reactantName': R.product})
|
|
52
52
|
return pd.DataFrame(rows)
|
|
53
53
|
|
|
54
|
+
_TRANSROT_STEP_DEG_ = 10.0
|
|
55
|
+
"""Angular step of the turn scan in Molecule.transrot."""
|
|
56
|
+
|
|
57
|
+
_TRANSROT_WARN_NM_ = 0.10
|
|
58
|
+
"""Closest approach, in nm, below which a template's starting geometry is reported as crowded.
|
|
59
|
+
|
|
60
|
+
Contacts of 1.2-1.5 A between the new piece and the rest are routine before
|
|
61
|
+
minimization; below 1 A they have been seen to stop sqm converging (a TMB ring
|
|
62
|
+
methyl H 0.82 A from a triazine N).
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _rotate_about_axis(xyz, point, axis, theta):
|
|
67
|
+
"""Rotates points by theta about the line through point along unit vector axis (Rodrigues).
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
xyz (numpy.ndarray): (n, 3) positions
|
|
71
|
+
point (numpy.ndarray): a point on the axis
|
|
72
|
+
axis (numpy.ndarray): unit vector along the axis
|
|
73
|
+
theta (float): angle in radians
|
|
74
|
+
|
|
75
|
+
Returns:
|
|
76
|
+
numpy.ndarray: rotated (n, 3) positions
|
|
77
|
+
"""
|
|
78
|
+
if theta == 0.0:
|
|
79
|
+
return xyz.copy()
|
|
80
|
+
k = axis / np.linalg.norm(axis)
|
|
81
|
+
K = np.array([[0, -k[2], k[1]], [k[2], 0, -k[0]], [-k[1], k[0], 0]])
|
|
82
|
+
R = np.eye(3) + np.sin(theta) * K + (1.0 - np.cos(theta)) * (K @ K)
|
|
83
|
+
return (xyz - point) @ R.T + point
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _min_distance(a, b):
|
|
87
|
+
"""Smallest distance between any point of a and any point of b; inf if either is empty."""
|
|
88
|
+
if len(a) == 0 or len(b) == 0:
|
|
89
|
+
return np.inf
|
|
90
|
+
diff = a[:, np.newaxis, :] - b[np.newaxis, :, :]
|
|
91
|
+
return float(np.sqrt((diff * diff).sum(axis=2)).min())
|
|
92
|
+
|
|
93
|
+
|
|
54
94
|
class Molecule:
|
|
55
95
|
def __init__(self, name='', generator:Reaction=None, origin:str=None):
|
|
56
96
|
self.name = name
|
|
@@ -830,7 +870,16 @@ class Molecule:
|
|
|
830
870
|
Rj = TC.get_R(from_idx)
|
|
831
871
|
logger.debug(f'Ri {at_idx} {Ri} {type(Ri)} {Ri.dtype}')
|
|
832
872
|
logger.debug(f'Rj {from_idx} {Rj} {type(Rj)} {Rj.dtype}')
|
|
833
|
-
|
|
873
|
+
# The two sacrificial H's are made to coincide, which puts at_idx, the H's
|
|
874
|
+
# and from_idx on one line. The moving piece can still turn freely about
|
|
875
|
+
# that line, and that freedom is what clears a crowded site: a third
|
|
876
|
+
# tetramethyl bisphenol on a triazine lands its ortho methyl inside the
|
|
877
|
+
# ring at the unrotated placement. So each H pairing is tried at a
|
|
878
|
+
# range of turns, and the one farthest from the residues that stay put
|
|
879
|
+
# wins. (Measuring against all of TC would include the moving piece's
|
|
880
|
+
# own pre-move positions.)
|
|
881
|
+
fixed = C[~C['resNum'].isin(bresids)]
|
|
882
|
+
overall_maximum = (-1.e9, -1, -1, 0.0)
|
|
834
883
|
coord_trials = {}
|
|
835
884
|
for myH, myHnm in myHpartners.items(): # keys are globalIdx's, values are names
|
|
836
885
|
coord_trials[myH] = {}
|
|
@@ -838,17 +887,13 @@ class Molecule:
|
|
|
838
887
|
logger.debug(f' Rh {myH} {Rh} {Rh.dtype}')
|
|
839
888
|
Rih = Ri - Rh
|
|
840
889
|
Rih *= 1.0 / np.linalg.norm(Rih)
|
|
890
|
+
fixed_xyz = fixed.loc[fixed['globalIdx'] != myH, ['posX', 'posY', 'posZ']].to_numpy(dtype=float)
|
|
841
891
|
for otH, otHnm in otHpartners.items():
|
|
842
892
|
logger.debug(f'{self.name}: Considering {myH} {otH}')
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
Rk = coord_trials[myH][otH].get_R(otH)
|
|
846
|
-
logger.debug(f'{self.name}: otH {otH} Rk {Rk} {Rk.dtype}')
|
|
893
|
+
aligned = deepcopy(BTC)
|
|
894
|
+
Rk = aligned.get_R(otH)
|
|
847
895
|
Rkj = Rk - Rj
|
|
848
896
|
Rkj *= 1.0 / np.linalg.norm(Rkj)
|
|
849
|
-
logger.debug(f'Rkj {Rkj} {Rkj.dtype} Rih {Rih} {Rih.dtype}')
|
|
850
|
-
#Rhk=Rh-Rk
|
|
851
|
-
#rhk=np.linalg.norm(Rhk)
|
|
852
897
|
cp = np.cross(Rkj,Rih)
|
|
853
898
|
c = np.dot(Rkj,Rih)
|
|
854
899
|
v = np.array([[0,-cp[2],cp[1]],[cp[2],0,-cp[0]],[-cp[1],cp[0],0]])
|
|
@@ -856,19 +901,31 @@ class Molecule:
|
|
|
856
901
|
I = np.array([[1.,0.,0.],[0.,1.,0.],[0.,0.,1.]])
|
|
857
902
|
# R is the rotation matrix that will rotate donb to align with accb
|
|
858
903
|
R = I + v + v2 / (1. + c)
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
coord_trials[myH][otH].rotate(R)
|
|
862
|
-
Rk = coord_trials[myH][otH].get_R(otH)
|
|
904
|
+
aligned.rotate(R)
|
|
905
|
+
Rk = aligned.get_R(otH)
|
|
863
906
|
# overlap the two H atoms by translation
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
907
|
+
aligned.translate(Rh - Rk)
|
|
908
|
+
A = aligned.Coordinates.A
|
|
909
|
+
moving_mask = (A['globalIdx'] != otH).to_numpy()
|
|
910
|
+
xyz = A[['posX', 'posY', 'posZ']].to_numpy(dtype=float)
|
|
911
|
+
best = None
|
|
912
|
+
for theta in np.deg2rad(np.arange(0.0, 360.0, _TRANSROT_STEP_DEG_)):
|
|
913
|
+
trial = _rotate_about_axis(xyz, Rh, Rih, theta)
|
|
914
|
+
minD = _min_distance(trial[moving_mask], fixed_xyz)
|
|
915
|
+
if best is None or minD > best[0]:
|
|
916
|
+
best = (minD, theta, trial)
|
|
917
|
+
minD, theta, trial = best
|
|
918
|
+
A[['posX', 'posY', 'posZ']] = trial
|
|
919
|
+
coord_trials[myH][otH] = aligned
|
|
920
|
+
logger.debug(f'{self.name}: {myH}/{otH} best turn {np.rad2deg(theta):.0f} deg, minD {minD}')
|
|
868
921
|
if minD > overall_maximum[0]:
|
|
869
|
-
overall_maximum = (minD, myH, otH)
|
|
922
|
+
overall_maximum = (minD, myH, otH, theta)
|
|
870
923
|
logger.debug(f'{self.name}: overall_maximum {overall_maximum}')
|
|
871
|
-
minD, myH, otH = overall_maximum
|
|
924
|
+
minD, myH, otH, _ = overall_maximum
|
|
925
|
+
if minD < _TRANSROT_WARN_NM_:
|
|
926
|
+
logger.warning(f'{self.name}: the best placement found for the new bond still leaves two atoms '
|
|
927
|
+
f'{minD*10:.2f} A apart; a semi-empirical charge method (bcc, abcg2) may fail to converge '
|
|
928
|
+
f'on this starting geometry')
|
|
872
929
|
BTC = coord_trials[myH][otH]
|
|
873
930
|
TC.overwrite_coords(BTC)
|
|
874
931
|
TC.swap_atom_names(myH, list(myHighestH.keys())[0])
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: htpolynet
|
|
3
|
-
Version: 2.10.
|
|
3
|
+
Version: 2.10.2
|
|
4
4
|
Summary: Automated MD System Builder for Amorphous Network Polymers
|
|
5
5
|
Project-URL: Source, https://github.com/cameronabrams/htpolynet
|
|
6
6
|
Project-URL: Documentation, https://htpolynet.readthedocs.io/
|
|
@@ -9,7 +9,7 @@ htpolynet/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
9
9
|
htpolynet/core/bondtemplate.py,sha256=_1vYMugonDuogysu15IsbpthvxYb6uJKC5ao7pQcWvg,9969
|
|
10
10
|
htpolynet/core/configuration.py,sha256=RKnsVz_SX7GrCxuL-1rXP9AQ23EcFyiQSYeLiG6CHc4,5191
|
|
11
11
|
htpolynet/core/coordinates.py,sha256=CGTHkdfw2ikc2ANacA5akRhZ9tOyM2IbELwQ2FVcKRw,23878
|
|
12
|
-
htpolynet/core/molecule.py,sha256=
|
|
12
|
+
htpolynet/core/molecule.py,sha256=M2IgRZrSqFFLzMvdk4qZLYo1veiWXkEhjN1uX8C4i-w,55359
|
|
13
13
|
htpolynet/core/paramcache.py,sha256=A99VVqf1SdcdzoW5tEkRnN_GEPMjnw-1yy0J-S6FzJI,5660
|
|
14
14
|
htpolynet/core/projectfilesystem.py,sha256=2U_EToZxN7yUGWu9BIRABVsYdp1AKkOuManwuFBz89k,20983
|
|
15
15
|
htpolynet/core/runtime.py,sha256=FQUHlU0SUPxAqcUnMZHhpLgNu8fa5zRmPy8kv5pv72w,62251
|
|
@@ -98,8 +98,8 @@ htpolynet/utils/logsetup.py,sha256=o0mlVXNzqcfua2SAlJPkGSh4lM_bmI10gWwpb9gqYu8,1
|
|
|
98
98
|
htpolynet/utils/profiling.py,sha256=su7qpGEz6FXVU4KT2HQDWG82bc1sgsfpDQBbAfPpsHc,7331
|
|
99
99
|
htpolynet/utils/stringthings.py,sha256=Mr6o55EM8o4YAaVYpjIJj2IxDToNdbPzb-lpQ3w3jFk,1176
|
|
100
100
|
htpolynet/utils/vmd_viz.py,sha256=Crk3Ln88PKiJ9X7DMMkFEVh2Ru6a1y0RUgj3w6EIgFc,10867
|
|
101
|
-
htpolynet-2.10.
|
|
102
|
-
htpolynet-2.10.
|
|
103
|
-
htpolynet-2.10.
|
|
104
|
-
htpolynet-2.10.
|
|
105
|
-
htpolynet-2.10.
|
|
101
|
+
htpolynet-2.10.2.dist-info/METADATA,sha256=M2phMgBpu4Ry-usT-iLjtO6hhBfHhaVtMN5BlhAW6fc,6589
|
|
102
|
+
htpolynet-2.10.2.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
103
|
+
htpolynet-2.10.2.dist-info/entry_points.txt,sha256=G5tx55llJf-IV9dIe7J8myGdyrhCVggCAhKrVNGP_s0,48
|
|
104
|
+
htpolynet-2.10.2.dist-info/licenses/LICENSE,sha256=piPSGqJdmTGyzF9HOnjlO2KvgOKT8NHwhCuGYM778tY,1071
|
|
105
|
+
htpolynet-2.10.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|