-
Notifications
You must be signed in to change notification settings - Fork 65
Allow nonlinearity with custom medium (FXC-3548) #2960
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
Conversation
|
@yaugenst-flex once we support anisotropic (not fully anisotropic, just diagonally anisotropic) nonlinear medium (a minor change perhaps), we can get rid of this |
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.
1 file reviewed, 1 comment
d9ca2d4 to
bee7644
Compare
f960e6c to
8d3c139
Compare
|
@yaugenst-flex @momchil-flex I also got rid of the warning that evaluating the permittivity of a nonlinear medium ignores the nonlinearity. I think this is obvious (we aren't running the simulation so there is no source intensity anyway). And this warning comes up all the time when I don't need it, like in plotting, or computing source fields for simulations with nonlinear + plane wave for example. Let me know if you think this is ok; an alternative is suppressing this warning where we don't want it, but I personally would never want to see it. |
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
|
Hmm I'm not sure about this. I think the warning is good, even if it might be obvious considering the rest of the setup. I feel like it's an easy thing to miss and a reminder that you're getting the linear response is helpful. I think if warning noise is the issue, it might be better to perhaps demote it to |
momchil-flex
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.
Yeah not sure. I guess basically the definition of permittivity is 1 + chi(1), i.e. taking only the linear susceptibility. So indeed one shouldn't expect anything different when "getting epsilon". But of course in some cases we do think of a nonlinearity-induced change to the linear response...
I guess downgrading to INFO is fine, even though practically speaking it will never be seen by users. :)
8d3c139 to
8a6f27f
Compare
|
Ok, I'll just restore the previous handling. If it gets annoying we can address it in a future PR. |
8a6f27f to
5eb28b4
Compare
5eb28b4 to
d41f500
Compare
This PR allows
nonlinear_specto be applied toCustomMediumandCustomDispersiveMedium. Anisotropic media are still not supported, and the nonlinearity cannot vary spatially.Greptile Overview
Updated On: 2025-11-05 19:15:49 UTC
Greptile Summary
This PR extends nonlinearity support to
CustomMediumandCustomDispersiveMediumclasses. The implementation correctly validates that anisotropic media are rejected by checking theis_isotropicproperty before the type check.Key changes:
is_time_modulatedfirst, thenis_isotropic, and finally the type checkCustomMediumandCustomDispersiveMediumto the list of allowed medium types in theisinstancecheckIssues found:
Note: The previous comment about missing anisotropic validation has been addressed - the code properly checks
medium.is_isotropicbefore allowing custom media.Confidence Score: 4/5
CustomMediumandCustomDispersiveMediumhave theis_isotropicproperty, so the check will correctly reject anisotropic custom media. The only issue is a missing CHANGELOG entry, which is a documentation concern rather than a code quality issue.Important Files Changed
File Analysis
CustomMediumandCustomDispersiveMediumby reordering validation checks and updating allowed types. The validation properly checksis_isotropicbefore type checking.Sequence Diagram
sequenceDiagram participant User participant NonlinearSpec participant NonlinearModel participant Medium User->>NonlinearSpec: Create NonlinearSpec with models User->>Medium: Create CustomMedium/CustomDispersiveMedium with nonlinear_spec NonlinearSpec->>NonlinearModel: Validate medium compatibility NonlinearModel->>Medium: Check is_time_modulated property alt is_time_modulated == True NonlinearModel-->>User: Raise ValidationError (time-modulated not supported) end NonlinearModel->>Medium: Check is_isotropic property alt is_isotropic == False NonlinearModel-->>User: Raise ValidationError (anisotropic not supported) end NonlinearModel->>Medium: Check medium type alt not in (Medium, DispersiveMedium, CustomMedium, CustomDispersiveMedium) NonlinearModel-->>User: Raise ValidationError (unsupported medium type) end NonlinearModel-->>NonlinearSpec: Validation passed NonlinearSpec-->>User: Medium with nonlinearity created successfully