HTPolyNet 2.11.1__py3-none-any.whl → 2.11.3__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/runtime.py CHANGED
@@ -718,6 +718,12 @@ class Runtime:
718
718
  rc.state.iter += 1
719
719
  pfs.go_proj()
720
720
  rc.state.to_yaml(statefile)
721
+ # the last batch of rings never sees another closure ladder, so it reaches
722
+ # postcure carrying whatever the ladder left in it
723
+ pfs.go_to(pfs.Dirs.systems_iter(rc.state.iter))
724
+ TC.grab_files()
725
+ rc.settle(TC, gromacs_dict=gromacs_dict)
726
+ pfs.go_proj()
721
727
  self._report_molecule_charges('after ring cure')
722
728
  my_logger(f'Ring cure ends: {rc.state.rings} ring(s), conversion '
723
729
  f'{rc.state.conversion:.3f}', logger.info)
@@ -33,6 +33,21 @@ from ..repair.topology_surgery import neutralize_touched_fragments
33
33
  logger = logging.getLogger(__name__)
34
34
 
35
35
 
36
+ def _triple_key(donors):
37
+ """A ring's identity, in terms that survive from one iteration to the next.
38
+
39
+ A triple is held as row numbers into the site table, and that table is rebuilt
40
+ every iteration and shrinks as groups react, so those numbers name a different
41
+ ring next time. The three donor atoms do not move: one per group, unique to it,
42
+ and fixed for the life of the system.
43
+
44
+ The two ring orientations deliberately share a key. :func:`candidate_triples`
45
+ scores both and keeps the better one, so the orientation that was declined is the
46
+ better one, and the other would have farther to go.
47
+ """
48
+ return frozenset(int(d) for d in donors)
49
+
50
+
36
51
  class RingCureState:
37
52
  """How far a ring cure has got, and enough to resume it."""
38
53
 
@@ -81,6 +96,8 @@ class RingController:
81
96
  'same_residue': False,
82
97
  'relax': [{'ensemble': 'min'},
83
98
  {'ensemble': 'nvt', 'temperature': 300, 'nsteps': 2000}],
99
+ 'settle': [{'ensemble': 'min'},
100
+ {'ensemble': 'nvt', 'temperature': 300, 'nsteps': 2500}],
84
101
  'closure': {'nstages': 8, 'target': 0.15, 'kb': 300000.0, 'max_accept': 0.30,
85
102
  'equilibration': [{'ensemble': 'min'},
86
103
  {'ensemble': 'nvt', 'temperature': 600, 'nsteps': 1000}]},
@@ -93,6 +110,7 @@ class RingController:
93
110
  self.dicts = d
94
111
  self.state = state or RingCureState()
95
112
  self.rings_df = None
113
+ self.declined = set()
96
114
 
97
115
  # ---- what the loop decides, all of it testable without MD ----
98
116
 
@@ -172,16 +190,49 @@ class RingController:
172
190
  cands = candidate_triples(sites, positions, self.radius, box,
173
191
  same_molecule=self.dicts['same_molecule'],
174
192
  same_residue=self.dicts['same_residue'])
175
- chosen = select_disjoint(cands, max_triples=self.dicts['max_rings_per_iteration'])
193
+ allowed = self._drop_declined(cands, sites)
194
+ chosen = select_disjoint(allowed, max_triples=self.dicts['max_rings_per_iteration'])
195
+ passed = len(cands) - len(allowed)
176
196
  logger.info(f'Iteration {self.state.iter}: {len(sites)} unreacted group(s), '
177
- f'{len(cands)} candidate ring(s) within {self.radius:.3f} nm, '
178
- f'{len(chosen)} accepted')
197
+ f'{len(cands)} candidate ring(s) within {self.radius:.3f} nm'
198
+ + (f' ({passed} passed over as already failed)' if passed else '')
199
+ + f', {len(chosen)} accepted')
179
200
  if len(chosen) >= floor or self.radius >= self.dicts['max_radius']:
201
+ if not chosen and cands and self.declined:
202
+ # the memory is now the only thing keeping this iteration idle, and
203
+ # the groups have moved since they were declined; try them again
204
+ logger.info(f'Iteration {self.state.iter}: every ring in reach has '
205
+ f'failed before; forgetting {len(self.declined)} of them '
206
+ f'and offering them again')
207
+ self.declined.clear()
208
+ chosen = select_disjoint(cands,
209
+ max_triples=self.dicts['max_rings_per_iteration'])
180
210
  return sites, chosen
