Nanoparticles¶
AutoPoly.nanoparticles.model
¶
Nanoparticle: a first-class finite inorganic component.
A Nanoparticle is passed to generate() alongside Polymer/Molecule models. It is not an RDKit macromolecule and not a planar substrate: its geometry comes from the material's registered shape builder (or an imported structure), its surface termination from the material's chemistry adapter, and its interaction parameters -- attached only in stage 2 -- from a registered inorganic force-field adapter.
>>> from AutoPoly.nanoparticles import Nanoparticle, SilicaSurface
>>> np_ = Nanoparticle(material="SiO2", structure="beta_cristobalite",
... shape="sphere", radius=12.0, count=2,
... surface=SilicaSurface(), motion="rigid")
>>> generate(system, "ps_silica", [ps, np_], force_field="oplsaa")
Created on 2026-11-13 @author: zwu
Classes:
| Name | Description |
|---|---|
Nanoparticle |
A nanoparticle species ( |
Nanoparticle
¶
A nanoparticle species (count identical instances).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
material
|
Union[str, Material]
|
Material ID/formula/alias ("SiO2", "Al2O3", "TiO2", "C", "Au", "Ag") or a Material object. |
'SiO2'
|
structure
|
Optional[str]
|
Phase / structure source (e.g. "alpha_quartz",
"beta_cristobalite", "alpha_corundum", "anatase", "rutile",
"graphene", "cnt", "fcc"); None = material default (or the
Material's crystal). |
None
|
shape
|
Union[str, Shape]
|
"sphere", "sheet", "tube", "cuboctahedron", "octahedron", "wulff", or a Shape object (Sphere, Sheet, Tube, Polyhedron). |
'sphere'
|
count
|
int
|
Number of identical instances to place (>= 1). |
1
|
motion
|
str
|
"rigid" (default; one LAMMPS rigid body per instance), "frozen" (excluded from time integration), or "flexible" (only with a force field that provides validated bonded terms; none of the built-in sets do). |
'rigid'
|
surface
|
Union[str, Surface, None]
|
Termination ID or Surface object (e.g. SilicaSurface(oh_density=4.6)); None = material default. |
None
|
force_field
|
Optional[str]
|
Inorganic force-field adapter name or alias (e.g.
"interface", "clayff"); None = material default.
|
None
|
name
|
Optional[str]
|
Component name (unique per system); default
" |
None
|
seed
|
int
|
Seed for stochastic surface steps (condensation pairing). |
42
|
allow_unqualified
|
bool
|
Permit MD export although the exact combination is not in the qualification matrix (recorded as user-qualified). |
False
|
grafts
|
Optional[Any]
|
Optional Grafting specification (covalently grafted chains; silica, host OPLS-AA). |
None
|
**shape_kwargs
|
Any
|
Shape size arguments (A) when |
{}
|
Methods:
| Name | Description |
|---|---|
from_file |
Nanoparticle from a validated atomistic cluster file. |
from_structure |
Nanoparticle from an in-memory AtomicStructure (validated). |
build_structure |
The force-field-agnostic structure (built once, cached). |
graft_plan |
Sites + anchor structure of the grafted particle (cached). |
graft_models |
Polymer models of the grafted chains (built in stage 1). |
geometry_entry |
The geometry.json inorganic entry of this species. |
summary |
Composition, size and surface report of one instance. |
write_structure |
Write the structure (.json AtomicStructure, .xyz or .pdb). |
Attributes:
| Name | Type | Description |
|---|---|---|
cap_length |
Optional[float]
|
Termination cap (O-H / C-H) length from the selected adapter. |
Source code in AutoPoly/nanoparticles/model.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | |
cap_length: Optional[float]
property
¶
Termination cap (O-H / C-H) length from the selected adapter.
from_file(path: Union[str, Path], material: Union[str, Material] = 'SiO2', name: Optional[str] = None, count: int = 1, motion: str = 'rigid', surface=None, force_field: Optional[str] = None, atom_types: Optional[str] = None, structure: Optional[str] = None, perceive_bonds: Optional[bool] = None, allow_unqualified: bool = False, center: bool = True) -> Nanoparticle
classmethod
¶
Nanoparticle from a validated atomistic cluster file.
Supported formats: .json (AtomicStructure dict, as written by
Nanoparticle.write_structure), .pdb with CONECT records, and
.xyz. XYZ files carry no bonds: pass perceive_bonds=True
to perceive them with the material's distance cutoffs (the result
is then validated against the material's valence rules). Charges
and parameters always come from the inorganic force-field adapter
through the roles the chemistry adapter assigns from connectivity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Union[str, Path]
|
Structure file. |
required |
material
|
Union[str, Material]
|
Material of the cluster. |
'SiO2'
|
structure
|
Optional[str]
|
Phase label (default: "amorphous" for silica if registered, else the material default). |
None
|
center
|
bool
|
Translate the cluster so its centroid is at the origin. |
True
|
Source code in AutoPoly/nanoparticles/model.py
from_structure(structure: AtomicStructure, material: Union[str, Material] = 'SiO2', **kwargs) -> Nanoparticle
classmethod
¶
Nanoparticle from an in-memory AtomicStructure (validated).
Source code in AutoPoly/nanoparticles/model.py
build_structure() -> AtomicStructure
¶
The force-field-agnostic structure (built once, cached).
Source code in AutoPoly/nanoparticles/model.py
graft_plan(exclude=()) -> Optional[Dict[str, Any]]
¶
Sites + anchor structure of the grafted particle (cached).
Source code in AutoPoly/nanoparticles/model.py
graft_models() -> List[Any]
¶
Polymer models of the grafted chains (built in stage 1).
geometry_entry(component_id: Optional[str] = None, geometry: Optional[Dict[str, Any]] = None) -> Dict[str, Any]
¶
The geometry.json inorganic entry of this species.
Source code in AutoPoly/nanoparticles/model.py
summary() -> Dict[str, Any]
¶
Composition, size and surface report of one instance.
Source code in AutoPoly/nanoparticles/model.py
write_structure(path: Union[str, Path]) -> Path
¶
Write the structure (.json AtomicStructure, .xyz or .pdb).
Shapes and surfaces¶
AutoPoly.nanoparticles.shapes
¶
Shape and surface specifications for nanoparticles.
Shapes define which atoms belong to the object (carved from the bulk crystal of the selected phase); surfaces define how the exposed atoms are terminated (delegated to the material's chemistry adapter). Neither says anything about interactions.
Created on 2026-11-13 @author: zwu
Classes:
| Name | Description |
|---|---|
Shape |
Base class of shape specifications. |
Sphere |
Spherical particle. |
Polyhedron |
Faceted fcc metal cluster (optional ASE builders). |
Sheet |
Finite sheet (graphene flake) in the xy plane. |
Tube |
Single-wall carbon nanotube along z. |
Imported |
Shape of an imported structure (no carving). |
Surface |
Surface-termination request. |
Functions:
| Name | Description |
|---|---|
make_shape |
Shape object from a name (+ size kwargs) or a Shape instance. |
SilicaSurface |
Silica termination: Q3/Q2 silanols on 4-coordinated Si. |
Shape
dataclass
¶
Base class of shape specifications.
Source code in AutoPoly/nanoparticles/shapes.py
Sphere
dataclass
¶
Bases: Shape
Spherical particle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float
|
Core cut radius (A): every framework cation (Si, Al, Ti, metal atom) within this distance of the center is kept. |
10.0
|
center_offset
|
Optional[Tuple[float, float, float]]
|
Optional shift of the particle center inside the crystal (A); varies which surface sites are exposed. |
None
|
Source code in AutoPoly/nanoparticles/shapes.py
Polyhedron
dataclass
¶
Bases: Shape
Faceted fcc metal cluster (optional ASE builders).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
"cuboctahedron", "octahedron" or "wulff". |
'cuboctahedron'
|
size
|
float
|
Approximate radius (A) used to choose the shell count / layer numbers. |
10.0
|
surface_energies
|
Optional[Dict[Tuple[int, int, int], float]]
|
Wulff construction only: {(h, k, l): energy} (relative values); defaults to (111) < (100) ratios for fcc. |
None
|
Source code in AutoPoly/nanoparticles/shapes.py
Sheet
dataclass
¶
Bases: Shape
Finite sheet (graphene flake) in the xy plane.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length
|
float
|
Extent along x (A, zigzag direction). |
30.0
|
width
|
float
|
Extent along y (A, armchair direction). |
30.0
|
layers
|
int
|
Number of AB-stacked layers (3.35 A apart). |
1
|
Source code in AutoPoly/nanoparticles/shapes.py
Tube
dataclass
¶
Bases: Shape
Single-wall carbon nanotube along z.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
First chiral index (n > 0). |
10
|
m
|
int
|
Second chiral index (0 <= m <= n). |
10
|
length
|
float
|
Tube length (A). |
30.0
|
Source code in AutoPoly/nanoparticles/shapes.py
Imported
dataclass
¶
Surface
dataclass
¶
Surface-termination request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
Optional[str]
|
Termination ID registered for the material ("hydroxylated", "stoichiometric", "h_passivated", "bare"); None = material default. |
None
|
params
|
Dict[str, Any]
|
Termination parameters (material specific). |
dict()
|
Source code in AutoPoly/nanoparticles/shapes.py
make_shape(shape, **kwargs) -> Shape
¶
Shape object from a name (+ size kwargs) or a Shape instance.
Source code in AutoPoly/nanoparticles/shapes.py
SilicaSurface(oh_density: Optional[float] = None, state: str = 'hydroxylated') -> Surface
¶
Silica termination: Q3/Q2 silanols on 4-coordinated Si.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
oh_density
|
Optional[float]
|
Target silanol density (sites/nm^2). Applied by Si-O-Si condensation where geometrically possible; the achieved density is reported (crystal-derived spheres are intrinsically at ~5-6 (cristobalite) or ~7-8 (quartz) /nm^2). For imported structures the value is the expected density, checked within tolerance. |
None
|
Source code in AutoPoly/nanoparticles/shapes.py
Grafting¶
AutoPoly.nanoparticles.grafting
¶
Covalent polymer grafting onto nanoparticle surface sites.
>>> from AutoPoly.nanoparticles import Nanoparticle, Grafting
>>> brush = Grafting(polymer=Polymer(chain_num=1, sequence=PE10),
... density=0.8) # chains / nm^2
>>> np_ = Nanoparticle(material="SiO2", radius=12.0, grafts=brush)
Model (silica, linker "silyl_ether"):
- Sites: N_g = round(sigma_g * A_accessible) silanol oxygens (or an
explicit
count), spread by farthest-point sampling, at most one per silicon. - Chemistry: Si-OH + H-C(head) -> Si-O-C(head): the silanol H and one H of the chain's head atom (the first heavy atom of the first monomer, which must carry H) are removed and the surface O bonds to the head atom. The grafted O ("OG") keeps the silanol-O Lennard-Jones parameters and carries the silanol group charge q(OH) + q(HO) plus the charge of the removed organic H, so the total charge of particle + grafts is conserved exactly.
- Conformations: every graft grows monomer by monomer from its anchor with
the obstacle-aware grower (packing.chain_regrowth): the head atom sits on
the anchor's vacated O-H direction at the O-C bond length, every atom
clears the core (
core_clearance) and earlier grafts; grafted chains are part of the particle class, not free matrix molecules. - Bonded linkage terms (host OPLS-AA only): bond O-C (OPLS CT-OS), angle Si-O-C (CT-OS-Si, wlj silyl ether), angles O-C-X (X-CT-OS) and dihedrals O-C-C-X (X-CT-CT-OS), with coefficients read from the bundled oplsaa.lt by the OPLS bonded classes of the typed atoms -- never invented. Si-O-C-X torsions are not defined for silica-bound ethers in OPLS-AA and are omitted (documented: low barrier); terms whose atoms all belong to the rigid core are irrelevant and omitted.
Created on 2026-11-13 @author: zwu
Classes:
| Name | Description |
|---|---|
GraftGrowthError |
A graft could not be grown from one surface site. |
Grafting |
Grafted-chain specification of a nanoparticle species. |
Functions:
| Name | Description |
|---|---|
head_and_cap |
(head heavy-atom index, index of one H on it) of a first monomer. |
grow_grafts |
Anchored growth of one chain per anchor around a rigid core. |
opls_coefficients |
Coefficient tokens of an OPLS bonded term by class names (either |
opls_class |
Bonded class ('b', 'a', 'd') of an OPLS @atom type (e.g. '81'). |
GraftGrowthError
¶
Bases: ValidationError
A graft could not be grown from one surface site.
Source code in AutoPoly/nanoparticles/grafting.py
Grafting
dataclass
¶
Grafted-chain specification of a nanoparticle species.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
polymer
|
Any
|
Polymer model of one grafted chain (its |
required |
density
|
Optional[float]
|
Target grafting density (chains/nm^2 of accessible area). |
None
|
count
|
Optional[int]
|
Explicit number of grafts per particle (overrides density). |
None
|
linker
|
str
|
Linkage template ("silyl_ether"). |
'silyl_ether'
|
seed
|
int
|
Site-selection and growth seed. |
0
|
core_clearance
|
float
|
Minimum distance (A) of graft atoms from core atoms other than the anchor O and its Si. |
2.0
|
attempts
|
int
|
Independent anchored growth attempts per graft. |
60
|
Methods:
| Name | Description |
|---|---|
chain_model |
Copy of the graft polymer with chain_num = n. |
Source code in AutoPoly/nanoparticles/grafting.py
chain_model(n: int)
¶
Copy of the graft polymer with chain_num = n.
Source code in AutoPoly/nanoparticles/grafting.py
head_and_cap(template: Dict[str, Any]) -> Tuple[int, int]
¶
(head heavy-atom index, index of one H on it) of a first monomer.
Source code in AutoPoly/nanoparticles/grafting.py
grow_grafts(core: AtomicStructure, anchors: Dict[int, Dict], chains: List[Dict], variants: Dict[str, Any], grafting: Grafting, cap_index: int) -> List[List[Tuple[np.ndarray, np.ndarray]]]
¶
Anchored growth of one chain per anchor around a rigid core.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core
|
AtomicStructure
|
Core AtomicStructure (anchor O already without H). |
required |
anchors
|
Dict[int, Dict]
|
new-O index -> {"si", "direction", ...}. |
required |
chains
|
List[Dict]
|
geometry.json chain entries (one per anchor, same order). |
required |
variants
|
Dict[str, Any]
|
geometry.json variants. |
required |
cap_index
|
int
|
Head-H index (in the first monomer) removed at grafting. |
required |
Returns:
| Type | Description |
|---|---|
List[List[Tuple[ndarray, ndarray]]]
|
Per graft, the list of monomer transforms (R, t) in the particle |
List[List[Tuple[ndarray, ndarray]]]
|
frame. |
Source code in AutoPoly/nanoparticles/grafting.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
opls_coefficients(kind: str, names: Sequence[str], ff_lt: Path)
¶
Coefficient tokens of an OPLS bonded term by class names (either direction); None if undefined.
Source code in AutoPoly/nanoparticles/grafting.py
opls_class(atom_type: str, slot: str, ff_lt: Path) -> str
¶
Bonded class ('b', 'a', 'd') of an OPLS @atom type (e.g. '81').
Source code in AutoPoly/nanoparticles/grafting.py
Coarse-grained fillers (bead-spring)¶
AutoPoly.nanoparticles.cg
¶
Coarse-grained (CG) spherical fillers for the bead-spring backend.
A CG filler is a rigid (or frozen) particle made of LJ beads -- a solid FCC cut ("fcc") or a Fibonacci surface shell ("shell") of one filler bead type -- in the reduced LJ units of the bead-spring models:
>>> from AutoPoly.models.bead_spring import BeadType
>>> from AutoPoly.nanoparticles import CGFiller
>>> bss = BeadSpringSystem("nc", system, bead_types=[BeadType("A"),
... BeadType("F", epsilon=1.0)], pair_style="lj",
... density=0.5)
>>> bss.add_species(arch.linear([("A", 50)]), n_chains=40)
>>> bss.add_filler(CGFiller(radius=4.0, count=2, bead_type="F"))
>>> bss.generate(backend="direct")
Construction: fillers are placed first (random positions and
orientations, periodic minimum-image gap min_gap between particle
envelopes), then the chains grow by SAW around them (beads may not enter
the filler envelope, radius + half a filler bead). The run script holds
the fillers during minimization, integrates each rigid filler as one body
(fix rigid/nvt molecule) or keeps frozen fillers in place, skips
intra-filler pair forces, and reports a matrix-only temperature.
CG fillers are generic LJ particles: their mapping onto a real material (bead size, polymer-filler attraction epsilon, see BeadSpringSystem.set_pair_coeff) is the user's modelling choice and is not part of the atomistic material qualification matrix.
Created on 2026-11-13 @author: zwu
Classes:
| Name | Description |
|---|---|
CGFiller |
Coarse-grained spherical filler species (LJ units). |
PlacedFiller |
One placed CG particle. |
Functions:
| Name | Description |
|---|---|
fcc_sphere |
FCC lattice sites (nearest-neighbor distance |
sphere_shell |
Near-uniform beads on a sphere of |
place_fillers |
Random sequential placement of all CG particles in the periodic cubic |
filler_volume |
Total envelope volume of all CG particles (sigma^3). |
motion_groups |
motion -> filler bead-type names (each type has one motion). |
group_lines |
LAMMPS group commands; type tokens are numeric ids (direct backend) |
production_lines |
Integrators: matrix NVT, one rigid body per rigid particle, frozen |
compression_hint |
Commented NPT block: the filler-aware SAW packs below melt density |
summary |
Filler block of BeadSpringSystem.get_system_info(). |
CGFiller
dataclass
¶
Coarse-grained spherical filler species (LJ units).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float
|
Particle radius (sigma); every bead center lies within it. |
required |
count
|
int
|
Number of particles. |
1
|
bead_type
|
str
|
Filler BeadType name; must be in the system's bead types and not used by any chain species. |
'F'
|
structure
|
str
|
"fcc" (solid FCC cut, default) or "shell" (beads on the sphere surface only). |
'fcc'
|
spacing
|
float
|
Nearest-neighbor bead distance (sigma). |
1.0
|
motion
|
str
|
"rigid" (one rigid body per particle) or "frozen". |
'rigid'
|
name
|
str
|
Species label. |
'filler'
|
Methods:
| Name | Description |
|---|---|
bead_positions |
(n, 3) bead centers of one particle, centered at the origin. |
Source code in AutoPoly/nanoparticles/cg.py
bead_positions() -> np.ndarray
¶
(n, 3) bead centers of one particle, centered at the origin.
Source code in AutoPoly/nanoparticles/cg.py
PlacedFiller
dataclass
¶
fcc_sphere(radius: float, spacing: float) -> np.ndarray
¶
FCC lattice sites (nearest-neighbor distance spacing) within
radius of a lattice site at the origin.
Source code in AutoPoly/nanoparticles/cg.py
sphere_shell(radius: float, spacing: float) -> np.ndarray
¶
Near-uniform beads on a sphere of radius, about spacing
apart (hexagonal area per bead, Fibonacci lattice).
Source code in AutoPoly/nanoparticles/cg.py
place_fillers(fillers: Sequence[CGFiller], box_size: float, bead_sigma: Dict[str, float], min_gap: float = 1.0, max_attempts: int = 5000) -> List[PlacedFiller]
¶
Random sequential placement of all CG particles in the periodic cubic
box [-L/2, L/2)^3 with envelope gaps >= min_gap (minimum image).
Raises:
| Type | Description |
|---|---|
ValueError
|
A particle does not fit the box or no free position was found (box too small for the requested count). |
Source code in AutoPoly/nanoparticles/cg.py
filler_volume(fillers: Sequence[CGFiller], bead_sigma: Dict[str, float]) -> float
¶
Total envelope volume of all CG particles (sigma^3).
Source code in AutoPoly/nanoparticles/cg.py
motion_groups(fillers: Sequence[CGFiller]) -> Dict[str, List[str]]
¶
motion -> filler bead-type names (each type has one motion).
Source code in AutoPoly/nanoparticles/cg.py
group_lines(groups: Dict[str, List[str]]) -> List[str]
¶
LAMMPS group commands; type tokens are numeric ids (direct backend) or @atom: names (moltemplate In Settings).
Source code in AutoPoly/nanoparticles/cg.py
production_lines(groups: Dict[str, List[str]]) -> str
¶
Integrators: matrix NVT, one rigid body per rigid particle, frozen particles at rest.
Source code in AutoPoly/nanoparticles/cg.py
compression_hint(groups: Dict[str, List[str]]) -> str
¶
Commented NPT block: the filler-aware SAW packs below melt density (periodic overlap checks), so the box is usually compressed first.
Source code in AutoPoly/nanoparticles/cg.py
summary(placed: Sequence[PlacedFiller], box_size: float) -> Dict
¶
Filler block of BeadSpringSystem.get_system_info().
Source code in AutoPoly/nanoparticles/cg.py
Materials¶
AutoPoly.materials.registry
¶
Material registry: the single source of truth for inorganic materials.
Every inorganic component (built-in substrate slab or nanoparticle) resolves its material through this registry. A MaterialSpec records identity and provenance -- phases/structure sources, shape builders, surface-termination models, the inorganic force-field adapters defined for it -- and where each builder lives (dotted "module:function" references resolved lazily), so the pipeline never branches on material names.
Registration is not a promise of simulation readiness. Capability is tracked per stage:
registered: metadata/selection exists,geometry_ready: a built-in (or import) path produces structures that pass topology checks and can be exported,surface_ready: a surface-termination model with chemical validation (valence, stoichiometry, charge) exists,md_ready: at least one exact combination (material + phase + surface + inorganic FF + polymer FF + motion) is listed in the qualification matrix (AutoPoly.materials.qualification) with passing smoke-test evidence.
Five material families are registered as six IDs: sio2, al2o3,
tio2, c, au, ag.
Created on 2026-11-13 @author: zwu
Classes:
| Name | Description |
|---|---|
PhaseSpec |
One phase / structure source of a material. |
SurfaceStateSpec |
One surface-termination model. |
MaterialSpec |
Registry entry of one inorganic material (see module docstring). |
Functions:
| Name | Description |
|---|---|
resolve_callable |
Import a "package.module:function" reference. |
register_material |
Register a material (IDs and aliases must be unique). |
get_material |
Resolve a material by ID, formula or alias (case-insensitive): |
PhaseSpec
dataclass
¶
One phase / structure source of a material.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Stable phase ID (e.g. "alpha_quartz"). |
description |
str
|
Human-readable description. |
space_group |
str
|
Space group (crystalline phases) or "" (amorphous). |
crystal |
Optional[str]
|
Key into AutoPoly.materials.crystals.CRYSTALS (bulk cell used by the built-in shape builders), or None when the phase is only available as an imported structure. |
shapes |
Tuple[str, ...]
|
Shapes with a built-in builder for this phase. |
aliases |
Tuple[str, ...]
|
Alternative names. |
citation |
str
|
Structure reference. |
Source code in AutoPoly/materials/registry.py
SurfaceStateSpec
dataclass
¶
One surface-termination model.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Stable ID ("hydroxylated", "stoichiometric", "h_passivated", "bare", "periodic"). |
description |
str
|
What the termination does. |
site_types |
Tuple[str, ...]
|
Surface-site labels it produces. |
validated |
bool
|
True when chemical validation (valence, stoichiometry, charge) is implemented and tested. |
Source code in AutoPoly/materials/registry.py
MaterialSpec
dataclass
¶
Registry entry of one inorganic material (see module docstring).
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Stable material ID ("sio2", ...). |
name |
str
|
Display name. |
formula |
str
|
Chemical formula. |
family |
str
|
"oxide", "carbon", or "metal". |
elements |
Tuple[str, ...]
|
Elements a structure of this material may contain (including termination atoms). |
aliases |
Tuple[str, ...]
|
Accepted alternative names (case-insensitive). |
phases |
Dict[str, PhaseSpec]
|
phase ID -> PhaseSpec. |
default_phase |
Optional[str]
|
Phase used when none is given. |
surface_states |
Dict[str, SurfaceStateSpec]
|
termination ID -> SurfaceStateSpec. |
default_surface |
Optional[str]
|
Termination used when none is given. |
chemistry |
Optional[str]
|
Module implementing the chemistry adapter
( |
builders |
Dict[str, str]
|
shape -> "module:function" geometry builder. |
force_fields |
Tuple[str, ...]
|
Inorganic FF adapter names defined for the material. |
default_force_field |
Optional[str]
|
Adapter used when none is requested. |
radius_range |
Tuple[float, float]
|
Allowed built-in particle radius range (A). |
capabilities |
Dict[str, bool]
|
Declared stage -> bool for registered / geometry_ready / surface_ready (cross-checked by tests); md_ready is derived from the qualification matrix. |
citations |
/ notes
|
Provenance. |
Methods:
| Name | Description |
|---|---|
resolve_phase |
Phase by ID or alias (None = default phase). |
resolve_surface |
Surface termination by ID (None = default). |
builder |
Geometry builder callable for a shape. |
chemistry_module |
The chemistry adapter module (None if not implemented). |
capability |
Capability of one stage. |
Source code in AutoPoly/materials/registry.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
resolve_phase(phase: Optional[str]) -> PhaseSpec
¶
Phase by ID or alias (None = default phase).
Source code in AutoPoly/materials/registry.py
resolve_surface(surface: Optional[str]) -> SurfaceStateSpec
¶
Surface termination by ID (None = default).
Source code in AutoPoly/materials/registry.py
builder(shape: str) -> Callable
¶
Geometry builder callable for a shape.
Source code in AutoPoly/materials/registry.py
chemistry_module()
¶
capability(stage: str) -> bool
¶
Capability of one stage. md_ready is derived from the
qualification matrix (never declared); the other stages are
declared here and cross-checked by the test suite.
Source code in AutoPoly/materials/registry.py
resolve_callable(ref: str) -> Callable
¶
Import a "package.module:function" reference.
Source code in AutoPoly/materials/registry.py
register_material(spec: MaterialSpec) -> None
¶
Register a material (IDs and aliases must be unique).
Source code in AutoPoly/materials/registry.py
get_material(name: str) -> MaterialSpec
¶
Resolve a material by ID, formula or alias (case-insensitive):
get_material("SiO2") is get_material("silica").
Source code in AutoPoly/materials/registry.py
Qualification matrix¶
AutoPoly.materials.qualification
¶
Material qualification matrix: which exact combinations are md_ready.
A combination is md_ready only when all of the following were
independently tested for exactly that model:
(A) registry metadata (B) geometry/topology
(C) surface termination (D) inorganic parameterization
(E) polymer cross terms (F) LAMMPS smoke test
QUALIFIED_COMBINATIONS lists those combinations together with the test
evidence that exercises them (tests/test_nanocomposite_lammps_smoke.py
and friends). Anything not listed is not md_ready: MD preparation of a
nanoparticle fails with an actionable error instead of falling back to
generic organic typing or guessed mixing. Material-level capability
(md_ready in the registry) is derived from this table, never declared.
Built-in substrate slabs (SubstrateSpec(builder=...)) keep their legacy behavior: they are reported against this matrix but never blocked.
Created on 2026-11-13 @author: zwu
Classes:
| Name | Description |
|---|---|
QualifiedCombination |
One md_ready combination. |
Functions:
| Name | Description |
|---|---|
register_qualification |
Add a qualified combination (IDs must be unique). |
find_qualification |
The qualified combination covering these settings, or None. |
require_md_ready |
Return the qualified combination or raise an actionable error naming |
qualification_matrix |
Per-material stage table (A-F) for docs/CI. |
qualification_markdown |
The qualification matrix as a Markdown table. |
QualifiedCombination
dataclass
¶
One md_ready combination.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Stable identifier (reported in units.json / the FF report). |
material |
str
|
Material ID. |
phases |
Tuple[str, ...]
|
Phase IDs covered (structure sources). |
geometry_types |
Tuple[str, ...]
|
Geometry types covered ("cluster", "sheet", ...). |
surface |
str
|
Surface-termination ID. |
inorganic_ff |
str
|
Inorganic adapter name. |
polymer_ffs |
Tuple[str, ...]
|
Organic host force fields covered. |
motions |
Tuple[str, ...]
|
Motion treatments covered. |
cross_rule |
str
|
Rule for organic-inorganic pairs ("host" = follow the host force field's mixing rule; otherwise explicit). |
evidence |
Tuple[str, ...]
|
Test node IDs exercising (B)-(F). |
grafting |
Tuple[str, ...]
|
Grafting linkers covered ("silyl_ether"); empty = only ungrafted particles. |
notes |
str
|
Caveats. |
Source code in AutoPoly/materials/qualification.py
register_qualification(q: QualifiedCombination) -> None
¶
Add a qualified combination (IDs must be unique).
Source code in AutoPoly/materials/qualification.py
find_qualification(material: str, phase: Optional[str], geometry_type: str, surface: str, inorganic_ff: str, polymer_ff: str, motion: str, linker: Optional[str] = None) -> Optional[QualifiedCombination]
¶
The qualified combination covering these settings, or None.
Source code in AutoPoly/materials/qualification.py
require_md_ready(material: str, phase: Optional[str], geometry_type: str, surface: str, inorganic_ff: str, polymer_ff: str, motion: str, linker: Optional[str] = None) -> QualifiedCombination
¶
Return the qualified combination or raise an actionable error naming what is missing.
Source code in AutoPoly/materials/qualification.py
qualification_matrix() -> List[Dict[str, object]]
¶
Per-material stage table (A-F) for docs/CI.
A: registered; B: geometry_ready; C: surface_ready; D: an inorganic adapter is registered; E/F: a qualified combination exists.
Source code in AutoPoly/materials/qualification.py
qualification_markdown() -> str
¶
The qualification matrix as a Markdown table.
Source code in AutoPoly/materials/qualification.py
Atomic structures¶
AutoPoly.materials.structure
¶
Force-field-agnostic atomic structure for inorganic components.
AtomicStructure is the shared representation behind built-in substrate slabs and finite nanoparticles (clusters, sheets, rods, imported structures). It holds what a structure is -- elements, coordinates, cell/periodicity, bond topology with periodic image shifts, chemical-role and surface-site annotations, geometry descriptors and provenance -- and deliberately nothing about how it interacts: charges and Lennard-Jones parameters are attached later, after force-field selection, as a ParameterAssignment (see AutoPoly.materials.forcefields).
Conventions:
bonds[k] = (i, j)withimages[k] = (nx, ny, nz): atom j is bonded to the periodic image of atom j shifted byn . cell(i.e. the bond vector isr_j + n . cell - r_i). Finite structures have all-zero images.cellrows are the lattice vectors (A). Only axes withpbc=Trueare periodic; non-periodic axes may still carry an (informational) cell extent.- Per-atom annotations (
roles,surface,site_types,component_ids) are optional lists aligned withelements.
Created on 2026-11-13 @author: zwu
Classes:
| Name | Description |
|---|---|
AtomicStructure |
Force-field-agnostic atomic structure (see module docstring). |
Functions:
| Name | Description |
|---|---|
element_mass |
Atomic mass (amu) of an element symbol (RDKit table as fallback). |
AtomicStructure
dataclass
¶
Force-field-agnostic atomic structure (see module docstring).
Attributes:
| Name | Type | Description |
|---|---|---|
elements |
List[str]
|
Element symbol per atom. |
positions |
ndarray
|
(N, 3) Cartesian coordinates in Angstrom. |
bonds |
List[Tuple[int, int]]
|
Bonded atom index pairs. |
images |
ndarray
|
(M, 3) integer periodic image shift per bond (zeros for finite structures). |
cell |
Optional[ndarray]
|
Optional (3, 3) lattice vectors (rows), Angstrom. |
pbc |
Tuple[bool, bool, bool]
|
Per-axis periodicity flags. |
roles |
Optional[List[str]]
|
Optional chemical role per atom (e.g. "Si", "OB", "OH", "HO" for silica), assigned by a chemistry adapter. |
surface |
Optional[List[bool]]
|
Optional per-atom surface flag. |
site_types |
Optional[List[Optional[str]]]
|
Optional per-atom surface-site label (e.g. "silanol"). |
normals |
Optional[ndarray]
|
Optional (N, 3) outward surface normals (zero for bulk). |
component_ids |
Optional[List[int]]
|
Optional connected-component index per atom. |
geometry_type |
str
|
"slab", "cluster", "sheet", "rod", or "imported". |
descriptors |
Dict[str, Any]
|
Geometry descriptors (envelope, core volume, accessible area, ...) -- never force-field data. |
provenance |
Dict[str, Any]
|
Source/builder/parameters/citations/seed record. |
metadata |
Dict[str, Any]
|
Material identity and chemistry bookkeeping (material id, phase, termination, silanol counts, ...). |
Methods:
| Name | Description |
|---|---|
element_counts |
Element -> count, in first-appearance order. |
formula |
Hill-like formula string (counts in first-appearance order). |
masses |
Per-atom masses (amu). |
total_mass |
Total mass (amu). |
validate |
Check internal consistency (array shapes, bond indices, PBC). |
bond_vectors |
(M, 3) bond vectors r_j + image.cell - r_i. |
bond_lengths |
(M,) bond lengths (A), periodic images applied. |
neighbors |
Per-atom bonded neighbor index lists (bond order preserved). |
coordination |
Per-atom bonded coordination number. |
connected_components |
Connected-component index per atom (largest component = 0). |
annotate_components |
Fill |
rotate |
Rotate coordinates (and normals) about |
bounding_radius |
Max distance of any atom from |
subset |
New structure with only the atoms in |
to_dict |
JSON-serializable dict (round-trips through from_dict). |
Source code in AutoPoly/materials/structure.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | |
element_counts() -> Dict[str, int]
¶
Element -> count, in first-appearance order.
formula() -> str
¶
Hill-like formula string (counts in first-appearance order).
masses() -> np.ndarray
¶
total_mass() -> float
¶
validate() -> None
¶
Check internal consistency (array shapes, bond indices, PBC).
Raises:
| Type | Description |
|---|---|
ValidationError
|
On any inconsistency. |
Source code in AutoPoly/materials/structure.py
bond_vectors() -> np.ndarray
¶
(M, 3) bond vectors r_j + image.cell - r_i.
Source code in AutoPoly/materials/structure.py
bond_lengths() -> np.ndarray
¶
neighbors() -> List[List[int]]
¶
Per-atom bonded neighbor index lists (bond order preserved).
Source code in AutoPoly/materials/structure.py
coordination() -> np.ndarray
¶
connected_components() -> List[int]
¶
Connected-component index per atom (largest component = 0).
annotate_components() -> None
¶
rotate(matrix: np.ndarray, center: Optional[Sequence[float]] = None) -> None
¶
Rotate coordinates (and normals) about center (default origin).
Source code in AutoPoly/materials/structure.py
bounding_radius(center: Optional[Sequence[float]] = None) -> float
¶
Max distance of any atom from center (default: centroid).
Source code in AutoPoly/materials/structure.py
subset(keep: Iterable[int]) -> AtomicStructure
¶
New structure with only the atoms in keep (sorted, bonds whose
both ends survive are kept with their images).
Source code in AutoPoly/materials/structure.py
to_dict() -> Dict[str, Any]
¶
JSON-serializable dict (round-trips through from_dict).
Source code in AutoPoly/materials/structure.py
element_mass(element: str) -> float
¶
Atomic mass (amu) of an element symbol (RDKit table as fallback).
Source code in AutoPoly/materials/structure.py
Inorganic force fields¶
AutoPoly.materials.forcefields.registry
¶
Versioned inorganic force-field (parameter) adapters.
An InorganicForceField maps the chemical roles assigned by a material's chemistry adapter (e.g. silica "Si"/"OB"/"OH"/"HO") onto moltemplate atom types, masses, charges and 12-6 Lennard-Jones parameters, and records what the parameter set may be used for:
- which materials it is defined for,
- the combining rule it was parameterized with (explicit cross terms are generated with it; see compatibility.py),
- the allowed motion treatments (built-in sets are nonbonded-only, so only "frozen" and "rigid" are permitted -- never "flexible"),
- the O-H (or other cap) bond length used when terminating surfaces,
- citations and provenance.
Applying an adapter to an AtomicStructure yields a ParameterAssignment (the "typed structure"); the structure itself is never modified, so one geometry can be typed under several compatible force fields.
Created on 2026-11-13 @author: zwu
Classes:
| Name | Description |
|---|---|
RoleParameters |
Nonbonded parameters of one chemical role. |
ParameterAssignment |
Force-field parameters attached to an AtomicStructure (typed structure). |
InorganicForceField |
One named, versioned inorganic parameter set (see module docstring). |
Functions:
| Name | Description |
|---|---|
register_inorganic_ff |
Register an inorganic force-field adapter (and its aliases). |
get_inorganic_ff |
Resolve an inorganic force field by registry name, or by alias in the |
registered_inorganic_ffs |
Sorted adapter names (optionally only those for one material). |
RoleParameters
dataclass
¶
Nonbonded parameters of one chemical role.
Source code in AutoPoly/materials/forcefields/registry.py
ParameterAssignment
dataclass
¶
Force-field parameters attached to an AtomicStructure (typed structure).
Attributes:
| Name | Type | Description |
|---|---|---|
force_field |
str
|
Adapter name (e.g. "interface_silica"). |
version |
str
|
Adapter version string. |
roles |
List[str]
|
Role per atom (copied from the structure). |
type_names |
List[str]
|
Moltemplate @atom type per atom. |
charges |
ndarray
|
(N,) per-atom charges (e). |
type_masses |
Dict[str, float]
|
type -> mass (amu). |
type_lj |
Dict[str, Tuple[float, float]]
|
type -> (epsilon kcal/mol, sigma A). |
combining_rule |
str
|
Rule for explicit cross terms. |
motions |
Tuple[str, ...]
|
Motion treatments the parameters are valid for. |
notes |
List[str]
|
Free-form provenance notes (overrides applied, ...). |
Methods:
| Name | Description |
|---|---|
type_table |
type -> {mass, epsilon, sigma, charges...} summary (sorted). |
Source code in AutoPoly/materials/forcefields/registry.py
type_table() -> Dict[str, Dict[str, float]]
¶
type -> {mass, epsilon, sigma, charges...} summary (sorted).
Source code in AutoPoly/materials/forcefields/registry.py
InorganicForceField
dataclass
¶
One named, versioned inorganic parameter set (see module docstring).
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Registry name (e.g. "interface_silica"). |
version |
str
|
Parameter-set version. |
label |
str
|
Short human-readable label. |
material_ids |
Tuple[str, ...]
|
Material IDs the set is defined for. |
roles |
Dict[str, RoleParameters]
|
role -> RoleParameters. |
combining_rule |
str
|
"arithmetic" (Lorentz-Berthelot), "geometric", or "host" (follow the organic host force field's rule). |
motions |
Tuple[str, ...]
|
Allowed motion treatments. |
cap_bond_length |
Optional[float]
|
Cap (e.g. O-H) bond length used for termination. |
aliases |
Tuple[str, ...]
|
Alternative names (e.g. "interface"). |
citations |
Tuple[str, ...]
|
Literature references. |
notes |
str
|
Provenance and usage notes. |
Methods:
| Name | Description |
|---|---|
with_overrides |
Role table with per-role overrides applied (unknown roles ignored). |
assign |
Type a structure from its per-atom roles. |
Source code in AutoPoly/materials/forcefields/registry.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
with_overrides(types: Optional[Mapping[str, str]] = None, charges: Optional[Mapping[str, float]] = None, lj: Optional[Mapping[str, Sequence[float]]] = None) -> Dict[str, RoleParameters]
¶
Role table with per-role overrides applied (unknown roles ignored).
Source code in AutoPoly/materials/forcefields/registry.py
assign(roles: Sequence[str], table: Optional[Mapping[str, RoleParameters]] = None, notes: Optional[List[str]] = None) -> ParameterAssignment
¶
Type a structure from its per-atom roles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
roles
|
Sequence[str]
|
Chemical role per atom. |
required |
table
|
Optional[Mapping[str, RoleParameters]]
|
Optional role table (e.g. from with_overrides()). |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If a role is not covered by the table, or two roles map one type name onto different parameters. |
Source code in AutoPoly/materials/forcefields/registry.py
register_inorganic_ff(ff: InorganicForceField) -> None
¶
Register an inorganic force-field adapter (and its aliases).
Source code in AutoPoly/materials/forcefields/registry.py
get_inorganic_ff(name: str, material_id: Optional[str] = None) -> InorganicForceField
¶
Resolve an inorganic force field by registry name, or by alias in the context of a material (e.g. ("interface", "sio2") -> interface_silica).
Raises:
| Type | Description |
|---|---|
ValidationError
|
Unknown name, or the set is not defined for the material. |
Source code in AutoPoly/materials/forcefields/registry.py
registered_inorganic_ffs(material_id: Optional[str] = None) -> List[str]
¶
Sorted adapter names (optionally only those for one material).
Source code in AutoPoly/materials/forcefields/registry.py
AutoPoly.materials.forcefields.compatibility
¶
Organic-inorganic force-field compatibility checks and cross terms.
Three responsibilities:
-
Host (organic) force-field style introspection: read the pair/bond style, mixing rule, special_bonds and kspace settings from the moltemplate force-field .lt the film/matrix is typed with (host_styles()). Inorganic .lt classes must carry the host's hybrid sub-style keywords, and class2 / many-body hosts are refused.
-
Explicit cross interactions: after moltemplate has numbered the atom types, write an explicit
pair_coeff i jfor every pair involving an inorganic type, computed with the declared combining rule of the inorganic adapter (or the host rule when the adapter declares "host"). The resulting system no longer depends onpair_modify mixfor any organic-inorganic pair (write_explicit_cross_terms()). -
A machine-readable record of every decision for the force-field compatibility report.
Created on 2026-11-13 @author: zwu
Classes:
| Name | Description |
|---|---|
HostStyles |
Style settings of the organic host force field. |
InorganicClassPolicy |
Cross-interaction policy of one inorganic moltemplate class. |
CrossTermReport |
What write_explicit_cross_terms() did. |
Functions:
| Name | Description |
|---|---|
host_styles |
Parse the host force-field style lines from its moltemplate .lt. |
combine |
(epsilon, sigma) cross parameters for a 12-6 LJ pair. |
resolve_rule |
Concrete rule for a declared adapter rule ("host" -> host rule). |
read_type_assignments |
Atom type id -> (namespace path, type name) from |
read_instance_assignments |
(mol ids, atom ids) from ttree_assignments.txt: |
read_self_pair_coeffs |
type id -> (epsilon, sigma) from |
write_explicit_cross_terms |
Append explicit pair_coeff lines for every pair involving an |
HostStyles
dataclass
¶
Style settings of the organic host force field.
Attributes:
| Name | Type | Description |
|---|---|---|
pair_substyle |
Optional[str]
|
LJ sub-style for hybrid pair styles (None for plain styles). |
bond_substyle |
Optional[str]
|
'harmonic' if the host uses a hybrid bond style. |
lj_style |
Optional[str]
|
The 12-6 LJ pair (sub-)style in use, or None. |
mixing_rule |
str
|
'geometric', 'arithmetic', 'sixthpower' (LAMMPS default geometric). |
Source code in AutoPoly/materials/forcefields/compatibility.py
pair_substyle: Optional[str]
property
¶
LJ sub-style for hybrid pair styles (None for plain styles).
bond_substyle: Optional[str]
property
¶
'harmonic' if the host uses a hybrid bond style.
lj_style: Optional[str]
property
¶
The 12-6 LJ pair (sub-)style in use, or None.
mixing_rule: str
property
¶
'geometric', 'arithmetic', 'sixthpower' (LAMMPS default geometric).
InorganicClassPolicy
dataclass
¶
Cross-interaction policy of one inorganic moltemplate class.
Source code in AutoPoly/materials/forcefields/compatibility.py
CrossTermReport
dataclass
¶
What write_explicit_cross_terms() did.
Source code in AutoPoly/materials/forcefields/compatibility.py
host_styles(force_field: str, ff_lt: Optional[Path]) -> HostStyles
¶
Parse the host force-field style lines from its moltemplate .lt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force_field
|
str
|
Host force-field name. |
required |
ff_lt
|
Optional[Path]
|
Path of the force-field .lt (None = not available, only allowed for "openff", whose generated file always uses the same styles). |
required |
Source code in AutoPoly/materials/forcefields/compatibility.py
combine(rule: str, a: Tuple[float, float], b: Tuple[float, float]) -> Tuple[float, float]
¶
(epsilon, sigma) cross parameters for a 12-6 LJ pair.
Source code in AutoPoly/materials/forcefields/compatibility.py
resolve_rule(rule: str, host: HostStyles) -> str
¶
Concrete rule for a declared adapter rule ("host" -> host rule).
Source code in AutoPoly/materials/forcefields/compatibility.py
read_type_assignments(moltemplate_dir: Path) -> Dict[int, Tuple[str, str]]
¶
Atom type id -> (namespace path, type name) from output_ttree/ttree_assignments.txt (e.g. 6 -> ("QuartzSlab", "i15_sc4"), 1 -> ("GAFF", "c3")).
Source code in AutoPoly/materials/forcefields/compatibility.py
read_instance_assignments(moltemplate_dir: Path)
¶
(mol ids, atom ids) from ttree_assignments.txt:
- mols: instance path -> molecule id (
$/mol:np_1-> 2), - atoms: instance path -> sorted atom ids of that instance subtree.
Source code in AutoPoly/materials/forcefields/compatibility.py
read_self_pair_coeffs(settings: Path) -> Dict[int, Tuple[float, float]]
¶
type id -> (epsilon, sigma) from pair_coeff i i ... lines.
Source code in AutoPoly/materials/forcefields/compatibility.py
write_explicit_cross_terms(moltemplate_dir: Path, policies: Dict[str, InorganicClassPolicy], host: HostStyles, settings_file: str = 'system.in.settings') -> CrossTermReport
¶
Append explicit pair_coeff lines for every pair involving an inorganic type to system.in.settings.
Rules:
- inorganic x organic: the class's organic_rule ("host" resolves
to the host mixing rule),
- inorganic x inorganic of the same adapter: the adapter's native
rule ("host" resolves to the host rule),
- inorganic x inorganic of different adapters: refused (no validated
policy).
Raises:
| Type | Description |
|---|---|
ValidationError
|
Missing self coefficients, unsupported host pair style, or an unqualified inorganic-inorganic pair. |
Source code in AutoPoly/materials/forcefields/compatibility.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | |
Nanocomposite packing¶
AutoPoly.packing.nanocomposite
¶
Nanocomposite packing: fillers first, then an obstacle-aware matrix.
Strategy "nanocomposite_mc" (stage 3; reads only units.json + the per-unit class-local coordinate files written by stage 2):
- Box: explicit box_dims / box_size win; otherwise a cubic box sized for
the matrix at
initial_densityplus the nominal filler core volume: V_box = M_matrix / rho_init + sum(V_core). (Atomistic estimate only: build at modest density, compress/equilibrate in MD.) - Fillers: every instance of every filler unit gets a random position and
orientation under full 3D periodic boundaries; its atoms must keep
min_gapfrom every atom of every other filler including periodic images. A particle must also be smaller than the box (no self-image contact). - Matrix: every polymer chain / molecule instance gets a random rigid-body
placement (orientation + an anchor atom dropped into a free voxel); all
its atoms must keep
filler_clearancefrom filler atoms andpolymer_clearancefrom atoms of other matrix instances (minimum image). Coils interpenetrate freely as long as atoms do not clash -- whole-chain bounding spheres are never used. When rigid placement of a pre-grown chain fails ("auto" mode, default) -- or always ("regrow") -- the chain is regrown monomer by monomer inside the box around the obstacles (packing/chain_regrowth.py) and written as a per-instance class with the new monomer transforms (typing untouched). - No silent fallback: an instance that cannot be placed raises a PackingError with the free-volume diagnostics and concrete suggestions.
- An exact minimum-image neighbor search over all atoms verifies every clearance before the lt commands are emitted; the achieved minimum distances, nominal loading and box are returned in the result report.
Created on 2026-11-13 @author: zwu
Classes:
| Name | Description |
|---|---|
PackingError |
Raised when the nanocomposite packing cannot place an instance. |
NanocompositePacking |
Configuration of the "nanocomposite_mc" strategy. |
NanocompositeMCStrategy |
Filler-first, obstacle-aware atom-level random packing. |
PackingError
¶
Bases: ValidationError
Raised when the nanocomposite packing cannot place an instance.
NanocompositePacking
dataclass
¶
Configuration of the "nanocomposite_mc" strategy.
Attributes:
| Name | Type | Description |
|---|---|---|
initial_density |
float
|
Matrix mass density (g/cm^3) used to size the box when no explicit box is given. Building pre-grown chains at the final melt density is rarely possible; the generated run script compresses toward target_polymer_density. |
target_polymer_density |
Optional[float]
|
Final matrix density (g/cm^3) recorded in the report and used by the compression stage of in.run; None = no compression stage. |
min_gap |
float
|
Minimum atom-atom distance between two fillers (A), periodic images included (surface-to-surface gap). |
filler_clearance |
float
|
Minimum matrix-atom to filler-atom distance (A). |
polymer_clearance |
float
|
Minimum distance (A) between atoms of different matrix instances (heavy atoms). |
hydrogen_clearance |
float
|
Same, for contacts with matrix hydrogen atoms (A); smaller because H atoms are small. |
max_initial_overlap |
float
|
Allowed penetration below the clearances (A); 0.0 = strict. The exact final check uses clearance - this. |
max_attempts |
int
|
Placement attempts per instance before PackingError ("rigid" mode). |
matrix_placement |
str
|
"auto" (rigid placement, regrow the chain in place when that fails), "rigid" (pre-grown conformations only), or "regrow" (always regrow polymer chains in the box). |
rigid_attempts |
int
|
"auto" mode: rigid attempts before regrowing. |
regrow_starts |
int
|
Independent in-box regrowth attempts per chain. |
intra_clearance |
float
|
Minimum distance between atoms of the same chain more than three bonds apart (regrown chains) (A). |
intra14_clearance |
float
|
Same for 1-4 pairs across a junction (A). |
voxel_size |
float
|
Collision-grid resolution (A). |
seed |
Optional[int]
|
RNG seed (None = nondeterministic; the BoxPacker rng_seed is used when unset). |
packing_failure |
str
|
Only "raise" (never fall back to overlapping positions). |
Source code in AutoPoly/packing/nanocomposite.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
NanocompositeMCStrategy
¶
Bases: PlacementStrategy
Filler-first, obstacle-aware atom-level random packing.
Source code in AutoPoly/packing/nanocomposite.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 | |
LAMMPS smoke test¶
AutoPoly.pipeline.smoke
¶
LAMMPS smoke test of a generated system.
Turns the generated in.run into a short run (bounded minimization, a few hundred MD steps, no dumps), executes LAMMPS, and checks that
- LAMMPS exits cleanly (no ERROR, no lost atoms/bonds),
- every thermo energy is finite, the temperature stays bounded,
- the expected number of rigid bodies was created (nanocomposites).
Used by the qualification tests (tests/test_nanocomposite_lammps_smoke.py) and available to users:
>>> from AutoPoly.pipeline.smoke import run_smoke
>>> report = run_smoke("runs/ps_silica", steps=200)
Created on 2026-11-13 @author: zwu
Classes:
| Name | Description |
|---|---|
SmokeReport |
Outcome of a smoke run. |
Functions:
| Name | Description |
|---|---|
lammps_executable |
First LAMMPS binary found on PATH (None if none). |
smoke_input |
Shorten a generated in.run: bounded minimize, short run, no dumps. |
parse_log |
All thermo rows of a LAMMPS log. |
run_smoke |
Run the shortened |
SmokeReport
dataclass
¶
Outcome of a smoke run.
Source code in AutoPoly/pipeline/smoke.py
lammps_executable(candidates=('lmp', 'lmp_serial', 'lmp_mpi')) -> Optional[str]
¶
First LAMMPS binary found on PATH (None if none).
smoke_input(run_script: str, steps: int = 200, min_iterations: int = 200) -> str
¶
Shorten a generated in.run: bounded minimize, short run, no dumps.
Source code in AutoPoly/pipeline/smoke.py
parse_log(text: str) -> List[Dict[str, float]]
¶
All thermo rows of a LAMMPS log.
Source code in AutoPoly/pipeline/smoke.py
run_smoke(project_dir, steps: int = 200, lmp: Optional[str] = None, expected_rigid_bodies: Optional[int] = None, max_temperature: float = 5000.0, timeout: float = 1800.0, script: str = 'in.run') -> SmokeReport
¶
Run the shortened script (default in.run; in.polymer for the
bead-spring backends) of project_dir with LAMMPS.
Raises:
| Type | Description |
|---|---|
WorkflowError
|
No LAMMPS executable or no run script. |