Skip to content
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

correcting plot functions for ModeSolver #1966

Merged
merged 1 commit into from
Oct 10, 2024
Merged

Conversation

FilipeFcp
Copy link
Contributor

There was a little bug in the _center_and_lims method, so simulations with the center not in origin would plot an incorrect ModeSolver plot.

Also, I made a little adaptation to ensure that the plot functions would plot the entire plane object of the ModeSolver. I believe that the computation will be carried out in the plane right, regardless of whether it is larger than the Simulation object size, is that correct?

I did some tests in this notebook

There seems to be still a little bug with the plot_pml function.

@e-g-melo
Copy link
Collaborator

Hi @FilipeFcp! Regarding the size of the mode plane, I understand that we should show the calculation plane for users. However, the fact that it differs from the values they used to define the mode plane can create confusion. If the user sets a 3 x 2 microns plane and visualizes a 3.2 x 2.1 (or other value), that can sound like an error (maybe more critical for GUI users).

@momchil-flex, if we include grid snapping_points on the mode plane lower left and upper right corners, could we make the calculation plane dimension the same as in the component definition?
Side Note: a user complained about the PML lying within the mode plane rather than outside of it. Would it be very hard to change this?

@FilipeFcp
Copy link
Contributor Author

Hi @e-g-melo, I just spoke with Tom and realized I misunderstood the ModeSolver behavior. I initially thought that if the ModeSolver plane was larger than the simulation size, the calculation would take place on the larger plane.

I've reverted to the current version and just corrected the plane positioning.

Copy link
Collaborator

@e-g-melo e-g-melo left a comment

Choose a reason for hiding this comment

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

Thanks @FilipeFcp! Those questions still remain, though. The simulation plane is usually slightly larger than the mode plane definition by some nanometers (~100-300 nm). If we can make it the same size, that would be interesting.

@momchil-flex
Copy link
Collaborator

@momchil-flex, if we include grid snapping_points on the mode plane lower left and upper right corners, could we make the calculation plane dimension the same as in the component definition?

Maybe, I'm not 100% sure if we don't do like an extra pixel in some cases or something like that.

Side Note: a user complained about the PML lying within the mode plane rather than outside of it. Would it be very hard to change this?

Yeah I've thought about this a few times but my conclusion always is that it's unfortunately not that straightforward. We should do it some day.. but since it won't be quick, I'm not sure when.

@FilipeFcp
Copy link
Contributor Author

Hi @e-g-melo, I believe it should be relatively easy to add this extra space to the plot.

Regarding the PML, would it be possible to include the PML in the ModeSolver.plot, as it is in the Simulation.plot? This way, it might be easier for the user to notice if the PML isn't positioned properly and adjust the simulation using Simulation.updated_copy to accommodate the PML size.

@e-g-melo
Copy link
Collaborator

Regarding the PML, would it be possible to include the PML in the ModeSolver.plot, as it is in the Simulation.plot? This way, it might be easier for the user to notice if the PML isn't positioned properly and adjust the simulation using Simulation.updated_copy to accommodate the PML size.

Yes.. that is good!

@FilipeFcp FilipeFcp force-pushed the filipe/ms_plot_field branch 2 times, most recently from 040f08e to 4fce96b Compare September 25, 2024 21:35
@FilipeFcp
Copy link
Contributor Author

@e-g-melo I made a minor adjustment so that the plot method will call the plot_pml. I believe it could be good since the PML positioning is a bit not intuitive. But I can revert to the previous version and just correct for the positioning if you think is better.

@e-g-melo
Copy link
Collaborator

Hi @FilipeFcp! It sounds good and will help our users. Thanks

h_min = self.plane.center[t_axes[0]] - self.plane.size[t_axes[0]] / 2
h_max = self.plane.center[t_axes[0]] + self.plane.size[t_axes[0]] / 2
v_min = self.plane.center[t_axes[1]] - self.plane.size[t_axes[1]] / 2
v_max = self.plane.center[t_axes[1]] + self.plane.size[t_axes[1]] / 2

h_lim = [
h_min if abs(h_min) < abs(h_min_s) else h_min_s,
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed you had removed the absolute value here, but now it is restored. Seems like it shouldn't be here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Initially, I thought the definition of h_lim was causing issues in some situations, but I realized that wasn't the case. Since this definition is equivalent to mine without the absolute value, I decided to keep the original. Do you think I should revise it?

@caseyflex
Copy link
Contributor

caseyflex commented Sep 26, 2024 via email

@momchil-flex
Copy link
Collaborator

I haven't really followed this but @e-g-melo @FilipeFcp if you think this is now done we could merge.

@FilipeFcp
Copy link
Contributor Author

Hi @momchil-flex, I believe it is. The only modification is that the .plot method for ModeSolver now includes plotting the PML (so does that same as the .plot_pml method). Apart from that, it's just a minor correction.

@e-g-melo
Copy link
Collaborator

e-g-melo commented Oct 1, 2024

Hi @FilipeFcp! Since you have included the PML in ModeSolver.plot(), we should remove the structures from ModeSolver.plot_pml() to show only the PML as in Simulation.plot_pml().

@FilipeFcp FilipeFcp force-pushed the filipe/ms_plot_field branch from 4fce96b to 494eed4 Compare October 2, 2024 18:19
@FilipeFcp
Copy link
Contributor Author

Hi @e-g-melo . I removed the structures for the plot_pml. Now instead of creating the structures, it will just creat the ax object and set the correct limits. Let me know if it needs any modification.

@e-g-melo
Copy link
Collaborator

e-g-melo commented Oct 2, 2024

Thanks @FilipeFcp! It seems good!

@momchil-flex
Copy link
Collaborator

@FilipeFcp could you just add a changelog item for this please? Or message it to me I need to update the changelog a bit before release anyway.

@FilipeFcp
Copy link
Contributor Author

Hi @momchil-flex. I would add this under ###fixed: - ModeSolver.plot method when the simulation is not at the origin.

@momchil-flex momchil-flex merged commit c09a16b into develop Oct 10, 2024
15 checks passed
@momchil-flex momchil-flex deleted the filipe/ms_plot_field branch October 10, 2024 07:17
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.

4 participants