181
211
  self.state.radius_index += 1
182
212
  logger.info(f'Radius increased to {self.radius:.3f} nm '
183
213
  f'({len(chosen)}/{floor} ring(s) so far)')
184
214
 
215
+ def _drop_declined(self, cands, sites):
216
+ """Passes over the triples this cure has already failed to pull shut.
217
+
218
+ A declined ring leaves its three groups unreacted by design, and the next search
219
+ offers them again -- so a rigid endgame proposes the same triples, runs the same
220
+ closure ladder, and declines them again. Measured at conversion 0.97 with 24
221
+ groups left: nine iterations running, 77 declines, about 67 s apiece, before one
222
+ triple finally closed and the cure finished at 0.971.
223
+
224
+ A preference, not a prohibition, because the geometry between one decline and the
225
+ next search is not identical -- the inter-iteration relaxation moves the groups,
226
+ which is how that cure escaped. Skipping a triple saves a ladder that would
227
+ almost certainly fail; refusing it outright would have ended that cure three
228
+ iterations early. :meth:`search` therefore lifts the whole memory rather than
229
+ come back empty-handed.
230
+ """
231
+ if not self.declined:
232
+ return cands
233
+ return [c for c in cands
234
+ if _triple_key(sites.at[a, 'donor'] for a in c[1]) not in self.declined]
235
+
185
236
  def record(self, chosen):
186
237
  """Counts the rings formed and the groups they consumed."""
187
238
  self.state.rings += len(chosen)
@@ -244,6 +295,11 @@ class RingController:
244
295
  next iteration, by which time the neighbourhood has moved; only if they can never
245
296
  close does the cure lose them, which is the right outcome.
246
297
 
298
+ The combination itself is recorded for :meth:`_drop_declined`, which prefers not
299
+ to spend another ladder on it while any untried ring is in reach. That is what
300
+ a rigid endgame otherwise does: nine iterations running, 77 declines, the same
301
+ few triples every time.
302
+
247
303
  Args:
248
304
  bdf (pandas.DataFrame): this iteration's bonds, three rows per ring
249
305
  work (pandas.DataFrame): the same pairs with their final distances
@@ -261,9 +317,11 @@ class RingController:
261
317
  return bdf, chosen
262
318
  for n in range(len(chosen)):
263
319
  if n not in keep:
320
+ self.declined.add(_triple_key(bdf[bdf['triple'] == n]['ai']))
264
321
  logger.info(f'Iteration {self.state.iter}: declining a ring still '
265
322
  f'{worst[n]:.3f} nm from closing (limit {limit:.3f} nm); its '
266
- f'groups stay unreacted and will be offered again')
323
+ f'groups stay unreacted, and this combination waits until '
324
+ f'nothing untried is in reach')
267
325
  renumber = {old: new for new, old in enumerate(keep)}
268
326
  bdf = bdf[bdf['triple'].isin(keep)].copy()
269
327
  bdf['triple'] = [renumber[t] for t in bdf['triple']]
@@ -285,6 +343,45 @@ class RingController:
285
343
  gromacs_dict or {})
286
344
  logger.info(f'Iteration {self.state.iter}: new ring bonds relaxed')
287
345
 
