Skip to content

Custom BGMN params#28

Open
Andrea-gm wants to merge 15 commits into
mainfrom
thermal_params
Open

Custom BGMN params#28
Andrea-gm wants to merge 15 commits into
mainfrom
thermal_params

Conversation

@Andrea-gm
Copy link
Copy Markdown
Member

Summary

Major changes:

  • feature 1: Added the custom_lines argument to the cif2str function to support injecting arbitrary BGMN string parameters, mathematical equations, and defect models directly into the generated .str files.
  • feature 2: Added the element_params_map argument (typed as dict[str, dict]) to dynamically override or add parameters to specific Wyckoff lines. By using Python's .update() method, this cleanly removes the previous reliance on the hardcoded TDS string, allowing users to explicitly define independent parameters like {"TDS": "BO", "Occ": "OccO"} per element. Includes wildcard (*) support to easily apply global variables across the entire crystal structure.
  • fix 1: Resolved the limitation where high-temperature and highly disordered refinements (e.g., alpha-phase K2CO3) would crash or fail to converge due to the rigid, hardcoded room-temperature TDS=0.010000 default.

Todos

If this is work in progress, what else needs to be done?

  • fix 2: Verify that cif2str kwargs are properly exposed and passed through the higher-level RefinementPhase and do_refinement manager classes so users can access these new arguments seamlessly from the top-level API.

Checklist

  • All existing tests pass.
  • Tests have been added for any new features/fixes.
  • Docstrings have been added in the Google docstring format.

This update introduces custom_lines and element_params_map to the cif2str function, enabling advanced crystallographic constraints directly from Python without needing to manually edit the generated .str files. The custom_lines argument allows users to inject arbitrary BGMN parameters and mathematical equations into the refinement. The element_params_map argument overrides hardcoded atomic parameters like TDS with custom variables or occupancies, and it includes wildcard support using an asterisk to easily apply global parameters across the entire crystal structure. These additions significantly improve the wrapper's flexibility, making it much easier to model highly disordered, defective, or high-temperature phases.
To fix ruff errors
Fixed generality of parameters
@Andrea-gm Andrea-gm changed the title Thermal params Custom BGMN params Apr 6, 2026
@Andrea-gm Andrea-gm requested a review from idocx April 6, 2026 23:40
Andrea-gm added 11 commits April 9, 2026 15:07
Changed params names to better names
fixed errors
Fixed bug that did not allow to fit TDS for elements with 2 letters
Fixed for Ruff
Fixed test to ignore FutureWarning from pymatgen to maintain compatibility
Allow lattice_range to be an explicit (lo, hi) tuple in addition to a symmetric float or "fixed". Updated make_lattice_parameters_str and cif2str signatures, added docstrings, and implemented validation (lo <= hi). When a float is provided the code normalizes it to (-r, r) so existing behavior is preserved; when a tuple is provided bounds are applied as fractional deltas [v*(1+lo), v*(1+hi)]. Also added normalization of lattice_range inside cif2str and improved error messages.
Now accepts lattice_range = tuple() of values that are both larger or smaller than 0% lattice expansion. Useful to constrain expansion for patterns measured at high temperature (e.g. in-situ XRD)
To accept constraints on gewicht, defined as for all other params: "start_min^max"
Fixed bug. now accepts lattice_range = "fixed", literal expression
Can now fix lattice expansion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant