|
10 | 10 | import pydantic.v1 as pd
|
11 | 11 | import pytest
|
12 | 12 | import xarray as xr
|
| 13 | +from shapely import LineString |
13 | 14 |
|
14 | 15 | import tidy3d as td
|
15 | 16 | import tidy3d.components.microwave.path_integrals.current_spec
|
|
22 | 23 | mutual_inductance_colinear_wire_segments,
|
23 | 24 | total_inductance_colinear_rectangular_wire_segments,
|
24 | 25 | )
|
| 26 | +from tidy3d.components.microwave.path_integrals.mode_plane_analyzer import ( |
| 27 | + ModePlaneAnalyzer, |
| 28 | +) |
25 | 29 | from tidy3d.components.microwave.path_integrals.path_integral_factory import (
|
26 | 30 | make_current_integral,
|
27 | 31 | make_path_integrals,
|
@@ -466,6 +470,51 @@ def test_path_integral_creation():
|
466 | 470 | )
|
467 | 471 |
|
468 | 472 |
|
| 473 | +def test_mode_plane_analyzer_errors(): |
| 474 | + """Check that the ModePlaneAnalyzer reports errors properly.""" |
| 475 | + |
| 476 | + path_spec_gen = ModePlaneAnalyzer(size=(0, 2, 2), field_data_colocated=False) |
| 477 | + |
| 478 | + # First some quick sanity checks with the helper |
| 479 | + test_path = td.Box(center=(0, 0, 0), size=(0, 0.9, 0.1)) |
| 480 | + test_shapely = [LineString([(-1, 0), (1, 0)])] |
| 481 | + assert path_spec_gen._check_box_intersects_with_conductors(test_shapely, test_path) |
| 482 | + |
| 483 | + test_path = td.Box(center=(0, 0, 0), size=(0, 2.1, 0.1)) |
| 484 | + test_shapely = [LineString([(-1, 0), (1, 0)])] |
| 485 | + assert not path_spec_gen._check_box_intersects_with_conductors(test_shapely, test_path) |
| 486 | + |
| 487 | + sim = make_mw_sim(False, False, "microstrip") |
| 488 | + coax = td.GeometryGroup( |
| 489 | + geometries=( |
| 490 | + td.ClipOperation( |
| 491 | + operation="difference", |
| 492 | + geometry_a=td.Cylinder(axis=0, radius=2 * mm, center=(0, 0, 5 * mm), length=td.inf), |
| 493 | + geometry_b=td.Cylinder( |
| 494 | + axis=0, radius=1.4 * mm, center=(0, 0, 5 * mm), length=td.inf |
| 495 | + ), |
| 496 | + ), |
| 497 | + td.Cylinder(axis=0, radius=1 * mm, center=(0, 0, 5 * mm), length=td.inf), |
| 498 | + ) |
| 499 | + ) |
| 500 | + coax_struct = td.Structure(geometry=coax, medium=td.PEC) |
| 501 | + sim = sim.updated_copy(structures=[coax_struct]) |
| 502 | + mode_monitor = sim.monitors[0] |
| 503 | + modal_plane = td.Box(center=mode_monitor.center, size=mode_monitor.size) |
| 504 | + path_spec_gen = ModePlaneAnalyzer( |
| 505 | + center=modal_plane.center, |
| 506 | + size=modal_plane.size, |
| 507 | + field_data_colocated=mode_monitor.colocate, |
| 508 | + ) |
| 509 | + with pytest.raises(SetupError): |
| 510 | + path_spec_gen.get_conductor_bounding_boxes( |
| 511 | + sim.structures, |
| 512 | + sim.grid, |
| 513 | + sim.symmetry, |
| 514 | + sim.bounding_box, |
| 515 | + ) |
| 516 | + |
| 517 | + |
469 | 518 | def test_impedance_spec_validation():
|
470 | 519 | """Check that the various allowed methods for supplying path specifications are validated."""
|
471 | 520 |
|
|
0 commit comments