346
+ def settle(self, TC, gromacs_dict=None):
347
+ """Relaxes the network one last time before the cure hands it on.
348
+
349
+ Every batch of rings but the last is relaxed twice: once by :meth:`relax` as
350
+ soon as its bonds exist, and again -- much harder -- by the next iteration's
351
+ closure ladder, which is eight minimizations and 16 ps at 600 K against relax's
352
+ one minimization and 4 ps at 300 K. The final batch only ever gets the first,
353
+ and whatever the cure ends on goes straight into postcure.
354
+
355
+ Measured by htpolynet-study on three 2.11.1 builds, all of which ended on a
356
+ ring-forming iteration, so all of which had been relaxed: bond energy entering
357
+ the anneal tracked how many rings that last iteration formed -- 1, 1 and 4 rings
358
+ for 18849, 26113 and 35959 kJ/mol, against 13619 +/- 226 for a route that enters
359
+ already relaxed. An inventory of one such structure found five bonds beyond
360
+ 2.0 A: one triazine's three ring bonds at 2.24 A, and two monomers whose own
361
+ backbones the ladder had stretched to 2.34 and 3.20 A while pulling their two
362
+ arms toward different rings. Nothing after the restraints come off relieves
363
+ either, and the strain then has to be absorbed by a 500 K anneal, which is where
364
+ 11 of 20 builds died.
365
+
366
+ Unconditional on purpose. The cure has four ways to end -- target reached,
367
+ iterations exhausted, radius exhausted, every ring declined -- and which of them
368
+ leaves strain behind is not worth reasoning about per exit when the remedy is
369
+ this cheap.
370
+
371
+ Args:
372
+ TC (TopoCoord): the system
373
+ gromacs_dict (dict): gromacs directives
374
+ """
375
+ stages = self.dicts['settle']
376
+ if not stages:
377
+ return False
378
+ TC.write_top(f'ringsettle-{self.state.iter}.top')
379
+ TC.write_gro(f'ringsettle-{self.state.iter}.gro')
380
+ self._run_stages(TC, f'ringsettle-{self.state.iter}', stages, gromacs_dict or {})
381
+ logger.info(f'Ring cure settled after {self.state.rings} ring(s); the network is '
382
+ f'relaxed before postcure rather than at 500 K')
383
+ return True
384
+
288
385
  def _run_stages(self, TC, deffnm, stages, gromacs_dict):
289
386
  """Runs one equilibration sequence, as the cure's ladders do."""
290
387
  for stage in stages:
@@ -842,6 +842,20 @@ attributes:
842
842
  Allow two groups of one residue in a ring, which for a dicyanate is both
843
843
  arms into one triazine.
844
844
  default: false
845
+ - name: settle
846
+ type: list
847
+ text: >
848
+ Equilibration run once at the end of the cure, before postcure. Every
849
+ batch of rings but the last is relaxed again by the next iteration's
850
+ closure ladder; the last one is not, and reaches postcure still carrying
851
+ the strain the ladder left -- stretched ring bonds, and monomers whose
852
+ backbones were pulled while their arms went to different rings. An empty
853
+ list skips it.
854
+ default:
855
+ - ensemble: min
856
+ - ensemble: nvt
857
+ temperature: 300
858
+ nsteps: 2500
845
859
  - name: closure
846
860
  type: dict
847
861
  text: >
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: htpolynet
3
- Version: 2.11.1
3
+ Version: 2.11.3
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/
@@ -13,7 +13,7 @@ htpolynet/core/molecule.py,sha256=j0I0qsk5mRTg8QMysxJz6U9HxgTRpRSzHEgJ_SRT-jQ,63
13
13
  htpolynet/core/paramcache.py,sha256=37S88gRXZ5_xAdWyUE-Q3Etxc5HMv8L_RHrykkq9YAs,6966
14
14
  htpolynet/core/productsplice.py,sha256=asFVCW8G_rcMIizvO2Sh98MpOsFqzP1kIX1JySei_p8,12816
15
15
  htpolynet/core/projectfilesystem.py,sha256=2U_EToZxN7yUGWu9BIRABVsYdp1AKkOuManwuFBz89k,20983
16
- htpolynet/core/runtime.py,sha256=yBDfo0-ExUKFmfycWNi-ldnV249yR_j_dkUCkZG0sx8,72385
16
+ htpolynet/core/runtime.py,sha256=SceUjC4lNiY1wO-XvAsy3SJ-RanF6BtXF6GKvqviJ4s,72678
17
17
  htpolynet/core/topocoord.py,sha256=jUgFg9TuUdSm14wo_464xX6dC4okJMrj1FbIzmaoA0Q,110520
18
18
  htpolynet/core/topology.py,sha256=ASyNbyWxw4bvFUACBmydCr-gGl705o68aB7vGYl7cHk,65405
19
19
  htpolynet/cure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -21,7 +21,7 @@ htpolynet/cure/chain.py,sha256=-d5BFE5xUKjFdNkxLfSnCnZIRSJCtr7xuxYzNHBeSgU,5344
21
21
  htpolynet/cure/curecontroller.py,sha256=eTJc1JqrD7w6XLg4pL5ACHXo5N1oJ6P5pVdzMONxiBU,59756
22
22
  htpolynet/cure/expandreactions.py,sha256=eN35-SQrzjoo8ftZVLJkiAKxpA_FigERTwZ8jtoxDng,20682
