diff --git a/CHANGELOG.md b/CHANGELOG.md index bbbb55e9f..e2e1115f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added heat sources with custom spatial dependence. It is now possible to add a `SpatialDataArray` as the `rate` in a `HeatSource`. - Added Transient Heat simulations. It is now possible to run transient Heat simulations. This can be done by specifying `analysis_spec` of `HeatChargeSimulation` object as `UnsteadyHeatAnalysis`. - A `num_grid_cells` field to `WavePort`, which ensures that there are 5 grid cells across the port. Grid refinement can be disabled by passing `None` to `num_grid_cells`. +- Enable singularity correction at PEC edges. ### Fixed - Fixed bug in broadband adjoint source creation when forward simulation had a pulse amplitude greater than 1 or a nonzero pulse phase. diff --git a/tests/test_components/test_simulation.py b/tests/test_components/test_simulation.py index 999ca4a00..90b85ec7d 100644 --- a/tests/test_components/test_simulation.py +++ b/tests/test_components/test_simulation.py @@ -2385,6 +2385,27 @@ def test_conformal_dt(): assert sim_heuristic.dt == dt +def test_edge_correction(): + """make sure edge correction can be enabled for PEC, but not lossy meal.""" + sim = td.Simulation( + size=(2.0, 2.0, 2.0), + run_time=1e-12, + structures=[], + grid_spec=td.GridSpec.uniform(dl=0.1), + subpixel=td.SubpixelSpec(pec=td.PECConformal(edge_singularity_correction=False)), + ) + + sim = sim.updated_copy( + subpixel=td.SubpixelSpec(pec=td.PECConformal(edge_singularity_correction=True)) + ) + + # but cannot be True for lossy metal + with pytest.raises(pydantic.ValidationError): + sim = sim.updated_copy( + subpixel=td.SubpixelSpec(metal=td.SurfaceImpedance(edge_singularity_correction=True)) + ) + + def test_sim_volumetric_structures(tmp_path): """Test volumetric equivalent of 2D materials.""" sigma = 0.45 diff --git a/tidy3d/components/subpixel_spec.py b/tidy3d/components/subpixel_spec.py index 1781b0487..568ebee39 100644 --- a/tidy3d/components/subpixel_spec.py +++ b/tidy3d/components/subpixel_spec.py @@ -6,7 +6,7 @@ import pydantic.v1 as pd from .base import Tidy3dBaseModel, cached_property -from .types import TYPE_TAG_STR +from .types import TYPE_TAG_STR, Literal # Default Courant number reduction rate in PEC conformal's scheme DEFAULT_COURANT_REDUCTION_PEC_CONFORMAL = 0.3 @@ -120,6 +120,14 @@ class PECConformal(AbstractSubpixelAveragingMethod): ge=0, ) + edge_singularity_correction: bool = pd.Field( + True, + title="Apply Singularity Model At Metal Edges", + description="Apply field correction model at metallic edges where field singularity occurs. " + "The correction is applied to straight edges aligned with the primal grids, and the wedge angle is either " + "0 or 90 degree.", + ) + @cached_property def courant_ratio(self) -> float: """The scaling ratio applied to Courant number so that the courant number @@ -146,6 +154,14 @@ class SurfaceImpedance(PECConformal): ge=0, ) + edge_singularity_correction: Literal[False] = pd.Field( + False, + title="Apply Singularity Model At Metal Edges", + description="Apply field correction model at metallic edges where field singularity occurs. " + "The correction is applied to straight edges aligned with the primal grids, and the wedge angle is either " + "0 or 90 degree.", + ) + LossyMetalSubpixelType = Union[Staircasing, VolumetricAveraging, SurfaceImpedance]