Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add framework for property model parameter generation #251

Merged

Conversation

bocklund
Copy link
Member

@bocklund bocklund commented Dec 11, 2023

This is a significant feature improvement that introduces the concept of a ModelFittingDescription made up of FittingStep objects to tell ESPEI how to generate model parameters (with a capability to support generating parameters for custom models). In addition, these changes include:

  • Significant refactoring and simplification of espei.paramselect, the main module for parameter selection:
    • Most of the code that was duplicated for fitting endmembers, binary interactions, and ternary interactions was unified.
    • The fit_ternary_interactions function was completely removed and binary and ternary interactions now run the exact same code path.
    • The most significant changes are in fit_parameters, which now relies on dependency injection of a fitting description to know what fitting steps to take (we try to not make any assumptions about what parameters or data types are being fit) and this function is more streamlined to 1) select relevant data from datasets, 2) get the RHS (b in Ax=b) of the linear problem from the fitting step, 3) build candidate models (build a collection feature matrices, A), 4) select the best model from the candidates, and 5) insert the parameter and coefficients for the best model into the database
  • Refactoring to remove espei.parameter_selection.utils. Some of the functionality got moved to be in fitting steps, and get_sample_condition_dicts was moved to espei.error_functions.non_equilibrium_thermochemical_error, with get_prop_samples that it is used in conjunction with. Trying to have fewer "utils" modules.
  • Tests to verify that molar volume and custom property models (elastic) work against various edge cases
  • New docs page with a tutorial for using a custom model and fitting description for fitting elastic constants with a repository containing the code
  • Small tweak to follow links in dataset recursive glob search. This is useful for organizing datasets for different runs while having one single source of truth for the data

This PR relies on pycalphad/pycalphad#501 that includes fixes for molar volume models. Tests will probably fail until that gets into the development branch.

Closes #5

…s successive

The goal here is that we may have some models that don't want to use
`make_successive` for feature sets.
modifies ESPEI code and def breaks gibbs energies, using this commit for backup
Factor out TDB analysis from notebook 2
Start moving get_data_quantities to a FittingStep staticmethod
Binary VM (VA) fitting looks like it works now!
The changes are mostly in adding parameters and not really the fitting itself - that was working.

This may be throwaway code (see the comment added), so it's not too complex.
The idea of the modified version is that we also compute the actual site
fractions because individual site fractions are not currently handled by
ESPEI, but can slip in from existing models if not using a reference
state where those contributions cancel (e.g. no _MIX or _FORM refstates
keep the unary extrapolation). to do this, we'll use the config tuple
and create site fractions from the points dict.

tests currently pass locally
fit_formation_energy -> fit_parameters
Pass through all the function indirection.
@bocklund bocklund added this to the 0.9 milestone Dec 11, 2023
@bocklund
Copy link
Member Author

@nury12n if you could review :)

Copy link

@nury12n nury12n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some comments regarding the fitting steps, mainly thoughts I had when working with the FittingStep and AbstractLinearFittingStep classes, but I think it'd probably be better to leave as is.

I gave some thought about the diffusing species and I think it'll make more sense to consider them after there's some support in kawin for mobility fitting.

@bocklund
Copy link
Member Author

Added some comments regarding the fitting steps, mainly thoughts I had when working with the FittingStep and AbstractLinearFittingStep classes, but I think it'd probably be better to leave as is.

I gave some thought about the diffusing species and I think it'll make more sense to consider them after there's some support in kawin for mobility fitting.

Thanks for reviewing! Since PyCalphad supports diffusion species, it's something that could be in scope for ESPEI, but my guess is that there are assumptions elsewhere in the parameter generation code that would need to be broken to be able to handle that extra dimension that parameters can also be a function of diffusing species. At least, I think having these FittingStep and FittingDescription abstractions are compatible with what would be needed to fit parameters with diffusion species and it's mostly a book-keeping and dataset selection operations in espei.paramselect.phase_fit and espei.paramselect.fit_parameters

@bocklund
Copy link
Member Author

Tests are passing on pycalphad development versions and not release versions (as expected from pycalphad/pycalphad#501). Merging

@bocklund bocklund merged commit c3457ff into PhasesResearchLab:master Jan 17, 2024
6 of 9 checks passed
@bocklund bocklund deleted the property-parameter-generation branch January 17, 2024 19:32
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.

Support parameter selection for custom single phase models
2 participants