23
23
  htpolynet/cure/reaction.py,sha256=_kRJ1JzT_fjLIAF6j9lH_Sft41KD1kVQuWPmXdHia-M,13446
24
- htpolynet/cure/ringcontroller.py,sha256=kfJkHeaezH9HoLWsUHcSP7xX0hixsHlo_IDRwwr8aIw,16752
24
+ htpolynet/cure/ringcontroller.py,sha256=3gIJi6BJegAqB-djMZGX5YmIBnzrfdqIxXI7cnk-27U,22292
25
25
  htpolynet/cure/triplesearch.py,sha256=54Dl0RU_LHcwCDa4-0AiRH08eIEA8bTacrA1TDhs5I8,10605
26
26
  htpolynet/external/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  htpolynet/external/ambertools.py,sha256=NkZ0fP6iqwMnMk2jMD3-EaiGCmutHb1MVFOTFJiQ7WI,6286
@@ -92,7 +92,7 @@ htpolynet/resources/molecules/sample-inputs/STY.mol2,sha256=r1NqpovL6L7E96Kkyc6U
92
92
  htpolynet/resources/tcl/readbonds.tcl,sha256=l_bh7eMjbxVi44UMPMi32bFntZltij92KmKfXC1qDz4,972
93
93
  htpolynet/resources/tcl/readgrx.tcl,sha256=A1KvyIpFC_lwfze3XOqTCPqLIkq7HwmqJ96lZH42W0U,1731
94
94
  htpolynet/resources/tcl/render.tcl,sha256=KUszYxzWtfuL7OXdtdk8n6eAQbz8DJfKJrGbb0pOdrI,2379
95
- htpolynet/schema/base.yaml,sha256=rIAWZDJuiZLIpnVU5DZCv40Z7KmQ5cx8o5RJyOY2i20,40385
95
+ htpolynet/schema/base.yaml,sha256=UFnNDWitwAqv2g5TH7PtGCIfKa7ZWiw7-vIAyHL4A4g,40997
96
96
  htpolynet/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
97
97
  htpolynet/utils/banner.py,sha256=hdw6xoHNAo9p6X33LmhW5qyb67qAaQ3hmLnct3ZuDy0,906
98
98
  htpolynet/utils/checkpoint.py,sha256=QTZIJ8K777T6o-mNpjPdelTqrpT0amLlQcgpHBiq5V0,2924
@@ -103,8 +103,8 @@ htpolynet/utils/logsetup.py,sha256=o0mlVXNzqcfua2SAlJPkGSh4lM_bmI10gWwpb9gqYu8,1
103
103
  htpolynet/utils/profiling.py,sha256=su7qpGEz6FXVU4KT2HQDWG82bc1sgsfpDQBbAfPpsHc,7331
104
104
  htpolynet/utils/stringthings.py,sha256=Mr6o55EM8o4YAaVYpjIJj2IxDToNdbPzb-lpQ3w3jFk,1176
105
105
  htpolynet/utils/vmd_viz.py,sha256=Crk3Ln88PKiJ9X7DMMkFEVh2Ru6a1y0RUgj3w6EIgFc,10867
106
- htpolynet-2.11.1.dist-info/METADATA,sha256=PTLVAdHklYafqGf5MONjWD8PZ9u90joApW9uBdS9KYQ,6589
107
- htpolynet-2.11.1.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
108
- htpolynet-2.11.1.dist-info/entry_points.txt,sha256=G5tx55llJf-IV9dIe7J8myGdyrhCVggCAhKrVNGP_s0,48
109
- htpolynet-2.11.1.dist-info/licenses/LICENSE,sha256=piPSGqJdmTGyzF9HOnjlO2KvgOKT8NHwhCuGYM778tY,1071
110
- htpolynet-2.11.1.dist-info/RECORD,,
106
+ htpolynet-2.11.3.dist-info/METADATA,sha256=pDmyTILiYe8AJTW40OguOMZcfN2q0mhNboexlAMOZ64,6589
107
+ htpolynet-2.11.3.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
108
+ htpolynet-2.11.3.dist-info/entry_points.txt,sha256=G5tx55llJf-IV9dIe7J8myGdyrhCVggCAhKrVNGP_s0,48
109
+ htpolynet-2.11.3.dist-info/licenses/LICENSE,sha256=piPSGqJdmTGyzF9HOnjlO2KvgOKT8NHwhCuGYM778tY,1071
110
+ htpolynet-2.11.3.dist-info/RECORD,,