HTPolyNet 2.3.1__py3-none-any.whl → 2.5.0__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/cli.py CHANGED
@@ -5,11 +5,15 @@ Author: Cameron F. Abrams <cfa22@drexel.edu>
5
5
 
6
6
  import logging
7
7
  import os
8
+ import shutil
8
9
  import textwrap
9
10
 
10
11
  import argparse as ap
11
12
  import yaml
12
13
 
14
+ from importlib.resources import files as pkg_files
15
+ from pathlib import Path
16
+
13
17
  from .analysis.analyze import analyze
14
18
  from .analysis.plot import plots
15
19
  from .analysis.postsim import postsim
@@ -119,6 +123,37 @@ def fetch_example(args):
119
123
  _fetch_one(depot, fullname)
120
124
 
121
125
 
126
+ def setup_claude(args: ap.Namespace):
127
+ """Handles the setup-claude subcommand.
128
+
129
+ Copies the bundled skill into the user's skills directory. This runs only
130
+ when the user asks for it; installing the package never touches
131
+ ``~/.claude/``.
132
+
133
+ Args:
134
+ args (argparse.Namespace): parsed arguments
135
+ """
136
+ # Resolve through htpolynet.resources, which is a real package; the claude/
137
+ # subdirectory carries no __init__.py, matching every other resource
138
+ # subdirectory.
139
+ source = pkg_files('htpolynet.resources').joinpath('claude', 'SKILL.md')
140
+ if not source.is_file():
141
+ raise FileNotFoundError(f'Bundled skill not found at {source}')
142
+
143
+ skill_dir = Path(args.skills_dir).expanduser() / 'htpolynet'
144
+ target = skill_dir / 'SKILL.md'
145
+
146
+ if target.exists() and not args.force:
147
+ print(f'{target} already exists; re-run with --force to overwrite it')
148
+ return
149
+
150
+ skill_dir.mkdir(parents=True, exist_ok=True)
151
+ with source.open('rb') as fh, open(target, 'wb') as out:
152
+ shutil.copyfileobj(fh, out)
153
+ print(f'Written: {target}')
154
+ print('Claude Code picks the skill up on its next session in any directory.')
155
+
156
+
122
157
  def _add_run_options(p, loglevel='debug'):
123
158
  """Adds run options (no positional config) shared by run and gen-slurm-script."""
124
159
  p.add_argument('-lib',type=str,default='lib',help='local user library of molecular structures and parameterizations')
@@ -257,6 +292,7 @@ def cli():
257
292
  ('analyze', analyze, "perform 'gmx <command>' style analyses specified in the config file"),
258
293
  ('gen-slurm-script', gen_slurm_script, 'generate a SLURM submission script for running htpolynet on a cluster'),
259
294
  ('make-viz', make_viz, 'regenerate VMD viz files (.viz.psf + .viz.tcl) from an existing gromacs top + gro pair'),
295
+ ('setup-claude', setup_claude, "install htpolynet's Claude Code skill so an agent can drive htpolynet"),
260
296
  ]
261
297
 
262
298
  parser = ap.ArgumentParser(description=textwrap.dedent(banner_message),formatter_class=ap.RawDescriptionHelpFormatter)
@@ -291,6 +327,10 @@ def cli():
291
327
  cp['make-viz'].add_argument('-grx', type=str, default=None, help='input htpolynet .grx (default: auto-detect <gro-stem>.grx; needed for the constituent-selection macros)')
292
328
  cp['make-viz'].add_argument('-prefix', type=str, default=None, help='output basename; the .viz.psf, .viz.tcl, and .viz.macros.tcl are written next to the input gro (default: stem of -gro)')
293
329
 
330
+ cp['setup-claude'].add_argument('--skills-dir', type=str, default='~/.claude/skills',
331
+ help='skills directory to install into (default: %(default)s); use ./.claude/skills to scope the skill to one project')
332
+ cp['setup-claude'].add_argument('--force', default=False, action='store_true', help='overwrite an existing installed skill')
333
+
294
334
  _add_analysis_args(cp['postsim'])
295
335
  _add_analysis_args(cp['analyze'])
296
336
 
htpolynet/core/runtime.py CHANGED
@@ -7,6 +7,8 @@ import os
7
7
  import random
8
8
  import shutil
9
9
 
10
+ import yaml
11
+
10
12
  from collections import namedtuple
11
13
  from copy import deepcopy
12
14
 
@@ -470,8 +472,9 @@ class Runtime:
470
472
  from ..repair import run_repair
471
473
  TC = self.TopoCoord
472
474
  my_logger(f'Postcure repair in {pfs.cwd()}', logger.info)
473
- n_repaired = run_repair(TC, self.molecules, specs, self.reactions)
475
+ n_repaired, repair_stats = run_repair(TC, self.molecules, specs, self.reactions)
474
476
  my_logger(f'Postcure repair performed {n_repaired} dismantle operations', logger.info)
477
+ self._report_repair_conversion(repair_stats)
475
478
  # Write out the repaired system so the relaxation can pick it up
476
479
  TC.write_grx_attributes('repaired.grx')
477
480
  TC.write_gro('repaired.gro')
@@ -487,6 +490,45 @@ class Runtime:
487
490
  deffnm='repair-nvt')
488
491
  return {c: os.path.basename(x) for c, x in TC.files.items() if c != 'mol2'}
489
492
 
