Skip to content

Updates for isbits functionals#1188

Draft
Technici4n wants to merge 6 commits intomasterfrom
dft-functionals-isbits
Draft

Updates for isbits functionals#1188
Technici4n wants to merge 6 commits intomasterfrom
dft-functionals-isbits

Conversation

@Technici4n
Copy link
Copy Markdown
Collaborator

@Technici4n Technici4n commented Nov 11, 2025

Currently including the manifest such that I can run CI.

Copy link
Copy Markdown
Member

@mfherbst mfherbst left a 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.

Comment thread src/workarounds/forwarddiff_rules.jl Outdated
psp
end

# term types don't have a supertype, so we use a different function name
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That can be changed ...

Comment thread src/terms/xc.jl Outdated
Comment on lines +29 to +33
if f isa DispatchFunctional
string(f.inner.identifier)
else
string(f)
end
Copy link
Copy Markdown
Member

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 ?

Copy link
Copy Markdown
Collaborator Author

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))

Copy link
Copy Markdown
Member

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).

Copy link
Copy Markdown
Collaborator Author

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

Copy link
Copy Markdown
Member

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 :)

Copy link
Copy Markdown
Collaborator Author

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?

Copy link
Copy Markdown
Member

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.

Comment thread src/workarounds/forwarddiff_rules.jl Outdated
@Technici4n
Copy link
Copy Markdown
Collaborator Author

Now updated following the discussion last week.

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.

2 participants