Add warning for non-positive semidefinite sigma tensor for Lorentzian susceptibility#3230
Open
oskooi wants to merge 2 commits into
Open
Add warning for non-positive semidefinite sigma tensor for Lorentzian susceptibility#3230oskooi wants to merge 2 commits into
sigma tensor for Lorentzian susceptibility#3230oskooi wants to merge 2 commits into
Conversation
stevengj
reviewed
Jun 18, 2026
| if (!sbb || !sab) continue; | ||
| LOOP_OVER_VOL(gv, ca, idx) { | ||
| const realnum a = saa[idx], b = sbb[idx], o = sab[idx]; | ||
| if (a > 0 && b > 0 && o * o > a * b * (1 + 1e-6)) return true; |
Collaborator
There was a problem hiding this comment.
Why is it checking "2x2" tensors, and not the full 3x3 matrix?
stevengj
reviewed
Jun 18, 2026
| // boundaries (see PR #666). sigma is static in time, so the | ||
| // predicate is the same every step; apply it branchlessly so the | ||
| // loop still vectorizes. Where s[i] == 0, p[i] and pp[i] are left | ||
| // unchanged, exactly as the original guarded update did. |
Collaborator
There was a problem hiding this comment.
It would be nice to know how much of a performance difference this makes in two cases:
- the chunk is completely filled with σ ≠ 0 (so
mask == 1everywhere). - the chunk is mostly σ = 0 (so that you end up doing a bunch of extra computation that would have otherwise been removed by the
if).
Collaborator
|
My other concern about this PR is that it is looking at σ on the Yee grid, for which different components of σ are stored at different Yee grid points. If σ is not constant in space, then it is problematic to simply treat the different components as part of the same σ tensor … you would need to define some effective σ tensor by some kind of spatial average of σ components. One alternative is simply to check positive-definiteness at a higher level, e.g. in the list of materials/objects in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #3229.
This PR adds a warning if the user-supplied anisotropic Lorentzian susceptibility tensor (
sigma) is non positive semidefinite. Additionally, the guard introduced in #666 to skip update of the polarization fields at material interfaces (to ensure stability) is reorganized to enable loop vectorization.