kups.application.mcmc
¶
IsMCMCFixedData
¶
IsMCMCState
¶
Bases: Protocol
Protocol for states compatible with MCMC logging.
Source code in src/kups/application/mcmc/logging.py
IsMCMCStepData
¶
Bases: Protocol
Contract for data from the per_step reader group.
Source code in src/kups/application/mcmc/analysis.py
IsMCMCSystemStepData
¶
Bases: Protocol
Contract for per-system step data.
Source code in src/kups/application/mcmc/analysis.py
MCMCAnalysisResult
dataclass
¶
Results from MCMC simulation analysis for a single system.
Attributes:
| Name | Type | Description |
|---|---|---|
energy |
BlockAverageResult
|
Average total potential energy with SEM (eV). |
loading |
BlockAverageResult
|
Average particle count per species with SEM (dimensionless). |
heat_of_adsorption |
BlockAverageResult
|
Per-species heat of adsorption with SEM (eV). |
total_heat_of_adsorption |
BlockAverageResult
|
Composition-weighted total heat of adsorption (eV). |
Source code in src/kups/application/mcmc/analysis.py
MCMCGroup
¶
Molecular group state for rigid-body MCMC.
Attributes:
| Name | Type | Description |
|---|---|---|
system |
Index[SystemId]
|
Index mapping each group to its parent system. |
motif |
Index[MotifId]
|
Index mapping each group to its adsorbate species. |
Source code in src/kups/application/mcmc/data.py
labels
property
¶
Group labels derived from motif index.
MCMCLoggedData
¶
HDF5 writer group layout: one-shot host data + per-cycle adsorbate data.
Source code in src/kups/application/mcmc/logging.py
MCMCParticles
¶
Bases: Particles
Particle state for rigid-body MCMC with group membership.
Attributes:
| Name | Type | Description |
|---|---|---|
group |
Index[GroupId]
|
Index mapping each particle to its molecular group. |
Source code in src/kups/application/mcmc/data.py
MCMCSystemStepData
¶
Per-system, per-cycle data: energies, move statistics, and stress.
Source code in src/kups/application/mcmc/logging.py
MCMCSystems
¶
Per-system thermodynamic state for MCMC simulations.
Attributes:
| Name | Type | Description |
|---|---|---|
unitcell |
UnitCell
|
Unit cell geometry, batched shape |
temperature |
Array
|
Temperature (K), shape |
potential_energy |
Array
|
Total potential energy per system (eV), shape |
log_fugacity |
Array
|
Log fugacity per species (dimensionless), shape |
Source code in src/kups/application/mcmc/data.py
log_activity
property
¶
Log activity: log(fugacity / kT), shape (n_systems, n_species).
RunConfig
¶
Bases: BaseModel
Run configuration for MCMC simulation.
Source code in src/kups/application/mcmc/data.py
exchange_prob = 1 / 2
class-attribute
instance-attribute
¶
Ordered move sequence for the palindrome propagator.
num_cycles
instance-attribute
¶
Number of production cycles.
num_warmup_cycles
instance-attribute
¶
Number of warmup cycles (not written to output).
out_file
instance-attribute
¶
Path to the output HDF5 file.
seed = None
class-attribute
instance-attribute
¶
Random seed. None uses a time-based seed.
analyze_mcmc(fixed, per_step, n_blocks=None)
¶
Analyze MCMC simulation results from pre-loaded data.
Computes energy, loading (average particle counts), and heat of adsorption per species using block averaging for error estimation. Analysis is performed independently for each system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fixed
|
IsMCMCFixedData
|
Fixed (one-shot) logged data containing system metadata. |
required |
per_step
|
IsMCMCStepData
|
Per-step logged data containing energies and particle counts. |
required |
n_blocks
|
int | None
|
Number of blocks for error estimation. |
None
|
Returns:
| Type | Description |
|---|---|
dict[SystemId, MCMCAnalysisResult]
|
Per-system analysis results keyed by |
Source code in src/kups/application/mcmc/analysis.py
analyze_mcmc_file(hdf5_path, n_blocks=None)
¶
Analyze MCMC simulation results from an HDF5 file.
Convenience wrapper that reads the HDF5 file and delegates to
:func:analyze_mcmc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hdf5_path
|
str | Path
|
Path to HDF5 output file from
:func: |
required |
n_blocks
|
int | None
|
Number of blocks for error estimation. |
None
|
Returns:
| Type | Description |
|---|---|
dict[SystemId, MCMCAnalysisResult]
|
Per-system analysis results keyed by |
Source code in src/kups/application/mcmc/analysis.py
make_mcmc_logged_data(state, stress_fn=None)
¶
Create MCMC logging config that logs host particles once and adsorbate buffer per step.
Host particles are identified by having out-of-bounds group indices (they belong to no molecular group). This works for any number of host systems regardless of how particles are interleaved in the buffer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
S
|
The initial MCMC state (after padding). |
required |
stress_fn
|
StateProperty[S, Table[SystemId, StressResult]] | None
|
Optional stress tensor function. When provided, the guest stress tensor is logged each cycle. |
None
|
Returns:
| Type | Description |
|---|---|
MCMCLoggedData
|
Configured logging data with host/adsorbate split. |
Source code in src/kups/application/mcmc/logging.py
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 | |
run_mcmc(key, propagator, state, config, logged_data)
¶
Run a µVT MCMC simulation with warmup and production phases.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Array
|
JAX PRNG key. |
required |
propagator
|
Propagator[State]
|
Propagator, e.g. from :func: |
required |
state
|
State
|
Initial simulation state. |
required |
config
|
RunConfig
|
Run configuration. |
required |
logged_data
|
MCMCLoggedData
|
Logging configuration with host/adsorbate split. |
required |
Returns:
| Type | Description |
|---|---|
State
|
Final simulation state after production run. |