493
+ def _report_repair_conversion(self, repair_stats):
494
+ """Reports the conversion a repaired system actually carries, next to the one the cure reported.
495
+
496
+ The cure iterates on bond conversion: bonds formed over bonds
497
+ possible. Repair then dismantles every crosslinker that did not fill
498
+ all of its sites, so the structure that leaves this stage contains
499
+ only complete crosslinkers, and the fraction of those is what an
500
+ experiment measures. The two numbers differ -- for a trifunctional
501
+ crosslinker under random placement the second is roughly the cube of
502
+ the first -- and reporting only the cure's number invites a run at a
503
+ bond conversion of 0.90 to be written up as a 0.90 when it is closer
504
+ to 0.76. Both numbers, and the counts behind them, are also written
505
+ to ``repair-summary.yaml`` in this stage's directory.
506
+
507
+ Args:
508
+ repair_stats (list): statistics dicts returned by :func:`htpolynet.repair.run_repair`
509
+ """
510
+ if not any(st['n_crosslinkers'] for st in repair_stats):
511
+ return
512
+ bond_conversion = None
513
+ cc = getattr(self, 'cc', None)
514
+ if cc is not None:
515
+ bond_conversion = cc.conversion()
516
+ record = {'bond_conversion': bond_conversion, 'repairs': repair_stats}
517
+ for st in repair_stats:
518
+ if not st['n_crosslinkers']:
519
+ continue
520
+ msg = (f'Crosslinker conversion after repair: '
521
+ f'{st["crosslinker_conversion"]:.3f} '
522
+ f'({st["n_complete"]}/{st["n_crosslinkers"]} {st["residue"]} complete)')
523
+ if bond_conversion is not None:
524
+ msg += f'; the cure reported a bond conversion of {bond_conversion:.3f}'
525
+ my_logger(msg, logger.info)
526
+ try:
527
+ with open('repair-summary.yaml', 'w') as f:
528
+ yaml.dump(record, f, default_flow_style=False)
529
+ except Exception as e:
530
+ logger.warning(f'Could not write repair-summary.yaml: {e}')
531
+
490
532
  @cp.enableCheckpoint
491
533
  def do_postcure(self):
492
534
  """Manages execution of mdrun to perform any post-cure MD simulation(s).
@@ -27,6 +27,43 @@ from ..utils.stringthings import my_logger
27
27
 
28
28
  logger = logging.getLogger(__name__)
29
29
 
30
+ def residue_reaction_counts(adf):
31
+ """Counts, per residue, how many bonds that residue's atoms have already formed.
32
+
33
+ Args:
34
+ adf (pandas.DataFrame): the global atom dataframe; must carry the 'resNum' and 'nreactions' attributes
35
+
36
+ Returns:
37
+ pandas.Series: number of bonds already formed, indexed by residue number
38
+ """
39
+ return adf.groupby('resNum')['nreactions'].sum()
40
+
41
+ def rank_bond_candidates(bdf,reaction_counts=None):
42
+ """Orders bond candidates ahead of the greedy one-bond-per-residue downselection.
43
+
44
+ The default ordering is by pair separation alone. Separation is
45
+ uncorrelated with how many bonds a crosslinker already carries, so bonds
46
+ spread evenly over all crosslinkers rather than completing the
47
+ partly-reacted ones. Supplying ``reaction_counts`` promotes candidates
48
+ whose B-side residue already carries the most bonds, with each such group
49
+ still ordered by separation; because the downselection that follows is
50
+ greedy and admits at most one bond per residue per iteration, this ordering
51
+ is what decides which residues react.
52
+
53
+ Args:
54
+ bdf (pandas.DataFrame): bond candidates, with column 'r' and, when biasing, column 'rj'
55
+ reaction_counts (pandas.Series): bonds already formed per residue, as returned by :func:`residue_reaction_counts`; None (the default) selects the distance-only ordering
56
+
57
+ Returns:
58
+ pandas.DataFrame: bdf reordered; its columns are unchanged
59
+ """
60
+ if reaction_counts is None:
61
+ return bdf.sort_values('r',axis=0,ignore_index=True).reset_index(drop=True)
62
+ ranked=bdf.copy()
63
+ ranked['_nrx']=ranked['rj'].map(reaction_counts).fillna(0).astype(int)
64
+ ranked=ranked.sort_values(['_nrx','r'],ascending=[False,True],ignore_index=True)
65
+ return ranked.drop(columns=['_nrx']).reset_index(drop=True)
66
+
30
67
  class cure_step(Enum):
31
68
  """Enumerated CURE step
32
69
  """
@@ -127,6 +164,7 @@ class CureController:
127
164
  'desired_conversion': 0.5,
128
165
  'min_allowable_bondcycle_length':-1, # not set
129
166
  'min_bonds_per_iteration': 10, # grow radius until >= this many bonds (or max radius)
167
+ 'completion_bias': False, # rank bond candidates by B-side completion before distance
130
168
  'ncpu' : os.cpu_count()
131
169
  },
132
170
  'drag': {
@@ -261,6 +299,19 @@ class CureController:
261
299
  if not self.state.max_nxlinkbonds: return 0
262
300
  return float(self.state.cum_nxlinkbonds)/self.state.max_nxlinkbonds
263
301
 
302
+ def conversion(self):
303
+ """Returns the current bond conversion: the fraction of all possible crosslink bonds that have been formed.
304
+
305
+ This is the number the cure iterates against and reports. For a
306
+ chemistry whose crosslinkers only count as reacted once every one of
307
+ their sites is filled, it is an upper bound on the conversion an
308
+ experiment would measure; see :mod:`htpolynet.repair.cyanate_cap`.
309
+
310
+ Returns:
311
+ float: bond conversion
312
+ """
313
+ return self._curr_conversion()
314
+
264
315
  def reset(self):
265
316
  """Resets this CureController object by resetting its CureState, its bonds dataframe, and its search_failed member.
