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

remove adjoint grad_eps monitors #945

Merged
merged 1 commit into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Removed validator from `CustomFieldSource` that ensured data spanned the source geometry. Now the current values are extrapolated outside of the supplied data ranges.
- `CustomMedium` now take fields `permittivity` and `conductivity`. `eps_dataset` will be deprecated in v3.0.
- Moved `CustomMedium._interp` to `Coords.spatial_interp` to be used by custom current sources.
- Adjoint simulations no longer contain unused gradient permittivity monitors, reducing processing time.

### Fixed
- Plotting 2D materials in `SimulationData.plot_field` and other circumstances.
Expand Down
1 change: 1 addition & 0 deletions tidy3d/plugins/adjoint/components/data/sim_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def make_adjoint_simulation(self, fwidth: float) -> JaxSimulation:
self.simulation.get_grad_monitors(
input_structures=self.simulation.input_structures,
freq_adjoint=self.simulation.freq_adjoint,
include_eps_mnts=False,
)
)
return self.simulation.updated_copy(**update_dict)
7 changes: 5 additions & 2 deletions tidy3d/plugins/adjoint/components/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,9 @@ def to_simulation_fwd(self) -> Tuple[Simulation, JaxInfo, JaxInfo]:
return sim_fwd, jax_info_fwd, jax_info

@staticmethod
def get_grad_monitors(input_structures: List[Structure], freq_adjoint: float) -> dict:
def get_grad_monitors(
input_structures: List[Structure], freq_adjoint: float, include_eps_mnts: bool = True
) -> dict:
"""Return dictionary of gradient monitors for simulation."""
grad_mnts = []
grad_eps_mnts = []
Expand All @@ -434,7 +436,8 @@ def get_grad_monitors(input_structures: List[Structure], freq_adjoint: float) ->
freq=freq_adjoint, name=f"grad_mnt_{index}"
)
grad_mnts.append(grad_mnt)
grad_eps_mnts.append(grad_eps_mnt)
if include_eps_mnts:
grad_eps_mnts.append(grad_eps_mnt)
return dict(grad_monitors=grad_mnts, grad_eps_monitors=grad_eps_mnts)

def store_vjp(
Expand Down