Skip to content

Conversation

@Technici4n
Copy link
Contributor

@Technici4n Technici4n commented Nov 11, 2025

  • The functional identifier is now optional; if nothing is returned it means that the identifier is not available, and the functional will be printed using the default print for structs.
  • The built-in PBE x and c functionals don't store their identifier directly anymore. However we check if the parameters match one of the known functionals, and if so we return the corresponding identifier. If the parameters are unknown then we return no identifier.
  • Functionals directly store their parameters instead of a ComponentArray.

- Functionals don't store their identifier anymore. The creator of a
  functional is responsible for remembering its identifier, if
  applicable.
- Functionals directly store their parameters instead of a
  ComponentArray.

identifier(pbe::PbeCorrelation) = pbe.identifier
parameters(pbe::PbeCorrelation) = pbe.parameters
function change_parameters(pbe::PbeCorrelation, parameters::ComponentArray;
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure we don't need this ?

Copy link
Member

Choose a reason for hiding this comment

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

The point was to have something, that allows to change parameters without knowing which parameters are actually around (e.g. many functionals have β and γ parameters under the same meaning and you may want something like change_parameter(xc, β=1.0) to be able to generically change this parameter without knowing what xc is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that allows to change parameters without knowing which parameters are actually around

Indeed, but I am not sure that this operation makes sense in practice. You'd still have to assume that the functional takes exactly β and γ for example, without knowing what they are used for.

The biggest use case is probably unwrapping Duals -- for that I have a @generated trick in DFTK.

Copy link
Member

@mfherbst mfherbst Nov 12, 2025

Choose a reason for hiding this comment

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

I'm happy to drop it for now if it causes headaches.

But I want to remark that this does indeed give a generic way to perform sensitivity analysis in standard functionals ... an aspect that I think is aspirational for us in the long run, so we should think a little if there is still a way this can be achieved generically, if we drop this.

Copy link

Choose a reason for hiding this comment

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

Looking towards the future and GPUs, a function like change_parameters can be quite useful.

The GPU compiler needs very explicit types for successful compilation. In my POC branch, I've used it to insure that upon entry of a function to be differentiated, all types are explicitly converted to match (e.g. here).

Generally, I think it can be convenient to get and set functional parameters in a generic way. This could be done by writing a function which returns the parameters as a NamedTuple, and a change_parameters function that takes a NamedTuple/ComponentArray.

Copy link

@abussy abussy left a comment

Choose a reason for hiding this comment

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

Overall, I think these are good changes. This will make the porting to GPU easier and cleaner than the proposed solution of #23.

@Technici4n
Copy link
Contributor Author

Updated as discussed. The identifier is now looked up based on the parameters' values.

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.

3 participants