Fix atom type consistency#10
Merged
chaibhave merged 3 commits intoIdahoLabResearch:mainfrom Apr 13, 2026
Merged
Conversation
2a44ce0 to
8806920
Compare
…LabResearch#9 - Atom.py: use dict.fromkeys instead of set() to preserve insertion order when auto-generating type_map, preventing non-deterministic type IDs. - GBMaker.py: reuse unit_cell.type_map IDs when writing LAMMPS files if atom names are a known subset, preventing ID drift across writes. - GBManipulator.py: accept type_dict as dict[str,int] or dict[int,str] and normalise to both directions internally; auto-derive from unit_cell.type_map when not explicitly supplied; pass type_map to Atom.as_array in remove_atoms/insert_atoms; fix bytes handling in convert_type; fix atoms_to_add keyed by atom_type not ratio; replace identity comparison with equality for central_type check. - tests: add roundtrip test verifying element names survive write→read cycles after translate, remove, insert, slice_and_merge, and soft-mode displacement. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace bare dict/list access with None-safe handling throughout _evaluate_generation: wrap gb_energy_func calls in try/except and assign a PENALTY (1e30) to any candidate that errors or produces a missing dump file. - Add _is_valid_file helper to safely test dump file existence. - Guard _make_next_generation against empty files or indices lists. - Filter valid candidates before selection: build valid_old_idxs, valid_energies, and valid_files so selection only operates on survivors; re-seed entirely from the current best when no candidates survive a generation. - Copy initial system arrays (np.array(..., copy=True)) before passing to the energy function to prevent in-place mutation side-effects. - Add **kwargs pass-through to run_MC and preserve type_dict when reconstructing the manipulator after an accepted MC step. - Switch imports: pathlib.Path replaces sys; typing.Optional added. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Both MonteCarloMinimizer and GeneticAlgorithmMinimizer accept an optional initial_structure keyword argument (None, GBMaker, or a file path) that seeds the starting manipulator instead of always constructing one fresh from self.GB. - _make_initial_manipulator() encapsulates this logic on both classes. - Mutator.mutate() now returns (mutation_label, new_system) so callers can record what operation was applied. - MonteCarloMinimizer tracks the full accept/reject history in operation_list as [mutation_label, accepted] pairs; the initial entry is ["START", True]. Closes IdahoLabResearch#7 - GeneticAlgorithmMinimizer seeds one member of the initial population directly from the evaluated initial structure when initial_structure is supplied. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
8806920 to
11ec56b
Compare
Collaborator
Author
This was referenced Apr 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.