266
317
  """
@@ -569,6 +620,22 @@ class CureController:
569
620
  self.state.current_stage[mode]=0
570
621
  self.state._to_yaml()
571
622
 
623
+ def _completion_bias_counts(self,adf):
624
+ """Returns per-residue reaction counts when the completion bias is enabled, else None.
625
+
626
+ Args:
627
+ adf (pandas.DataFrame): the global atom dataframe
628
+
629
+ Returns:
630
+ pandas.Series: per-residue bond counts, or None to rank by distance alone
631
+ """
632
+ if not self.dicts['controls'].get('completion_bias',False):
633
+ return None
634
+ if 'nreactions' not in adf.columns:
635
+ logger.warning('completion_bias is enabled but the atom dataframe carries no "nreactions" attribute; ranking bond candidates by distance alone')
636
+ return None
637
+ return residue_reaction_counts(adf)
638
+
572
639
  # TODO: move to searchbonds.by; split into make_candidates() and apply_filters()
573
640
  def _searchbonds(self,TC:TopoCoord,RL:ReactionList,MD:MoleculeDict,stage=reaction_stage.cure,abs_max=0,apply_probabilities=False,reentry=False):
574
641
  """Manages the search for bonds.
@@ -679,7 +746,11 @@ class CureController:
679
746
  # logger.debug(ln)
680
747
 
681
748
  if stage==reaction_stage.cure and bdf.shape[0]>0:
682
- bdf=bdf.sort_values('r',axis=0,ignore_index=True).reset_index(drop=True)
749
+ reaction_counts=self._completion_bias_counts(adf)
750
+ bdf=rank_bond_candidates(bdf,reaction_counts)
751
+ if reaction_counts is not None:
752
+ nrx=bdf['rj'].map(reaction_counts).fillna(0).astype(int)
753
+ logger.debug(f'Completion bias: {int((nrx>0).sum())} of {bdf.shape[0]} candidates extend an already-reacted B-side residue (most bonds already carried: {int(nrx.max())})')
683
754
  bdf['allowed']=[True for x in range(bdf.shape[0])]
684
755
  unique_atomidx=set(bdf.ai.to_list()).union(set(bdf.aj.to_list()))
685
756
  unique_resids=set(bdf.ri.to_list()).union(set(bdf.rj.to_list()))
@@ -97,8 +97,13 @@ def _get_git_commit():
97
97
  report. Reporting 'unknown' there leaves a build with no way to answer
98
98
  "what code produced this" from inside itself, which is exactly the
99
99
  question the parameterization records exist to answer for molecules.
100
- Fall back to the installed distribution version, which for a released
101
- install maps to a tag and is the honest answer.
100
+ The published container bakes the commit it was built from into
101
+ ``HTPOLYNET_COMMIT``, which is consulted next: the image's version string
102
+ alone is misleading between releases, since the scheduled rebuild builds
103
+ from ``main`` HEAD and reports whatever ``pyproject.toml`` last said.
104
+
105
+ Failing both, fall back to the installed distribution version, which for a
106
+ released install maps to a tag and is the honest answer.
102
107
  """
103
108
  global git_commit
104
109
  src = os.path.dirname(__file__)
@@ -118,6 +123,10 @@ def _get_git_commit():
118
123
  return
119
124
  except Exception:
120
125
  pass
126
+ baked = os.environ.get('HTPOLYNET_COMMIT', '').strip()
127
+ if baked and baked != 'unknown':
128
+ git_commit = f'{baked[:7]} (baked in at image build)'
129
+ return
121
130
  try:
122
131
  from importlib.metadata import version, PackageNotFoundError
123
132
  try:
@@ -24,16 +24,21 @@ def run_repair(TC, moldict, repair_specs, reactions):
24
24
  parameter templates by the drivers.
25
25
 
26
26
  Returns:
27
- int: number of repairs performed across all drivers.
27
+ tuple: (int, list) -- the number of repairs performed across all
28
+ drivers, and one statistics dict per driver that reported any
29
+ (see :func:`htpolynet.repair.cyanate_cap._completion_stats`).
28
30
  """
29
31
  if not repair_specs:
30
- return 0
32
+ return 0, []
31
33
  total = 0
34
+ stats = []
32
35
  for spec in repair_specs:
33
36
  rtype = spec.get('type')
34
37
  if rtype == 'triazine_to_cyanate_cap':
35
38
  from .cyanate_cap import triazine_to_cyanate_cap
36
- total += triazine_to_cyanate_cap(TC, moldict, spec, reactions)
39
+ result = triazine_to_cyanate_cap(TC, moldict, spec, reactions)
40
+ total += result['n_dismantled']
41
+ stats.append(result)
37
42
  else:
38
43
  logger.warning(f'Unknown postcure_repair type "{rtype}"; skipping')
39
- return total
44
+ return total, stats
@@ -127,6 +127,42 @@ def _place_cyn_along(bpa_o_xyz, bpa_o_h_xyz, oc_len=0.136, cn_len=0.116):
127
127
  # ---------------------------------------------------------------------------
128
128
 
129
129
 
