-
Notifications
You must be signed in to change notification settings - Fork 731
Resolve m-number adjoint bugs introduced by 1855 #2194
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4279,6 +4279,23 @@ def change_k_point(self, k): | |
| py_v3_to_vec(self.dimensions, self.k_point, self.is_cylindrical) | ||
| ) | ||
|
|
||
| def change_m_number(self, m): | ||
|
||
| """ | ||
| Change the `m` number (the angular ϕ dependence). | ||
| """ | ||
| self.m = m | ||
|
|
||
| if self.fields: | ||
| needs_complex_fields = not (not self.m or self.m == 0) | ||
|
|
||
| if needs_complex_fields and self.fields.is_real: | ||
| self.fields = None | ||
| self._is_initialized = False | ||
| self.init_sim() | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be better to just add a boolean argument to |
||
| else: | ||
| if self.m is not None: | ||
| self.fields.change_m_number(m) | ||
|
|
||
| def change_sources(self, new_sources): | ||
| """ | ||
| Change the list of sources in `Simulation.sources` to `new_sources`, and changes | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -793,4 +793,13 @@ bool operator==(const comms_key &lhs, const comms_key &rhs) { | |
| return (lhs.ft == rhs.ft) && (lhs.phase == rhs.phase) && (lhs.pair == rhs.pair); | ||
| } | ||
|
|
||
| void fields::change_m_number(double new_m) { | ||
| m = new_m; | ||
| for (int i = 0; i < num_chunks; i++) { | ||
| chunks[i]->change_m_number(new_m); | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At the very least, this needs to check that
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you envision Or are you suggesting we refactor the initialization of the fields to
As a first pass, it might be easiest to leave
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My latest commit adds a check to make sure that the fields are consistent. If the user requests complex fields when the current setup is using real fields, I just abort. This isn't a problem for the adjoint code. We have a similar check in the python routine. But rather than aborting, we just reinitialize. |
||
| } | ||
|
|
||
| void fields_chunk::change_m_number(double new_m) { m = new_m; } | ||
|
|
||
| } // namespace meep | ||
Uh oh!
There was an error while loading. Please reload this page.