Skip to content

Commit

Permalink
allow downsampling of near fields for field projection monitors
Browse files Browse the repository at this point in the history
  • Loading branch information
shashwat-sh committed Nov 22, 2023
1 parent 192c547 commit 8a2e6f5
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 49 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `_hash_self` to base model, uses `hashlib` to hash a Tidy3D component the same way every session.
- `ComponentModeler.plot_sim_eps()` method to plot the simulation permittivity and ports.
- Support for 2D PEC materials.
- Ability to downsample recorded near fields to speed up server-side far field projections.

### Changed
- Indent for the json string of Tidy3D models has been changed to `None` when used internally; kept as `indent=4` for writing to `json` and `yaml` files.
Expand Down
Binary file modified tests/sims/simulation_2_5_0rc3.h5
Binary file not shown.
121 changes: 111 additions & 10 deletions tests/sims/simulation_2_5_0rc3.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,107 @@
}
}
},
{
"geometry": {
"type": "Box",
"center": [
-1.0,
0.0,
0.0
],
"size": [
1.0,
0.0,
1.0
]
},
"name": null,
"type": "Structure",
"medium": {
"name": null,
"frequency_range": null,
"allow_gain": false,
"nonlinear_spec": null,
"modulation_spec": null,
"heat_spec": null,
"type": "Medium2D",
"ss": {
"name": "PEC",
"frequency_range": null,
"allow_gain": false,
"nonlinear_spec": null,
"modulation_spec": null,
"heat_spec": null,
"type": "PECMedium"
},
"tt": {
"name": "PEC",
"frequency_range": null,
"allow_gain": false,
"nonlinear_spec": null,
"modulation_spec": null,
"heat_spec": null,
"type": "PECMedium"
}
}
},
{
"geometry": {
"type": "Box",
"center": [
-1.0,
0.0,
0.0
],
"size": [
1.0,
1.0,
1.0
]
},
"name": null,
"type": "Structure",
"medium": {
"name": null,
"frequency_range": null,
"allow_gain": null,
"nonlinear_spec": null,
"modulation_spec": null,
"heat_spec": null,
"type": "AnisotropicMedium",
"xx": {
"name": "PEC",
"frequency_range": null,
"allow_gain": false,
"nonlinear_spec": null,
"modulation_spec": null,
"heat_spec": null,
"type": "PECMedium"
},
"yy": {
"name": null,
"frequency_range": null,
"allow_gain": false,
"nonlinear_spec": null,
"modulation_spec": null,
"heat_spec": null,
"type": "Medium",
"permittivity": 1.0,
"conductivity": 0.0
},
"zz": {
"name": null,
"frequency_range": null,
"allow_gain": false,
"nonlinear_spec": null,
"modulation_spec": null,
"heat_spec": null,
"type": "Medium",
"permittivity": 1.0,
"conductivity": 0.0
}
}
},
{
"geometry": {
"type": "GeometryGroup",
Expand Down Expand Up @@ -910,14 +1011,14 @@
},
"transform": [
[
0.9659258262890683,
-0.25881904510252074,
0.9659258262890684,
-0.2588190451025208,
0.0,
0.0
],
[
0.25881904510252074,
0.9659258262890683,
0.2588190451025208,
0.9659258262890684,
0.0,
0.0
],
Expand Down Expand Up @@ -1405,7 +1506,7 @@
1,
1
],
"colocate": true,
"colocate": 1,
"freqs": [
200000000000000.0,
250000000000000.0
Expand Down Expand Up @@ -1437,7 +1538,7 @@
1,
1
],
"colocate": true,
"colocate": 1,
"start": 0.0,
"stop": null,
"interval": 1,
Expand Down Expand Up @@ -1586,7 +1687,7 @@
1,
1
],
"colocate": true,
"colocate": 1,
"freqs": [
250000000000000.0,
300000000000000.0
Expand Down Expand Up @@ -1731,7 +1832,7 @@
1,
1
],
"colocate": true,
"colocate": 1,
"freqs": [
250000000000000.0,
300000000000000.0
Expand Down Expand Up @@ -1783,7 +1884,7 @@
1,
1
],
"colocate": true,
"colocate": 1,
"freqs": [
250000000000000.0,
300000000000000.0
Expand Down Expand Up @@ -1832,7 +1933,7 @@
1,
1
],
"colocate": true,
"colocate": 1,
"freqs": [
250000000000000.0,
300000000000000.0
Expand Down
33 changes: 29 additions & 4 deletions tests/test_components/test_field_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,28 @@ def make_proj_monitors(center, size, freqs):
far_field_approx=False,
)

return n2f_angle_monitor, n2f_cart_monitor, n2f_ksp_monitor, exact_cart_monitor
downsampled_cart_monitor = td.FieldProjectionCartesianMonitor(
center=center,
size=size,
freqs=freqs,
name="downsampled_cart",
custom_origin=center,
x=list(xs),
y=list(ys),
proj_axis=proj_axis,
proj_distance=z,
normal_dir="+",
exclude_surfaces=exclude_surfaces,
interval_space=(1, 2, 3),
)

return (
n2f_angle_monitor,
n2f_cart_monitor,
n2f_ksp_monitor,
exact_cart_monitor,
downsampled_cart_monitor,
)


def test_proj_monitors():
Expand Down Expand Up @@ -292,9 +313,13 @@ def test_proj_clientside():
)

# make near-to-far monitors
n2f_angle_monitor, n2f_cart_monitor, n2f_ksp_monitor, exact_cart_monitor = make_proj_monitors(
center, size, [f0]
)
(
n2f_angle_monitor,
n2f_cart_monitor,
n2f_ksp_monitor,
exact_cart_monitor,
_,
) = make_proj_monitors(center, size, [f0])

far_fields_angular = proj.project_fields(n2f_angle_monitor)
far_fields_cartesian = proj.project_fields(n2f_cart_monitor)
Expand Down
Loading

0 comments on commit 8a2e6f5

Please sign in to comment.