build_interaction¶
Build a fully populated interaction list from a TOML config or dict.
build_interaction
¶
build_interaction(
config: Union[dict, str, Path],
*,
geometry_fn: Optional[Callable] = None,
intrcmap_fn: Optional[Callable] = None,
model_fn: Optional[Callable] = None,
space_fn: Optional[Callable] = None,
) -> Tuple[List[Interaction], Index, Geometry]
Build a fully populated interaction list from a TOML config.
Orchestrates the four-stage MPO construction pipeline:
- Geometry — constructs a
Geometrystruct fromgeo_cfgviageometry_fn. - Intrcmap — generates the bare interaction list with sites and
labels but no tensors and
cpl == 0.0viaintrcmap_fn. - Model — fills
cpland tensor fields on each interaction (without baking coupling into the tensors). - Returns
(interactions, spc, geo)ready forbuild_hamiltonian.
Callable overrides (geometry_fn, intrcmap_fn, model_fn, space_fn)
take priority over [plugin] section entries in the config, which in turn
take priority over the built-in dispatch tables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Union[dict, str, Path]
|
Either a config dict (with |
required |
geometry_fn
|
Optional[Callable]
|
Optional override for the geometry struct factory. Signature:
|
None
|
intrcmap_fn
|
Optional[Callable]
|
Optional override for the interaction-map builder. Signature:
|
None
|
model_fn
|
Optional[Callable]
|
Optional override for the model builder. Signature:
|
None
|
space_fn
|
Optional[Callable]
|
Optional override for the operator-set builder (normally called
internally by the model builder). Passed through to the model builder
as a keyword argument |
None
|
Returns:
| Type | Description |
|---|---|
tuple
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If a required key is missing or an unknown |
TOML Config Structure¶
A minimal config dict (or TOML section) must contain two sub-tables:
[model.geometry]
lattice = "chain"
lx = 10
bcx = "OBC"
n2x = true
[model.model]
category = "bosonic"
label = "Heisenberg"
symmetry = "U1"
spin = 0.5
J = 1.0
An optional [model.plugin] table can override geometry, intrcmap, space, or model callables:
[model.plugin]
geometry = "my_dir/my_geometry.py:build_my_lattice"
intrcmap = "my_dir/my_intrcmap.py:build_my_intrcmap"
model = "my_dir/my_model.py:build_my_model"
Plugin specs use the format "path/to/file.py:function_name".
Extension Hooks¶
| Kwarg | Plugin key | Signature | Description |
|---|---|---|---|
geometry_fn |
[plugin] geometry |
(dict) -> Geometry |
Replace the geometry-building step |
intrcmap_fn |
[plugin] intrcmap |
(Geometry) -> list[Interaction2Site] |
Replace the interaction-map step |
model_fn |
[plugin] model |
(interactions, L, **cfg) -> None |
Replace the model-filling step |
space_fn |
[plugin] space |
(category, **cfg) -> (Index, dict) |
Replace the local-space step |
Keyword arguments take priority over [plugin] entries.
Return Value¶
build_interaction returns a three-tuple (interactions, spc, geo):
| Element | Type | Description |
|---|---|---|
interactions |
list[Interaction] |
Fully populated interaction list |
spc |
Index |
Physical index (local space) |
geo |
Geometry |
Resolved lattice geometry; use geo.L as the chain length for build_hamiltonian |
The chain length is accessed as geo.L:
interactions, spc, geo = build_interaction(config)
hamiltonian = build_hamiltonian(interactions, geo.L, spc)
See Also¶
- Interaction, Interaction2Site — objects returned in the list.
- Geometry — the geometry struct returned as the third element.
- build_hamiltonian — next step after
build_interaction. - AutoMPO from TOML example
- Custom geometry example
- Custom intrcmap example