Skip to content

Commit

Permalink
Merge pull request #1185 from flexcompute/tyler/merge/2.4.2
Browse files Browse the repository at this point in the history
merge current state of develop (2.4.2) into pre/2.5
  • Loading branch information
dbochkov-flexcompute authored Oct 4, 2023
2 parents e155c4f + 8262c43 commit e22b540
Show file tree
Hide file tree
Showing 22 changed files with 4,233 additions and 116 deletions.
31 changes: 30 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,40 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

## [Unreleased]

### Added

### Changed

### Fixed
- Properly handle `.freqs` in `output_monitors` of adjoint plugin.

## [2.4.2] - 2023-9-28

### Added
- Warnings for too many frequencies in monitors; too many modes requested in a ``ModeSpec``; too many number of grid points in a mode monitor or mode source.

### Changed
- Time domain monitors warn about data usage if all defaults used in time sampler specs.

### Fixed
- Faster sorting of modes in `ModeSolverData.overlap_sort` by avoiding excessive data copying.
- Ensure same `Grid` is generated in forward and adjoint simulations by setting `GridSpec.wavelength` manually in adjoint.
- Properly handling of `JaxBox` derivatives both for multi-cell and single cell thickness.
- Properly handle `JaxSimulation.monitors` with `.freqs` as `np.ndarray` in adjoint plugin.
- Properly handle `JaxDataArray.sel()` with single coordinates and symmetry expansion.
- Properly handle `JaxDataArray * xr.DataArray` broadcasting.
- Stricter validation of `JaxDataArray` coordinates and values shape.


## [2.4.1] - 2023-9-20

### Added
- `ModeSolverData.pol_fraction` and `ModeSolverData.pol_fraction_waveguide` properties to compute polarization fraction of modes using two different definitions.
- `ModeSolverData.to_dataframe()` and `ModeSolverData.modes_info` for a convenient summary of various modal properties of the computed modes.
- Loss upper bound estimation in `PoleResidue` material model.
- Command line tool `tidy3d convert` for conversion from `.lsf` project files into equivalent python scripts implementing the project in Tidy3D. Usage: `tidy3d convert example.lsf tidy3d_script.py`.

### Changed
- Output task URL before and after simulation run and make URLs blue underline formatting.
Expand Down Expand Up @@ -949,7 +977,8 @@ which fields are to be projected is now determined automatically based on the me
- Job and Batch classes for better simulation handling (eventually to fully replace webapi functions).
- A large number of small improvements and bug fixes.

[Unreleased]: https://github.com/flexcompute/tidy3d/compare/v2.4.1...develop
[Unreleased]: https://github.com/flexcompute/tidy3d/compare/v2.4.2...develop
[2.4.2]: https://github.com/flexcompute/tidy3d/compare/v2.4.1...v2.4.2
[2.4.1]: https://github.com/flexcompute/tidy3d/compare/v2.4.0...v2.4.1
[2.4.0]: https://github.com/flexcompute/tidy3d/compare/v2.3.3...v2.4.0
[2.3.3]: https://github.com/flexcompute/tidy3d/compare/v2.3.2...v2.3.3
Expand Down
179 changes: 179 additions & 0 deletions tests/data/example.lsf
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# https://optics.ansys.com/hc/en-us/articles/360034923553-Lumerical-scripting-language-Alphabetical-list
# https://readthedocs.org/projects/lumopt/downloads/pdf/latest/

switchtolayout;
selectall;
delete;

## SIM PARAMS
size_x=6e-6;
size_y=8e-6;
size_z=0;
mesh_x=20e-9;
mesh_y=20e-9;
finer_mesh_size=2.5e-6;
mesh_accuracy=2;

addsphere;
set("name","new_sphere");
set("x",1e-6);
set("y",2e-6);
set("z",0);
set("radius",0.5e-6);

# testing space with comment
test_dict1 = 'yee';
test_dict2 = test_dict1; # check comment after declaration
test_dict3 = True; # further weird ## comment # case
test_dict4 = False;

## GEOMETRY
#INPUT WAVEGUIDE
addrect;
set('name','input wg');
set('x span',3e-6);
set('y span',0.5e-6);
set('z span',220e-9);
set('y',0.0);
set('x',-2.5e-6);
set('index',2.8);

addplane;
set("injection axis","z");
set("direction","backward");
set("x",0);
set("x span",0.5e-6);
set("y",0);
set("y span",5e-6);
set("z",0e-6);
set("wavelength start",0.3e-6);
set("wavelength stop",1.2e-6);

#OUTPUT WAVEGUIDES
addrect;
set('name','output wg top');
set('x span',3e-6);
set('y span',0.5e-6);
set('z span',220e-9);
set('y',0.35e-6);
set('x',2.5e-6);
set('index',2.8);

addrect;
set('name','output wg bottom');
set('x span',3e-6);
set('y span',0.5e-6);
set('z span',220e-9);
set('y',-0.35e-6);
set('x',2.5e-6);
set('index',2.8);

## SOURCE
addmode;
set('direction','Forward');
set('injection axis','x-axis');
#set('polarization angle',0);
set('wavelength start',0.55e-6);
set('wavelength stop', 0.55e-6);
set('y',0.0);
set('y span',size_y);
set('x span',size_x);
set('x',-1.25e-6);
set('override global source settings',false);
set('mode selection','fundamental TE mode');
addgaussian;
set("injection axis","z");
set("direction","backward");
set("x",0);
set("x span",0.5e-6);
set("y",3);
set("y span",0.3e-6);
set("z",0e-6);
set("use scalar approximation",1);
set("waist radius w0",0.5e-6);
set("distance from waist",-5e-6);

