Skip to content

VACUUM - To be (Hermitian) or not to be (deprecating force_wv_symmetry)#330

Merged
logan-nc merged 3 commits into
developfrom
feature/auto-symmetrize-vacuum-energy
Jul 17, 2026
Merged

VACUUM - To be (Hermitian) or not to be (deprecating force_wv_symmetry)#330
logan-nc merged 3 commits into
developfrom
feature/auto-symmetrize-vacuum-energy

Conversation

@jhalpern30

@jhalpern30 jhalpern30 commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Brought about by my investigation for the plasma response matrix in #93, I realized that we can deprecate the force_wv_symmetry parameter.

The response matrices are inherently Hermitian - they compute real quantities (energies), so they must have all real eigenvalues and the formulation of the code expects this. However, numerical errors allow for non-Hermitian components to appear. In ForceFreeStates, this is highly nontrivial (again, see #93), but in Vacuum, its must simpler. The non-Hermitian error is only due to the error induced from discretization and can be easily decreased by increasing the number of grid points:

image

In general, this is much less than the non-Hermitian errors seen in the plasma response matrix. I chose the value of 1e-4 relatively arbitrarily to be just a bit tighter than the arbitrary one for the plasma response matrix tolerance we've been using.

The force_wv_symmetry parameter (lsymz) in the Fortran, allowed a flag to turn this on/off in the vacuum code. However, for the above reasons, this was pretty much always left as true. Because of this and my above arguments, I have deprecated this "always-on" parameter in favor or always symmetrizing the matrix, and including a simple warning statement for large Hermitian errors, requesting the user to increase the grid size (this will go hand in hand with just increasing the accuracy needed to converge the boundary integral too), so I doubt users will ever really run into this, but just in case.

Since this parameter defaulted to true, this doesn't change the outputs. However, I've added it to the list of deprecated parameters for backwards compatibility.

As an example of usage, I ran DIIID ideal as normal (and nothing changed), and then dropped mthvac down to an unrealistic 32, and the warnings pop up like this

[ Info:    ψ = 0.995,  q= 6.188,  max(S) = 8.60e+00,  steps = 51
[ Info:    ψ = 0.995,  q= 6.200,  max(S) = 8.19e+00,  steps = 52
┌ Warning: Vacuum energy matrix Wᵛ is non-Hermitian above tolerance 0.00948512437201021 > 0.0001 before symmetrization. Increase vacuum grid resolution to reduce it.
└ @ GeneralizedPerturbedEquilibrium.Vacuum ~/Github/JPEC/src/Vacuum/Vacuum.jl:48

@jhalpern30
jhalpern30 marked this pull request as ready for review July 16, 2026 19:58
@jhalpern30
jhalpern30 requested a review from logan-nc July 16, 2026 19:59
@jhalpern30

Copy link
Copy Markdown
Collaborator Author

@logan-nc relatively quick one here motivated by background reading I was doing to prep for the perturbed eq updated

@logan-nc logan-nc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good!

@logan-nc logan-nc self-assigned this Jul 17, 2026
@logan-nc
logan-nc merged commit 41cfbcb into develop Jul 17, 2026
7 checks passed
@logan-nc
logan-nc deleted the feature/auto-symmetrize-vacuum-energy branch July 17, 2026 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants