Skip to content

Delegate PEC check from MultiPhysicsMedium to its Optical Medium #2431

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

Merged
Show file tree
Hide file tree
Changes from 5 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
16 changes: 16 additions & 0 deletions tests/test_components/test_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ def test_plot_eps():
plt.close()


def test_plot_eps_multiphysics():
s = td.Scene(
structures=[
td.Structure(
geometry=td.Box(size=(1, 1, 1), center=(-1, 0.5, 0.5)),
medium=td.MultiPhysicsMedium(
optical=td.Medium(permittivity=3.9),
charge=td.ChargeInsulatorMedium(permittivity=3.9),
name="SiO2",
),
)
]
)
s.plot_eps(x=0)


def test_plot_eps_bounds():
_ = SCENE_FULL.plot_eps(x=0, hlim=[-0.45, 0.45])
plt.close()
Expand Down
10 changes: 10 additions & 0 deletions tidy3d/components/material/multi_physics.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ class MultiPhysicsMedium(Tidy3dBaseModel):
None, title="Charge properties", description="Specifies properties for Charge simulations."
)

def __getattr__(self, name: str):
"""Delegates calls to missing attributes to the inner media."""
if self.optical is not None and hasattr(self.optical, name):
return getattr(self.optical, name)
if self.heat is not None and hasattr(self.heat, name):
return getattr(self.heat, name)
if self.charge is not None and hasattr(self.charge, name):
return getattr(self.charge, name)
return None

@property
def heat_spec(self):
if self.heat is not None:
Expand Down
Loading