## FDTD
addfdtd;
set('dimension','2D');
set('background index',1.44);
set('mesh accuracy',mesh_accuracy);
set('x',0.0);
set('x span',size_x);
set('y',0.0);
set('y span',size_y);
set('z span',size_z);
set('force symmetric y mesh',true);
set('y min bc','Anti-Symmetric');
set('pml layers',12);

## MESH IN OPTIMIZABLE REGION
addmesh;
set('x',0);
set('x span',finer_mesh_size+2.0*mesh_x);

set('y',0);
set('y span',finer_mesh_size);
set('dx',mesh_x);
set('dy',mesh_y);

## OPTIMIZATION FIELDS MONITOR IN OPTIMIZABLE REGION
addpower;
set('name','opt_fields');
set('monitor type','2D Z-normal');
set('x',0);
set('x span',finer_mesh_size);
set('y',0);
set('y span',finer_mesh_size);

addcircle;
set("name","new_circle");
set("x",-1e-6);
set("y",2e-6);
set("radius",0.25e-6);
set("z",0);
set("z span",10e-6);



vtx = [(1,1),(2,2),(2.5,2),(2,1.5),(2.2,1)]; # comment
addpoly;
set("name","random_polygon");
set("vertices",vtx);
set("z span",2e-6);

adddipole;
set("x",0);
set("y",1e-6);
set("z",0e-6);

## FOM FIELDS
addpower;
set('name','fom');
set('monitor type','2D X-normal');
set('x',finer_mesh_size/2.0);
set('y',0.0);
set('y span',size_y);

addefieldmonitor;
set("name","E_field");
set("monitor type",6); # 2D y-normal
set("x",0);
set("x span",5e-6);
set("y",0);
set("z",0);
set("y span",5e-6);
set("record electrostatic potential",1);
set("save data",1);
filename = "electric_field.mat";
set("filename",filename);

addtestUnavailableCommand;

addmodeexpansion;
set("name","mode monitor");
set("x",0);
set("x span",5e-6);
set("y",0);
set("z",0);
set("y span",5e-6);
140 changes: 140 additions & 0 deletions tests/data/monitors.lsf
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# https://optics.ansys.com/hc/en-us/articles/360034923553-Lumerical-scripting-language-Alphabetical-list
# https://readthedocs.org/projects/lumopt/downloads/pdf/latest/

switchtolayout;
selectall;
delete;

## SIM PARAMS
size_x=16e-6;
size_y=18e-6;
size_z=0;
mesh_x=20e-9;
mesh_y=20e-9;
finer_mesh_size=0.5e-6;
mesh_accuracy=2;

addsphere;
set("name","s");
set("x",1e-6);
set("y",2e-6);
set("z",0);
set("radius",0.5e-6);



## FDTD
addfdtd;
set('dimension','2D');
set('background index',1.44);
set('mesh accuracy',mesh_accuracy);
set('x',0.0);
set('x span',size_x);
set('y',0.0);
set('y span',size_y);
set('z span',size_z);
set('force symmetric y mesh',true);
set('y min bc','Anti-Symmetric');
set('pml layers',12);


## OPTIMIZATION FIELDS MONITOR IN OPTIMIZABLE REGION
addpower;
set('name','opt_fields');
set('monitor type','2D Z-normal');
set('x',-6.5e-6);
set('x span',finer_mesh_size);
set('y',7.5e-6);
set('y span',finer_mesh_size);


#adddipole;
#set("x",0);
#set("y",1e-6);
#set("z",0e-6);

addefieldmonitor;
set("name","E_field");
set("monitor type",6); # 2D y-normal
set("x",-4.5e-6);
set("x span",0.5e-6);
set("y",7.5e-6);
set("z",0);
set("y span",0.5e-6);
set("record electrostatic potential",1);
set("save data",1);
filename = "electric_field.mat";
set("filename",filename);

addtestUnavailableCommand;

addmodeexpansion;
set("name","mode monitor");
set("x",-3.5e-6);
set("x span",5e-6);
set("y",7.5e-6);
set("z",0);
set("y span",1e-6);

addindex;
set("name","index_monitor");
set("x",0);
set("x span",5e-6);
set("z",0);
set("y",8e-6);
set("y span",2.5e-6);

addeffectiveindex;
set("name","neff");
set("x",1e-6);
set("x span",0.7e-6);
set("y",5e-6);
set("y span",0.7e-6);

addtime;

set("name","time_1");
set("monitor type",1); # point
set("x",2.5e-6);
set("z",0);
set("y",5e-6);

addmovie;
set("name","movie_1");
set("monitor type",3); # 1 = 2D x-normal, 2 = 2D y-normal, 3 = 2D z-normal
set("x",4e-6);
set("x span",0.5e-6);
set("y",5e-6);
set("y span",5e-6);
set("z",0);
set("lock aspect ratio",1);
set("horizontal resolution",240);

addprofile;
set("name","field_profile");
set("monitor type",7); # 2D z-normal
set("x",6e-6);
set("x span",1e-6);
set("y",5);
set("y span",1e-6);
set("z",0);

setactivesolver("EME");
addemeindex;

setactivesolver("EME");
addemeprofile;

addemfieldmonitor;
set("name","T");
set("use source limits",1);
set("reference source","plane_wave");
set("surface type","solid");
set("solid","2D rectangle");

addemfieldtimemonitor;
set("name","time");
set("geometry type","point");
set("x",-2.5e-6);
set("y",2.5e-6);
set("z",0);
Loading

0 comments on commit e22b540

Please sign in to comment.