MC Placement & Chain Growth¶
AutoPoly builds the initial configuration of your simulation box with Monte Carlo (MC) methods: chains are grown monomer-by-monomer as self-avoiding walks (SAW), and whole molecules are placed with collision detection. The result is a coiled, overlap-free starting structure that equilibrates far faster than a grid or an extended chain.
Placement methods¶
Choose with the strategy parameter of generate:
| Value | Behavior |
|---|---|
"mc_random" (default) |
Monte Carlo placement with SAW chain growth — realistic coiled conformations |
"grid" |
Deterministic grid placement — extended chains on a lattice; simple, but far from equilibrium |
"on_substrate" |
Film on a physical substrate slab — auto-selected when substrate= is passed; see Substrates & Films |
from AutoPoly import generate, GeometryConfig
generate(
system,
"polymer_mc",
[polymer],
force_field="oplsaa",
strategy="mc_random", # Monte Carlo placement (default)
mc_max_attempts=10000, # max placement attempts
monomer_density=0.085, # target density (monomers / ų)
geometry_config=GeometryConfig(
use_mc_chain_growth=True, # SAW chain growth (default)
mc_bond_angle_min=50.0, # min deflection angle (degrees)
mc_bond_angle_max=90.0, # max deflection angle (degrees)
),
)
How SAW chain growth works¶
- Each chain starts from a random seed monomer.
- Every next monomer is attached at a random orientation within the allowed deflection angle window (
mc_bond_angle_min…mc_bond_angle_max). Deflection = 180° − bond angle, so a tetrahedral carbon corresponds to ≈ 70.5°. - A cell-linked-list collision detector rejects placements that overlap existing atoms — both other chains and, with
mc_intrachain_exclude_neighbors(default 2), the growing chain itself beyond its bonded neighbors. - If no valid position is found within
mc_max_attempts, growth backtracks and retries.
Set use_mc_chain_growth=False in the GeometryConfig to place whole chains rigidly instead of growing them.
Box sizing¶
Boxes are sized from SAW scaling — N^0.6 × bond_length for a chain of N monomers — combined with the target monomer_density, rather than the fully extended chain length. This produces compact, realistic boxes at low initial density, leaving room for overlap-free placement before NPT compression.
Tuning guide¶
| Symptom | Knob |
|---|---|
| Placement fails / "max attempts exceeded" | Lower monomer_density (looser box), raise mc_max_attempts |
| Chains too extended or too knotted | Adjust mc_bond_angle_min/max in GeometryConfig toward your chemistry's real bond angles |
| False-positive collisions along a chain | Raise mc_intrachain_exclude_neighbors in GeometryConfig (2 is recommended) |
| Want reproducible grid layout | strategy="grid" |
The mc module¶
The placement engine is a standalone subpackage — see the mc API reference for CollisionDetector, ChainGrowthMC, and MolecularPlacementMC. The same collision machinery drives bead-spring generation.
See also¶
- Substrates & Films — film-on-slab systems, rectangular
box_dims, carve subtract - MC Placement tutorial — grid vs MC random vs chain growth, side by side
- generate API — the
strategyand density parameters;GeometryConfigfor the chain-growth knobs