generate¶
One-shot convenience function composing the three pipeline stages
(GeometryBuilder → UnitTyper → BoxPacker). Use the stage classes
directly when you need control between stages (e.g. typing one geometry
under multiple force fields); use generate() for single-force-field
one-shot runs.
Beyond the bulk-melt default, generate() also accepts:
substrate=SubstrateSpec(...)— build a film on a physical substrate slab (auto-selects theon_substratestrategy);subtract=[CutAbove(...) / Cylinder(...) / ...]— whole-instance carve regions applied after placement;box_dims=(lx, ly, lz)— rectangular boxes (per-axis auto-sizing withNone).
See the Substrates & Films guide for the full surface-simulation workflow.
AutoPoly.pipeline.workflow
¶
Workflow Convenience Function for AutoPoly Package
This module provides :func:generate, a thin one-shot convenience function
that composes the three pipeline stages:
GeometryBuilder (stage 1: FF-agnostic coordinates -> geometry/)
UnitTyper (stage 2: force-field typing -> build/<ff>/)
BoxPacker (stage 3: box packing + moltemplate -> moltemplate/)
All stage logic lives in the stage modules (geometry.py, typing.py, packer.py, packing/). Use the stage classes directly when you need control between stages (e.g. typing one geometry under multiple force fields); use generate() when a single force field one-shot run is all you need.
Created on 2026-01-06 @author: zwu
Functions:
| Name | Description |
|---|---|
generate |
Generate a complete LAMMPS system in one call (three-stage pipeline). |
generate(system: object, name: str, models: List[object], force_field: str = 'oplsaa', *, strategy: str = 'mc_random', geometry_config: Optional[GeometryConfig] = None, box_size: Optional[float] = None, mc_max_attempts: int = 10000, monomer_density: float = 0.085, rng_seed: Optional[int] = None, run_moltemplate: bool = True, substrate: Optional[SubstrateSpec] = None, subtract: Optional[list] = None, box_dims: Optional[tuple] = None) -> PlacementResult
¶
Generate a complete LAMMPS system in one call (three-stage pipeline).
Runs GeometryBuilder -> UnitTyper -> BoxPacker, producing:
<out>/<name>/geometry/geometry.json<out>/<name>/build/<ff>/*.lt+units.json<out>/<name>/moltemplate/system.lt-> moltemplate ->system.dataetc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
object
|
System object providing get_folder_path(). |
required |
name
|
str
|
Project name; outputs go to |
required |
models
|
List[object]
|
List of Polymer and/or Molecule objects (the "film" models when a substrate is used). |
required |
force_field
|
str
|
Force field name (see FORCE_FIELD_REGISTRY). Defaults to "oplsaa". |
'oplsaa'
|
strategy
|
str
|
Box packing strategy ("mc_random", "grid",
"on_substrate", ...). Defaults to "mc_random". When
|
'mc_random'
|
geometry_config
|
Optional[GeometryConfig]
|
Optional GeometryConfig for stage 1 (MC chain growth parameters). Defaults to GeometryConfig(). |
None
|
box_size
|
Optional[float]
|
Optional explicit box edge length (Angstrom) for stage 3. |
None
|
mc_max_attempts
|
int
|
Maximum placement attempts for MC placement. Defaults to 10000. |
10000
|
monomer_density
|
float
|
Target monomer density (monomers/A^3) for MC box sizing. Defaults to 0.085. |
0.085
|
rng_seed
|
Optional[int]
|
Optional RNG seed for reproducible placement. |
None
|
run_moltemplate
|
bool
|
Run moltemplate at the end of stage 3. Defaults to True. |
True
|
substrate
|
Optional[SubstrateSpec]
|
Optional SubstrateSpec describing a physical substrate slab; film models are packed on top of it. Selects the "on_substrate" strategy automatically. |
None
|
subtract
|
Optional[list]
|
Optional list of CarveRegion specs (CutAbove, Cylinder, ...) removing whole instances after placement. Supported by "mc_random" and "on_substrate". |
None
|
box_dims
|
Optional[tuple]
|
Optional per-axis box sides (lx, ly, lz) in Angstrom; any element may be None (auto-sized). Overrides box_size per axis where given. |
None
|
Returns:
| Type | Description |
|---|---|
PlacementResult
|
PlacementResult from the packing stage. |
Raises:
| Type | Description |
|---|---|
WorkflowError
|
If any critical step fails or required files are missing |
ValidationError
|
On contradictory strategy/substrate/subtract combinations or unresolvable substrate counts. |
Example
from AutoPoly import System, Polymer, generate system = System(out="pmma_out") polymer = Polymer(chain_num=4, sequence=sequence, ... topology="linear", tacticity="atactic") generate(system, "pmma", [polymer], force_field="oplsaa")
Film on a substrate slab:¶
from AutoPoly.packing import SubstrateSpec spec = SubstrateSpec(model=Molecule(Count=200, Smiles="O=[Si]=O", ... Name="sio2"), ... thickness=15.0, packing="grid", gap=3.0) generate(system, "pmma_on_sio2", [polymer], ... substrate=spec, box_dims=(60.0, 60.0, None))
Source code in AutoPoly/pipeline/workflow.py
34 35 36 37 38 39 40 41 42 43 44 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 | |