130
+ def _completion_stats(residue_name, n_crosslinkers, n_incomplete, log=True):
131
+ """Summarize crosslinker completion and log it.
132
+
133
+ A crosslinker survives this repair only if every one of its sites is
134
+ filled; the incomplete ones are dismantled back into caps. So the
135
+ fraction of crosslinkers that survive intact -- not the bond conversion
136
+ the cure iterates against -- is the quantity an experiment measures.
137
+ For a cyanate ester that is the FTIR -OCN conversion, because each
138
+ complete triazine consumes exactly three -OCN groups.
139
+
140
+ Args:
141
+ residue_name (str): crosslinker residue name, used only in the message
142
+ n_crosslinkers (int): number of crosslinker residues in the system
143
+ n_incomplete (int): how many of them are being dismantled
144
+ log (bool): emit the summary message; False when there is nothing to summarize
145
+
146
+ Returns:
147
+ dict: n_crosslinkers, n_complete, n_dismantled, crosslinker_conversion
148
+ """
149
+ n_complete = n_crosslinkers - n_incomplete
150
+ chi = n_complete / n_crosslinkers if n_crosslinkers else 0.0
151
+ if log:
152
+ logger.info(
153
+ f'triazine_to_cyanate_cap: {n_complete} of {n_crosslinkers} '
154
+ f'{residue_name} residues are complete and survive repair; '
155
+ f'crosslinker conversion {chi:.3f}'
156
+ )
157
+ return {
158
+ 'residue': residue_name,
159
+ 'n_crosslinkers': n_crosslinkers,
160
+ 'n_complete': n_complete,
161
+ 'n_dismantled': n_incomplete,
162
+ 'crosslinker_conversion': chi,
163
+ }
164
+
165
+
130
166
  def triazine_to_cyanate_cap(TC, moldict, spec, reactions):
131
167
  """Execute the triazine-to-cyanate-cap repair.
132
168
 
@@ -139,7 +175,7 @@ def triazine_to_cyanate_cap(TC, moldict, spec, reactions):
139
175
  reactions: ReactionList (currently unused; reserved for cross-checks).
140
176
 
141
177
  Returns:
142
- int: number of incomplete triazines dismantled.
178
+ dict: completion statistics as returned by :func:`_completion_stats`.
143
179
  """
144
180
  cl = spec['crosslinker']
145
181
  br = spec['bridge']
@@ -158,7 +194,7 @@ def triazine_to_cyanate_cap(TC, moldict, spec, reactions):
158
194
  cl_residues = _find_crosslinker_residues(TC, cl['residue'])
159
195
  if not cl_residues:
160
196
  logger.info(f'triazine_to_cyanate_cap: no {cl["residue"]} residues found; nothing to do')
161
- return 0
197
+ return _completion_stats(cl['residue'], 0, 0, log=False)
162
198
 
163
199
  incomplete_plans = [] # list of dicts, one per incomplete triazine
164
200
  h_to_delete = set() # global H indices, batched for final deletion
@@ -197,7 +233,7 @@ def triazine_to_cyanate_cap(TC, moldict, spec, reactions):
197
233
  f'triazine_to_cyanate_cap: all {len(cl_residues)} {cl["residue"]} '
198
234
  f'residues are fully bonded; nothing to do'
199
235
  )
200
- return 0
236
+ return _completion_stats(cl['residue'], len(cl_residues), 0)
201
237
 
202
238
  total_caps = sum(len(p['caps']) for p in incomplete_plans)
203
239
  free_caps_planned = sum(1 for p in incomplete_plans for c in p['caps'] if c['bonded_o'] is None)
@@ -326,7 +362,7 @@ def triazine_to_cyanate_cap(TC, moldict, spec, reactions):
326
362
  msg='triazine_to_cyanate_cap post-deletion rebalance',
327
363
  )
328
364
 
329
- return len(incomplete_plans)
365
+ return _completion_stats(cl['residue'], len(cl_residues), len(incomplete_plans))
330
366
 
331
367
 
332
368
  # ---------------------------------------------------------------------------
