HTPolyNet 2.11.1__py3-none-any.whl → 2.11.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.
@@ -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
 
@@ -93,6 +108,7 @@ class RingController:
93
108
  self.dicts = d
94
109
  self.state = state or RingCureState()
95
110
  self.rings_df = None
111
+ self.declined = set()
96
112
 
97
113
  # ---- what the loop decides, all of it testable without MD ----
98
114
 
@@ -172,16 +188,49 @@ class RingController:
172
188
  cands = candidate_triples(sites, positions, self.radius, box,
173
189
  same_molecule=self.dicts['same_molecule'],
174
190
  same_residue=self.dicts['same_residue'])
175
- chosen = select_disjoint(cands, max_triples=self.dicts['max_rings_per_iteration'])
191
+ allowed = self._drop_declined(cands, sites)
192
+ chosen = select_disjoint(allowed, max_triples=self.dicts['max_rings_per_iteration'])
193
+ passed = len(cands) - len(allowed)
176
194
  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')
195
+ f'{len(cands)} candidate ring(s) within {self.radius:.3f} nm'
196
+ + (f' ({passed} passed over as already failed)' if passed else '')
197
+ + f', {len(chosen)} accepted')
179
198
  if len(chosen) >= floor or self.radius >= self.dicts['max_radius']:
199
+ if not chosen and cands and self.declined:
200
+ # the memory is now the only thing keeping this iteration idle, and
201
+ # the groups have moved since they were declined; try them again
202
+ logger.info(f'Iteration {self.state.iter}: every ring in reach has '
203
+ f'failed before; forgetting {len(self.declined)} of them '
204
+ f'and offering them again')
205
+ self.declined.clear()
206
+ chosen = select_disjoint(cands,
207
+ max_triples=self.dicts['max_rings_per_iteration'])
180
208
  return sites, chosen
181
209
  self.state.radius_index += 1
182
210
  logger.info(f'Radius increased to {self.radius:.3f} nm '
183
211
  f'({len(chosen)}/{floor} ring(s) so far)')
184
212
 
213
+ def _drop_declined(self, cands, sites):
214
+ """Passes over the triples this cure has already failed to pull shut.
215
+
216
+ A declined ring leaves its three groups unreacted by design, and the next search
217
+ offers them again -- so a rigid endgame proposes the same triples, runs the same
218
+ closure ladder, and declines them again. Measured at conversion 0.97 with 24
219
+ groups left: nine iterations running, 77 declines, about 67 s apiece, before one
220
+ triple finally closed and the cure finished at 0.971.
221
+
222
+ A preference, not a prohibition, because the geometry between one decline and the
223
+ next search is not identical -- the inter-iteration relaxation moves the groups,
224
+ which is how that cure escaped. Skipping a triple saves a ladder that would
225
+ almost certainly fail; refusing it outright would have ended that cure three
226
+ iterations early. :meth:`search` therefore lifts the whole memory rather than
227
+ come back empty-handed.
228
+ """
229
+ if not self.declined:
230
+ return cands
231
+ return [c for c in cands
232
+ if _triple_key(sites.at[a, 'donor'] for a in c[1]) not in self.declined]
233
+
185
234
  def record(self, chosen):
186
235
  """Counts the rings formed and the groups they consumed."""
187
236
  self.state.rings += len(chosen)
@@ -244,6 +293,11 @@ class RingController:
244
293
  next iteration, by which time the neighbourhood has moved; only if they can never
245
294
  close does the cure lose them, which is the right outcome.
246
295
 
296
+ The combination itself is recorded for :meth:`_drop_declined`, which prefers not
297
+ to spend another ladder on it while any untried ring is in reach. That is what
298
+ a rigid endgame otherwise does: nine iterations running, 77 declines, the same
299
+ few triples every time.
300
+
247
301
  Args:
248
302
  bdf (pandas.DataFrame): this iteration's bonds, three rows per ring
249
303
  work (pandas.DataFrame): the same pairs with their final distances
@@ -261,9 +315,11 @@ class RingController:
261
315
  return bdf, chosen
262
316
  for n in range(len(chosen)):
263
317
  if n not in keep:
318
+ self.declined.add(_triple_key(bdf[bdf['triple'] == n]['ai']))
264
319
  logger.info(f'Iteration {self.state.iter}: declining a ring still '
265
320
  f'{worst[n]:.3f} nm from closing (limit {limit:.3f} nm); its '
266
- f'groups stay unreacted and will be offered again')
321
+ f'groups stay unreacted, and this combination waits until '
322
+ f'nothing untried is in reach')
267
323
  renumber = {old: new for new, old in enumerate(keep)}
268
324
  bdf = bdf[bdf['triple'].isin(keep)].copy()
269
325
  bdf['triple'] = [renumber[t] for t in bdf['triple']]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: htpolynet
3
- Version: 2.11.1
3
+ Version: 2.11.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/
@@ -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=T104pX6qUwjzRgOmROuQnxiV6Eu3xSSZim2XBsFwNaY,19962
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
@@ -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.2.dist-info/METADATA,sha256=OC5RW8dmoa0N3Ud9ZbTkPDqJnNPvX0PpA1fESIu-wes,6589
107
+ htpolynet-2.11.2.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
108
+ htpolynet-2.11.2.dist-info/entry_points.txt,sha256=G5tx55llJf-IV9dIe7J8myGdyrhCVggCAhKrVNGP_s0,48
109
+ htpolynet-2.11.2.dist-info/licenses/LICENSE,sha256=piPSGqJdmTGyzF9HOnjlO2KvgOKT8NHwhCuGYM778tY,1071
110
+ htpolynet-2.11.2.dist-info/RECORD,,