-
Notifications
You must be signed in to change notification settings - Fork 66
feat(FXC-4425) Adding plot function for charge #3056
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
base: develop
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR adds support for plotting charge simulations by introducing a new property="charge" option to the plot_property function. Previously, plotting charge simulations with SemiconductorMedium failed because these mediums don't have a conductivity value. The new option plots structures with fixed styling (lightgray fill with black borders) and displays electric boundary conditions.
Key Changes:
- Added
"charge"as a valid property option for plotting functions - Implemented special handling for charge simulations that bypasses conductivity-based coloring
- Added validation to ensure
property="charge"is only used with charge simulations
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tidy3d/components/tcad/simulation/heat_charge.py | Updated plot_property to accept "charge" property, disable colorbar for charge, add validation logic, and filter boundaries/sources appropriately for charge simulations |
| tidy3d/components/scene.py | Added "charge" property handling in plotting functions with type hints, custom plot parameters (lightgray/black), and property bounds |
| tests/test_components/test_heat_charge.py | Added test coverage for the new charge plotting functionality and refactored charge_tolerance fixture to module scope |
Comments suppressed due to low confidence (1)
tidy3d/components/scene.py:1722
- When
property="charge"andcbar=True, a colorbar will be added with an empty label. Since the "charge" property doesn't use grayscale coloring (it uses fixed lightgray), the colorbar is not meaningful. Consider adding a condition to skip the colorbar whenproperty == "charge":
if cbar and property != "charge":
# ... existing colorbar code if cbar:
label = ""
if property == "heat_conductivity":
label = f"Thermal conductivity ({THERMAL_CONDUCTIVITY})"
elif property == "electric_conductivity":
label = f"Electric conductivity ({CONDUCTIVITY})"
self._add_cbar(
vmin=property_val_min,
vmax=property_val_max,
label=label,
cmap=STRUCTURE_HEAT_COND_CMAP,
ax=ax,
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
3 files reviewed, 1 comment
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
|
Currently we have basically two options of platting our simulation object for HeatChargeSimulation object that involve using the property argument in the plot_property function:
In the case of Charge simulations, we don’t have a value for conductivity in the SemiconductorMedium and so the function fails to plot the strucutres.
The idea is to include a new property that allows us to plot the structures and show electric BCs
Greptile Overview
Greptile Summary
Adds a new
"charge"property option toplot_property()inHeatChargeSimulation, allowing visualization of charge simulations that useSemiconductorMedium(which lacks a conductivity value). This addresses a limitation whereproperty="electric_conductivity"would fail for such simulations.plot_property(),plot_boundaries(), andplot_sources()to handle"charge"propertyproperty="charge"charge_tolerancefixture from class-level to module-level for broader test reuseConfidence Score: 4/5
_get_structure_heat_charge_property_plot_paramsand missing CHANGELOG entry.Important Files Changed
File Analysis
plot_property()and related methods (plot_boundaries,plot_sources,source_bounds), enabling visualization of charge simulations with appropriate boundary conditions and sources.plot_heat_charge_property,heat_charge_property_bounds, and related methods with appropriate styling (gray fill, black edge).test_plot_property_chargetest and refactorscharge_tolerancefixture from class-level to module-level scope for broader reuse.Sequence Diagram
sequenceDiagram participant User participant HeatChargeSimulation participant Scene participant PlotMethods User->>HeatChargeSimulation: plot_property(property="charge", z=0) HeatChargeSimulation->>HeatChargeSimulation: _get_simulation_types() alt CHARGE not in simulation_types HeatChargeSimulation-->>User: ValueError end HeatChargeSimulation->>Scene: plot_heat_charge_property(property="charge") Scene->>Scene: heat_charge_property_bounds(property="charge") Scene-->>Scene: return (0, 1) loop for each structure Scene->>Scene: _plot_shape_structure(property="charge") Scene->>Scene: _get_structure_plot_params(property="charge") Note over Scene: Apply edgecolor="k", linewidth=1 end HeatChargeSimulation->>PlotMethods: plot_sources(property="charge") Note over PlotMethods: Filter ChargeSourceTypes HeatChargeSimulation->>PlotMethods: plot_boundaries(property="charge") Note over PlotMethods: Filter ElectricBCTypes HeatChargeSimulation-->>User: matplotlib.axesContext used:
dashboard- Require a changelog entry for any PR that is not purely an internal refactor. (source)