@@ -0,0 +1,165 @@
1
+ ---
2
+ name: htpolynet
3
+ description: Build crosslinked polymer systems with htpolynet — authoring a run configuration, parameterizing monomers, running a cure, and reading the results. Use when the task involves an htpolynet YAML config, the `htpolynet` command (run, input-check, gen-slurm-script, plots, postsim, analyze, make-viz), a monomer's active form or sacrificial hydrogens, a cure that stalls below its target conversion, or sizing an htpolynet build for a cluster.
4
+ ---
5
+
6
+ # Working with htpolynet
7
+
8
+ htpolynet builds crosslinked polymer systems: it parameterizes monomers with
9
+ GAFF, packs them, and then *cures* the system by repeatedly forming bonds
10
+ between reactive atoms until it reaches a target conversion. The output is a
11
+ Gromacs topology and coordinate pair plus the analysis to characterize it.
12
+
13
+ ## The working loop
14
+
15
+ 1. Fetch the bundled example closest in **reaction topology** and run it
16
+ unmodified once.
17
+ 2. Edit it into your system. Describe monomers in their **active form**.
18
+ 3. `htpolynet input-check <cfg>` — fast, touches nothing, reports the atom
19
+ count you size a core request against.
20
+ 4. `htpolynet run <cfg>`, in the background, or via a batch script.
21
+ 5. `htpolynet plots build --proj proj-0` to see what you got.
22
+
23
+ ## Start from an example, never from an empty file
24
+
25
+ A working configuration is a few hundred lines and most of it is not
26
+ chemistry-specific. Writing one from scratch is the slowest route and the one
27
+ that produces silent errors.
28
+
29
+ ```bash
30
+ htpolynet fetch-example 1 # linear chain growth (polystyrene)
31
+ htpolynet fetch-example 2 # A2 + B4 thermoset (bisGMA/styrene)
32
+ htpolynet fetch-example 3 # amine + epoxy (PACM/DGEBA)
33
+ htpolynet fetch-example 6 # cyclotrimerization (cyanate ester)
34
+ ```
35
+
36
+ Pick by **reaction topology**, not by chemistry. Building a step-growth
37
+ thermoset from a difunctional and a tetrafunctional monomer? Example 2 beats
38
+ an example that shares a functional group but polymerizes by chain growth.
39
+
40
+ Run it unmodified first. That confirms the toolchain and gives you a
41
+ known-good log to diff against when your own config misbehaves.
42
+
43
+ ## Monomers are described in their active form
44
+
45
+ The most common conceptual error, and it produces a build that completes and
46
+ is wrong rather than one that fails.
47
+
48
+ htpolynet conserves valence: when two atoms bond, each gives up a
49
+ **sacrificial hydrogen**. So you do not describe the textbook monomer — you
50
+ describe the monomer with its reactive sites already saturated. Styrene is
51
+ described as ethylbenzene.
52
+
53
+ Prefer SMILES written directly into `constituents` with RDKit atom-map
54
+ labels, which name reactive atoms by chemical identity rather than by file
55
+ index:
56
+
57
+ ```yaml
58
+ constituents:
59
+ STY:
60
+ smiles: "c1ccccc1[CH2:1][CH3:2]"
61
+ reactive_atoms: {1: C1, 2: C2}
62
+ ```
63
+
64
+ In SMILES bracket atoms the hydrogen count is explicit: `[C:1]` means *zero*
65
+ implicit hydrogens. For an sp³ carbon you almost always want `[CH2:1]` or
66
+ `[CH3:1]`. A wrong count usually surfaces much later as a missing GAFF angle
67
+ parameter in `tleap`, a long way from its cause.
68
+
69
+ ## Check before spending compute
70
+
71
+ `htpolynet input-check <cfg>` reports the initial atom count in about a
72
+ second. Run it every time you change monomer counts.
73
+
74
+ Know what it does **not** check. It does not verify that
75
+ `symmetry_equivalent_atoms` groups really are topologically equivalent, that
76
+ A2 + B3 site counts balance, or that `desired_conversion` is reachable given
77
+ the monomer counts. Those are silent failure modes: a wrong symmetry group
78
+ generates reaction templates the cure stage never matches, and the build
79
+ spends its full wall-clock reaching a conversion it could never have reached.
80
+
81
+ ## Running
82
+
83
+ Builds are slow — production systems are hours to a day. Run them in the
84
+ background, or generate a batch script rather than writing one:
85
+
86
+ ```bash
87
+ htpolynet gen-slurm-script <cfg>
88
+ ```
89
+
90
+ Size the core request from the `input-check` atom count.
91
+
92
+ **If you are using the container image, target CPU partitions.** Its Gromacs
93
+ comes from conda-forge, built against OpenCL, which Gromacs no longer uses to
94
+ drive NVIDIA devices. The image cannot use a GPU: `--gres=gpu` and `--nv` buy
95
+ nothing and may cost queue time.
96
+
97
+ Parameterization runs first and is cached across projects and directories.
98
+ The first run of a new chemistry pays several minutes per species; later runs
99
+ reuse it. Editing a monomer's structure **without renaming it** silently
100
+ reuses the old parameterization — `--force-parameterization` rebuilds.
101
+
102
+ ## Builds are not reproducible run to run
103
+
104
+ There is no seed control. Conformer selection, the per-bond probability test,
105
+ and Gromacs velocity generation are all unseeded, so two runs of one config
106
+ diverge. Convenient in one direction — independent replicas of a
107
+ quenched-disorder ensemble come free, and each `htpolynet run` in the same
108
+ base directory makes its own project directory — but an exact rebuild is not
109
+ available. Record the commit (`htpolynet info`) when the result matters.
110
+
111
+ ## Reading the results
112
+
113
+ ```bash
114
+ htpolynet plots build --proj proj-0 # traces, reaction graph, cluster sizes
115
+ htpolynet make-viz -top final.top -gro final.gro
116
+ htpolynet postsim postsim.yaml --proj proj-0
117
+ htpolynet plots post --proj proj-0 # E and Tg
118
+ htpolynet analyze analyze.yaml --proj proj-0
119
+ ```
120
+
121
+ **The postcure NPT plateau is not an equilibrated density.** It is an
122
+ under-relaxed structure, and on the bundled cyanate-ester example it sits
123
+ about 2.3% below what the same system gives after a melt and slow re-cool.
124
+ Do not report a plateau density as a force-field result.
125
+
126
+ ## Subcommand routing
127
+
128
+ | Intent | Command |
129
+ |---|---|
130
+ | Build a system | `htpolynet run <cfg>` |
131
+ | Size it before queueing | `htpolynet input-check <cfg>` |
132
+ | Stop after parameterization | `htpolynet run --param-only <cfg>` |
133
+ | Submit to a cluster | `htpolynet gen-slurm-script <cfg>` |
134
+ | Plot a finished build | `htpolynet plots build --proj <dir>` |
135
+ | Post-build MD / analysis | `htpolynet postsim`, `htpolynet analyze` |
136
+ | Rebuild VMD viz files | `htpolynet make-viz` |
137
+ | Report the environment | `htpolynet info` |
138
+
139
+ ## When something goes wrong
140
+
141
+ - **The cure stalls below the target conversion.** Usually a reaction
142
+ template that never matches: suspect `symmetry_equivalent_atoms` and
143
+ reactive-atom names before suspecting the chemistry.
144
+ - **A `tleap` error about a missing parameter.** Usually an atom typed
145
+ wrongly from a hydrogen-count error in a SMILES bracket atom.
146
+ - **Results that do not match the config you are reading.** Suspect a stale
147
+ cache entry: a structure edit without a rename.
148
+ - **A build that dies during cure.** `-restart` is experimental and currently
149
+ broken at the cure stage, which is the worst place to lose work. Treat a
150
+ dead cure as a restart from the beginning.
151
+ - **Anything else.** `htpolynet info` reports the versions of every external
152
+ tool the build depends on; include its output in any bug report.
153
+
154
+ ## Do not
155
+
156
+ Do not write workarounds into this file. If the tool surprises a user in a
157
+ way that requires a ritual to avoid, that is a bug: fix it in code, or file
158
+ it with enough context to act on later. A skill that teaches people to route
159
+ around a defect keeps the defect.
160
+
161
+ ## Full reference
162
+
163
+ <https://htpolynet.readthedocs.io/> — in particular the user guide's
164
+ *Building a System, Start to Finish*, which this file condenses, and
165
+ *Molecular Structure Inputs*, which explains the active form with pictures.
@@ -128,8 +128,16 @@ CURE:
128
128
  radial_increment: 0.25 # nm
129
129
  min_bonds_per_iteration: 10
130
130
  max_iterations: 150
131
- desired_conversion: 0.90
131
+ desired_conversion: 0.90 # BOND conversion; the cyanate (FTIR) conversion
132
+ # this yields is lower -- roughly its cube, since
133
+ # a triazine survives repair only if all three of
134
+ # its sites filled. Both numbers are reported at
135
+ # the end of the repair stage.
132
136
  late_threshold: 0.80
137
+ # completion_bias: true # finish partly-reacted triazines before starting
138
+ # untouched ones, so desired_conversion means the
139
+ # cyanate conversion. Off here so this example
140
+ # keeps its published behavior.
133
141
  drag:
134
142
  trigger_distance: 0.6 # nm
135
143
  increment: 0.08 # nm
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: htpolynet
3
- Version: 2.3.1
3
+ Version: 2.5.0
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/
@@ -67,21 +67,24 @@ pip install -e .
67
67
 
68
68
  Once installed, the user has access to the main ``htpolynet`` command.
69
69
 
70
+ If you drive htpolynet with [Claude Code](https://claude.com/claude-code), install the bundled skill so the agent knows how to use it:
71
+ ```bash
72
+ htpolynet setup-claude
73
+ ```
74
+ This writes `~/.claude/skills/htpolynet/SKILL.md`; nothing is installed there unless you run it.
75
+
70
76
  IMPORTANT NOTES: The programs ``antechamber``, ``parmchk2`` and ``tleap`` from AmberTools must be in your path. These can be installed using the ``ambertools`` package from ``conda-forge`` or compiled from source. You also need Gromacs installed so ``gmx`` is in your path. The examples show how to build input monomer structures using OpenBabel, so to use them you need ``obabel`` in your path as well.
71
77
 
72
78
  ## Docker
73
79
 
74
- As an alternative to a local installation, a prebuilt container image is published at ``ghcr.io/cameronabrams/htpolynet``. It bundles htpolynet together with Gromacs, AmberTools, and OpenBabel, so no additional dependencies are required on the host beyond Docker (and, optionally, the NVIDIA Container Toolkit for GPU runs).
80
+ As an alternative to a local installation, a prebuilt container image is published at ``ghcr.io/cameronabrams/htpolynet``. It bundles htpolynet together with Gromacs, AmberTools, and OpenBabel, so no additional dependencies are required on the host beyond Docker.
75
81
 
76
82
  Run htpolynet against a configuration file in the current directory:
77
83
  ```bash
78
84
  docker run --rm -v $(pwd):/work ghcr.io/cameronabrams/htpolynet run config.yaml
79
85
  ```
80
86
 
81
- With GPU support:
82
- ```bash
83
- docker run --rm --gpus all -v $(pwd):/work ghcr.io/cameronabrams/htpolynet run config.yaml
84
- ```
87
+ **The image cannot use a GPU.** Its Gromacs comes from conda-forge, built against OpenCL rather than CUDA, and Gromacs no longer drives NVIDIA devices through OpenCL. Passing `--gpus all` starts the container and changes nothing about how it computes; on a cluster, target CPU partitions and do not request `--gres=gpu` or pass `--nv`. If you need GPU-accelerated Gromacs, install htpolynet natively against a CUDA-enabled Gromacs.
85
88
 
86
89
  A Docker Compose file is also provided in [docker/compose.yml](docker/compose.yml) for a shorter invocation (``docker compose run --rm htpolynet run config.yaml``). See [docs/source/user-guide/container-usage.rst](docs/source/user-guide/container-usage.rst) for the full story, including Singularity/Apptainer use on HPC systems.
87
90
 
@@ -1,5 +1,5 @@
1
1
  htpolynet/__init__.py,sha256=_ApfhZLLP4Hd3b5ZCHAw6FHEj2VpQhu3RrZrZPiTef4,80
2
- htpolynet/cli.py,sha256=4QjaltjS1LLBciGc5uiENFbKC4_ReIHVHMq6PVe-7ZQ,15186
2
+ htpolynet/cli.py,sha256=hj-JHRPmfaiQrvmcytywGtcrIf4rCAJN2zOmMVW6ERU,16949
3
3
  htpolynet/analysis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  htpolynet/analysis/analyze.py,sha256=vM-FpM7rC6hiXw7VjrKFmpTjrfRzSbWHG9McsaZrhMs,9132
5
5
  htpolynet/analysis/plot.py,sha256=ncLduM4cK7ncQjksE2qL0Z086gqQOCpMs66rlI7AbOk,33020
@@ -12,12 +12,12 @@ htpolynet/core/coordinates.py,sha256=CGTHkdfw2ikc2ANacA5akRhZ9tOyM2IbELwQ2FVcKRw
12
12
  htpolynet/core/molecule.py,sha256=xUA52zkRMyAFCE8LbXvXghweDCPkrgD4rx1mcimddn0,52751
13
13
  htpolynet/core/paramcache.py,sha256=3MTG96F4vtT5w-pn1RWNmXic0QKB7WVcwCrD-BSY3B0,4508
14
14
  htpolynet/core/projectfilesystem.py,sha256=2U_EToZxN7yUGWu9BIRABVsYdp1AKkOuManwuFBz89k,20983
15
- htpolynet/core/runtime.py,sha256=BmWDttIKtRJnqYiYgrv7bJcivLaBtsgXK8q1jdYVKGw,53299
15
+ htpolynet/core/runtime.py,sha256=lOI5mbrdnez-llynuFg6wgd_ZhKwAo5Nd918FvLSexE,55430
16
16
  htpolynet/core/topocoord.py,sha256=jtQcwzvzPVNjU9VxBF9iXw8g3KiY55_jGDlwAZDOSjs,101564
17
17
  htpolynet/core/topology.py,sha256=XcFL96x2E4MsMrUr9upjE211-VcPVwLVoPL9vrV4DOw,56954
18
18
  htpolynet/cure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  htpolynet/cure/chain.py,sha256=-d5BFE5xUKjFdNkxLfSnCnZIRSJCtr7xuxYzNHBeSgU,5344
20
- htpolynet/cure/curecontroller.py,sha256=a97x1GaJ7Q2ayDEN48K4QHS9EOCPEljraUN_joR9ag8,36040
20
+ htpolynet/cure/curecontroller.py,sha256=Mkx72GzcknanmEDeMkashm1C7MbWshu86BBwQo9EiWE,39554
21
21
  htpolynet/cure/expandreactions.py,sha256=_NNsAuOCdgHMBLyEwl6S7VAZyDT5ei-m4OBBXjDE3YQ,13774
22
22
  htpolynet/cure/reaction.py,sha256=S-w60HocYknKnGbq1_uwLpKTL5Fte_o7zxwk3FbyQ1I,10557
23
23
  htpolynet/external/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -26,7 +26,7 @@ htpolynet/external/command.py,sha256=KYmWV8P4nuw_ciE16WazviorxjGj5un_z7dL62n0TG0
26
26
  htpolynet/external/gromacs.py,sha256=KEtHA4TuHaSA_nFXoz2NyrX3JUr9a733-KkOv5BE4Lc,12848
27
27
  htpolynet/external/slurm.py,sha256=FvnKyNqFXgDe5bdTDB4Kcn9KU4mxq9Gcw675SzU-4w0,4082
28
28
  htpolynet/external/smiles_input.py,sha256=vt-CdEHSqpJ5EA57NqQSCywjpHnTE5wCk2im2oxhM3U,9830
29
- htpolynet/external/software.py,sha256=vVgm7hvF9PyjWZ8-gUTDMl4XdnC3IIK7QEWQGr0-B7g,9569
29
+ htpolynet/external/software.py,sha256=Uzd1vkNnLm8C6By9ryFlbAnVPII30oFHLUOxzxdJJmw,10054
30
30
  htpolynet/geometry/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
31
  htpolynet/geometry/bondlist.py,sha256=ps6AreIHLz-55zZieJiBg9rbd9zZctw8gPrmQYK0MbI,6144
32
32
  htpolynet/geometry/lattice.py,sha256=YgrX52xHjiK9DP-T_xFiqiCYLHukU5tKCxutl-rC5c0,896
@@ -37,18 +37,19 @@ htpolynet/io/__init__.py,sha256=nX1-mb5tNRK_FTH1NP55ESWBSmiY_yBBU-43NMgzeA4,160
37
37
  htpolynet/io/gro.py,sha256=QGsAIlTIJlMRxtv_Juo0wdpbICAzyfQvSzzaMWrlMmA,7141
38
38
  htpolynet/io/mol2.py,sha256=5aU3HmQ5DS0LBF7tBPCNYKzBScwj8V3xfEUcFIrsevk,7314
39
39
  htpolynet/io/pdb.py,sha256=Np44dTbM0IcEAzfz6OGuH0rdQ63BGps3kOmkzH6syls,5293
40
- htpolynet/repair/__init__.py,sha256=7YEjlCLojgVi-PybKnMQ2r4fl65bp4lIEF-G9Tyud0E,1477
41
- htpolynet/repair/cyanate_cap.py,sha256=EfyQJeuu22oMoEpAmY4khJNwCQbXZzLR03JdoBLmoXs,17596
40
+ htpolynet/repair/__init__.py,sha256=cP3i-P-Wc6s0MgoFDp63kbLomM-ti3mMGEgeQzUVKuY,1740
41
+ htpolynet/repair/cyanate_cap.py,sha256=JaGLU2_ttzc9jGm7NSsboOs4SBnFDyNBc2v_G9aZxdg,19298
42
42
  htpolynet/repair/topology_surgery.py,sha256=aJ1md2SE4UzVU1YTS-Tiox8QXrr1hZwU6cCuEimlSrU,10030
43
43
  htpolynet/resources/README.md,sha256=epKLyqtcxtQOSzTYvaGlwhz970UA4vAU7r-iSBbbpmA,1432
44
44
  htpolynet/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
+ htpolynet/resources/claude/SKILL.md,sha256=1EWFhZVkeCtfgu9JV4i-4Cqs327-N9wUO3VlO8-9Cyw,7412
45
46
  htpolynet/resources/example_depot/0-liquid-styrene.yaml,sha256=-VrLYhDgCD5WdzMckIrm8F9aIEUFfhYlnu8V9TGxp14,2262
46
47
  htpolynet/resources/example_depot/1-polystyrene.yaml,sha256=TXKI-7UrrpJmblcg9elM8qFsvdtAgA1IcHdfBM5BCj4,3527
47
48
  htpolynet/resources/example_depot/2-bisgma-styrene-thermoset.yaml,sha256=Xk2sVcuxgwEZu-SXaLk9bK_UAB7SN3XzZRbdx1ObIeY,5958
48
49
  htpolynet/resources/example_depot/3-pacm-dgeba-epoxy-thermoset.yaml,sha256=zOuU-cxUm8YsUHKzRFNr8EvrpCqxbG4NA3v89yzAOi4,4296
49
50
  htpolynet/resources/example_depot/4-dfda-fde-epoxy-thermoset.yaml,sha256=ydKmJ6cZSL-HFsrvd_YnRyYyFXIHNP90CR6KMf7Wvdk,4271
50
51
  htpolynet/resources/example_depot/5-htpb-ipdi.yaml,sha256=ZEdLzM9k68d0ED5uhKDUlqgcp4pynehI5ri2ckTmt9U,10441
51
- htpolynet/resources/example_depot/6-cyanate-ester.yaml,sha256=dyXRg2QOYjpsKEFZTmrqsguCjQM7nxE1697RjyicFso,8770
52
+ htpolynet/resources/example_depot/6-cyanate-ester.yaml,sha256=lrTH7M4SJW870lylZS4o63mEHxmkRAf2hVDqlkUzML0,9439
52
53
  htpolynet/resources/mdp/README.md,sha256=48RjM7HLRF776FUJXUxQIw8RZxc7z1ti6za3YB7_U80,20
53
54
  htpolynet/resources/mdp/drag-min.mdp,sha256=CrMRQIzwtG4TlYRY-nB1P7HPgdwrpwSJJW6yoYdfahY,225
54
55
  htpolynet/resources/mdp/drag-npt.mdp,sha256=vbU-LuDH-CLmB8s3kRx0SYkKMxR7Qjh8PuXGgpC2EGs,911
@@ -95,8 +96,8 @@ htpolynet/utils/logsetup.py,sha256=o0mlVXNzqcfua2SAlJPkGSh4lM_bmI10gWwpb9gqYu8,1
95
96
  htpolynet/utils/profiling.py,sha256=su7qpGEz6FXVU4KT2HQDWG82bc1sgsfpDQBbAfPpsHc,7331
96
97
  htpolynet/utils/stringthings.py,sha256=Mr6o55EM8o4YAaVYpjIJj2IxDToNdbPzb-lpQ3w3jFk,1176
97
98
  htpolynet/utils/vmd_viz.py,sha256=Crk3Ln88PKiJ9X7DMMkFEVh2Ru6a1y0RUgj3w6EIgFc,10867
98
- htpolynet-2.3.1.dist-info/METADATA,sha256=tXtk99WECunWtlinNhiRCqy6z8XiB6bzZMcDrEdB1Ms,6036
99
- htpolynet-2.3.1.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
100
- htpolynet-2.3.1.dist-info/entry_points.txt,sha256=G5tx55llJf-IV9dIe7J8myGdyrhCVggCAhKrVNGP_s0,48
101
- htpolynet-2.3.1.dist-info/licenses/LICENSE,sha256=piPSGqJdmTGyzF9HOnjlO2KvgOKT8NHwhCuGYM778tY,1071
102
- htpolynet-2.3.1.dist-info/RECORD,,
99
+ htpolynet-2.5.0.dist-info/METADATA,sha256=Juj2GYFIHR_dLQY_1xvSyB0Yu8WfYy_zULfaEtCj6qo,6557
100
+ htpolynet-2.5.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
101
+ htpolynet-2.5.0.dist-info/entry_points.txt,sha256=G5tx55llJf-IV9dIe7J8myGdyrhCVggCAhKrVNGP_s0,48
102
+ htpolynet-2.5.0.dist-info/licenses/LICENSE,sha256=piPSGqJdmTGyzF9HOnjlO2KvgOKT8NHwhCuGYM778tY,1071
103
+ htpolynet-2.5.0.dist-info/RECORD,,