GeneratorConfig#
- class pasted._config.GeneratorConfig(n_atoms: int, charge: int, mult: int, mode: str = 'gas', region: str | None = None, branch_prob: float = 0.3, chain_persist: float = 0.5, chain_bias: float = 0.0, bond_range: tuple[float, float] = (1.2, 1.6), center_z: int | None = None, coord_range: tuple[int, int] = (4, 8), shell_radius: tuple[float, float] = (1.8, 2.5), elements: str | list[str] | None = None, element_fractions: dict[str, float] | None = None, element_min_counts: dict[str, int] | None = None, element_max_counts: dict[str, int] | None = None, cov_scale: float = 1.0, relax_cycles: int = 1500, affine_strength: float = 0.0, affine_stretch: float | None = None, affine_shear: float | None = None, affine_jitter: float | None = None, maxent_steps: int = 300, maxent_lr: float = 0.05, maxent_cutoff_scale: float = 2.5, trust_radius: float = 0.5, convergence_tol: float = 0.001, add_hydrogen: bool = True, n_samples: int = 1, n_success: int | None = None, seed: int | None = None, n_bins: int = 20, w_atom: float = 0.5, w_spatial: float = 0.5, cutoff: float | None = None, filters: list[str] | None = None, verbose: bool = False)[source]#
Bases:
objectImmutable configuration for
StructureGenerator.All fields correspond exactly to the keyword parameters of
StructureGeneratorandgenerate(). See those docstrings for full per-field documentation.The three fields without defaults (n_atoms, charge, mult) must always be supplied explicitly.
Examples
Construct and pass to the class API:
from dataclasses import replace from pasted import GeneratorConfig, StructureGenerator cfg = GeneratorConfig( n_atoms=20, charge=0, mult=1, mode="gas", region="sphere:10", elements="6,7,8", n_samples=100, seed=0, ) result = StructureGenerator(cfg).generate() # Reuse with a different seed: result2 = StructureGenerator(replace(cfg, seed=1)).generate()
Pass directly to the functional API:
from pasted import generate, GeneratorConfig cfg = GeneratorConfig(n_atoms=12, charge=0, mult=1, mode="chain", elements="6,7,8", n_samples=50, seed=42) result = generate(cfg)
- __repr__()#
Return repr(self).
- affine_strength: float = 0.0#
Global affine transform strength.
0.0disables (default). Individual operations can be overridden via affine_stretch, affine_shear, and affine_jitter.
Required fields
The three fields without defaults — n_atoms, charge, mult — must always be supplied explicitly. All other fields carry sensible defaults and are optional.
One-field override pattern
GeneratorConfig is frozen=True, so instances are immutable
and hashable. Use dataclasses.replace() to derive a new config
that differs in exactly one field without mutating the original:
import dataclasses
from pasted import GeneratorConfig, StructureGenerator
base = GeneratorConfig(
n_atoms=20, charge=0, mult=1,
mode="gas", region="sphere:10",
elements="6,7,8", n_samples=100, seed=42,
)
for seed in range(10):
cfg = dataclasses.replace(base, seed=seed)
result = StructureGenerator(cfg).generate()
Passing to the functional API
generate() also accepts a
GeneratorConfig as its first positional argument:
from pasted import generate, GeneratorConfig
result = generate(
GeneratorConfig(n_atoms=12, charge=0, mult=1,
mode="chain", elements="6,7,8",
n_samples=50, seed=0)
)
The original keyword-argument style is fully backward-compatible and continues to work without modification.
Affine-transform fields (StructureGenerator)
Note
affine_jitter has no visible effect when used inside
StructureGenerator because the internal
move_step is 0.0 at generation time. The jitter term is only
meaningful in StructureOptimizer, where
move_step is set per MC step.
See Affine moves in the optimizer documentation for details.