-
Notifications
You must be signed in to change notification settings - Fork 97
Updates for isbits functionals #1188
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
base: master
Are you sure you want to change the base?
Conversation
mfherbst
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally less bad than what I expected. I wonder if we should somehow add a mechanism to conserve the functional symbols inside the xc term if we happen to know them ? Like the standard_models.jl functions (LDA(), PBE() and similar) could probably easily do that.
| psp | ||
| end | ||
|
|
||
| # term types don't have a supertype, so we use a different function name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That can be changed ...
| if f isa DispatchFunctional | ||
| string(f.inner.identifier) | ||
| else | ||
| string(f) | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this because it implies that when explicitly using DftFunctionals to make a standard functional such as LDA exchang (as opposed to a DispatchFunctional) a different string results, right? Moreover I'm not sure the default returned string(f) is super nice (especially when we have dual type parameters) ... but perhaps that we should fix inside DftFunctionals by providing good show functions for all functionals ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is an example:
Without duals:
PbeExchange{Float64, Float64}(0.804, 0.21951497276451704)
With duals:
PbeExchange{Float64, Dual{ForwardDiff.Tag{Main.var"##239".ForwardDiffWrappers.DerivativeTag, Float64}, Float64, 1}}(0.804, Dual{ForwardDiff.Tag{Main.var"##239".ForwardDiffWrappers.DerivativeTag, Float64}}(0.21951497276451704,0.0))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Case in point, that's not super useful. But we can fix this with a custom show in DftFunctionals. In fact what we could do is actually re-introduce the identifier function, that employs knowledge of the parameter values to return the appropriate libxc symbol ? Or at the very least something like PbeExchange(β=0.804, γ=0.2195) (note rounding).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that for a custom functional, we would previously report something like pbe_x_custom, which I don't find super useful, and loses part of the info. My thought process was thus:
- For exact reconstruction, JLD2 will be able to reconstruct the object exactly anyway, nothing special needs to be done.
- The identifier was mostly used to give some info to users, e.g. when printing a model or basis. So for the standard DispatchFunctional you'd see the identifiers. But if the user is calling DftFunctionals directly I expect them to be an "expert" and thus be able to deal with the raw display.
that employs knowledge of the parameter values to return the appropriate libxc symbol
Could be done as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be done as well
Yes and should not be too hard :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, but is it relevant if any non-standard parameter choice will just be printed as pbe_x_custom or similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have only a print function that for those we could print the actual parameter values. So you have something more specific where possible (just e.g. gga_x_pbe) and something less specific for the rest PbeExchange(β=..., γ=....). I think that would be very useful.
| Xc(functionals, ForwardDiff.value(x.scaling_factor), x.potential_threshold, x.use_nlcc) | ||
| end | ||
| # get the value of each field of the functional | ||
| @generated function construct_value(x::F) where {F <: DftFunctionals.Functional} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@niklasschmitz pointed out that we could use https://fluxml.ai/Functors.jl/stable/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's not too heavy as a dependency and sufficiently stable as a package, I'm happy wtih it. But in my experience there is few worse things that commiting on too many, too brittle helper packages, that we need to undo or fix later.
See JuliaMolSim/DftFunctionals.jl#24.
Currently including the manifest such that I can run CI.