Mkphuthi/intercalation calc [WIP] - #251
Conversation
…files Adds a PropCalc subclass that removes intercalating ions from a host structure across a range of concentrations, scoring each configuration via single-point or relaxation and sampling with Metropolis-Hastings. Writes a per-concentration ASE trajectory and serializes results with monty. Exported through matcalc.__init__. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…mation Adds a PropCalc subclass that runs Metropolis-Hastings sampling using any user-supplied transformation object (duck-typed apply_transformation). The transform_initial flag samples configurations at a fixed concentration by applying the transformation to the pristine structure each step, and a trajectory plus acceptance ratio are tracked at save_freq intervals. A grand-canonical step is stubbed for later. Exported through matcalc.__init__. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replaces the inline Metropolis-Hastings loop, boltzmann-weight helper, and RelaxCalc construction with a per-concentration MCCalc run driven by a new _RemoveKSites transformation (transform_initial=True for fixed-composition sampling). IntercalationCalc keeps the concentration sweep, per-k trajectory naming, results aggregation, and serialization. The per-level acceptance is now reported under the key "acceptance_ratio". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds Cu/Cu_supercell/emt_calculator conftest fixtures and unit tests covering canonical Monte Carlo sampling and the concentration sweep on a 32-atom Cu cell with 3 vacancies, using ASE EMT for speed. One test exercises relaxation; the rest use single-point scoring. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds a swap move on a configurable sublattice for true canonical MCMC: given an ordered host and a disordered structure marking the active sublattice, each call relocates n_swaps occupants (species<->vacancy or species<->species), conserving composition. Stateless, so driving it with MCCalc(transform_initial=False) gives a genuine Markov chain. Not yet wired into IntercalationCalc. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds algorithm="markov" alongside the default "independent" sampler. Markov mode seeds a configuration at each concentration and runs a true Metropolis chain of local _SwapSites moves (transform_initial=False), conserving composition. Adds a module-level _build_disordered helper (species/vacancy sublattice) and a markov test asserting fixed composition and one swap per accepted step. The independent path and public API are unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Avoids leaking a caller-supplied max_steps from relax_calc_kwargs into **kwargs (which would duplicate the max_steps argument to RelaxCalc). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
MCCalc now records the minimum-energy configuration visited across the chain and exposes it as min_energy / min_structure (instance attrs and result keys). This surfaces the ground-state ordering at each concentration in IntercalationCalc, not just the last accepted state. Adds min_energy <= energy assertions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Runze Liu <146490083+rul048@users.noreply.github.com>
|
Thanks for the contribution! I have resolved the conflicts and please check the output from the lint and pytest. |
|
🤖 Automated PR review by Claude (posted via @shyuep). Based on static analysis of the diff; no code was executed locally. Substantial and well-documented addition — Blocking: the lint job is failing (
The test suite (including fp-loaders) passes. Marked [WIP], so flagging these for when you're ready to finalize rather than as a merge gate. |
Signed-off-by: Runze Liu <146490083+rul048@users.noreply.github.com>
Signed-off-by: Runze Liu <146490083+rul048@users.noreply.github.com>
shyuep
left a comment
There was a problem hiding this comment.
Automated PR review generated by Claude (on behalf of @shyuep)
Re-review of commits since 2026-06-30 (main merge, __init__ export, datetime/UTC cleanup, mypy signature fixes). CI green (5/5). Comments on the current state:
- Module-level
warnings.filterwarnings("ignore", message="logm result may be inaccurate")in_intercalation.pymutates global warning state for any process that merely imports matcalc. Scope it withwarnings.catch_warnings()around the relax/score call instead. MCCalc(ensemble="grand_canonical")is accepted but unimplemented — raiseNotImplementedErrorin__init__rather than at first use.- Default
trajfile="mc.traj"silently writes into the CWD; suggestNonedefault meaning "don't write". _SwapSites(composition-conserving MCMC) vs_RemoveKSites+transform_initial=True(independent resampling, not a Markov chain): the docstrings distinguish these well, butMCCalcreportsacceptance_ratioin both modes — for the resampling mode it's not a standard Metropolis acceptance ratio; a note would prevent misinterpretation.
Still [WIP] per title (benchmarks/theory docs pending), so not flagging for merge yet. Structure and test coverage look good.
|
Automated PR review generated by Claude (scheduled routine, posted on behalf of @shyuep) — re-review after new commits since the 2026-06-30 automated review. The architecture has firmed up nicely: Notes for before this leaves WIP: (1) the module-level |
Summary
Major changes:
Todos
Checklist