Skip to content

Custom BGMN params#28

Open
Andrea-gm wants to merge 7 commits intomainfrom
thermal_params
Open

Custom BGMN params#28
Andrea-gm wants to merge 7 commits intomainfrom
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
Changed params names to better names
fixed errors
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