HTPolyNet 2.3.1__py3-none-any.whl → 2.4.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 +40 -0
- htpolynet/external/software.py +11 -2
- htpolynet/resources/claude/SKILL.md +165 -0
- {htpolynet-2.3.1.dist-info → htpolynet-2.4.0.dist-info}/METADATA +1 -1
- {htpolynet-2.3.1.dist-info → htpolynet-2.4.0.dist-info}/RECORD +8 -7
- {htpolynet-2.3.1.dist-info → htpolynet-2.4.0.dist-info}/WHEEL +0 -0
- {htpolynet-2.3.1.dist-info → htpolynet-2.4.0.dist-info}/entry_points.txt +0 -0
- {htpolynet-2.3.1.dist-info → htpolynet-2.4.0.dist-info}/licenses/LICENSE +0 -0
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/external/software.py
CHANGED
|
@@ -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
|
-
|
|
101
|
-
|
|
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:
|
|
@@ -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.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: htpolynet
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.4.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/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
htpolynet/__init__.py,sha256=_ApfhZLLP4Hd3b5ZCHAw6FHEj2VpQhu3RrZrZPiTef4,80
|
|
2
|
-
htpolynet/cli.py,sha256=
|
|
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
|
|
@@ -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=
|
|
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
|
|
@@ -42,6 +42,7 @@ htpolynet/repair/cyanate_cap.py,sha256=EfyQJeuu22oMoEpAmY4khJNwCQbXZzLR03JdoBLmo
|
|
|
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
|
|
@@ -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.
|
|
99
|
-
htpolynet-2.
|
|
100
|
-
htpolynet-2.
|
|
101
|
-
htpolynet-2.
|
|
102
|
-
htpolynet-2.
|
|
99
|
+
htpolynet-2.4.0.dist-info/METADATA,sha256=QevvufdlQm4SnXlihXKRVpBbMCSaFZi8I_9CKn365zE,6036
|
|
100
|
+
htpolynet-2.4.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
101
|
+
htpolynet-2.4.0.dist-info/entry_points.txt,sha256=G5tx55llJf-IV9dIe7J8myGdyrhCVggCAhKrVNGP_s0,48
|
|
102
|
+
htpolynet-2.4.0.dist-info/licenses/LICENSE,sha256=piPSGqJdmTGyzF9HOnjlO2KvgOKT8NHwhCuGYM778tY,1071
|
|
103
|
+
htpolynet-2.4.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|