├── .binder └── requirements.txt ├── .gitattributes ├── .gitconfig ├── .github ├── ISSUE_TEMPLATE │ ├── autograd_bug.md │ ├── bug_report.md │ └── feature_request.md └── workflows │ ├── release.yml │ ├── run_tests.yml │ ├── sync-to-readthedocs-repo.yaml │ ├── test_daily_latest_submodule.yaml │ ├── test_develop_cli.yaml │ └── test_pr_latest_submodule.yaml ├── .gitignore ├── .gitmodules ├── .pre-commit-config.yaml ├── .readthedocs.yaml ├── CHANGELOG.md ├── COPYRIGHT ├── LICENSE ├── README.md ├── docs ├── 404.rst ├── _ext │ ├── custom-meta.py │ ├── custom-robots.py │ └── custom-sitemap.py ├── _static │ ├── css │ │ ├── TWKEverett-Bold.otf │ │ ├── TWKEverett-Extrabold.otf │ │ ├── TWKEverett-Regular.otf │ │ └── custom.css │ ├── img │ │ ├── 404.png │ │ ├── AdjointFlow.svg │ │ ├── Tidy3D-logo-white.svg │ │ ├── Tidy3D-logo.svg │ │ ├── apodization.png │ │ ├── beam_waist.png │ │ ├── courant_instability.png │ │ ├── courant_instability_2d.png │ │ ├── design.png │ │ ├── diagram_Geometry.png │ │ ├── diagram_Monitor.png │ │ ├── diagram_Simulation.png │ │ ├── diagram_Source.png │ │ ├── diagram_Structure.png │ │ ├── diverged-fdtd-simulation.png │ │ ├── diverged-fdtd-simulation1.png │ │ ├── documentation_versions.png │ │ ├── erosion_dilation.png │ │ ├── field_update_fdtd.png │ │ ├── filter_project.png │ │ ├── gui_overview.png │ │ ├── lumped_dist_type.png │ │ ├── mode_vs_dipole_source.png │ │ ├── numerical_dispersion_discretization_1d.png │ │ ├── numerical_dispersion_grid_1d.png │ │ ├── permittivity_on_yee_grid.png │ │ ├── photonforge_overview.png │ │ ├── pml_boundary.png │ │ ├── simcloud_overview.png │ │ ├── snippet.png │ │ ├── snippet2.png │ │ ├── structure.png │ │ ├── subpixel_permittivity_1d.png │ │ ├── yee_grid.png │ │ └── yee_grid_illustration.png │ ├── js │ │ └── custom-download.js │ ├── logo.svg │ ├── pml_right_wrong.png │ ├── quickstart_fields.png │ ├── ring_resonator.png │ └── robots.txt ├── _templates │ ├── material_class.rst │ ├── material_functions.rst │ ├── materials.rst │ └── module.rst ├── api │ ├── abstract_base.rst │ ├── abstract_models.rst │ ├── analytic_beams.rst │ ├── boundary_conditions.rst │ ├── charge │ │ ├── boundary_conditions.rst │ │ ├── discretization.rst │ │ ├── index.rst │ │ ├── mediums.rst │ │ ├── monitor.rst │ │ ├── output_data.rst │ │ ├── simulation.rst │ │ └── source.rst │ ├── constants.rst │ ├── discretization.rst │ ├── eme │ │ ├── grid.rst │ │ ├── index.rst │ │ ├── monitor.rst │ │ ├── output_data.rst │ │ ├── simulation.rst │ │ └── sweep.rst │ ├── field_projector.rst │ ├── geometry.rst │ ├── heat │ │ ├── analysis.rst │ │ ├── boundary_conditions.rst │ │ ├── discretization.rst │ │ ├── index.rst │ │ ├── mediums.rst │ │ ├── monitor.rst │ │ ├── output_data.rst │ │ ├── simulation.rst │ │ └── source.rst │ ├── index.rst │ ├── logging.rst │ ├── lumped_elements.rst │ ├── material_library.rst │ ├── mediums.rst │ ├── microwave │ │ ├── index.rst │ │ └── output_data.rst │ ├── mode.rst │ ├── monitors.rst │ ├── output_data.rst │ ├── plugins │ │ ├── adjoint.rst │ │ ├── autograd.rst │ │ ├── design.rst │ │ ├── dispersion.rst │ │ ├── index.rst │ │ ├── invdes.rst │ │ ├── microwave.rst │ │ ├── mode_solver.rst │ │ ├── polyslab.rst │ │ ├── resonance.rst │ │ ├── smatrix.rst │ │ └── waveguide.rst │ ├── rf_material_library.rst │ ├── scene.rst │ ├── simulation.rst │ ├── sources.rst │ ├── spice.rst │ ├── structures.rst │ ├── submit_simulations.rst │ ├── subpixel_averaging.rst │ └── viz.rst ├── changelog.rst ├── conf.py ├── development │ ├── documentation.rst │ ├── index.rst │ ├── installation.rst │ ├── introduction │ │ ├── code_quality_principles.rst │ │ ├── index.rst │ │ ├── project_structure.rst │ │ ├── understanding_poetry.rst │ │ └── understanding_virtual_environments.rst │ ├── recommendations.rst │ ├── release │ │ ├── documentation.rst │ │ ├── flow.rst │ │ ├── index.rst │ │ └── notebooks.rst │ └── usage.rst ├── generate_doc.py ├── index.rst ├── install.rst ├── lectures │ ├── fdtd101.rst │ ├── fdtd_workshop.rst │ ├── index.rst │ └── inversedesign.rst └── versions │ ├── 2_5_to_2_6.json │ ├── README.md │ └── test_replace_in_files.json ├── poetry.lock ├── poetry.toml ├── pyproject.toml ├── scripts ├── benchmark_import.py ├── make_script.py ├── pre_release.sh ├── sample.py ├── schema.py ├── test_coverage.sh └── test_format.sh ├── tests ├── README.md ├── __init__.py ├── _test_data │ ├── __init__.py │ └── _test_datasets_no_vtk.py ├── _test_local │ ├── __init__.py │ ├── _test_adjoint_performance.py │ ├── _test_adjoint_performance_multi.py │ ├── _test_data_performance.py │ ├── _test_fit_web.py │ ├── _test_plugins_web.py │ └── _test_web.py ├── _test_notebooks │ └── full_test_notebooks.py ├── conftest.py ├── data │ ├── example.lsf │ ├── monitor_data.hdf5 │ ├── monitors.lsf │ ├── n_data.csv │ ├── nk_data.csv │ ├── tetrahedron.stl │ └── two_boxes_separate.stl ├── sims │ ├── full_charge.h5 │ ├── full_charge.json │ ├── full_conduction.h5 │ ├── full_conduction.json │ ├── full_fdtd.h5 │ ├── full_fdtd.json │ ├── full_steady_heat.h5 │ ├── full_steady_heat.json │ ├── full_unsteady_heat.h5 │ └── full_unsteady_heat.json ├── test_cli │ └── full_test_develop.py ├── test_components │ ├── __init__.py │ ├── material │ │ └── test_multi_physics.py │ ├── test_IO.py │ ├── test_apodization.py │ ├── test_autograd.py │ ├── test_autograd_mode_polyslab_numerical.py │ ├── test_autograd_numerical.py │ ├── test_base.py │ ├── test_bc_placement.py │ ├── test_beam.py │ ├── test_boundaries.py │ ├── test_custom.py │ ├── test_eme.py │ ├── test_field_projection.py │ ├── test_frequencies.py │ ├── test_geometry.py │ ├── test_grid.py │ ├── test_grid_spec.py │ ├── test_heat.py │ ├── test_heat_charge.py │ ├── test_layerrefinement.py │ ├── test_lumped_element.py │ ├── test_medium.py │ ├── test_meshgenerate.py │ ├── test_microwave.py │ ├── test_mode.py │ ├── test_monitor.py │ ├── test_packaging.py │ ├── test_parameter_perturbation.py │ ├── test_perturbation_medium.py │ ├── test_scene.py │ ├── test_sidewall.py │ ├── test_simulation.py │ ├── test_source.py │ ├── test_structure.py │ ├── test_time_modulation.py │ ├── test_types.py │ └── test_viz.py ├── test_data │ ├── __init__.py │ ├── test_data_arrays.py │ ├── test_datasets.py │ ├── test_monitor_data.py │ └── test_sim_data.py ├── test_material_library │ ├── __init__.py │ └── test_material_library.py ├── test_package │ ├── __init__.py │ ├── test_compat.py │ ├── test_config.py │ ├── test_convert.py │ ├── test_log.py │ ├── test_main.py │ ├── test_make_script.py │ ├── test_material_library.py │ └── test_parametric_variants.py ├── test_plugins │ ├── __init__.py │ ├── autograd │ │ ├── __init__.py │ │ ├── invdes │ │ │ ├── __init__.py │ │ │ ├── test_filters.py │ │ │ ├── test_parametrizations.py │ │ │ └── test_penalties.py │ │ ├── primitives │ │ │ ├── __init__.py │ │ │ ├── test_interpolate.py │ │ │ └── test_misc.py │ │ ├── test_differential_operators.py │ │ ├── test_functions.py │ │ └── test_utilities.py │ ├── expressions │ │ ├── __init__.py │ │ ├── test_functions.py │ │ ├── test_operators.py │ │ └── test_variables.py │ ├── pytorch │ │ └── test_wrapper.py │ ├── smatrix │ │ ├── __init__.py │ │ ├── terminal_component_modeler_def.py │ │ ├── test_component_modeler.py │ │ └── test_terminal_component_modeler.py │ ├── test_adjoint.py │ ├── test_array_factor.py │ ├── test_design.py │ ├── test_dispersion_fitter.py │ ├── test_invdes.py │ ├── test_microwave.py │ ├── test_mode_solver.py │ ├── test_polyslab.py │ ├── test_resonance_finder.py │ └── test_waveguide.py ├── test_web │ ├── __init__.py │ ├── mock_web.py │ ├── test_cli.py │ ├── test_env.py │ ├── test_material_fitter.py │ ├── test_task.py │ ├── test_tidy3d_folder.py │ ├── test_tidy3d_material_library.py │ ├── test_tidy3d_task.py │ ├── test_webapi.py │ ├── test_webapi_account.py │ ├── test_webapi_eme.py │ ├── test_webapi_heat.py │ ├── test_webapi_mode.py │ └── test_webapi_mode_sim.py └── utils.py └── tidy3d ├── README.md ├── __init__.py ├── __main__.py ├── compat.py ├── components ├── README.md ├── __init__.py ├── apodization.py ├── autograd │ ├── __init__.py │ ├── boxes.py │ ├── derivative_utils.py │ ├── functions.py │ ├── types.py │ └── utils.py ├── base.py ├── base_sim │ ├── __init__.py │ ├── data │ │ ├── __init__.py │ │ ├── monitor_data.py │ │ └── sim_data.py │ ├── monitor.py │ ├── simulation.py │ └── source.py ├── bc_placement.py ├── beam.py ├── boundary.py ├── data │ ├── README.md │ ├── __init__.py │ ├── data_array.py │ ├── dataset.py │ ├── monitor_data.py │ ├── sim_data.py │ ├── unstructured │ │ ├── __init__.py │ │ ├── base.py │ │ ├── tetrahedral.py │ │ └── triangular.py │ ├── utils.py │ ├── validators.py │ └── zbf.py ├── dispersion_fitter.py ├── eme │ ├── __init__.py │ ├── data │ │ ├── __init__.py │ │ ├── dataset.py │ │ ├── monitor_data.py │ │ └── sim_data.py │ ├── grid.py │ ├── monitor.py │ ├── simulation.py │ └── sweep.py ├── field_projection.py ├── file_util.py ├── frequencies.py ├── geometry │ ├── __init__.py │ ├── base.py │ ├── bound_ops.py │ ├── mesh.py │ ├── polyslab.py │ ├── primitives.py │ ├── triangulation.py │ ├── utils.py │ └── utils_2d.py ├── grid │ ├── __init__.py │ ├── corner_finder.py │ ├── grid.py │ ├── grid_spec.py │ └── mesher.py ├── lumped_element.py ├── material │ ├── README.md │ ├── __init__.py │ ├── multi_physics.py │ ├── solver_types.py │ ├── tcad │ │ ├── __init__.py │ │ ├── charge.py │ │ └── heat.py │ └── types.py ├── medium.py ├── microwave │ ├── __init__.py │ ├── data │ │ ├── __init__.py │ │ └── monitor_data.py │ └── formulas │ │ ├── __init__.py │ │ └── circuit_parameters.py ├── mode │ ├── LICENSE │ ├── __init__.py │ ├── data │ │ ├── __init__.py │ │ └── sim_data.py │ ├── derivatives.py │ ├── mode_solver.py │ ├── simulation.py │ ├── solver.py │ └── transforms.py ├── mode_spec.py ├── monitor.py ├── parameter_perturbation.py ├── run_time_spec.py ├── scene.py ├── simulation.py ├── source │ ├── __init__.py │ ├── base.py │ ├── current.py │ ├── field.py │ ├── time.py │ └── utils.py ├── spice │ ├── __init__.py │ ├── analysis │ │ ├── __init__.py │ │ └── dc.py │ ├── sources │ │ ├── __init__.py │ │ ├── dc.py │ │ └── types.py │ └── types.py ├── structure.py ├── subpixel_spec.py ├── tcad │ ├── __init__.py │ ├── analysis │ │ ├── __init__.py │ │ └── heat_simulation_type.py │ ├── bandgap.py │ ├── boundary │ │ ├── __init__.py │ │ ├── abstract.py │ │ ├── charge.py │ │ ├── heat.py │ │ └── specification.py │ ├── data │ │ ├── __init__.py │ │ ├── monitor_data │ │ │ ├── __init__.py │ │ │ ├── abstract.py │ │ │ ├── charge.py │ │ │ └── heat.py │ │ ├── sim_data.py │ │ └── types.py │ ├── doping.py │ ├── generation_recombination.py │ ├── grid.py │ ├── mobility.py │ ├── monitors │ │ ├── __init__.py │ │ ├── abstract.py │ │ ├── charge.py │ │ └── heat.py │ ├── simulation │ │ ├── __init__.py │ │ ├── heat.py │ │ └── heat_charge.py │ ├── source │ │ ├── __init__.py │ │ ├── abstract.py │ │ ├── coupled.py │ │ └── heat.py │ ├── types.py │ └── viz.py ├── time.py ├── time_modulation.py ├── transformation.py ├── type_util.py ├── types.py ├── types_extra.py ├── validators.py └── viz │ ├── __init__.py │ ├── axes_utils.py │ ├── descartes.py │ ├── flex_color_palettes.py │ ├── flex_style.py │ ├── plot_params.py │ ├── plot_sim_3d.py │ ├── styles.py │ └── visualization_spec.py ├── config.py ├── constants.py ├── exceptions.py ├── log.py ├── material_library ├── __init__.py ├── material_library.py ├── material_reference.py ├── parametric_materials.py └── util.py ├── packaging.py ├── plugins ├── __init__.py ├── adjoint │ ├── README.md │ ├── __init__.py │ ├── components │ │ ├── __init__.py │ │ ├── base.py │ │ ├── data │ │ │ ├── __init__.py │ │ │ ├── data_array.py │ │ │ ├── dataset.py │ │ │ ├── monitor_data.py │ │ │ └── sim_data.py │ │ ├── geometry.py │ │ ├── medium.py │ │ ├── simulation.py │ │ ├── structure.py │ │ └── types.py │ ├── utils │ │ ├── __init__.py │ │ ├── filter.py │ │ └── penalty.py │ └── web.py ├── autograd │ ├── README.md │ ├── __init__.py │ ├── constants.py │ ├── differential_operators.py │ ├── functions.py │ ├── invdes │ │ ├── __init__.py │ │ ├── filters.py │ │ ├── misc.py │ │ ├── parametrizations.py │ │ ├── penalties.py │ │ └── projections.py │ ├── primitives │ │ ├── __init__.py │ │ ├── interpolate.py │ │ └── misc.py │ ├── types.py │ └── utilities.py ├── design │ ├── README.md │ ├── __init__.py │ ├── design.py │ ├── method.py │ ├── parameter.py │ └── result.py ├── dispersion │ ├── __init__.py │ ├── fit.py │ ├── fit_fast.py │ ├── fit_web.py │ └── web.py ├── expressions │ ├── README.md │ ├── __init__.py │ ├── base.py │ ├── functions.py │ ├── metrics.py │ ├── operators.py │ ├── types.py │ └── variables.py ├── invdes │ ├── README.md │ ├── __init__.py │ ├── base.py │ ├── design.py │ ├── initialization.py │ ├── optimizer.py │ ├── penalty.py │ ├── region.py │ ├── result.py │ ├── transformation.py │ ├── utils.py │ └── validators.py ├── microwave │ ├── __init__.py │ ├── array_factor.py │ ├── auto_path_integrals.py │ ├── custom_path_integrals.py │ ├── impedance_calculator.py │ ├── lobe_measurer.py │ ├── models │ │ ├── __init__.py │ │ ├── coupled_microstrip.py │ │ └── microstrip.py │ ├── path_integrals.py │ ├── rf_material_library.py │ ├── rf_material_reference.py │ └── viz.py ├── mode │ ├── LICENSE │ ├── README.md │ ├── __init__.py │ ├── mode_solver.py │ └── web.py ├── polyslab │ ├── __init__.py │ └── polyslab.py ├── pytorch │ ├── README.md │ ├── __init__.py │ └── wrapper.py ├── resonance │ ├── __init__.py │ └── resonance.py ├── smatrix │ ├── __init__.py │ ├── component_modelers │ │ ├── __init__.py │ │ ├── base.py │ │ ├── modal.py │ │ └── terminal.py │ ├── data │ │ ├── __init__.py │ │ └── terminal.py │ ├── ports │ │ ├── __init__.py │ │ ├── base_lumped.py │ │ ├── base_terminal.py │ │ ├── coaxial_lumped.py │ │ ├── modal.py │ │ ├── rectangular_lumped.py │ │ └── wave.py │ └── smatrix.py └── waveguide │ ├── __init__.py │ └── rectangular_dielectric.py ├── schema.json ├── style.mplstyle ├── updater.py ├── version.py └── web ├── __init__.py ├── api ├── __init__.py ├── asynchronous.py ├── autograd │ ├── __init__.py │ ├── autograd.py │ └── utils.py ├── cacert.pem ├── connect_util.py ├── container.py ├── material_fitter.py ├── material_libray.py ├── mode.py ├── tidy3d_stub.py └── webapi.py ├── cli ├── __init__.py ├── app.py ├── constants.py ├── develop │ ├── __init__.py │ ├── documentation.py │ ├── index.py │ ├── install.py │ ├── packaging.py │ ├── tests.py │ └── utils.py ├── migrate.py └── readme.md ├── core ├── __init__.py ├── account.py ├── cache.py ├── constants.py ├── core_config.py ├── environment.py ├── exceptions.py ├── file_util.py ├── http_util.py ├── s3utils.py ├── stub.py ├── task_core.py ├── task_info.py └── types.py └── environment.py /.binder/requirements.txt: -------------------------------------------------------------------------------- 1 | tidy3d 2 | tmm 3 | nlopt 4 | tqdm 5 | gdspy 6 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Linguist-vendored files 2 | docs/* linguist-vendored 3 | notebooks/* linguist-vendored 4 | tests/* linguist-vendored 5 | 6 | # Disable linguist detection for IPython notebooks 7 | *.ipynb linguist-detectable=false 8 | 9 | # Mark IPython notebooks as generated files 10 | *.ipynb linguist-generated=true 11 | 12 | # Specify merge attributes for CHANGELOG.md 13 | CHANGELOG.md merge=union 14 | 15 | # Specify diff and merge attributes for IPython notebooks 16 | *.ipynb diff=jupyternotebook 17 | *.ipynb merge=jupyternotebook 18 | -------------------------------------------------------------------------------- /.gitconfig: -------------------------------------------------------------------------------- 1 | [diff "jupyternotebook"] 2 | command = git-nbdiffdriver diff 3 | [merge "jupyternotebook"] 4 | driver = git-nbmergedriver merge %O %A %B %L %P 5 | name = jupyter notebook merge driver 6 | [difftool "nbdime"] 7 | cmd = git-nbdifftool diff \"$LOCAL\" \"$REMOTE\" \"$BASE\" 8 | [difftool] 9 | prompt = false 10 | [mergetool "nbdime"] 11 | cmd = git-nbmergetool merge \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\" 12 | [mergetool] 13 | prompt = false 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/autograd_bug.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Autograd Bug Report 3 | about: Create a report to help us improve our autograd feature 4 | title: 'Autograd Bug' 5 | labels: 'autograd' 6 | assignees: 'tylerflex' 7 | 8 | --- 9 | 10 | **Description** 11 | Please paste the error message displayed in your warning when running `tidy3d.web.run()` or `tidy3d.web.run_async()` 12 | 13 | **Simulation Setup** 14 | 15 | Please describe your simulation setup as specifically as you can, including code snippets or uploading the `simulation.to_file('sim.json')` file. 16 | 17 | Also please include what options were passed to the `web` function. 18 | 19 | **Other information** 20 | Anything else you'd like to add to help us look into it? 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest a feature for tidy3d 4 | title: '' 5 | labels: feature 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | 22 | **If Flexcompute Team Member** 23 | Please assign an estimate for the "priority" of the project (tiny, small, medium, large, XL) 24 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "docs/notebooks"] 2 | path = docs/notebooks 3 | url = git@github.com:flexcompute/tidy3d-notebooks.git 4 | [submodule "docs/faq"] 5 | path = docs/faq 6 | url = https://github.com/flexcompute/tidy3d-faq 7 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/astral-sh/ruff-pre-commit 3 | rev: "v0.11.11" 4 | hooks: 5 | - id: ruff-check 6 | args: [ --fix ] 7 | - id: ruff-format 8 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | submodules: 4 | include: 5 | - docs/notebooks 6 | - docs/faq 7 | recursive: true 8 | 9 | build: 10 | os: "ubuntu-20.04" 11 | tools: 12 | python: "3.10" 13 | sphinx: 14 | fail_on_warning: false 15 | configuration: docs/conf.py 16 | 17 | python: 18 | # Install our python package before building the docs 19 | install: 20 | - method: pip 21 | path: . 22 | extra_requirements: 23 | - dev 24 | 25 | formats: [] 26 | 27 | # Build from the docs/ directory with Sphinx 28 | # sphinx: 29 | # configuration: docs/conf.py 30 | # 31 | # # Explicitly set the version of Python and its requirements 32 | # python: 33 | # install: 34 | # - requirements: docs/requirements.txt 35 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | Copyright (C) 2021-2022 Flexcompute 2 | 3 | This program is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU Affero General Public License as published 5 | by the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Affero General Public License for more details. 12 | 13 | You should have received a copy of the GNU Affero General Public License 14 | along with this program. If not, see . -------------------------------------------------------------------------------- /docs/404.rst: -------------------------------------------------------------------------------- 1 | .. _404: 2 | 3 | 404 4 | === 5 | 6 | Oops! You've hit a wavelength that doesn't resonate with our server. Try a different frequency! 7 | 8 | If you have arrived here from a link in our pre-v2.6 documentation, we apologize for the inconvenience. We have restructured our documentation to make it more user-friendly and informative, and the page links have changed. We recommend you return to the `homepage `_ and navigate to the page you were looking for from there. 9 | 10 | Please let us know what happened that got you here by raising a `GitHub issue `_ if not! We'll do our best to help you out. 11 | 12 | .. image:: /_static/img/404.png 13 | :alt: 404 - Page not found 14 | :align: center -------------------------------------------------------------------------------- /docs/_ext/custom-meta.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import os 4 | 5 | 6 | def html_page_context(app, pagename, templatename, context, doctree): 7 | notebook_path = app.env.doc2path(os.path.abspath("" + pagename), base=None) 8 | if "notebook" in notebook_path or notebook_path.endswith("examples.rst"): 9 | context["metatags"] += "".join(['\n\t']) 10 | 11 | 12 | def setup(app): 13 | app.connect("html-page-context", html_page_context) 14 | -------------------------------------------------------------------------------- /docs/_ext/custom-robots.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import os 4 | 5 | 6 | def process_robots_txt(app, exception): 7 | # Get the path to the robots.txt file 8 | robots_file = os.path.join(app.outdir, "robots.txt") 9 | 10 | # Read the contents of the robots.txt file 11 | with open(robots_file) as f: 12 | contents = f.read() 13 | 14 | # Modify the contents as needed 15 | # site_map = app.config['html_baseurl'] + app.config['version'] + app.config['language'] + 'sitemap.xml' 16 | site_map = "/".join( 17 | [app.config["html_baseurl"], app.config["language"], app.config["version"], "sitemap.xml"] 18 | ).replace("//", "/") 19 | new_content = f"\nSitemap: {site_map}" 20 | contents += new_content 21 | 22 | # Update the robots.txt file with the modified contents 23 | with open(robots_file, "w") as f: 24 | f.write(contents) 25 | 26 | 27 | def setup(app): 28 | # Bind the process_sitemap function to build-finished event 29 | # exclude_pattern= dir(app.config) 30 | app.connect("build-finished", process_robots_txt) 31 | -------------------------------------------------------------------------------- /docs/_ext/custom-sitemap.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import re 4 | import xml.etree.ElementTree as ET 5 | 6 | 7 | def match_exclude_url(app, url): 8 | exclude_pattern = app.config._raw_config["custom_sitemap_excludes"] 9 | for regex in exclude_pattern: 10 | if re.search(regex, url): 11 | return True 12 | return False 13 | 14 | 15 | def process_sitemap(app, exception): 16 | # Only process sitemap for successful builds 17 | if exception is not None: 18 | return 19 | 20 | # Get path to sitemap.xml file 21 | sitemap_path = app.outdir + "/sitemap.xml" 22 | 23 | # Parse sitemap.xml file 24 | tree = ET.parse(sitemap_path) 25 | root = tree.getroot() 26 | 27 | # Process each URL node in the sitemap 28 | for url in root.findall("{http://www.sitemaps.org/schemas/sitemap/0.9}url"): 29 | loc = url.find("{http://www.sitemaps.org/schemas/sitemap/0.9}loc").text 30 | if match_exclude_url(app, loc): 31 | root.remove(url) 32 | # Do something with the URL... 33 | with open(sitemap_path, "wb") as f: 34 | tree.write(f, encoding="UTF-8") 35 | 36 | 37 | def setup(app): 38 | # Bind the process_sitemap function to build-finished event 39 | app.connect("build-finished", process_sitemap) 40 | -------------------------------------------------------------------------------- /docs/_static/css/TWKEverett-Bold.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/css/TWKEverett-Bold.otf -------------------------------------------------------------------------------- /docs/_static/css/TWKEverett-Extrabold.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/css/TWKEverett-Extrabold.otf -------------------------------------------------------------------------------- /docs/_static/css/TWKEverett-Regular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/css/TWKEverett-Regular.otf -------------------------------------------------------------------------------- /docs/_static/img/404.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/404.png -------------------------------------------------------------------------------- /docs/_static/img/apodization.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/apodization.png -------------------------------------------------------------------------------- /docs/_static/img/beam_waist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/beam_waist.png -------------------------------------------------------------------------------- /docs/_static/img/courant_instability.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/courant_instability.png -------------------------------------------------------------------------------- /docs/_static/img/courant_instability_2d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/courant_instability_2d.png -------------------------------------------------------------------------------- /docs/_static/img/design.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/design.png -------------------------------------------------------------------------------- /docs/_static/img/diagram_Geometry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/diagram_Geometry.png -------------------------------------------------------------------------------- /docs/_static/img/diagram_Monitor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/diagram_Monitor.png -------------------------------------------------------------------------------- /docs/_static/img/diagram_Simulation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/diagram_Simulation.png -------------------------------------------------------------------------------- /docs/_static/img/diagram_Source.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/diagram_Source.png -------------------------------------------------------------------------------- /docs/_static/img/diagram_Structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/diagram_Structure.png -------------------------------------------------------------------------------- /docs/_static/img/diverged-fdtd-simulation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/diverged-fdtd-simulation.png -------------------------------------------------------------------------------- /docs/_static/img/diverged-fdtd-simulation1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/diverged-fdtd-simulation1.png -------------------------------------------------------------------------------- /docs/_static/img/documentation_versions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/documentation_versions.png -------------------------------------------------------------------------------- /docs/_static/img/erosion_dilation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/erosion_dilation.png -------------------------------------------------------------------------------- /docs/_static/img/field_update_fdtd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/field_update_fdtd.png -------------------------------------------------------------------------------- /docs/_static/img/filter_project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/filter_project.png -------------------------------------------------------------------------------- /docs/_static/img/gui_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/gui_overview.png -------------------------------------------------------------------------------- /docs/_static/img/lumped_dist_type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/lumped_dist_type.png -------------------------------------------------------------------------------- /docs/_static/img/mode_vs_dipole_source.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/mode_vs_dipole_source.png -------------------------------------------------------------------------------- /docs/_static/img/numerical_dispersion_discretization_1d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/numerical_dispersion_discretization_1d.png -------------------------------------------------------------------------------- /docs/_static/img/numerical_dispersion_grid_1d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/numerical_dispersion_grid_1d.png -------------------------------------------------------------------------------- /docs/_static/img/permittivity_on_yee_grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/permittivity_on_yee_grid.png -------------------------------------------------------------------------------- /docs/_static/img/photonforge_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/photonforge_overview.png -------------------------------------------------------------------------------- /docs/_static/img/pml_boundary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/pml_boundary.png -------------------------------------------------------------------------------- /docs/_static/img/simcloud_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/simcloud_overview.png -------------------------------------------------------------------------------- /docs/_static/img/snippet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/snippet.png -------------------------------------------------------------------------------- /docs/_static/img/snippet2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/snippet2.png -------------------------------------------------------------------------------- /docs/_static/img/structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/structure.png -------------------------------------------------------------------------------- /docs/_static/img/subpixel_permittivity_1d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/subpixel_permittivity_1d.png -------------------------------------------------------------------------------- /docs/_static/img/yee_grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/yee_grid.png -------------------------------------------------------------------------------- /docs/_static/img/yee_grid_illustration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/img/yee_grid_illustration.png -------------------------------------------------------------------------------- /docs/_static/js/custom-download.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | 3 | function getFileAbsoluteUrl(url) { 4 | return new URL(url, window.location.href);; 5 | } 6 | 7 | function _xhrDownload(url, fileName) { 8 | let xhr = new XMLHttpRequest(); 9 | xhr.open('get', url, true); 10 | xhr.setRequestHeader('Cache-Control', 'no-cache'); 11 | xhr.setRequestHeader('Content-type', 'application/ipynb'); 12 | xhr.responseType = 'blob'; 13 | xhr.onload = function () { 14 | if (this.status === 200) { 15 | let blob = this.response; 16 | let url = window.URL.createObjectURL(blob); 17 | let a = document.createElement('a'); 18 | a.href = url; 19 | a.download = fileName; 20 | a.click(); 21 | } 22 | }; 23 | xhr.onerror = function () { 24 | console.error('error occurred when download file'); 25 | }; 26 | xhr.send(); 27 | } 28 | 29 | function handleIpynbDownload(url) { 30 | const fileName = url.split("/").pop(); 31 | _xhrDownload(url, fileName) 32 | } 33 | 34 | function enhanceDownload() { 35 | window.onload = function () { 36 | setTimeout(() => { 37 | const aTags = document.querySelectorAll( 38 | 'a[data-original-title="Download source file"]' 39 | ); 40 | // Change the downloading behavior of elements. 41 | // Remove the href attribute and add an onclick event. 42 | aTags.forEach((aTag) => { 43 | aTag.setAttribute("download", ""); 44 | const href = aTag.getAttribute("href") 45 | const absoluteUrl = getFileAbsoluteUrl(href); 46 | aTag.setAttribute("onclick", "handleIpynbDownload('" + absoluteUrl + "')") 47 | aTag.setAttribute("href", "javascript:void(0)") 48 | }); 49 | }, 1000); 50 | }; 51 | } 52 | 53 | enhanceDownload() 54 | 55 | window.handleIpynbDownload = handleIpynbDownload 56 | 57 | })() 58 | -------------------------------------------------------------------------------- /docs/_static/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /docs/_static/pml_right_wrong.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/pml_right_wrong.png -------------------------------------------------------------------------------- /docs/_static/quickstart_fields.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/quickstart_fields.png -------------------------------------------------------------------------------- /docs/_static/ring_resonator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/docs/_static/ring_resonator.png -------------------------------------------------------------------------------- /docs/_static/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | 3 | Disallow: /notebooks/ # Hidden version 4 | -------------------------------------------------------------------------------- /docs/_templates/material_class.rst: -------------------------------------------------------------------------------- 1 | {{ fullname }} 2 | {{ underline }} 3 | 4 | .. currentmodule:: {{ module }} 5 | 6 | .. autoclass:: {{ objname }} -------------------------------------------------------------------------------- /docs/_templates/material_functions.rst: -------------------------------------------------------------------------------- 1 | Material library 2 | {{ underline }} 3 | 4 | .. automodule:: {{ fullname }} 5 | 6 | {% block functions %} 7 | {% if functions %} 8 | {{ objname }} 9 | {% for item in functions %} 10 | {{ item }} 11 | {%- endfor %} 12 | {% endif %} 13 | {% endblock %} 14 | -------------------------------------------------------------------------------- /docs/_templates/materials.rst: -------------------------------------------------------------------------------- 1 | Material library 2 | {{ underline }} 3 | 4 | .. automodule:: {{ fullname }} 5 | 6 | {% block classes %} 7 | {% if classes %} 8 | 9 | .. autosummary:: 10 | :toctree: {{ objname }} 11 | :template: material_class.rst 12 | {% for item in classes %} 13 | {{ item }} 14 | {%- endfor %} 15 | {% endif %} 16 | {% endblock %} -------------------------------------------------------------------------------- /docs/_templates/module.rst: -------------------------------------------------------------------------------- 1 | :html_theme.sidebar_secondary.remove: 2 | {{ fullname | escape | underline}} 3 | 4 | .. autoclass:: {{ fullname }} 5 | :members: 6 | :show-inheritance: 7 | :undoc-members: 8 | :member-order: bysource 9 | 10 | {% block attributes %} 11 | {% if attributes %} 12 | .. rubric:: Attributes 13 | 14 | .. autosummary:: 15 | :toctree: 16 | {% for item in attributes %} 17 | {% if item not in inherited_members %} 18 | {{ item }} 19 | {% endif %} 20 | {%- endfor %} 21 | {% endif %} 22 | {% endblock %} 23 | 24 | {% block methods %} 25 | {% if methods %} 26 | .. rubric:: Methods 27 | 28 | .. autosummary:: 29 | :toctree: 30 | {% for item in methods %} 31 | {% if item not in inherited_members %} 32 | {{ item }} 33 | {% endif %} 34 | {%- endfor %} 35 | {% endif %} 36 | {% endblock %} 37 | 38 | 39 | .. rubric:: Inherited Common Usage 40 | 41 | .. include:: ../_custom_autosummary/{{ fullname }}.rst -------------------------------------------------------------------------------- /docs/api/abstract_base.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Abstract Base Models 4 | ===================== 5 | 6 | Base classes that represent abstractions of the core elements of a common components. Provide inherited functionality. 7 | 8 | 9 | .. autosummary:: 10 | :toctree: _autosummary/ 11 | :template: module.rst 12 | 13 | tidy3d.components.base_sim.data.sim_data.AbstractSimulationData 14 | tidy3d.components.base_sim.monitor.AbstractMonitor 15 | tidy3d.components.base_sim.simulation.AbstractSimulation 16 | tidy3d.components.base_sim.source.AbstractSource 17 | tidy3d.components.data.dataset.AbstractFieldDataset 18 | tidy3d.components.data.monitor_data.AbstractFieldProjectionData 19 | tidy3d.components.parameter_perturbation.AbstractPerturbation 20 | tidy3d.components.parameter_perturbation.AbstractPerturbation 21 | tidy3d.components.medium.AbstractCustomMedium 22 | tidy3d.components.medium.AbstractMedium 23 | tidy3d.components.simulation.AbstractYeeGridSimulation 24 | tidy3d.components.structure.AbstractStructure 25 | tidy3d.components.time.AbstractTimeDependence 26 | 27 | -------------------------------------------------------------------------------- /docs/api/analytic_beams.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Analytic Beams 4 | ============== 5 | 6 | .. autosummary:: 7 | :toctree: _autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.PlaneWaveBeamProfile 11 | tidy3d.GaussianBeamProfile 12 | tidy3d.AstigmaticGaussianBeamProfile 13 | -------------------------------------------------------------------------------- /docs/api/boundary_conditions.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Boundary Conditions 4 | =================== 5 | 6 | .. autosummary:: 7 | :toctree: _autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.BoundarySpec 11 | tidy3d.Boundary 12 | tidy3d.BoundaryEdge 13 | 14 | 15 | Types of Boundaries 16 | ------------------- 17 | 18 | .. autosummary:: 19 | :toctree: _autosummary/ 20 | :template: module.rst 21 | 22 | tidy3d.Periodic 23 | tidy3d.PECBoundary 24 | tidy3d.PMCBoundary 25 | tidy3d.BlochBoundary 26 | 27 | 28 | Absorbing Boundaries 29 | --------------------- 30 | 31 | 32 | Types of Absorbers 33 | ^^^^^^^^^^^^^^^^^^^ 34 | 35 | .. autosummary:: 36 | :toctree: _autosummary/ 37 | :template: module.rst 38 | 39 | tidy3d.PML 40 | tidy3d.StablePML 41 | tidy3d.Absorber 42 | 43 | Absorber Parameters 44 | ^^^^^^^^^^^^^^^^^^^ 45 | 46 | .. autosummary:: 47 | :toctree: _autosummary/ 48 | :template: module.rst 49 | 50 | tidy3d.AbsorberParams 51 | tidy3d.PMLParams -------------------------------------------------------------------------------- /docs/api/charge/boundary_conditions.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Boundary Conditions 4 | ----------------------------- 5 | 6 | Specifications 7 | ^^^^^^^^^^^^^^ 8 | 9 | .. autosummary:: 10 | :toctree: ../_autosummary/ 11 | :template: module.rst 12 | 13 | tidy3d.HeatBoundarySpec 14 | tidy3d.HeatChargeBoundarySpec 15 | 16 | 17 | Types 18 | ^^^^^^^^^^^^^^^^^ 19 | 20 | .. autosummary:: 21 | :toctree: ../_autosummary/ 22 | :template: module.rst 23 | 24 | tidy3d.VoltageBC 25 | tidy3d.CurrentBC 26 | tidy3d.InsulatingBC 27 | 28 | Placement 29 | ^^^^^^^^^^^^^^^^^ 30 | 31 | .. autosummary:: 32 | :toctree: ../_autosummary/ 33 | :template: module.rst 34 | 35 | tidy3d.StructureStructureInterface 36 | tidy3d.StructureBoundary 37 | tidy3d.MediumMediumInterface 38 | tidy3d.StructureSimulationBoundary 39 | tidy3d.SimulationBoundary -------------------------------------------------------------------------------- /docs/api/charge/discretization.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Grid Specification 4 | -------------------- 5 | 6 | .. autosummary:: 7 | :toctree: ../_autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.UniformUnstructuredGrid 11 | tidy3d.DistanceUnstructuredGrid 12 | -------------------------------------------------------------------------------- /docs/api/charge/index.rst: -------------------------------------------------------------------------------- 1 | Charge |:zap:| 2 | ============== 3 | 4 | .. toctree:: 5 | :hidden: 6 | 7 | simulation 8 | mediums 9 | boundary_conditions 10 | source 11 | discretization 12 | monitor 13 | output_data 14 | 15 | 16 | .. include:: /api/charge/simulation.rst 17 | .. include:: /api/charge/mediums.rst 18 | .. include:: /api/charge/boundary_conditions.rst 19 | .. include:: /api/charge/source.rst 20 | .. include:: /api/charge/discretization.rst 21 | .. include:: /api/charge/monitor.rst 22 | .. include:: /api/charge/output_data.rst -------------------------------------------------------------------------------- /docs/api/charge/mediums.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Charge Mediums 4 | ------------------------------- 5 | 6 | .. autosummary:: 7 | :toctree: ../_autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.ChargeConductorMedium 11 | tidy3d.ChargeInsulatorMedium 12 | tidy3d.SemiconductorMedium 13 | 14 | Mobility 15 | ^^^^^^^^^^^^^^ 16 | 17 | .. autosummary:: 18 | :toctree: ../_autosummary/ 19 | :template: module.rst 20 | 21 | tidy3d.CaugheyThomasMobility 22 | 23 | 24 | Generation Recombination 25 | ^^^^^^^^^^^^^^^^^^^^^^^^ 26 | 27 | .. autosummary:: 28 | :toctree: ../_autosummary/ 29 | :template: module.rst 30 | 31 | tidy3d.AugerRecombination 32 | tidy3d.RadiativeRecombination 33 | tidy3d.ShockleyReedHallRecombination 34 | 35 | 36 | Doping 37 | ^^^^^^ 38 | 39 | .. autosummary:: 40 | :toctree: ../_autosummary/ 41 | :template: module.rst 42 | 43 | tidy3d.ConstantDoping 44 | tidy3d.GaussianDoping 45 | 46 | 47 | Bandgap 48 | ^^^^^^^^ 49 | 50 | .. autosummary:: 51 | :toctree: ../_autosummary/ 52 | :template: module.rst 53 | 54 | tidy3d.SlotboomBandGapNarrowing 55 | 56 | 57 | Charge Carrier Properties 58 | ------------------------------------ 59 | 60 | .. autosummary:: 61 | :toctree: ../_autosummary/ 62 | :template: module.rst 63 | 64 | tidy3d.LinearChargePerturbation 65 | tidy3d.CustomChargePerturbation -------------------------------------------------------------------------------- /docs/api/charge/monitor.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Monitors 4 | ---------- 5 | 6 | .. autosummary:: 7 | :toctree: ../_autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.SteadyVoltageMonitor 11 | tidy3d.SteadyPotentialMonitor 12 | tidy3d.SteadyFreeCarrierMonitor 13 | tidy3d.SteadyCapacitanceMonitor -------------------------------------------------------------------------------- /docs/api/charge/output_data.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Output Data 4 | ------------- 5 | 6 | 7 | Simulation Data 8 | ^^^^^^^^^^^^^^^^^^^^ 9 | 10 | .. autosummary:: 11 | :toctree: ../_autosummary/ 12 | :template: module.rst 13 | 14 | tidy3d.HeatChargeSimulationData 15 | 16 | 17 | Monitor Data 18 | ^^^^^^^^^^^^ 19 | 20 | .. autosummary:: 21 | :toctree: ../_autosummary/ 22 | :template: module.rst 23 | 24 | tidy3d.SteadyVoltageData 25 | tidy3d.SteadyPotentialData 26 | tidy3d.SteadyFreeCarrierData 27 | tidy3d.SteadyCapacitanceData 28 | 29 | 30 | Unstructured Data Classes 31 | ^^^^^^^^^^^^^^^^^^^^^^^^^ 32 | 33 | .. autosummary:: 34 | :toctree: ../_autosummary/ 35 | :template: module.rst 36 | 37 | tidy3d.TriangularGridDataset 38 | tidy3d.TetrahedralGridDataset 39 | 40 | 41 | Individual Datasets 42 | ^^^^^^^^^^^^^^^^^^^ 43 | 44 | .. autosummary:: 45 | :toctree: ../_autosummary/ 46 | :template: module.rst 47 | 48 | tidy3d.PointDataArray 49 | tidy3d.CellDataArray 50 | tidy3d.IndexedDataArray 51 | -------------------------------------------------------------------------------- /docs/api/charge/simulation.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Simulation 4 | ----------- 5 | 6 | .. autosummary:: 7 | :toctree: ../_autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.HeatSimulation 11 | tidy3d.HeatChargeSimulation -------------------------------------------------------------------------------- /docs/api/charge/source.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Thermal Sources 4 | ----------------- 5 | 6 | .. autosummary:: 7 | :toctree: ../_autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.HeatFromElectricSource -------------------------------------------------------------------------------- /docs/api/discretization.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Discretization 4 | ============== 5 | 6 | .. autosummary:: 7 | :toctree: _autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.GridSpec 11 | tidy3d.AutoGrid 12 | tidy3d.UniformGrid 13 | tidy3d.QuasiUniformGrid 14 | tidy3d.CustomGrid 15 | tidy3d.CustomGridBoundaries 16 | tidy3d.Coords 17 | tidy3d.FieldGrid 18 | tidy3d.YeeGrid 19 | tidy3d.Grid 20 | tidy3d.LayerRefinementSpec 21 | tidy3d.GridRefinement 22 | tidy3d.CornerFinderSpec 23 | -------------------------------------------------------------------------------- /docs/api/eme/grid.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Grid Specification 4 | -------------------- 5 | 6 | .. autosummary:: 7 | :toctree: ../_autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.EMEUniformGrid 11 | tidy3d.EMECompositeGrid 12 | tidy3d.EMEExplicitGrid 13 | tidy3d.EMEGrid 14 | tidy3d.EMEModeSpec 15 | -------------------------------------------------------------------------------- /docs/api/eme/index.rst: -------------------------------------------------------------------------------- 1 | EME |:rainbow:| 2 | =============== 3 | 4 | .. toctree:: 5 | :hidden: 6 | 7 | simulation 8 | grid 9 | monitor 10 | sweep 11 | output_data 12 | 13 | 14 | .. include:: /api/eme/simulation.rst 15 | .. include:: /api/eme/grid.rst 16 | .. include:: /api/eme/monitor.rst 17 | .. include:: /api/eme/sweep.rst 18 | .. include:: /api/eme/output_data.rst 19 | -------------------------------------------------------------------------------- /docs/api/eme/monitor.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Monitors 4 | ---------- 5 | 6 | .. autosummary:: 7 | :toctree: ../_autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.EMECoefficientMonitor 11 | tidy3d.EMEModeSolverMonitor 12 | tidy3d.EMEFieldMonitor 13 | tidy3d.EMEMonitor 14 | -------------------------------------------------------------------------------- /docs/api/eme/output_data.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Output Data 4 | ------------- 5 | 6 | Monitor Data 7 | ^^^^^^^^^^^^^^^ 8 | 9 | .. autosummary:: 10 | :toctree: ../_autosummary/ 11 | :template: module.rst 12 | 13 | tidy3d.EMECoefficientData 14 | tidy3d.EMEModeSolverData 15 | tidy3d.EMEFieldData 16 | 17 | 18 | Simulation Data 19 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | 21 | .. autosummary:: 22 | :toctree: ../_autosummary/ 23 | :template: module.rst 24 | 25 | tidy3d.EMESimulationData 26 | -------------------------------------------------------------------------------- /docs/api/eme/simulation.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Simulation 4 | ----------- 5 | 6 | .. autosummary:: 7 | :toctree: ../_autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.EMESimulation 11 | -------------------------------------------------------------------------------- /docs/api/eme/sweep.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Propagation Sweeps 4 | -------------------- 5 | 6 | .. autosummary:: 7 | :toctree: ../_autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.EMELengthSweep 11 | tidy3d.EMEModeSweep 12 | -------------------------------------------------------------------------------- /docs/api/field_projector.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Field Projector 4 | =============== 5 | 6 | .. autosummary:: 7 | :toctree: _autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.FieldProjectionSurface 11 | tidy3d.FieldProjector 12 | -------------------------------------------------------------------------------- /docs/api/geometry.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Geometry 4 | ======== 5 | 6 | .. autosummary:: 7 | :toctree: _autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.Box 11 | tidy3d.Sphere 12 | tidy3d.Cylinder 13 | tidy3d.PolySlab 14 | tidy3d.TriangleMesh 15 | tidy3d.GeometryGroup 16 | tidy3d.ClipOperation 17 | tidy3d.Transformed 18 | 19 | Transformations 20 | ---------------- 21 | 22 | .. autosummary:: 23 | :toctree: _autosummary/ 24 | :template: module.rst 25 | 26 | tidy3d.RotationAroundAxis 27 | -------------------------------------------------------------------------------- /docs/api/heat/analysis.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Transient Heat Analysis 4 | ----------------- 5 | 6 | .. autosummary:: 7 | :toctree: ../_autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.UnsteadySpec 11 | tidy3d.UnsteadyHeatAnalysis -------------------------------------------------------------------------------- /docs/api/heat/boundary_conditions.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Boundary Conditions 4 | ----------------------------- 5 | 6 | Specifications 7 | ^^^^^^^^^^^^^^^^^ 8 | 9 | .. autosummary:: 10 | :toctree: ../_autosummary/ 11 | :template: module.rst 12 | 13 | tidy3d.HeatBoundarySpec 14 | tidy3d.HeatChargeBoundarySpec 15 | 16 | 17 | Types 18 | ^^^^^^^^^^^^^^^^^ 19 | 20 | .. autosummary:: 21 | :toctree: ../_autosummary/ 22 | :template: module.rst 23 | 24 | tidy3d.TemperatureBC 25 | tidy3d.ConvectionBC 26 | tidy3d.HeatFluxBC 27 | 28 | 29 | Placement 30 | ^^^^^^^^^^^^^^^^^ 31 | 32 | .. autosummary:: 33 | :toctree: ../_autosummary/ 34 | :template: module.rst 35 | 36 | tidy3d.StructureStructureInterface 37 | tidy3d.StructureBoundary 38 | tidy3d.MediumMediumInterface 39 | tidy3d.StructureSimulationBoundary 40 | tidy3d.SimulationBoundary -------------------------------------------------------------------------------- /docs/api/heat/discretization.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Grid Specification 4 | -------------------- 5 | 6 | .. autosummary:: 7 | :toctree: ../_autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.UniformUnstructuredGrid 11 | tidy3d.DistanceUnstructuredGrid 12 | tidy3d.GridRefinementRegion 13 | tidy3d.GridRefinementLine 14 | -------------------------------------------------------------------------------- /docs/api/heat/index.rst: -------------------------------------------------------------------------------- 1 | Heat |:fire:| 2 | ============= 3 | 4 | .. toctree:: 5 | :hidden: 6 | 7 | simulation 8 | mediums 9 | boundary_conditions 10 | source 11 | discretization 12 | monitor 13 | output_data 14 | 15 | 16 | .. include:: /api/heat/simulation.rst 17 | .. include:: /api/heat/mediums.rst 18 | .. include:: /api/heat/boundary_conditions.rst 19 | .. include:: /api/heat/source.rst 20 | .. include:: /api/heat/discretization.rst 21 | .. include:: /api/heat/monitor.rst 22 | .. include:: /api/heat/output_data.rst 23 | -------------------------------------------------------------------------------- /docs/api/heat/mediums.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Material Thermal 4 | ------------------------------- 5 | 6 | .. autosummary:: 7 | :toctree: ../_autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.FluidMedium 11 | tidy3d.SolidMedium 12 | 13 | tidy3d.FluidSpec 14 | tidy3d.SolidSpec 15 | 16 | 17 | Thermal Perturbation Specification 18 | ------------------------------------ 19 | 20 | .. autosummary:: 21 | :toctree: ../_autosummary/ 22 | :template: module.rst 23 | 24 | tidy3d.LinearHeatPerturbation 25 | tidy3d.CustomHeatPerturbation 26 | 27 | -------------------------------------------------------------------------------- /docs/api/heat/monitor.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Monitors 4 | ---------- 5 | 6 | .. autosummary:: 7 | :toctree: ../_autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.TemperatureMonitor -------------------------------------------------------------------------------- /docs/api/heat/output_data.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Output Data 4 | ------------- 5 | 6 | 7 | Simulation Data 8 | ^^^^^^^^^^^^^^^^^^^^ 9 | 10 | .. autosummary:: 11 | :toctree: ../_autosummary/ 12 | :template: module.rst 13 | 14 | tidy3d.HeatSimulationData 15 | tidy3d.HeatChargeSimulationData 16 | 17 | 18 | Monitor Data 19 | ^^^^^^^^^^^^ 20 | 21 | .. autosummary:: 22 | :toctree: ../_autosummary/ 23 | :template: module.rst 24 | 25 | tidy3d.TemperatureData 26 | 27 | 28 | Unstructured Data Classes 29 | ^^^^^^^^^^^^^^^^^^^^^^^^^ 30 | 31 | .. autosummary:: 32 | :toctree: ../_autosummary/ 33 | :template: module.rst 34 | 35 | tidy3d.TriangularGridDataset 36 | tidy3d.TetrahedralGridDataset 37 | 38 | 39 | Individual Datasets 40 | ^^^^^^^^^^^^^^^^^^^ 41 | 42 | .. autosummary:: 43 | :toctree: ../_autosummary/ 44 | :template: module.rst 45 | 46 | tidy3d.PointDataArray 47 | tidy3d.CellDataArray 48 | tidy3d.IndexedDataArray 49 | -------------------------------------------------------------------------------- /docs/api/heat/simulation.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Simulation 4 | ----------- 5 | 6 | .. autosummary:: 7 | :toctree: ../_autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.HeatSimulation 11 | tidy3d.HeatChargeSimulation -------------------------------------------------------------------------------- /docs/api/heat/source.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Thermal Sources 4 | ----------------- 5 | 6 | .. autosummary:: 7 | :toctree: ../_autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.UniformHeatSource 11 | tidy3d.HeatSource 12 | tidy3d.HeatFromElectricSource -------------------------------------------------------------------------------- /docs/api/index.rst: -------------------------------------------------------------------------------- 1 | *************** 2 | API |:computer:| 3 | *************** 4 | 5 | .. toctree:: 6 | :hidden: 7 | 8 | simulation 9 | boundary_conditions 10 | geometry 11 | mediums 12 | material_library 13 | rf_material_library 14 | structures 15 | sources 16 | analytic_beams 17 | monitors 18 | mode 19 | field_projector 20 | lumped_elements 21 | discretization 22 | subpixel_averaging 23 | output_data 24 | scene 25 | logging 26 | submit_simulations 27 | heat/index 28 | charge/index 29 | eme/index 30 | microwave/index 31 | plugins/index 32 | spice 33 | constants 34 | abstract_base 35 | abstract_models 36 | viz 37 | 38 | .. include:: /api/simulation.rst 39 | .. include:: /api/boundary_conditions.rst 40 | .. include:: /api/geometry.rst 41 | .. include:: /api/mediums.rst 42 | .. include:: /api/structures.rst 43 | .. include:: /api/sources.rst 44 | .. include:: /api/analytic_beams.rst 45 | .. include:: /api/monitors.rst 46 | .. include:: /api/mode.rst 47 | .. include:: /api/field_projector.rst 48 | .. include:: /api/lumped_elements.rst 49 | .. include:: /api/discretization.rst 50 | .. include:: /api/subpixel_averaging.rst 51 | .. include:: /api/output_data.rst 52 | .. include:: /api/scene.rst 53 | .. include:: /api/logging.rst 54 | .. include:: /api/submit_simulations.rst 55 | .. include:: /api/heat/index.rst 56 | .. include:: /api/charge/index.rst 57 | .. include:: /api/eme/index.rst 58 | .. include:: /api/microwave/index.rst 59 | .. include:: /api/plugins/index.rst 60 | .. include:: /api/constants.rst 61 | .. include:: /api/abstract_base.rst 62 | .. include:: /api/abstract_models.rst 63 | .. include:: /api/viz.rst -------------------------------------------------------------------------------- /docs/api/logging.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Logging 4 | ======= 5 | 6 | .. autosummary:: 7 | :toctree: _autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.log 11 | tidy3d.set_logging_level 12 | tidy3d.set_logging_file 13 | 14 | -------------------------------------------------------------------------------- /docs/api/lumped_elements.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Lumped Elements 4 | =============== 5 | 6 | Passive elements 7 | ---------------- 8 | .. autosummary:: 9 | :toctree: _autosummary/ 10 | :template: module.rst 11 | 12 | tidy3d.LumpedResistor 13 | tidy3d.CoaxialLumpedResistor 14 | tidy3d.RLCNetwork 15 | tidy3d.AdmittanceNetwork 16 | tidy3d.LinearLumpedElement -------------------------------------------------------------------------------- /docs/api/microwave/index.rst: -------------------------------------------------------------------------------- 1 | Microwave |:satellite:| 2 | ======================= 3 | 4 | .. warning:: 5 | 6 | RF simulations are subject to new license requirements in the future. These components are within the RF scope. 7 | 8 | 9 | .. toctree:: 10 | :hidden: 11 | 12 | output_data 13 | 14 | 15 | .. include:: /api/microwave/output_data.rst 16 | -------------------------------------------------------------------------------- /docs/api/microwave/output_data.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Output Data 4 | ----------- 5 | 6 | .. autosummary:: 7 | :toctree: ../_autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.AntennaMetricsData 11 | -------------------------------------------------------------------------------- /docs/api/mode.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Mode Specifications 4 | =================== 5 | 6 | .. autosummary:: 7 | :toctree: _autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.ModeSpec -------------------------------------------------------------------------------- /docs/api/monitors.rst: -------------------------------------------------------------------------------- 1 | 2 | .. currentmodule:: tidy3d 3 | 4 | Monitors 5 | ======== 6 | 7 | Monitor Types 8 | ------------- 9 | 10 | .. autosummary:: 11 | :toctree: _autosummary/ 12 | :template: module.rst 13 | 14 | tidy3d.FieldMonitor 15 | tidy3d.FieldTimeMonitor 16 | tidy3d.FluxMonitor 17 | tidy3d.FluxTimeMonitor 18 | tidy3d.ModeMonitor 19 | tidy3d.ModeSolverMonitor 20 | tidy3d.PermittivityMonitor 21 | tidy3d.FieldProjectionCartesianMonitor 22 | tidy3d.FieldProjectionAngleMonitor 23 | tidy3d.FieldProjectionKSpaceMonitor 24 | tidy3d.DiffractionMonitor 25 | tidy3d.DirectivityMonitor 26 | tidy3d.AuxFieldTimeMonitor 27 | 28 | Apodization Specification 29 | ------------------------- 30 | 31 | .. autosummary:: 32 | :toctree: _autosummary/ 33 | :template: module.rst 34 | 35 | tidy3d.ApodizationSpec 36 | -------------------------------------------------------------------------------- /docs/api/output_data.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Output Data 4 | =========== 5 | 6 | All Data for a Simulation 7 | ------------------------- 8 | 9 | .. autosummary:: 10 | :toctree: _autosummary/ 11 | :template: module.rst 12 | 13 | tidy3d.SimulationData 14 | 15 | Collections of Data from single monitor 16 | --------------------------------------- 17 | 18 | .. autosummary:: 19 | :toctree: _autosummary/ 20 | :template: module.rst 21 | 22 | tidy3d.FieldData 23 | tidy3d.FieldTimeData 24 | tidy3d.ModeSolverData 25 | tidy3d.PermittivityData 26 | tidy3d.FluxData 27 | tidy3d.FluxTimeData 28 | tidy3d.ModeData 29 | tidy3d.FieldProjectionAngleData 30 | tidy3d.FieldProjectionCartesianData 31 | tidy3d.FieldProjectionKSpaceData 32 | tidy3d.DiffractionData 33 | tidy3d.DirectivityData 34 | tidy3d.AuxFieldTimeData 35 | 36 | Individual Datasets 37 | ------------------- 38 | 39 | .. autosummary:: 40 | :toctree: _autosummary/ 41 | :template: module.rst 42 | 43 | tidy3d.SpatialDataArray 44 | tidy3d.PermittivityDataset 45 | tidy3d.ScalarFieldDataArray 46 | tidy3d.ScalarModeFieldDataArray 47 | tidy3d.ScalarFieldTimeDataArray 48 | tidy3d.ModeAmpsDataArray 49 | tidy3d.ModeIndexDataArray 50 | tidy3d.FluxDataArray 51 | tidy3d.FluxTimeDataArray 52 | tidy3d.FieldProjectionAngleDataArray 53 | tidy3d.FieldProjectionCartesianDataArray 54 | tidy3d.FieldProjectionKSpaceDataArray 55 | tidy3d.DiffractionDataArray 56 | tidy3d.DirectivityDataArray 57 | tidy3d.AxialRatioDataArray 58 | -------------------------------------------------------------------------------- /docs/api/plugins/adjoint.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Adjoint 4 | ------- 5 | 6 | .. toctree:: 7 | 8 | ./../../../tidy3d/plugins/adjoint/README.md 9 | 10 | .. autosummary:: 11 | :toctree: ../_autosummary/ 12 | :template: module.rst 13 | 14 | tidy3d.plugins.adjoint.web.run 15 | tidy3d.plugins.adjoint.web.run_async 16 | tidy3d.plugins.adjoint.JaxBox 17 | tidy3d.plugins.adjoint.JaxPolySlab 18 | tidy3d.plugins.adjoint.JaxComplexPolySlab 19 | tidy3d.plugins.adjoint.JaxMedium 20 | tidy3d.plugins.adjoint.JaxAnisotropicMedium 21 | tidy3d.plugins.adjoint.JaxCustomMedium 22 | tidy3d.plugins.adjoint.JaxStructure 23 | tidy3d.plugins.adjoint.JaxSimulation 24 | tidy3d.plugins.adjoint.JaxSimulationData 25 | tidy3d.plugins.adjoint.JaxModeData 26 | tidy3d.plugins.adjoint.JaxPermittivityDataset 27 | tidy3d.plugins.adjoint.JaxDataArray 28 | tidy3d.plugins.adjoint.utils.filter.ConicFilter 29 | tidy3d.plugins.adjoint.utils.filter.BinaryProjector 30 | tidy3d.plugins.adjoint.utils.penalty.RadiusPenalty 31 | -------------------------------------------------------------------------------- /docs/api/plugins/autograd.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Automatic Differentiation with Autograd 4 | --------------------------------------- 5 | 6 | .. toctree:: 7 | 8 | ./../../../tidy3d/plugins/autograd/README 9 | 10 | .. autosummary:: 11 | :toctree: ../_autosummary/ 12 | :template: module.rst 13 | 14 | tidy3d.plugins.autograd.functions.threshold 15 | tidy3d.plugins.autograd.functions.rescale 16 | tidy3d.plugins.autograd.functions.morphological_gradient_external 17 | tidy3d.plugins.autograd.functions.morphological_gradient_internal 18 | tidy3d.plugins.autograd.functions.morphological_gradient 19 | tidy3d.plugins.autograd.functions.grey_closing 20 | tidy3d.plugins.autograd.functions.grey_opening 21 | tidy3d.plugins.autograd.functions.grey_erosion 22 | tidy3d.plugins.autograd.functions.grey_dilation 23 | tidy3d.plugins.autograd.functions.pad 24 | tidy3d.plugins.autograd.functions.convolve 25 | 26 | tidy3d.plugins.autograd.utilities.chain 27 | tidy3d.plugins.autograd.utilities.make_kernel 28 | tidy3d.plugins.autograd.utilities.get_kernel_size_px 29 | 30 | tidy3d.plugins.autograd.primitives.gaussian_filter 31 | 32 | tidy3d.plugins.autograd.invdes.grey_indicator 33 | tidy3d.plugins.autograd.invdes.make_circular_filter 34 | tidy3d.plugins.autograd.invdes.make_conic_filter 35 | tidy3d.plugins.autograd.invdes.make_curvature_penalty 36 | tidy3d.plugins.autograd.invdes.make_erosion_dilation_penalty 37 | tidy3d.plugins.autograd.invdes.make_filter 38 | tidy3d.plugins.autograd.invdes.make_filter_and_project 39 | tidy3d.plugins.autograd.invdes.ramp_projection 40 | tidy3d.plugins.autograd.invdes.tanh_projection 41 | 42 | tidy3d.plugins.autograd.types.PaddingType 43 | tidy3d.plugins.autograd.types.KernelType 44 | 45 | -------------------------------------------------------------------------------- /docs/api/plugins/design.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Design Space Exploration 4 | ------------------------ 5 | 6 | .. toctree:: 7 | 8 | ../../../tidy3d/plugins/design/README 9 | 10 | .. autosummary:: 11 | :toctree: ../_autosummary/ 12 | :template: module.rst 13 | 14 | tidy3d.plugins.design.parameter.Parameter 15 | tidy3d.plugins.design.ParameterFloat 16 | tidy3d.plugins.design.ParameterInt 17 | tidy3d.plugins.design.ParameterAny 18 | tidy3d.plugins.design.method.Method 19 | tidy3d.plugins.design.MethodGrid 20 | tidy3d.plugins.design.MethodMonteCarlo 21 | tidy3d.plugins.design.MethodBayOpt 22 | tidy3d.plugins.design.MethodGenAlg 23 | tidy3d.plugins.design.MethodParticleSwarm 24 | tidy3d.plugins.design.DesignSpace 25 | tidy3d.plugins.design.Result 26 | -------------------------------------------------------------------------------- /docs/api/plugins/dispersion.rst: -------------------------------------------------------------------------------- 1 | 2 | .. currentmodule:: tidy3d 3 | 4 | Dispersive Model Fitting 5 | ------------------------ 6 | 7 | .. autosummary:: 8 | :toctree: ../_autosummary/ 9 | :template: module.rst 10 | 11 | tidy3d.plugins.dispersion.FastDispersionFitter 12 | tidy3d.plugins.dispersion.AdvancedFastFitterParam 13 | tidy3d.plugins.dispersion.DispersionFitter 14 | tidy3d.plugins.dispersion.AdvancedFitterParam 15 | tidy3d.plugins.dispersion.web.run 16 | tidy3d.plugins.dispersion.StableDispersionFitter -------------------------------------------------------------------------------- /docs/api/plugins/index.rst: -------------------------------------------------------------------------------- 1 | Plugins 2 | ======= 3 | 4 | .. toctree:: 5 | :hidden: 6 | 7 | ./mode_solver 8 | ./dispersion 9 | ./polyslab 10 | ./smatrix 11 | ./resonance 12 | ./autograd 13 | ./adjoint 14 | ./invdes 15 | ./design 16 | ./waveguide 17 | ./microwave 18 | 19 | 20 | .. include:: /api/plugins/mode_solver.rst 21 | .. include:: /api/plugins/dispersion.rst 22 | .. include:: /api/plugins/polyslab.rst 23 | .. include:: /api/plugins/smatrix.rst 24 | .. include:: /api/plugins/resonance.rst 25 | .. include:: /api/plugins/autograd.rst 26 | .. include:: /api/plugins/adjoint.rst 27 | .. include:: /api/plugins/invdes.rst 28 | .. include:: /api/plugins/design.rst 29 | .. include:: /api/plugins/waveguide.rst 30 | .. include:: /api/plugins/microwave.rst -------------------------------------------------------------------------------- /docs/api/plugins/invdes.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Inverse Design Plugin 4 | --------------------- 5 | 6 | .. toctree:: 7 | 8 | ./../../../tidy3d/plugins/invdes/README.md 9 | 10 | .. autosummary:: 11 | :toctree: ../_autosummary/ 12 | :template: module.rst 13 | 14 | tidy3d.plugins.invdes.FilterProject 15 | tidy3d.plugins.invdes.ErosionDilationPenalty 16 | tidy3d.plugins.invdes.TopologyDesignRegion 17 | tidy3d.plugins.invdes.InverseDesign 18 | tidy3d.plugins.invdes.InverseDesignMulti 19 | tidy3d.plugins.invdes.InverseDesignResult 20 | tidy3d.plugins.invdes.AdamOptimizer 21 | tidy3d.plugins.invdes.utils.get_amps 22 | tidy3d.plugins.invdes.utils.get_field_component 23 | tidy3d.plugins.invdes.utils.get_intensity 24 | tidy3d.plugins.invdes.utils.sum_array 25 | tidy3d.plugins.invdes.utils.sum_abs_squared 26 | tidy3d.plugins.invdes.utils.get_phase 27 | -------------------------------------------------------------------------------- /docs/api/plugins/microwave.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Microwave 4 | ---------------------------- 5 | 6 | .. warning:: 7 | 8 | RF simulations are subject to new license requirements in the future. These components are within the RF scope. 9 | 10 | 11 | .. autosummary:: 12 | :toctree: ../_autosummary/ 13 | :template: module.rst 14 | 15 | tidy3d.plugins.microwave.AxisAlignedPathIntegral 16 | tidy3d.plugins.microwave.VoltageIntegralAxisAligned 17 | tidy3d.plugins.microwave.CurrentIntegralAxisAligned 18 | tidy3d.plugins.microwave.CustomPathIntegral2D 19 | tidy3d.plugins.microwave.CustomVoltageIntegral2D 20 | tidy3d.plugins.microwave.CustomCurrentIntegral2D 21 | tidy3d.plugins.microwave.ImpedanceCalculator 22 | tidy3d.plugins.microwave.RectangularAntennaArrayCalculator 23 | tidy3d.plugins.microwave.LobeMeasurer 24 | -------------------------------------------------------------------------------- /docs/api/plugins/mode_solver.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Mode Solver 4 | ----------- 5 | 6 | .. autosummary:: 7 | :toctree: ../_autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.plugins.mode.ModeSolver 11 | tidy3d.plugins.mode.ModeSolverData -------------------------------------------------------------------------------- /docs/api/plugins/polyslab.rst: -------------------------------------------------------------------------------- 1 | 2 | .. currentmodule:: tidy3d 3 | 4 | Self-intersecting Polyslab 5 | -------------------------- 6 | 7 | .. autosummary:: 8 | :toctree: ../_autosummary/ 9 | :template: module.rst 10 | 11 | tidy3d.plugins.polyslab.ComplexPolySlab -------------------------------------------------------------------------------- /docs/api/plugins/resonance.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | 4 | Resonance Finder 5 | ---------------- 6 | 7 | .. autosummary:: 8 | :toctree: ../_autosummary/ 9 | :template: module.rst 10 | 11 | tidy3d.plugins.resonance.ResonanceFinder -------------------------------------------------------------------------------- /docs/api/plugins/smatrix.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Scattering Matrix Calculator 4 | ---------------------------- 5 | 6 | .. autosummary:: 7 | :toctree: ../_autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.plugins.smatrix.ComponentModeler 11 | tidy3d.plugins.smatrix.Port 12 | tidy3d.plugins.smatrix.ModalPortDataArray 13 | 14 | 15 | .. warning:: 16 | 17 | RF simulations are subject to new license requirements in the future. 18 | The components below are within the RF scope. 19 | 20 | 21 | .. autosummary:: 22 | :toctree: ../_autosummary/ 23 | :template: module.rst 24 | 25 | tidy3d.plugins.smatrix.TerminalComponentModeler 26 | tidy3d.plugins.smatrix.PortDataArray 27 | tidy3d.plugins.smatrix.TerminalPortDataArray 28 | tidy3d.plugins.smatrix.LumpedPort 29 | tidy3d.plugins.smatrix.CoaxialLumpedPort 30 | tidy3d.plugins.smatrix.WavePort 31 | -------------------------------------------------------------------------------- /docs/api/plugins/waveguide.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Waveguide 4 | --------- 5 | 6 | .. autosummary:: 7 | :toctree: ../_autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.plugins.waveguide.RectangularDielectric -------------------------------------------------------------------------------- /docs/api/scene.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Scene 4 | ===== 5 | 6 | .. autosummary:: 7 | :toctree: _autosummary/ 8 | :template: module.rst 9 | 10 | Scene -------------------------------------------------------------------------------- /docs/api/simulation.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Simulation 4 | ========== 5 | 6 | .. autosummary:: 7 | :toctree: _autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.Simulation 11 | tidy3d.RunTimeSpec 12 | -------------------------------------------------------------------------------- /docs/api/sources.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Sources 4 | ======= 5 | 6 | 7 | Types of Sources 8 | ---------------- 9 | 10 | .. autosummary:: 11 | :toctree: _autosummary/ 12 | :template: module.rst 13 | 14 | tidy3d.PointDipole 15 | tidy3d.UniformCurrentSource 16 | tidy3d.PlaneWave 17 | tidy3d.ModeSource 18 | tidy3d.GaussianBeam 19 | tidy3d.AstigmaticGaussianBeam 20 | tidy3d.CustomFieldSource 21 | tidy3d.CustomCurrentSource 22 | tidy3d.TFSF 23 | 24 | 25 | Source Time Dependence 26 | ---------------------- 27 | 28 | .. autosummary:: 29 | :toctree: _autosummary/ 30 | :template: module.rst 31 | 32 | tidy3d.GaussianPulse 33 | tidy3d.ContinuousWave 34 | tidy3d.SourceTime 35 | tidy3d.CustomSourceTime 36 | 37 | 38 | Angled Plane Wave Specifications 39 | -------------------------------- 40 | 41 | .. autosummary:: 42 | :toctree: _autosummary/ 43 | :template: module.rst 44 | 45 | tidy3d.FixedInPlaneK 46 | tidy3d.FixedAngle 47 | -------------------------------------------------------------------------------- /docs/api/spice.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | SPICE |:electric_plug:| 4 | =========================== 5 | 6 | Sources 7 | ---------------- 8 | 9 | .. autosummary:: 10 | :toctree: _autosummary/ 11 | :template: module.rst 12 | 13 | tidy3d.DCVoltageSource 14 | 15 | 16 | Analysis 17 | ---------------- 18 | 19 | .. autosummary:: 20 | :toctree: _autosummary/ 21 | :template: module.rst 22 | 23 | tidy3d.IsothermalSteadyChargeDCAnalysis 24 | -------------------------------------------------------------------------------- /docs/api/structures.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Structures 4 | ========== 5 | 6 | .. autosummary:: 7 | :toctree: _autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.Structure 11 | tidy3d.MeshOverrideStructure -------------------------------------------------------------------------------- /docs/api/submit_simulations.rst: -------------------------------------------------------------------------------- 1 | 2 | .. currentmodule:: tidy3d 3 | 4 | Submitting Simulations 5 | ====================== 6 | 7 | Generic Web API 8 | ---------------- 9 | 10 | .. autosummary:: 11 | :toctree: _autosummary/ 12 | :template: module.rst 13 | 14 | tidy3d.web.api.webapi.run 15 | tidy3d.web.api.webapi.upload 16 | tidy3d.web.api.webapi.estimate_cost 17 | tidy3d.web.api.webapi.real_cost 18 | tidy3d.web.api.webapi.get_info 19 | tidy3d.web.api.webapi.start 20 | tidy3d.web.api.webapi.monitor 21 | tidy3d.web.api.webapi.download 22 | tidy3d.web.api.webapi.load 23 | tidy3d.web.api.webapi.delete 24 | tidy3d.web.api.webapi.download_log 25 | tidy3d.web.api.webapi.download_json 26 | tidy3d.web.api.webapi.load_simulation 27 | tidy3d.web.api.asynchronous.run_async 28 | 29 | Job and Batch Containers 30 | ------------------------- 31 | 32 | .. autosummary:: 33 | :toctree: _autosummary/ 34 | :template: module.rst 35 | 36 | tidy3d.web.api.container.Job 37 | tidy3d.web.api.container.Batch 38 | tidy3d.web.api.container.BatchData 39 | 40 | Information Containers 41 | ---------------------- 42 | 43 | .. autosummary:: 44 | :toctree: _autosummary/ 45 | :template: module.rst 46 | 47 | tidy3d.web.core.task_info.TaskInfo 48 | tidy3d.web.core.task_info.TaskStatus 49 | 50 | 51 | Mode Solver Web API 52 | -------------------- 53 | 54 | .. autosummary:: 55 | :toctree: _autosummary/ 56 | :template: module.rst 57 | 58 | tidy3d.web.api.mode.run 59 | tidy3d.web.api.mode.run_batch 60 | tidy3d.web.api.mode.ModeSolverTask -------------------------------------------------------------------------------- /docs/api/subpixel_averaging.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Subpixel Averaging 4 | ================== 5 | 6 | .. autosummary:: 7 | :toctree: _autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.SubpixelSpec 11 | 12 | Types of Subpixel Averaging Methods 13 | ----------------------------------- 14 | 15 | .. autosummary:: 16 | :toctree: _autosummary/ 17 | :template: module.rst 18 | 19 | tidy3d.Staircasing 20 | tidy3d.VolumetricAveraging 21 | tidy3d.HeuristicPECStaircasing 22 | tidy3d.PolarizedAveraging 23 | tidy3d.ContourPathAveraging 24 | tidy3d.PECConformal 25 | tidy3d.SurfaceImpedance 26 | -------------------------------------------------------------------------------- /docs/api/viz.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: tidy3d 2 | 3 | Visualization and Plotting 4 | ========================== 5 | 6 | .. autosummary:: 7 | :toctree: _autosummary/ 8 | :template: module.rst 9 | 10 | tidy3d.restore_matplotlib_rcparams 11 | tidy3d.VisualizationSpec -------------------------------------------------------------------------------- /docs/changelog.rst: -------------------------------------------------------------------------------- 1 | ******************** 2 | Changelog |:rewind:| 3 | ******************** 4 | 5 | Documentation Versions 6 | ###################### 7 | 8 | You can find the documentation for all the supported versions of ``tidy3d`` within this website. 9 | To switch between versions, use the version selector in the bottom left corner of the page as per the image below. 10 | The version selector is only available on the main page of the documentation. 11 | 12 | .. image:: ./_static/img/documentation_versions.png 13 | :width: 50% 14 | :alt: Version Selector 15 | 16 | After version ``>=2.6``, the documentation was restructured so old internal documentation links will not match to the 17 | new internal documentation page links. To access the new documentation, we recommend navigating to the `main page <../>`_ and switching versions from there before navigating to the page. 18 | 19 | 20 | 21 | Version Release Notes 22 | ####################### 23 | 24 | .. include:: ../CHANGELOG.md 25 | :parser: myst_parser.sphinx_ 26 | -------------------------------------------------------------------------------- /docs/development/index.rst: -------------------------------------------------------------------------------- 1 | ******************************************************************** 2 | Development Guide |:hammer_and_wrench:| 3 | ******************************************************************** 4 | 5 | Welecome to the ``tidy3d`` developers guide! 6 | 7 | 8 | .. toctree:: 9 | :maxdepth: 2 10 | 11 | introduction/index 12 | installation 13 | usage 14 | recommendations 15 | release/index 16 | 17 | .. include:: /development/introduction/index.rst 18 | .. include:: /development/installation.rst 19 | .. include:: /development/usage.rst 20 | .. include:: /development/recommendations.rst 21 | .. include:: /development/release/index.rst 22 | -------------------------------------------------------------------------------- /docs/development/introduction/index.rst: -------------------------------------------------------------------------------- 1 | An Introduction to the Development Flow 2 | ======================================== 3 | 4 | This page hopefully will get you started to develop Tidy3D. 5 | 6 | **TLDR:** 7 | 8 | - Branch off of the target branch (usually ``develop`` or ``pre/x.x``), work on your branch, and submit a PR when ready. 9 | - Use isolated development environments with ``poetry``. 10 | - Use ``ruff`` to lint and format code, and install the pre-commit hook via ``pre-commit install`` to automate this. 11 | - Document code using NumPy-style docstrings. 12 | - Write unit tests for new features and try to maintain high test coverage. 13 | 14 | .. toctree:: 15 | :maxdepth: 1 16 | 17 | understanding_virtual_environments 18 | understanding_poetry 19 | code_quality_principles 20 | project_structure 21 | 22 | 23 | .. include:: /development/introduction/understanding_virtual_environments.rst 24 | .. include:: /development/introduction/understanding_poetry.rst 25 | .. include:: /development/introduction/code_quality_principles.rst 26 | .. include:: /development/introduction/project_structure.rst -------------------------------------------------------------------------------- /docs/development/release/documentation.rst: -------------------------------------------------------------------------------- 1 | Documentation Release 2 | --------------------- 3 | 4 | The `tidy3d-docs` repository automatically mirrors the `tidy3d` repository. Specifically, these branches are automatically synced. 5 | 6 | - main 7 | - latest 8 | - develop 9 | - 'pre/*' 10 | - 'v*' 11 | 12 | These branches are synced to the tidy3d-docs repo through the sync-readthedocs-repo Github action. 13 | You can read the latest versions synced in the action file. 14 | However, you need to configure how they appear in the documentation build in the readthedocs admin page. 15 | Only latest is the public version, others are private. 16 | 17 | The `latest` branch holds the state of the docs that we want to host in `latest` version on the website. These are the latest docs (including new notebooks, typo fixes, etc.) related to the last official release (not pre-release). 18 | 19 | The `stable` version of the docs on our website is built based on the last version tag which is not a pre-release tag (no `rc` ending). 20 | 21 | Hot Fix & Submodule Updates 22 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | 24 | To make a “hot fix” (eg fix a typo, add a notebook, update the release FAQ), just update the ``latest`` branch in ``tidy3d`` repo. This should automatically sync to `tidy3d-docs`, and trigger a docs rebuild. **However, we should avoid this as this will cause the ``develop`` and ``latest branches`` to diverge.** Ideally, these hot fixes could wait until the next pre/post-release to be propagated through. 25 | 26 | NOTE: To avoid conflicts, ideally we should only update ``latest`` by merging ``develop`` in it, or at the very least we should make sure changes are propagated to both branches. -------------------------------------------------------------------------------- /docs/development/release/index.rst: -------------------------------------------------------------------------------- 1 | Release Flow 2 | ============== 3 | 4 | This page contains all the relevant information relating to each version release process for ``tidy3d``. 5 | 6 | .. You just need to make sure that the ```` branches of both ``tidy3d/`` and ``tidy3d-notebooks/`` repositories within the ``./`` and ``./docs/notebooks/`` directories are updated. The ``readthedocs`` documentation will be automatically updated through the ``sync-readthedocs-repo`` Github action. 7 | 8 | .. toctree:: 9 | :maxdepth: 1 10 | :hidden: 11 | 12 | flow 13 | version 14 | documentation 15 | notebooks 16 | 17 | 18 | .. include:: /development/release/flow.rst 19 | .. include:: /development/release/documentation.rst 20 | .. include:: /development/release/notebooks.rst 21 | -------------------------------------------------------------------------------- /docs/development/release/notebooks.rst: -------------------------------------------------------------------------------- 1 | Notebooks Development 2 | ---------------------- 3 | 4 | All notebooks are now developed under the `tidy3d-notebooks `_, and you can also develop this submodule under ``tidy3d/notebooks``. Note that the submodule is linked to the ``develop`` branch of ``tidy3d-notebooks``. 5 | 6 | Say, you have done some changes onto the repository in `tidy3d-notebooks` and propagated them to the remote branch, you can run the following command: 7 | 8 | .. code-block:: 9 | 10 | poetry run tidy3d develop build-docs-from-remote-notebooks 11 | 12 | This command will pull the latest changes onto your notebook submodule and build the documentation. -------------------------------------------------------------------------------- /docs/lectures/fdtd101.rst: -------------------------------------------------------------------------------- 1 | ******** 2 | FDTD 101 3 | ******** 4 | 5 | FDTD 101 is an introduction to the Finite-Difference Time-Domain Method for Electromagnetics. We will walk you through the basics of setting up and running electromagnetic simulations using the FDTD method. Through this course, you will gain a knowledge of the fundamental concepts behind electromagnetic simulation as well as many advanced topics worth considering when you set up your simulations. 6 | 7 | `Lecture 1: Introduction to FDTD Simulation `_ 8 | 9 | `Lecture 2: Using FDTD to Compute a Transmission Spectrum `_ 10 | 11 | `Lecture 3: Applying FDTD to Photonic Crystal Slab Simulation `_ 12 | 13 | `Lecture 4: Prelude to Integrated Photonics Simulation: Mode Injection `_ 14 | 15 | `Lecture 5: Modeling dispersive material in FDTD `_ 16 | 17 | `Lecture 6: Introduction to perfectly matched layer (PML) `_ 18 | 19 | `Lecture 7: Time step size and CFL condition in FDTD `_ 20 | 21 | `Lecture 8: Numerical dispersion in FDTD `_ 22 | 23 | `Lecture 9: Dielectric constant assignment on Yee grids `_ 24 | 25 | `Lecture 10: Introduction to subpixel averaging `_ -------------------------------------------------------------------------------- /docs/lectures/fdtd_workshop.rst: -------------------------------------------------------------------------------- 1 | *************************** 2 | Future-Ready FDTD Workshop 3 | *************************** 4 | 5 | The Future-Ready FDTD Workshop Series is a collaborative effort between Tidy3D, iOptics, and Optica. The series aims to present a range of workshops focused on FDTD simulations for photonic devices. The workshop sessions took place from February 9th to March 8th, 2024, and covered theoretical foundations of concepts such as the FDTD method, Bragg filters and reflectors, multimode photonic design, photonic crystals, and inverse design. 6 | Each session included a live demonstration of setting up and running an FDTD simulation. Additionally, a challenge was proposed to enhance participants' skills. Challenge solutions are available upon request through our technical support. 7 | 8 | `Lecture 1: The FDTD Method Demystified `_ 9 | 10 | `Lecture 2: Multimode Photonics Design Made Easy `_ 11 | 12 | `Lecture 3: Designing Filters and Reflectors with Bragg Gratings `_ 13 | 14 | `Lecture 4: Photonic Crystal Slabs Controlling and Confining Light on the Nanoscale `_ 15 | 16 | `Lecture 5: Inverse Design in Photonics An Introduction `_ 17 | 18 | More lectures coming soon! 19 | -------------------------------------------------------------------------------- /docs/lectures/index.rst: -------------------------------------------------------------------------------- 1 | Lectures |:book:| 2 | ################## 3 | 4 | Welcome to our lecture series! 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | :hidden: 9 | 10 | fdtd101 11 | fdtd_workshop 12 | inversedesign 13 | 14 | 15 | .. include:: /lectures/fdtd101.rst 16 | .. include:: /lectures/fdtd_workshop.rst 17 | .. include:: /lectures/inversedesign.rst -------------------------------------------------------------------------------- /docs/lectures/inversedesign.rst: -------------------------------------------------------------------------------- 1 | *************************** 2 | Inverse design in photonics 3 | *************************** 4 | 5 | Adjoint optimization is a powerful tool that has gained significant attention in the photonics community. It leverages the adjoint method, a mathematical technique used to calculate gradients or derivatives of performance metrics with respect to design parameters. This method is particularly useful in photonics, where devices often have a large number of design parameters and complex performance metrics. This course is designed to provide a comprehensive understanding of the principles and applications of adjoint optimization in the field of photonics. 6 | 7 | `Lecture 1: Introduction to Inverse Design In Photonics `_ 8 | 9 | `Lecture 2: Adjoint Method `_ 10 | 11 | `Lecture 3: Adjoint Optimization `_ 12 | 13 | `Lecture 4: Fabrication Constraints `_ 14 | 15 | `Lecture 5: Shape Optimization `_ 16 | 17 | `Lecture 6: Level Set Parameterization `_ 18 | 19 | 20 | More lectures coming soon! 21 | -------------------------------------------------------------------------------- /docs/versions/2_5_to_2_6.json: -------------------------------------------------------------------------------- 1 | { 2 | "2.6.0": { 3 | "https://docs.flexcompute.com/projects/tidy3d/en/latest/_autosummary": "https://docs.flexcompute.com/projects/tidy3d/en/latest/api/_autosummary" 4 | } 5 | } -------------------------------------------------------------------------------- /docs/versions/README.md: -------------------------------------------------------------------------------- 1 | # Version Changes 2 | 3 | This directory contains the corresponding dictionaries to convert the docstrings between multiple versions. 4 | 5 | You can migrate between documentation versions by running the following command in the root directory of the repository: 6 | 7 | ```bash 8 | 9 | -------------------------------------------------------------------------------- /docs/versions/test_replace_in_files.json: -------------------------------------------------------------------------------- 1 | { 2 | "0.18.0": { 3 | "tidy3d.someuniquestringa": "tidy3d.someuniquestring2", 4 | "tidy3d.someuniquestringb": "tidy3d.someuniquestring2", 5 | "tidy3d.someuniquestringc": "tidy3d.someuniquestring2" 6 | } 7 | } -------------------------------------------------------------------------------- /poetry.toml: -------------------------------------------------------------------------------- 1 | [virtualenvs] 2 | create = true 3 | -------------------------------------------------------------------------------- /scripts/benchmark_import.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | 4 | def test_import(): 5 | import subprocess 6 | import time 7 | 8 | n = 100 9 | python_load_time = 0 10 | tidy3d_load_time = 0 11 | 12 | for _ in range(n): 13 | s = time.time() 14 | subprocess.call(["python", "-c", "import tidy3d"]) 15 | tidy3d_load_time += time.time() - s 16 | 17 | s = time.time() 18 | subprocess.call(["python", "-c", "pass"]) 19 | python_load_time += time.time() - s 20 | 21 | print(f"average tidy3d load time = {(tidy3d_load_time - python_load_time) / n}") 22 | 23 | 24 | if __name__ == "__main__": 25 | test_import() 26 | -------------------------------------------------------------------------------- /scripts/pre_release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | python scripts/schema.py 5 | python scripts/sample.py -------------------------------------------------------------------------------- /scripts/sample.py: -------------------------------------------------------------------------------- 1 | """Generates sample simulation json and h5 files in the tests/sims folder""" 2 | 3 | from __future__ import annotations 4 | 5 | import sys 6 | from os.path import join 7 | 8 | sys.path.append("tests") 9 | 10 | from utils import SAMPLE_SIMULATIONS 11 | 12 | FPREFIX_SIMULATION_SAMPLE = join("tests", "sims") 13 | 14 | for key, sim in SAMPLE_SIMULATIONS.items(): 15 | # Store a simulation sample as json and hdf5 16 | sim.to_json(join(FPREFIX_SIMULATION_SAMPLE, key) + ".json") 17 | sim.to_hdf5(join(FPREFIX_SIMULATION_SAMPLE, key) + ".h5") 18 | -------------------------------------------------------------------------------- /scripts/schema.py: -------------------------------------------------------------------------------- 1 | """Generates schema for Simulation, saves it to file.""" 2 | 3 | from __future__ import annotations 4 | 5 | import json 6 | 7 | import tidy3d 8 | 9 | FNAME = "tidy3d/schema.json" 10 | 11 | # https://pydantic-docs.helpmanual.io/usage/schema/ 12 | schema_dict = tidy3d.Simulation.schema() 13 | with open(FNAME, "w") as f: 14 | json.dump(schema_dict, f, indent=2) 15 | -------------------------------------------------------------------------------- /scripts/test_coverage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | pytest -rA --cov tests/ 5 | # to test without vtk, one has to restart pytest 6 | pytest -rA tests/_test_data/_test_datasets_no_vtk.py 7 | pytest --doctest-modules tidy3d/ docs/ 8 | coverage xml 9 | diff-cover --compare-branch=origin/develop coverage.xml 10 | -------------------------------------------------------------------------------- /scripts/test_format.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | ruff format tidy3d/ --check --diff 5 | ruff format tests/ --check --diff 6 | ruff format scripts/ --check --diff 7 | 8 | ruff check tidy3d --diff 9 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import sys 4 | 5 | sys.path.append("./") 6 | -------------------------------------------------------------------------------- /tests/_test_data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tests/_test_data/__init__.py -------------------------------------------------------------------------------- /tests/_test_data/_test_datasets_no_vtk.py: -------------------------------------------------------------------------------- 1 | """Tests tidy3d/components/data/dataset.py""" 2 | 3 | from __future__ import annotations 4 | 5 | import builtins 6 | 7 | import pytest 8 | 9 | from ..test_data.test_datasets import test_tetrahedral_dataset as _test_tetrahedral_dataset 10 | from ..test_data.test_datasets import test_triangular_dataset as _test_triangular_dataset 11 | 12 | 13 | @pytest.fixture 14 | def hide_vtk(monkeypatch, request): 15 | import_orig = builtins.__import__ 16 | 17 | def mocked_import(name, *args, **kwargs): 18 | if name in ["vtk", "vtkmodules.vtkCommonCore"]: 19 | raise ImportError 20 | return import_orig(name, *args, **kwargs) 21 | 22 | monkeypatch.setattr(builtins, "__import__", mocked_import) 23 | 24 | 25 | @pytest.mark.usefixtures("hide_vtk") 26 | def test_triangular_dataset_no_vtk(tmp_path): 27 | _test_triangular_dataset(tmp_path, "test_name", 0, no_vtk=True) 28 | 29 | 30 | @pytest.mark.usefixtures("hide_vtk") 31 | def test_tetrahedral_dataset_no_vtk(tmp_path): 32 | _test_tetrahedral_dataset(tmp_path, "test_name", 0, no_vtk=True) 33 | -------------------------------------------------------------------------------- /tests/_test_local/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tests/_test_local/__init__.py -------------------------------------------------------------------------------- /tests/_test_local/_test_plugins_web.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import numpy as np 4 | 5 | from tidy3d.plugins.fitter import DispersionFitter, StableDispersionFitter 6 | 7 | 8 | def test_dispersion_load_list(): 9 | """performs a fit on some random data""" 10 | num_data = 10 11 | n_data = np.random.random(num_data) 12 | wvls = np.linspace(1, 2, num_data) 13 | _ = StableDispersionFitter(wvl_um=wvls, n_data=n_data) 14 | 15 | 16 | def test_dispersion_load_file(): 17 | """loads dispersion model from nk data file""" 18 | _ = StableDispersionFitter.from_file("tests/data/nk_data.csv", skiprows=1, delimiter=",") 19 | 20 | 21 | def test_dispersion_load_url(): 22 | """performs a fit on some random data""" 23 | 24 | # both n and k 25 | url_csv = "https://refractiveindex.info/data_csv.php?datafile=data/main/Ag/Johnson.yml" 26 | url_txt = "https://refractiveindex.info/data_txt.php?datafile=data/main/Ag/Johnson.yml" 27 | fitter = DispersionFitter.from_url(url_csv, delimiter=",") 28 | fitter = StableDispersionFitter.from_url(url_csv, delimiter=",") 29 | fitter_txt = DispersionFitter.from_url(url_txt, delimiter="\t") 30 | fitter_txt = StableDispersionFitter.from_url(url_txt, delimiter="\t") 31 | fitter_txt.wvl_range = [0.3, 0.8] 32 | assert len(fitter_txt.freqs) < len(fitter.freqs) 33 | 34 | # only k 35 | url_csv = "https://refractiveindex.info/data_csv.php?datafile=data/main/N2/Peck-0C.yml" 36 | url_txt = "https://refractiveindex.info/data_txt.php?datafile=data/main/N2/Peck-0C.yml" 37 | fitter = DispersionFitter.from_url(url_csv, delimiter=",") 38 | fitter_txt = DispersionFitter.from_url(url_txt, delimiter="\t") 39 | -------------------------------------------------------------------------------- /tests/data/monitor_data.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tests/data/monitor_data.hdf5 -------------------------------------------------------------------------------- /tests/data/n_data.csv: -------------------------------------------------------------------------------- 1 | Wavelength,n 2 | 1,2.97925 3 | 1.12207,3.06649 4 | 1.24415,3.16381 5 | 1.36622,3.24205 6 | 1.48829,3.28913 7 | -------------------------------------------------------------------------------- /tests/data/tetrahedron.stl: -------------------------------------------------------------------------------- 1 | solid tetrahedron.stl 2 | facet normal 1.0 1.0 1.0 3 | outer loop 4 | vertex 1.0 0.0 0.0 5 | vertex 0.0 1.0 0.0 6 | vertex 0.0 0.0 1.0 7 | endloop 8 | endfacet 9 | facet normal -1.0 0.0 0.0 10 | outer loop 11 | vertex 0.0 0.0 0.0 12 | vertex 0.0 0.0 1.0 13 | vertex 0.0 1.0 0.0 14 | endloop 15 | endfacet 16 | facet normal 0.0 -1.0 0.0 17 | outer loop 18 | vertex 0.0 0.0 0.0 19 | vertex 1.0 0.0 0.0 20 | vertex 0.0 0.0 1.0 21 | endloop 22 | endfacet 23 | facet normal 0.0 0.0 -1.0 24 | outer loop 25 | vertex 0.0 0.0 0.0 26 | vertex 0.0 1.0 0.0 27 | vertex 1.0 0.0 0.0 28 | endloop 29 | endfacet 30 | endsolid tetrahedron.stl 31 | -------------------------------------------------------------------------------- /tests/sims/full_charge.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tests/sims/full_charge.h5 -------------------------------------------------------------------------------- /tests/sims/full_conduction.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tests/sims/full_conduction.h5 -------------------------------------------------------------------------------- /tests/sims/full_fdtd.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tests/sims/full_fdtd.h5 -------------------------------------------------------------------------------- /tests/sims/full_steady_heat.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tests/sims/full_steady_heat.h5 -------------------------------------------------------------------------------- /tests/sims/full_unsteady_heat.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tests/sims/full_unsteady_heat.h5 -------------------------------------------------------------------------------- /tests/test_components/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tests/test_components/__init__.py -------------------------------------------------------------------------------- /tests/test_components/material/test_multi_physics.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import copy 4 | 5 | import pytest 6 | 7 | import tidy3d as td 8 | 9 | 10 | @pytest.fixture 11 | def dummy_optical(): 12 | return td.Medium(permittivity=1.0) 13 | 14 | 15 | def test_delegated_attributes_work(dummy_optical): 16 | mp = td.MultiPhysicsMedium(optical=dummy_optical) 17 | 18 | # delegated names resolve 19 | assert mp.is_pec is dummy_optical.is_pec 20 | assert mp._eps_plot == dummy_optical._eps_plot 21 | assert mp.viz_spec == dummy_optical.viz_spec 22 | 23 | # deepcopy still succeeds because __deepcopy__ is ignored 24 | copy.deepcopy(mp) 25 | 26 | 27 | def test_delegated_attribute_without_optical_raises(): 28 | mp_no_opt = td.MultiPhysicsMedium(optical=None) 29 | 30 | with pytest.raises(AttributeError, match=r"optical medium is 'None'"): 31 | _ = mp_no_opt.is_pec 32 | 33 | 34 | def test_has_cached_props(dummy_optical): 35 | mp = td.MultiPhysicsMedium(optical=dummy_optical) 36 | mp._cached_properties 37 | 38 | 39 | def test_unknown_attribute_error(dummy_optical): 40 | mp = td.MultiPhysicsMedium(optical=dummy_optical) 41 | with pytest.raises(AttributeError, match=r"Did you mean to access the attribute of one"): 42 | _ = mp.not_a_real_attribute 43 | -------------------------------------------------------------------------------- /tests/test_components/test_apodization.py: -------------------------------------------------------------------------------- 1 | """Tests mode objects.""" 2 | 3 | from __future__ import annotations 4 | 5 | import matplotlib.pyplot as plt 6 | import pydantic.v1 as pydantic 7 | import pytest 8 | 9 | import tidy3d as td 10 | 11 | 12 | def test_apodization(): 13 | _ = td.ApodizationSpec(width=0.2) 14 | _ = td.ApodizationSpec(start=1, width=0.2) 15 | _ = td.ApodizationSpec(end=2, width=0.2) 16 | _ = td.ApodizationSpec(start=1, end=2, width=0.2) 17 | 18 | 19 | def test_end_lt_start(): 20 | with pytest.raises(pydantic.ValidationError): 21 | _ = td.ApodizationSpec(start=2, end=1, width=0.2) 22 | 23 | 24 | def test_no_width(): 25 | with pytest.raises(pydantic.ValidationError): 26 | _ = td.ApodizationSpec(start=1, end=2) 27 | with pytest.raises(pydantic.ValidationError): 28 | _ = td.ApodizationSpec(start=1) 29 | with pytest.raises(pydantic.ValidationError): 30 | _ = td.ApodizationSpec(end=2) 31 | 32 | 33 | def test_negative_times(): 34 | with pytest.raises(pydantic.ValidationError): 35 | _ = td.ApodizationSpec(start=-2, end=-1, width=0.2) 36 | 37 | with pytest.raises(pydantic.ValidationError): 38 | _ = td.ApodizationSpec(start=1, end=2, width=-0.2) 39 | 40 | with pytest.raises(pydantic.ValidationError): 41 | _ = td.ApodizationSpec(start=1, end=2, width=0) 42 | 43 | 44 | def test_plot(): 45 | run_time = 1.0e-13 46 | times = [0, 2.0e-14, 4.0e-14, 6.0e-14, 8.0e-14, 1.0e-13] 47 | 48 | a = td.ApodizationSpec(start=0.2 * run_time, end=0.8 * run_time, width=0.02 * run_time) 49 | a.plot(times) 50 | plt.close() 51 | 52 | fig, ax = plt.subplots(1, 1) 53 | a.plot(times, ax=ax) 54 | plt.close() 55 | -------------------------------------------------------------------------------- /tests/test_components/test_bc_placement.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from tidy3d.components.bc_placement import ( 4 | MediumMediumInterface, 5 | SimulationBoundary, 6 | StructureBoundary, 7 | StructureSimulationBoundary, 8 | StructureStructureInterface, 9 | ) 10 | 11 | 12 | def test_bc_placement(): 13 | _ = StructureBoundary(structure="box") 14 | _ = SimulationBoundary() 15 | _ = StructureSimulationBoundary(structure="box") 16 | _ = StructureStructureInterface(structures=["box", "sphere"]) 17 | _ = MediumMediumInterface(mediums=["dieletric", "metal"]) 18 | -------------------------------------------------------------------------------- /tests/test_components/test_frequencies.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import numpy as np 4 | import pytest 5 | 6 | import tidy3d as td 7 | 8 | 9 | def test_classification(): 10 | assert td.frequencies.classification(1) == ("near static",) 11 | assert td.wavelengths.classification(td.C_0) == ("near static",) 12 | assert td.frequencies.classification(td.C_0 / 1.55) == ("infrared", "NIR") 13 | assert td.wavelengths.classification(1.55) == ("infrared", "NIR") 14 | 15 | 16 | @pytest.mark.parametrize("band", ["O", "E", "S", "C", "L", "U"]) 17 | def test_bands(band): 18 | freqs = getattr(td.frequencies, band.lower() + "_band")() 19 | ldas = getattr(td.wavelengths, band.lower() + "_band")() 20 | assert np.allclose(freqs, td.C_0 / np.array(ldas)) 21 | -------------------------------------------------------------------------------- /tests/test_data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tests/test_data/__init__.py -------------------------------------------------------------------------------- /tests/test_material_library/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tests/test_material_library/__init__.py -------------------------------------------------------------------------------- /tests/test_package/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tests/test_package/__init__.py -------------------------------------------------------------------------------- /tests/test_package/test_compat.py: -------------------------------------------------------------------------------- 1 | # test_compat.py 2 | from __future__ import annotations 3 | 4 | import importlib 5 | import sys 6 | 7 | import pytest 8 | 9 | 10 | @pytest.fixture 11 | def restore_modules_and_meta_path(): 12 | """Fixture to restore sys.modules and sys.meta_path after test.""" 13 | original_modules = dict(sys.modules) 14 | original_meta_path = list(sys.meta_path) 15 | try: 16 | yield 17 | finally: 18 | sys.modules.clear() 19 | sys.modules.update(original_modules) 20 | sys.meta_path[:] = original_meta_path 21 | 22 | 23 | def test_alignment_import(restore_modules_and_meta_path): 24 | """Test normal import of alignment from xarray.""" 25 | # remove modules to ensure clean reload 26 | for modname in ("tidy3d.compat", "xarray.structure.alignment", "xarray.core.alignment"): 27 | if modname in sys.modules: 28 | del sys.modules[modname] 29 | 30 | import tidy3d.compat 31 | 32 | assert tidy3d.compat.alignment is not None, "Failed to import alignment normally." 33 | 34 | 35 | def test_compat_import_fallback(restore_modules_and_meta_path): 36 | """Test fallback to xarray.core.alignment when structure.alignment fails.""" 37 | 38 | # mock to simulate ImportError for xarray.structure.alignment 39 | class MockImporter: 40 | def find_spec(self, fullname, path=None, target=None): 41 | if fullname == "xarray.structure.alignment": 42 | raise ImportError 43 | return None 44 | 45 | sys.meta_path.insert(0, MockImporter()) 46 | 47 | # memove modules to force re-import 48 | for modname in ("tidy3d.compat", "xarray.structure.alignment", "xarray.core.alignment"): 49 | if modname in sys.modules: 50 | del sys.modules[modname] 51 | 52 | # import should trigger fallback mechanism 53 | import tidy3d.compat 54 | 55 | importlib.reload(tidy3d.compat) 56 | 57 | assert tidy3d.compat.alignment is not None, "Expected fallback alignment to be imported." 58 | -------------------------------------------------------------------------------- /tests/test_package/test_config.py: -------------------------------------------------------------------------------- 1 | """test the grid operations""" 2 | 3 | from __future__ import annotations 4 | 5 | import pydantic.v1 as pydantic 6 | import pytest 7 | 8 | import tidy3d as td 9 | from tidy3d.log import DEFAULT_LEVEL, _level_value 10 | 11 | 12 | def test_logging_level(): 13 | """Make sure setting the logging level in config affects the log.level""" 14 | 15 | # default level 16 | assert td.log.handlers["console"].level == _level_value[DEFAULT_LEVEL] 17 | 18 | # check setting all levels 19 | for key, val in _level_value.items(): 20 | td.config.logging_level = key 21 | assert td.log.handlers["console"].level == val 22 | 23 | 24 | def test_log_level_not_found(): 25 | with pytest.raises(pydantic.ValidationError): 26 | td.config.logging_level = "NOT_A_LEVEL" 27 | 28 | 29 | def _test_frozen(): 30 | """Make sure you can dynamically freeze tidy3d components.""" 31 | 32 | # make sure it's mutable 33 | b = td.Box(size=(1, 1, 1)) 34 | b.center = (1, 2, 3) 35 | 36 | # freeze and make sure it's immutable 37 | td.config.frozen = True 38 | with pytest.raises(TypeError): 39 | b.center = (2, 2, 2) 40 | 41 | # unfreeze and make sure it's mutable again 42 | td.config.frozen = False 43 | b.center = (1, 2, 3) 44 | -------------------------------------------------------------------------------- /tests/test_package/test_convert.py: -------------------------------------------------------------------------------- 1 | """Test converting .lsf files to Tidy3D python files.""" 2 | 3 | from __future__ import annotations 4 | 5 | import pytest 6 | 7 | from tidy3d.web.cli.app import convert 8 | 9 | 10 | def test_tidy3d_converter(): 11 | """Tidy3d convert fails properly""" 12 | 13 | with pytest.raises(ValueError): 14 | convert(["test", "test"]) 15 | -------------------------------------------------------------------------------- /tests/test_package/test_main.py: -------------------------------------------------------------------------------- 1 | """Test running tidy3d as command line application.""" 2 | 3 | from __future__ import annotations 4 | 5 | import pytest 6 | 7 | import tidy3d as td 8 | from tidy3d.__main__ import main 9 | 10 | 11 | def save_sim_to_path(path: str) -> None: 12 | sim = td.Simulation(size=(1, 1, 1), grid_spec=td.GridSpec.auto(wavelength=1.0), run_time=1e-12) 13 | sim.to_file(path) 14 | 15 | 16 | @pytest.mark.parametrize("extension", (".json", ".yaml")) 17 | def test_main(extension, tmp_path): 18 | path = str((tmp_path / "sim").with_suffix(extension)) 19 | save_sim_to_path(path) 20 | main([path, "--test_only"]) 21 | -------------------------------------------------------------------------------- /tests/test_package/test_make_script.py: -------------------------------------------------------------------------------- 1 | """Tests generation of pythons script from simulation file.""" 2 | 3 | from __future__ import annotations 4 | 5 | import tidy3d as td 6 | from scripts.make_script import main 7 | 8 | 9 | def test_make_script(tmp_path): 10 | # make a sim 11 | simulation = td.Simulation( 12 | size=(1, 1, 1), 13 | sources=( 14 | td.PointDipole( 15 | polarization="Ex", source_time=td.GaussianPulse(freq0=2e14, fwidth=1e14) 16 | ), 17 | ), 18 | monitors=(td.FluxMonitor(size=(0, 1, 1), freqs=[1e14], name="flux"),), 19 | run_time=1e-12, 20 | ) 21 | 22 | sim_path = tmp_path / "sim.json" 23 | out_path = tmp_path / "sim.py" 24 | 25 | # save it to file, assuring it does not exist already 26 | simulation.to_file(str(sim_path)) 27 | assert not out_path.exists(), f"out file {out_path} already exists." 28 | 29 | # generate out script from the simulation file 30 | main([str(sim_path), str(out_path)]) 31 | 32 | # make sure that file was created and is not empty 33 | assert out_path.is_file(), f"out file {out_path} wasn't created." 34 | assert len(out_path.read_text()) > 0, f"out file {out_path} is empty." 35 | -------------------------------------------------------------------------------- /tests/test_plugins/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tests/test_plugins/__init__.py -------------------------------------------------------------------------------- /tests/test_plugins/autograd/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tests/test_plugins/autograd/__init__.py -------------------------------------------------------------------------------- /tests/test_plugins/autograd/invdes/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tests/test_plugins/autograd/invdes/__init__.py -------------------------------------------------------------------------------- /tests/test_plugins/autograd/invdes/test_parametrizations.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import autograd.numpy as np 4 | import pytest 5 | 6 | from tidy3d.plugins.autograd.invdes.parametrizations import make_filter_and_project 7 | from tidy3d.plugins.autograd.types import PaddingType 8 | 9 | 10 | @pytest.mark.parametrize("radius", [1, 2, (1, 2)]) 11 | @pytest.mark.parametrize("dl", [0.1, 0.2, (0.1, 0.2)]) 12 | @pytest.mark.parametrize("size_px", [None, 5, (5, 7)]) 13 | @pytest.mark.parametrize("filter_type", ["circular", "conic"]) 14 | @pytest.mark.parametrize("padding", PaddingType.__args__) 15 | def test_make_filter_and_project(rng, radius, dl, size_px, filter_type, padding): 16 | """Test make_filter_and_project function for various parameters.""" 17 | filter_and_project_func = make_filter_and_project( 18 | radius=radius, 19 | dl=dl, 20 | size_px=size_px, 21 | beta=10, 22 | eta=0.5, 23 | filter_type=filter_type, 24 | padding=padding, 25 | ) 26 | array = rng.random((51, 51)) 27 | result = filter_and_project_func(array) 28 | assert result.shape == array.shape 29 | assert np.all(result >= 0) and np.all(result <= 1) 30 | -------------------------------------------------------------------------------- /tests/test_plugins/autograd/invdes/test_penalties.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import pytest 4 | 5 | from tidy3d.plugins.autograd.invdes.penalties import make_erosion_dilation_penalty 6 | from tidy3d.plugins.autograd.types import PaddingType 7 | 8 | 9 | @pytest.mark.parametrize("radius", [1, 2, (1, 2)]) 10 | @pytest.mark.parametrize("dl", [0.1, 0.2, (0.1, 0.2)]) 11 | @pytest.mark.parametrize("size_px", [None, 5, (5, 7)]) 12 | @pytest.mark.parametrize("padding", PaddingType.__args__) 13 | def test_make_erosion_dilation_penalty(rng, radius, dl, size_px, padding): 14 | """Test make_erosion_dilation_penalty function for various parameters.""" 15 | erosion_dilation_penalty_func = make_erosion_dilation_penalty( 16 | radius=radius, 17 | dl=dl, 18 | size_px=size_px, 19 | beta=10, 20 | eta=0.5, 21 | delta_eta=0.01, 22 | padding=padding, 23 | ) 24 | array = rng.random((51, 51)) 25 | result = erosion_dilation_penalty_func(array) 26 | assert isinstance(result, float) 27 | assert result >= 0 28 | -------------------------------------------------------------------------------- /tests/test_plugins/autograd/primitives/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tests/test_plugins/autograd/primitives/__init__.py -------------------------------------------------------------------------------- /tests/test_plugins/autograd/primitives/test_misc.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import pytest 4 | from autograd.test_util import check_grads 5 | 6 | from tidy3d.plugins.autograd.primitives import gaussian_filter 7 | 8 | 9 | @pytest.mark.parametrize("size", [10, 11]) 10 | @pytest.mark.parametrize("ndim", [1, 2, 3]) 11 | @pytest.mark.parametrize("sigma", [1, 2]) 12 | @pytest.mark.parametrize( 13 | "mode", 14 | [ 15 | "constant", 16 | "reflect", 17 | "wrap", 18 | pytest.param("nearest", marks=pytest.mark.skip(reason="Grads not implemented.")), 19 | pytest.param("mirror", marks=pytest.mark.skip(reason="Grads not implemented.")), 20 | ], 21 | ) 22 | def test_gaussian_filter_grad(rng, size, ndim, sigma, mode): 23 | x = rng.random((size,) * ndim) 24 | check_grads(lambda x: gaussian_filter(x, sigma=sigma, mode=mode), modes=["rev"], order=2)(x) 25 | -------------------------------------------------------------------------------- /tests/test_plugins/expressions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tests/test_plugins/expressions/__init__.py -------------------------------------------------------------------------------- /tests/test_plugins/expressions/test_functions.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import numpy as np 4 | import pytest 5 | 6 | from tidy3d.plugins.expressions.functions import Cos, Exp, Log, Log10, Sin, Sqrt, Tan 7 | from tidy3d.plugins.expressions.variables import Constant 8 | 9 | FUNCTIONS = [ 10 | (Sin, np.sin), 11 | (Cos, np.cos), 12 | (Tan, np.tan), 13 | (Exp, np.exp), 14 | (Log, np.log), 15 | (Log10, np.log10), 16 | (Sqrt, np.sqrt), 17 | ] 18 | 19 | 20 | @pytest.fixture(params=[1, 2.5, 1 + 2j, np.array([1, 2, 3]), np.array([1 + 2j, 3 - 4j, 5 + 6j])]) 21 | def value(request): 22 | return request.param 23 | 24 | 25 | @pytest.mark.parametrize("tidy3d_func, numpy_func", FUNCTIONS) 26 | def test_functions_evaluate(tidy3d_func, numpy_func, value): 27 | constant = Constant(value) 28 | func = tidy3d_func(constant) 29 | result = func.evaluate(constant.evaluate()) 30 | np.testing.assert_allclose(result, numpy_func(value)) 31 | 32 | 33 | @pytest.mark.parametrize("tidy3d_func, numpy_func", FUNCTIONS) 34 | def test_functions_type(tidy3d_func, numpy_func, value): 35 | constant = Constant(value) 36 | func = tidy3d_func(constant) 37 | result = func.evaluate(constant.evaluate()) 38 | assert isinstance(result, type(numpy_func(value))) 39 | -------------------------------------------------------------------------------- /tests/test_plugins/expressions/test_operators.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import operator 4 | 5 | import numpy as np 6 | import pytest 7 | 8 | from tidy3d.plugins.expressions.operators import ( 9 | Abs, 10 | Add, 11 | Divide, 12 | FloorDivide, 13 | MatMul, 14 | Modulus, 15 | Multiply, 16 | Negate, 17 | Power, 18 | Subtract, 19 | ) 20 | 21 | UNARY_OPS = [ 22 | (Abs, operator.abs), 23 | (Negate, operator.neg), 24 | ] 25 | 26 | BINARY_OPS = [ 27 | (Add, operator.add), 28 | (Subtract, operator.sub), 29 | (Multiply, operator.mul), 30 | (Divide, operator.truediv), 31 | (FloorDivide, operator.floordiv), 32 | (Modulus, operator.mod), 33 | (Power, operator.pow), 34 | (MatMul, operator.matmul), 35 | ] 36 | 37 | 38 | @pytest.mark.parametrize("tidy3d_op, python_op", BINARY_OPS) 39 | @pytest.mark.parametrize( 40 | "x, y", [(1, 2), (2.5, 3.7), (1 + 2j, 3 - 4j), (np.array([1, 2, 3]), np.array([4, 5, 6]))] 41 | ) 42 | def test_binary_operators(tidy3d_op, python_op, x, y): 43 | if any(isinstance(p, complex) for p in (x, y)) and any( 44 | tidy3d_op == op for op in (FloorDivide, Modulus) 45 | ): 46 | pytest.skip("operation undefined for complex inputs") 47 | if tidy3d_op == MatMul and (np.isscalar(x) or np.isscalar(y)): 48 | pytest.skip("matmul operation undefined for scalar inputs") 49 | 50 | tidy3d_result = tidy3d_op(left=x, right=y).evaluate(x) 51 | python_result = python_op(x, y) 52 | 53 | np.testing.assert_allclose(tidy3d_result, python_result) 54 | 55 | 56 | @pytest.mark.parametrize("tidy3d_op, python_op", UNARY_OPS) 57 | @pytest.mark.parametrize("x", [1, 2.5, 1 + 2j, np.array([1 + 2j, 3 - 4j, 5 + 6j])]) 58 | def test_unary_operators(tidy3d_op, python_op, x): 59 | tidy3d_result = tidy3d_op(operand=x).evaluate(x) 60 | python_result = python_op(x) 61 | 62 | np.testing.assert_allclose(tidy3d_result, python_result) 63 | -------------------------------------------------------------------------------- /tests/test_plugins/pytorch/test_wrapper.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import autograd.numpy as anp 4 | import torch 5 | from autograd import elementwise_grad 6 | from numpy.testing import assert_allclose 7 | 8 | from tidy3d.plugins.pytorch.wrapper import to_torch 9 | 10 | 11 | def test_to_torch_no_kwargs(rng): 12 | x_np = rng.uniform(-1, 1, 10).astype("f4") 13 | x_torch = torch.tensor(x_np, requires_grad=True) 14 | 15 | def f_np(x): 16 | return x * anp.sin(x) ** 2 17 | 18 | f_torch = to_torch(f_np) 19 | 20 | val = f_torch(x_torch) 21 | val.backward(torch.ones(x_torch.shape)) 22 | 23 | grad = x_torch.grad.numpy() 24 | expected_grad = elementwise_grad(f_np)(x_np) 25 | 26 | assert_allclose(grad, expected_grad) 27 | 28 | 29 | def test_to_torch_with_kwargs(rng): 30 | x_np = rng.uniform(-1, 1, 10).astype("f4") 31 | y_np = rng.uniform(-1, 1, 10).astype("f4") 32 | x_torch = torch.tensor(x_np, requires_grad=True) 33 | y_torch = torch.tensor(y_np, requires_grad=True) 34 | 35 | def f_np(x, y): 36 | return y * anp.sin(x) ** 2 37 | 38 | f_torch = to_torch(f_np) 39 | 40 | val = f_torch(y=y_torch, x=x_torch) 41 | val.backward(torch.ones(x_torch.shape)) 42 | 43 | grad = x_torch.grad.numpy(), y_torch.grad.numpy() 44 | expected_grad = elementwise_grad(f_np, argnum=[0, 1])(x_np, y_np) 45 | 46 | assert_allclose(grad, expected_grad) 47 | -------------------------------------------------------------------------------- /tests/test_plugins/smatrix/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tests/test_plugins/smatrix/__init__.py -------------------------------------------------------------------------------- /tests/test_web/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tests/test_web/__init__.py -------------------------------------------------------------------------------- /tests/test_web/mock_web.py: -------------------------------------------------------------------------------- 1 | # custom class to be the mock return value 2 | # will override the requests.Response returned from requests.get 3 | from __future__ import annotations 4 | 5 | 6 | class MockResponse: 7 | def __init__(self, code, json_data): 8 | self.status_code = code 9 | self.json_data = json_data 10 | 11 | def json(self): 12 | return self.json_data 13 | -------------------------------------------------------------------------------- /tests/test_web/test_cli.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | 4 | def test_tidy3d_cli(): 5 | pass 6 | # if os.path.exists(CONFIG_FILE): 7 | # shutil.move(CONFIG_FILE, f"{CONFIG_FILE}.bak") 8 | # 9 | # runner = CliRunner() 10 | # result = runner.invoke(tidy3d_cli, ["configure"], input="apikey") 11 | # 12 | # # assert result.exit_code == 0 13 | # if os.path.exists(CONFIG_FILE): 14 | # os.remove(CONFIG_FILE) 15 | # 16 | # if os.path.exists(f"{CONFIG_FILE}.bak"): 17 | # shutil.move(f"{CONFIG_FILE}.bak", CONFIG_FILE) 18 | -------------------------------------------------------------------------------- /tests/test_web/test_env.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import ssl 4 | 5 | from tidy3d.web.core.environment import Env 6 | 7 | 8 | def test_tidy3d_env(): 9 | Env.enable_caching(True) 10 | assert Env.current.enable_caching is True 11 | 12 | Env.enable_caching(False) 13 | assert Env.current.enable_caching is False 14 | 15 | 16 | def test_set_ssl_version(): 17 | Env.set_ssl_version(ssl.TLSVersion.TLSv1_3) 18 | assert Env.current.ssl_version == ssl.TLSVersion.TLSv1_3 19 | 20 | Env.set_ssl_version(ssl.TLSVersion.TLSv1_2) 21 | assert Env.current.ssl_version == ssl.TLSVersion.TLSv1_2 22 | 23 | Env.set_ssl_version(ssl.TLSVersion.TLSv1_1) 24 | assert Env.current.ssl_version == ssl.TLSVersion.TLSv1_1 25 | 26 | Env.set_ssl_version(None) 27 | assert Env.current.ssl_version is None 28 | -------------------------------------------------------------------------------- /tests/test_web/test_task.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from tidy3d.web.core.task_info import RunInfo 4 | 5 | 6 | def test_run_info_display(): 7 | ri = RunInfo(perc_done=50, field_decay=1e-3) 8 | ri.display() 9 | -------------------------------------------------------------------------------- /tests/test_web/test_tidy3d_material_library.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import pytest 4 | import responses 5 | 6 | import tidy3d as td 7 | from tidy3d.web.api.material_libray import MaterialLibray 8 | from tidy3d.web.core.environment import Env 9 | 10 | Env.dev.active() 11 | 12 | 13 | @pytest.fixture 14 | def set_api_key(monkeypatch): 15 | """Set the api key.""" 16 | import tidy3d.web.core.http_util as httputil 17 | 18 | monkeypatch.setattr(httputil, "api_key", lambda: "apikey") 19 | monkeypatch.setattr(httputil, "get_version", lambda: td.version.__version__) 20 | 21 | 22 | @responses.activate 23 | def test_lib(set_api_key): 24 | responses.add( 25 | responses.GET, 26 | f"{Env.current.web_api_endpoint}/tidy3d/libraries", 27 | json={"data": [{"id": "3eb06d16-208b-487b-864b-e9b1d3e010a7", "name": "medium1"}]}, 28 | status=200, 29 | ) 30 | libs = MaterialLibray.list() 31 | lib = libs[0] 32 | assert lib.name == "medium1" 33 | -------------------------------------------------------------------------------- /tests/test_web/test_webapi_account.py: -------------------------------------------------------------------------------- 1 | # Tests webapi and things that depend on it 2 | from __future__ import annotations 3 | 4 | import pytest 5 | import responses 6 | 7 | import tidy3d as td 8 | from tidy3d.web.api.webapi import ( 9 | account, 10 | ) 11 | from tidy3d.web.core.environment import Env 12 | 13 | task_core_path = "tidy3d.web.core.task_core" 14 | api_path = "tidy3d.web.api.webapi" 15 | 16 | Env.dev.active() 17 | 18 | 19 | @pytest.fixture 20 | def set_api_key(monkeypatch): 21 | """Set the api key.""" 22 | import tidy3d.web.core.http_util as http_module 23 | 24 | monkeypatch.setattr(http_module, "api_key", lambda: "apikey") 25 | monkeypatch.setattr(http_module, "get_version", lambda: td.version.__version__) 26 | 27 | 28 | @pytest.fixture 29 | def mock_get_account(monkeypatch, set_api_key): 30 | """Mocks webapi.get_info.""" 31 | 32 | responses.add( 33 | responses.GET, 34 | f"{Env.current.web_api_endpoint}/tidy3d/py/account", 35 | json={ 36 | "data": { 37 | "credit": 10.0, 38 | "creditExpiration": "2024-10-01T00:00:00.000Z", 39 | "allowanceCycleType": "Daily", 40 | "allowanceCurrentCycleAmount": 10.0, 41 | "allowanceCurrentCycleEndDate": "2024-09-01T00:00:00.000Z", 42 | "dailyFreeSimulationCounts": 2, 43 | } 44 | }, 45 | status=200, 46 | ) 47 | 48 | 49 | @responses.activate 50 | def test_account(mock_get_account): 51 | info = account() 52 | assert info is not None 53 | assert info.credit == 10.0 54 | -------------------------------------------------------------------------------- /tidy3d/compat.py: -------------------------------------------------------------------------------- 1 | """Compatibility layer for handling differences between package versions.""" 2 | 3 | from __future__ import annotations 4 | 5 | try: 6 | from xarray.structure import alignment 7 | except ImportError: 8 | from xarray.core import alignment 9 | 10 | __all__ = ["alignment"] 11 | -------------------------------------------------------------------------------- /tidy3d/components/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/autograd/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from .boxes import TidyArrayBox 4 | from .functions import interpn 5 | from .types import ( 6 | AutogradFieldMap, 7 | AutogradTraced, 8 | TracedCoordinate, 9 | TracedFloat, 10 | TracedSize, 11 | TracedSize1D, 12 | TracedVertices, 13 | ) 14 | from .utils import get_static, is_tidy_box, split_list 15 | 16 | __all__ = [ 17 | "AutogradFieldMap", 18 | "AutogradTraced", 19 | "TidyArrayBox", 20 | "TracedCoordinate", 21 | "TracedFloat", 22 | "TracedSize", 23 | "TracedSize1D", 24 | "TracedVertices", 25 | "add_at", 26 | "get_static", 27 | "interpn", 28 | "is_tidy_box", 29 | "split_list", 30 | "trapz", 31 | ] 32 | -------------------------------------------------------------------------------- /tidy3d/components/autograd/types.py: -------------------------------------------------------------------------------- 1 | # type information for autograd 2 | 3 | # utilities for working with autograd 4 | from __future__ import annotations 5 | 6 | import copy 7 | import typing 8 | 9 | import pydantic.v1 as pd 10 | from autograd.builtins import dict as dict_ag 11 | from autograd.extend import Box, defvjp, primitive 12 | 13 | from tidy3d.components.type_util import _add_schema 14 | from tidy3d.components.types import ArrayFloat2D, ArrayLike, Complex, Size1D 15 | 16 | # add schema to the Box 17 | _add_schema(Box, title="AutogradBox", field_type_str="autograd.tracer.Box") 18 | 19 | # make sure Boxes in tidy3d properly define VJPs for copy operations, for computational graph 20 | _copy = primitive(copy.copy) 21 | _deepcopy = primitive(copy.deepcopy) 22 | 23 | defvjp(_copy, lambda ans, x: lambda g: _copy(g)) 24 | defvjp(_deepcopy, lambda ans, x, memo: lambda g: _deepcopy(g, memo)) 25 | 26 | Box.__copy__ = lambda v: _copy(v) 27 | Box.__deepcopy__ = lambda v, memo: _deepcopy(v, memo) 28 | 29 | # Types for floats, or collections of floats that can also be autograd tracers 30 | TracedFloat = typing.Union[float, Box] 31 | TracedPositiveFloat = typing.Union[pd.PositiveFloat, Box] 32 | TracedSize1D = typing.Union[Size1D, Box] 33 | TracedSize = typing.Union[tuple[TracedSize1D, TracedSize1D, TracedSize1D], Box] 34 | TracedCoordinate = typing.Union[tuple[TracedFloat, TracedFloat, TracedFloat], Box] 35 | TracedVertices = typing.Union[ArrayFloat2D, Box] 36 | 37 | # poles 38 | TracedComplex = typing.Union[Complex, Box] 39 | TracedPoleAndResidue = tuple[TracedComplex, TracedComplex] 40 | 41 | # The data type that we pass in and out of the web.run() @autograd.primitive 42 | AutogradTraced = typing.Union[Box, ArrayLike] 43 | PathType = tuple[typing.Union[int, str], ...] 44 | AutogradFieldMap = dict_ag[PathType, AutogradTraced] 45 | 46 | InterpolationType = typing.Literal["nearest", "linear"] 47 | 48 | __all__ = [ 49 | "AutogradFieldMap", 50 | "AutogradTraced", 51 | "TracedCoordinate", 52 | "TracedFloat", 53 | "TracedSize", 54 | "TracedSize1D", 55 | "TracedVertices", 56 | ] 57 | -------------------------------------------------------------------------------- /tidy3d/components/autograd/utils.py: -------------------------------------------------------------------------------- 1 | # utilities for working with autograd 2 | from __future__ import annotations 3 | 4 | import typing 5 | 6 | from autograd.tracer import getval 7 | 8 | 9 | def get_static(x: typing.Any) -> typing.Any: 10 | """Get the 'static' (untraced) version of some value.""" 11 | return getval(x) 12 | 13 | 14 | def split_list(x: list[typing.Any], index: int) -> (list[typing.Any], list[typing.Any]): 15 | """Split a list at a given index.""" 16 | x = list(x) 17 | return x[:index], x[index:] 18 | 19 | 20 | def is_tidy_box(x: typing.Any) -> bool: 21 | """Check if a value is a tidy box.""" 22 | return getattr(x, "_tidy", False) 23 | 24 | 25 | __all__ = [ 26 | "get_static", 27 | "is_tidy_box", 28 | "split_list", 29 | ] 30 | -------------------------------------------------------------------------------- /tidy3d/components/base_sim/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/base_sim/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/base_sim/data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/base_sim/data/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/base_sim/data/monitor_data.py: -------------------------------------------------------------------------------- 1 | """Abstract base for monitor data structures.""" 2 | 3 | from __future__ import annotations 4 | 5 | from abc import ABC 6 | 7 | import pydantic.v1 as pd 8 | 9 | from tidy3d.components.base_sim.monitor import AbstractMonitor 10 | from tidy3d.components.data.dataset import Dataset 11 | 12 | 13 | class AbstractMonitorData(Dataset, ABC): 14 | """Abstract base class of objects that store data pertaining to a single 15 | :class:`AbstractMonitor`. 16 | """ 17 | 18 | monitor: AbstractMonitor = pd.Field( 19 | ..., 20 | title="Monitor", 21 | description="Monitor associated with the data.", 22 | ) 23 | 24 | @property 25 | def symmetry_expanded_copy(self) -> AbstractMonitorData: 26 | """Return copy of self with symmetry applied.""" 27 | return self.copy() 28 | -------------------------------------------------------------------------------- /tidy3d/components/base_sim/source.py: -------------------------------------------------------------------------------- 1 | """Abstract base for classes that define simulation sources.""" 2 | 3 | from __future__ import annotations 4 | 5 | from abc import ABC, abstractmethod 6 | 7 | import pydantic.v1 as pydantic 8 | 9 | from tidy3d.components.base import Tidy3dBaseModel 10 | from tidy3d.components.validators import validate_name_str 11 | from tidy3d.components.viz import PlotParams 12 | 13 | 14 | class AbstractSource(Tidy3dBaseModel, ABC): 15 | """Abstract base class for all sources.""" 16 | 17 | name: str = pydantic.Field(None, title="Name", description="Optional name for the source.") 18 | 19 | @abstractmethod 20 | def plot_params(self) -> PlotParams: 21 | """Default parameters for plotting a Source object.""" 22 | 23 | _name_validator = validate_name_str() 24 | -------------------------------------------------------------------------------- /tidy3d/components/data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/data/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/data/unstructured/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/data/unstructured/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/eme/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/eme/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/eme/data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/eme/data/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/eme/data/monitor_data.py: -------------------------------------------------------------------------------- 1 | """EME monitor data""" 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union 6 | 7 | import pydantic.v1 as pd 8 | 9 | from tidy3d.components.base_sim.data.monitor_data import AbstractMonitorData 10 | from tidy3d.components.data.monitor_data import ( 11 | ElectromagneticFieldData, 12 | ModeSolverData, 13 | PermittivityData, 14 | ) 15 | from tidy3d.components.eme.monitor import ( 16 | EMECoefficientMonitor, 17 | EMEFieldMonitor, 18 | EMEModeSolverMonitor, 19 | ) 20 | 21 | from .dataset import EMECoefficientDataset, EMEFieldDataset, EMEModeSolverDataset 22 | 23 | 24 | class EMEModeSolverData(ElectromagneticFieldData, EMEModeSolverDataset): 25 | """Data associated with an EME mode solver monitor.""" 26 | 27 | monitor: EMEModeSolverMonitor = pd.Field( 28 | ..., 29 | title="EME Mode Solver Monitor", 30 | description="EME mode solver monitor associated with this data.", 31 | ) 32 | 33 | 34 | class EMEFieldData(ElectromagneticFieldData, EMEFieldDataset): 35 | """Data associated with an EME field monitor.""" 36 | 37 | monitor: EMEFieldMonitor = pd.Field( 38 | ..., title="EME Field Monitor", description="EME field monitor associated with this data." 39 | ) 40 | 41 | 42 | class EMECoefficientData(AbstractMonitorData, EMECoefficientDataset): 43 | """Data associated with an EME coefficient monitor.""" 44 | 45 | monitor: EMECoefficientMonitor = pd.Field( 46 | ..., 47 | title="EME Coefficient Monitor", 48 | description="EME coefficient monitor associated with this data.", 49 | ) 50 | 51 | 52 | EMEMonitorDataType = Union[ 53 | EMEModeSolverData, EMEFieldData, EMECoefficientData, ModeSolverData, PermittivityData 54 | ] 55 | -------------------------------------------------------------------------------- /tidy3d/components/geometry/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/geometry/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/grid/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/grid/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/material/README.md: -------------------------------------------------------------------------------- 1 | # Medium 2 | 3 | This directory will be renamed to `medium` whenever we've finished the migration from `medium.py` into a more decoupled structure. -------------------------------------------------------------------------------- /tidy3d/components/material/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /tidy3d/components/material/solver_types.py: -------------------------------------------------------------------------------- 1 | """ 2 | Note in the future we might want to implement interpolation models here. 3 | """ 4 | 5 | from __future__ import annotations 6 | 7 | from typing import Union 8 | 9 | from tidy3d.components.material.tcad.charge import ( 10 | ChargeConductorMedium, 11 | ChargeInsulatorMedium, 12 | SemiconductorMedium, 13 | ) 14 | from tidy3d.components.material.tcad.heat import ThermalSpecType 15 | from tidy3d.components.medium import MediumType, MediumType3D 16 | 17 | OpticalMediumType = MediumType 18 | ElectricalMediumType = MediumType 19 | HeatMediumType = ThermalSpecType 20 | ChargeMediumType = Union[ChargeConductorMedium, ChargeInsulatorMedium, SemiconductorMedium] 21 | 22 | OpticalMediumType3D = ElectricalMediumType3D = ChargeMediumType3D = MediumType3D 23 | -------------------------------------------------------------------------------- /tidy3d/components/material/tcad/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/material/tcad/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/material/types.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Union 4 | 5 | from .multi_physics import MultiPhysicsMedium 6 | from .solver_types import ( 7 | ChargeMediumType, 8 | ChargeMediumType3D, 9 | ElectricalMediumType, 10 | ElectricalMediumType3D, 11 | HeatMediumType, 12 | OpticalMediumType, 13 | OpticalMediumType3D, 14 | ) 15 | 16 | StructureMediumType = Union[ 17 | MultiPhysicsMedium, 18 | OpticalMediumType, 19 | ElectricalMediumType, 20 | HeatMediumType, 21 | ChargeMediumType, 22 | ] 23 | 24 | MultiPhysicsMediumType3D = Union[ 25 | MultiPhysicsMedium, OpticalMediumType3D, ElectricalMediumType3D, ChargeMediumType3D 26 | ] 27 | -------------------------------------------------------------------------------- /tidy3d/components/microwave/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/microwave/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/microwave/data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/microwave/data/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/microwave/formulas/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/microwave/formulas/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/mode/LICENSE: -------------------------------------------------------------------------------- 1 | Some functions in the current module are derived from the ceviche package 2 | https://github.com/fancompute/ceviche 3 | 4 | MIT License 5 | 6 | Copyright (c) 2021 Flexcompute 7 | Copyright (c) 2019 Tyler Hughes 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in all 17 | copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | SOFTWARE. -------------------------------------------------------------------------------- /tidy3d/components/mode/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/mode/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/mode/data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/mode/data/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/run_time_spec.py: -------------------------------------------------------------------------------- 1 | # Defines specifications for how long to run a simulation 2 | from __future__ import annotations 3 | 4 | import pydantic.v1 as pd 5 | 6 | from .base import Tidy3dBaseModel 7 | 8 | 9 | class RunTimeSpec(Tidy3dBaseModel): 10 | """Defines specification for how long to run a simulation when added to ``Simulation.run_time``. 11 | 12 | Notes 13 | ----- 14 | 15 | The evaluated ``run_time`` will be computed from a ``RunTimeSpec()`` as follows: 16 | 17 | .. math:: 18 | 19 | \\text{run_time} = \\text{source_factor} * T_{src_max} + \\text{quality_factor} n_{max} L_{max} / c_{0} 20 | 21 | Where: ``source_factor`` and ``quality_factor`` are fields in the spec, 22 | :math:`T_{src_max}` is the longest time that a source is non-zero, 23 | :math:`n_{max}` is the maximum refractive index in the simulation, 24 | :math:`L_{max}` is the distance along the largest dimension in the simulation, and 25 | :math:`c_0` is the speed of light in vacuum. 26 | 27 | """ 28 | 29 | quality_factor: pd.PositiveFloat = pd.Field( 30 | ..., 31 | title="Quality Factor", 32 | description="Quality factor expected in the device. This determines how long the " 33 | "simulation will run as it assumes a field decay time that scales proportionally to " 34 | "this value.", 35 | ) 36 | 37 | source_factor: pd.PositiveFloat = pd.Field( 38 | 3, 39 | title="Source Factor", 40 | description="The contribution to the ``run_time`` from the longest source is computed from " 41 | "the ``source_time`` length times ``source_factor``. Larger values provide more buffer " 42 | "at the expense of potentially giving ``run_time`` values that are larger than needed.", 43 | ) 44 | -------------------------------------------------------------------------------- /tidy3d/components/source/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/source/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/source/utils.py: -------------------------------------------------------------------------------- 1 | """Defines electric current sources for injecting light into simulation.""" 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union 6 | 7 | from .current import CustomCurrentSource, PointDipole, UniformCurrentSource 8 | from .field import ( 9 | TFSF, 10 | AstigmaticGaussianBeam, 11 | CustomFieldSource, 12 | GaussianBeam, 13 | ModeSource, 14 | PlaneWave, 15 | ) 16 | 17 | # sources allowed in Simulation.sources 18 | SourceType = Union[ 19 | UniformCurrentSource, 20 | PointDipole, 21 | GaussianBeam, 22 | AstigmaticGaussianBeam, 23 | ModeSource, 24 | PlaneWave, 25 | CustomFieldSource, 26 | CustomCurrentSource, 27 | TFSF, 28 | ] 29 | -------------------------------------------------------------------------------- /tidy3d/components/spice/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/spice/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/spice/analysis/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/spice/analysis/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/spice/sources/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/spice/sources/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/spice/sources/types.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Union 4 | 5 | from .dc import DCCurrentSource, DCVoltageSource 6 | 7 | VoltageSourceType = Union[DCVoltageSource] 8 | CurrentSourceType = Union[DCCurrentSource] 9 | -------------------------------------------------------------------------------- /tidy3d/components/spice/types.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Union 4 | 5 | from tidy3d.components.spice.analysis.dc import IsothermalSteadyChargeDCAnalysis 6 | 7 | ElectricalAnalysisType = Union[IsothermalSteadyChargeDCAnalysis] 8 | -------------------------------------------------------------------------------- /tidy3d/components/tcad/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/tcad/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/tcad/analysis/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/tcad/analysis/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/tcad/analysis/heat_simulation_type.py: -------------------------------------------------------------------------------- 1 | """Dealing with time specifications for DeviceSimulation""" 2 | 3 | from __future__ import annotations 4 | 5 | import pydantic.v1 as pd 6 | 7 | from tidy3d.components.base import Tidy3dBaseModel 8 | from tidy3d.constants import KELVIN, SECOND 9 | 10 | 11 | class UnsteadySpec(Tidy3dBaseModel): 12 | """Defines an unsteady specification 13 | 14 | Example 15 | -------- 16 | >>> import tidy3d as td 17 | >>> time_spec = td.UnsteadySpec( 18 | ... time_step=0.01, 19 | ... total_time_steps=200, 20 | ... ) 21 | """ 22 | 23 | time_step: pd.PositiveFloat = pd.Field( 24 | ..., 25 | title="Time-step", 26 | description="Time step taken for each iteration of the time integration loop.", 27 | units=SECOND, 28 | ) 29 | 30 | total_time_steps: pd.PositiveInt = pd.Field( 31 | ..., 32 | title="Total time steps", 33 | description="Specifies the total number of time steps run during the simulation.", 34 | ) 35 | 36 | 37 | class UnsteadyHeatAnalysis(Tidy3dBaseModel): 38 | """ 39 | Configures relevant unsteady-state heat simulation parameters. 40 | 41 | Example 42 | ------- 43 | >>> import tidy3d as td 44 | >>> time_spec = td.UnsteadyHeatAnalysis( 45 | ... initial_temperature=300, 46 | ... unsteady_spec=td.UnsteadySpec( 47 | ... time_step=0.01, 48 | ... total_time_steps=200, 49 | ... ), 50 | ... ) 51 | """ 52 | 53 | initial_temperature: pd.PositiveFloat = pd.Field( 54 | ..., 55 | title="Initial temperature.", 56 | description="Initial value for the temperature field.", 57 | units=KELVIN, 58 | ) 59 | 60 | unsteady_spec: UnsteadySpec = pd.Field( 61 | ..., 62 | title="Unsteady specification", 63 | description="Time step and total time steps for the unsteady simulation.", 64 | ) 65 | -------------------------------------------------------------------------------- /tidy3d/components/tcad/boundary/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/tcad/boundary/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/tcad/boundary/abstract.py: -------------------------------------------------------------------------------- 1 | """Defines heat material specifications""" 2 | 3 | from __future__ import annotations 4 | 5 | from abc import ABC 6 | 7 | from tidy3d.components.base import Tidy3dBaseModel 8 | 9 | 10 | class HeatChargeBC(ABC, Tidy3dBaseModel): 11 | """Abstract heat-charge boundary conditions.""" 12 | -------------------------------------------------------------------------------- /tidy3d/components/tcad/boundary/heat.py: -------------------------------------------------------------------------------- 1 | """Defines heat material specifications""" 2 | 3 | from __future__ import annotations 4 | 5 | import pydantic.v1 as pd 6 | 7 | from tidy3d.components.tcad.boundary.abstract import HeatChargeBC 8 | from tidy3d.constants import HEAT_FLUX, HEAT_TRANSFER_COEFF, KELVIN 9 | 10 | 11 | class TemperatureBC(HeatChargeBC): 12 | """Constant temperature thermal boundary conditions. 13 | 14 | Example 15 | ------- 16 | >>> import tidy3d as td 17 | >>> bc = td.TemperatureBC(temperature=300) 18 | """ 19 | 20 | temperature: pd.PositiveFloat = pd.Field( 21 | title="Temperature", 22 | description=f"Temperature value in units of {KELVIN}.", 23 | units=KELVIN, 24 | ) 25 | 26 | 27 | class HeatFluxBC(HeatChargeBC): 28 | """Constant flux thermal boundary conditions. 29 | 30 | Example 31 | ------- 32 | >>> import tidy3d as td 33 | >>> bc = td.HeatFluxBC(flux=1) 34 | """ 35 | 36 | flux: float = pd.Field( 37 | title="Heat Flux", 38 | description=f"Heat flux value in units of {HEAT_FLUX}.", 39 | units=HEAT_FLUX, 40 | ) 41 | 42 | 43 | class ConvectionBC(HeatChargeBC): 44 | """Convective thermal boundary conditions. 45 | 46 | Example 47 | ------- 48 | >>> import tidy3d as td 49 | >>> bc = td.ConvectionBC(ambient_temperature=300, transfer_coeff=1) 50 | """ 51 | 52 | ambient_temperature: pd.PositiveFloat = pd.Field( 53 | title="Ambient Temperature", 54 | description=f"Ambient temperature value in units of {KELVIN}.", 55 | units=KELVIN, 56 | ) 57 | 58 | transfer_coeff: pd.NonNegativeFloat = pd.Field( 59 | title="Heat Transfer Coefficient", 60 | description=f"Heat flux value in units of {HEAT_TRANSFER_COEFF}.", 61 | units=HEAT_TRANSFER_COEFF, 62 | ) 63 | -------------------------------------------------------------------------------- /tidy3d/components/tcad/boundary/specification.py: -------------------------------------------------------------------------------- 1 | """Defines heat material specifications""" 2 | 3 | from __future__ import annotations 4 | 5 | import pydantic.v1 as pd 6 | 7 | from tidy3d.components.base import Tidy3dBaseModel 8 | from tidy3d.components.bc_placement import BCPlacementType 9 | from tidy3d.components.tcad.types import HeatChargeBCType 10 | from tidy3d.components.types import TYPE_TAG_STR 11 | 12 | 13 | class HeatChargeBoundarySpec(Tidy3dBaseModel): 14 | """Heat-Charge boundary conditions specification. 15 | 16 | Example 17 | ------- 18 | >>> import tidy3d as td 19 | >>> bc_v1 = td.HeatChargeBoundarySpec( 20 | ... condition=td.VoltageBC(source=td.DCVoltageSource(voltage=0)), 21 | ... placement=td.StructureBoundary(structure="contact_left"), 22 | ... ) 23 | """ 24 | 25 | placement: BCPlacementType = pd.Field( 26 | title="Boundary Conditions Placement", 27 | description="Location to apply boundary conditions.", 28 | discriminator=TYPE_TAG_STR, 29 | ) 30 | 31 | condition: HeatChargeBCType = pd.Field( 32 | title="Boundary Conditions", 33 | description="Boundary conditions to apply at the selected location.", 34 | discriminator=TYPE_TAG_STR, 35 | ) 36 | 37 | 38 | class HeatBoundarySpec(HeatChargeBoundarySpec): 39 | """Heat BC specification. DEPRECIATED. 40 | 41 | Warning 42 | ------- 43 | Included backward-compatibility only. 44 | 45 | Example 46 | -------- 47 | >>> import tidy3d as td 48 | >>> bc_spec = td.HeatBoundarySpec( 49 | ... placement=td.SimulationBoundary(), 50 | ... condition=td.ConvectionBC(ambient_temperature=300, transfer_coeff=1), 51 | ... ) 52 | 53 | """ 54 | -------------------------------------------------------------------------------- /tidy3d/components/tcad/data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/tcad/data/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/tcad/data/monitor_data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/tcad/data/monitor_data/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/tcad/data/types.py: -------------------------------------------------------------------------------- 1 | """Monitor level data, store the DataArrays associated with a single heat-charge monitor.""" 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union 6 | 7 | from tidy3d.components.tcad.data.monitor_data.charge import ( 8 | SteadyCapacitanceData, 9 | SteadyEnergyBandData, 10 | SteadyFreeCarrierData, 11 | SteadyPotentialData, 12 | ) 13 | from tidy3d.components.tcad.data.monitor_data.heat import TemperatureData 14 | 15 | TCADMonitorDataType = Union[ 16 | TemperatureData, 17 | SteadyPotentialData, 18 | SteadyFreeCarrierData, 19 | SteadyEnergyBandData, 20 | SteadyCapacitanceData, 21 | ] 22 | -------------------------------------------------------------------------------- /tidy3d/components/tcad/monitors/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/tcad/monitors/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/tcad/monitors/abstract.py: -------------------------------------------------------------------------------- 1 | """Objects that define how data is recorded from simulation.""" 2 | 3 | from __future__ import annotations 4 | 5 | from abc import ABC 6 | 7 | import pydantic.v1 as pd 8 | 9 | from tidy3d.components.base_sim.monitor import AbstractMonitor 10 | from tidy3d.components.types import ArrayFloat1D 11 | 12 | BYTES_REAL = 4 13 | 14 | 15 | class HeatChargeMonitor(AbstractMonitor, ABC): 16 | """Abstract base class for heat-charge monitors.""" 17 | 18 | unstructured: bool = pd.Field( 19 | False, 20 | title="Unstructured Grid", 21 | description="Return data on the original unstructured grid.", 22 | ) 23 | 24 | conformal: bool = pd.Field( 25 | False, 26 | title="Conformal Monitor Meshing", 27 | description="If ``True`` the simulation mesh will conform to the monitor's geometry. " 28 | "While this can be set for both Cartesian and unstructured monitors, it bears higher " 29 | "significance for the latter ones. Effectively, setting ``conformal = True`` for " 30 | "unstructured monitors (``unstructured = True``) ensures that returned values " 31 | "will not be obtained by interpolation during postprocessing but rather directly " 32 | "transferred from the computational grid.", 33 | ) 34 | 35 | def storage_size(self, num_cells: int, tmesh: ArrayFloat1D) -> int: 36 | """Size of monitor storage given the number of points after discretization.""" 37 | # stores 1 real number per grid cell, per time step, per field 38 | num_steps = self.num_steps(tmesh) 39 | return BYTES_REAL * num_steps * num_cells * len(self.fields) 40 | -------------------------------------------------------------------------------- /tidy3d/components/tcad/monitors/heat.py: -------------------------------------------------------------------------------- 1 | """Objects that define how data is recorded from simulation.""" 2 | 3 | from __future__ import annotations 4 | 5 | from pydantic.v1 import Field, PositiveInt 6 | 7 | from tidy3d.components.tcad.monitors.abstract import HeatChargeMonitor 8 | 9 | 10 | class TemperatureMonitor(HeatChargeMonitor): 11 | """Temperature monitor.""" 12 | 13 | interval: PositiveInt = Field( 14 | 1, 15 | title="Interval", 16 | description="Sampling rate of the monitor: number of time steps between each measurement. " 17 | "Set ``interval`` to 1 for the highest possible resolution in time. " 18 | "Higher integer values down-sample the data by measuring every ``interval`` time steps. " 19 | "This can be useful for reducing data storage as needed by the application." 20 | "NOTE: this is only relevant for unsteady (transient) Heat simulations. ", 21 | ) 22 | -------------------------------------------------------------------------------- /tidy3d/components/tcad/simulation/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/tcad/simulation/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/tcad/source/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/components/tcad/source/__init__.py -------------------------------------------------------------------------------- /tidy3d/components/tcad/source/abstract.py: -------------------------------------------------------------------------------- 1 | """Defines heat-charge material specifications for 'HeatChargeSimulation'""" 2 | 3 | from __future__ import annotations 4 | 5 | from abc import ABC 6 | 7 | import pydantic.v1 as pd 8 | 9 | from tidy3d.components.base import cached_property 10 | from tidy3d.components.base_sim.source import AbstractSource 11 | from tidy3d.components.tcad.viz import plot_params_heat_source 12 | from tidy3d.components.viz import PlotParams 13 | from tidy3d.exceptions import SetupError 14 | 15 | 16 | class AbstractHeatChargeSource(AbstractSource, ABC): 17 | """Abstract source for heat-charge simulations. All source types 18 | for 'HeatChargeSimulation' derive from this class.""" 19 | 20 | @cached_property 21 | def plot_params(self) -> PlotParams: 22 | """Default parameters for plotting a Source object.""" 23 | return plot_params_heat_source 24 | 25 | 26 | class StructureBasedHeatChargeSource(AbstractHeatChargeSource): 27 | """Abstract class associated with structures. Sources associated 28 | to structures must derive from this class""" 29 | 30 | structures: tuple[str, ...] = pd.Field( 31 | title="Target Structures", 32 | description="Names of structures where to apply heat source.", 33 | ) 34 | 35 | @pd.validator("structures", always=True) 36 | def check_non_empty_structures(cls, val): 37 | """Error if source doesn't point at any structures.""" 38 | if len(val) == 0: 39 | raise SetupError("List of structures for heat source is empty.") 40 | 41 | return val 42 | 43 | 44 | class GlobalHeatChargeSource(AbstractHeatChargeSource): 45 | """Abstract heat/charge source applied to all structures in the simulation""" 46 | -------------------------------------------------------------------------------- /tidy3d/components/tcad/source/coupled.py: -------------------------------------------------------------------------------- 1 | """Defines heat-charge material specifications for 'HeatChargeSimulation'""" 2 | 3 | from __future__ import annotations 4 | 5 | from tidy3d.components.tcad.source.abstract import GlobalHeatChargeSource 6 | 7 | 8 | class HeatFromElectricSource(GlobalHeatChargeSource): 9 | """Volumetric heat source generated from an electric simulation. 10 | 11 | Notes 12 | ----- 13 | 14 | If a :class`HeatFromElectricSource` is specified as a source, appropriate boundary 15 | conditions for an electric simulation must be provided, since such a simulation 16 | will be executed before the heat simulation can run. 17 | 18 | Example 19 | ------- 20 | >>> heat_source = HeatFromElectricSource() 21 | """ 22 | -------------------------------------------------------------------------------- /tidy3d/components/tcad/source/heat.py: -------------------------------------------------------------------------------- 1 | """Defines heat-charge material specifications for 'HeatChargeSimulation'""" 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Union 6 | 7 | import pydantic.v1 as pd 8 | 9 | from tidy3d.components.data.data_array import SpatialDataArray 10 | from tidy3d.components.tcad.source.abstract import StructureBasedHeatChargeSource 11 | from tidy3d.constants import VOLUMETRIC_HEAT_RATE 12 | from tidy3d.log import log 13 | 14 | 15 | class HeatSource(StructureBasedHeatChargeSource): 16 | """Adds a volumetric heat source (heat sink if negative values 17 | are provided) to specific structures in the scene. 18 | 19 | Example 20 | ------- 21 | >>> heat_source = HeatSource(rate=1, structures=["box"]) 22 | """ 23 | 24 | rate: Union[float, SpatialDataArray] = pd.Field( 25 | title="Volumetric Heat Rate", 26 | description="Volumetric rate of heating or cooling (if negative) in units of " 27 | f"{VOLUMETRIC_HEAT_RATE}.", 28 | units=VOLUMETRIC_HEAT_RATE, 29 | ) 30 | 31 | 32 | class UniformHeatSource(HeatSource): 33 | """Volumetric heat source. This class is deprecated. You can use 34 | 'HeatSource' instead. 35 | 36 | Example 37 | ------- 38 | >>> heat_source = UniformHeatSource(rate=1, structures=["box"]) # doctest: +SKIP 39 | """ 40 | 41 | # NOTE: wrapper for backwards compatibility. 42 | 43 | @pd.root_validator(skip_on_failure=True) 44 | def issue_warning_deprecated(cls, values): 45 | """Issue warning for 'UniformHeatSource'.""" 46 | log.warning( 47 | "'UniformHeatSource' is deprecated and will be discontinued. You can use " 48 | "'HeatSource' instead." 49 | ) 50 | return values 51 | -------------------------------------------------------------------------------- /tidy3d/components/tcad/types.py: -------------------------------------------------------------------------------- 1 | """File containing classes required for the setup of a DEVSIM case.""" 2 | 3 | from __future__ import annotations 4 | 5 | from tidy3d.components.tcad.bandgap import SlotboomBandGapNarrowing 6 | from tidy3d.components.tcad.boundary.charge import CurrentBC, InsulatingBC, VoltageBC 7 | from tidy3d.components.tcad.boundary.heat import ConvectionBC, HeatFluxBC, TemperatureBC 8 | from tidy3d.components.tcad.generation_recombination import ( 9 | AugerRecombination, 10 | RadiativeRecombination, 11 | ShockleyReedHallRecombination, 12 | ) 13 | from tidy3d.components.tcad.mobility import CaugheyThomasMobility, ConstantMobilityModel 14 | from tidy3d.components.tcad.monitors.charge import ( 15 | SteadyCapacitanceMonitor, 16 | SteadyEnergyBandMonitor, 17 | SteadyFreeCarrierMonitor, 18 | SteadyPotentialMonitor, 19 | ) 20 | from tidy3d.components.tcad.monitors.heat import TemperatureMonitor 21 | from tidy3d.components.tcad.source.coupled import HeatFromElectricSource 22 | from tidy3d.components.tcad.source.heat import HeatSource, UniformHeatSource 23 | from tidy3d.components.types import Union 24 | 25 | MobilityModelType = Union[CaugheyThomasMobility, ConstantMobilityModel] 26 | RecombinationModelType = Union[ 27 | AugerRecombination, RadiativeRecombination, ShockleyReedHallRecombination 28 | ] 29 | BandGapNarrowingModelType = Union[SlotboomBandGapNarrowing] 30 | 31 | # types of monitors that are accepted by heat simulation 32 | HeatChargeMonitorType = Union[ 33 | TemperatureMonitor, 34 | SteadyPotentialMonitor, 35 | SteadyFreeCarrierMonitor, 36 | SteadyEnergyBandMonitor, 37 | SteadyCapacitanceMonitor, 38 | ] 39 | HeatChargeSourceType = Union[HeatSource, HeatFromElectricSource, UniformHeatSource] 40 | HeatChargeBCType = Union[ 41 | TemperatureBC, HeatFluxBC, ConvectionBC, VoltageBC, CurrentBC, InsulatingBC 42 | ] 43 | -------------------------------------------------------------------------------- /tidy3d/components/tcad/viz.py: -------------------------------------------------------------------------------- 1 | """utilities for heat solver plotting""" 2 | 3 | from __future__ import annotations 4 | 5 | from tidy3d.components.viz import PlotParams 6 | 7 | """ Constants """ 8 | 9 | HEAT_BC_COLOR_TEMPERATURE = "orange" 10 | HEAT_BC_COLOR_FLUX = "green" 11 | HEAT_BC_COLOR_CONVECTION = "brown" 12 | CHARGE_BC_INSULATOR = "black" 13 | HEAT_SOURCE_CMAP = "coolwarm" 14 | CHARGE_DIST_CMAP = "viridis" 15 | 16 | plot_params_heat_bc = PlotParams(lw=3) 17 | plot_params_heat_source = PlotParams(edgecolor="red", lw=0, hatch="..", fill=False) 18 | -------------------------------------------------------------------------------- /tidy3d/components/type_util.py: -------------------------------------------------------------------------------- 1 | """Utilities for type & schema creation.""" 2 | 3 | from __future__ import annotations 4 | 5 | 6 | def _add_schema(arbitrary_type: type, title: str, field_type_str: str) -> None: 7 | """Adds a schema to the ``arbitrary_type`` class without subclassing.""" 8 | 9 | @classmethod 10 | def mod_schema_fn(cls, field_schema: dict) -> None: 11 | """Function that gets set to ``arbitrary_type.__modify_schema__``.""" 12 | field_schema.update({"title": title, "type": field_type_str}) 13 | 14 | arbitrary_type.__modify_schema__ = mod_schema_fn 15 | -------------------------------------------------------------------------------- /tidy3d/components/types_extra.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Any 4 | 5 | from tidy3d.packaging import check_import 6 | 7 | # TODO Complicated as trimesh should be a core package unless decoupled implementation types in functional location. 8 | # We need to restructure. 9 | if check_import("trimesh"): 10 | import trimesh # Won't add much overhead if already imported 11 | 12 | TrimeshType = trimesh.Trimesh 13 | else: 14 | TrimeshType = Any 15 | -------------------------------------------------------------------------------- /tidy3d/components/viz/flex_style.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from tidy3d.log import log 4 | 5 | _ORIGINAL_PARAMS = None 6 | 7 | 8 | def apply_tidy3d_params(): 9 | """ 10 | Applies a set of defaults to the matplotlib params that are following the tidy3d color palettes and design. 11 | """ 12 | global _ORIGINAL_PARAMS 13 | try: 14 | import matplotlib as mpl 15 | import matplotlib.pyplot as plt 16 | 17 | _ORIGINAL_PARAMS = mpl.rcParams.copy() 18 | 19 | try: 20 | plt.style.use("tidy3d.style") 21 | except Exception as e: 22 | log.error(f"Failed to apply Tidy3D plotting style on import. Error: {e}") 23 | _ORIGINAL_PARAMS = {} 24 | except ImportError: 25 | pass 26 | 27 | 28 | def restore_matplotlib_rcparams(): 29 | """ 30 | Resets matplotlib rcParams to the values they had before the Tidy3D 31 | style was automatically applied on import. 32 | """ 33 | global _ORIGINAL_PARAMS 34 | try: 35 | import matplotlib.pyplot as plt 36 | from matplotlib import style 37 | 38 | if not _ORIGINAL_PARAMS: 39 | style.use("default") 40 | return 41 | 42 | plt.rcParams.update(_ORIGINAL_PARAMS) 43 | except ImportError: 44 | log.error("Matplotlib is not installed on your system. Failed to reset to default styles.") 45 | except Exception as e: 46 | log.error(f"Failed to reset previous Matplotlib style. Error: {e}") 47 | -------------------------------------------------------------------------------- /tidy3d/components/viz/styles.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | try: 4 | from matplotlib.patches import ArrowStyle 5 | 6 | arrow_style = ArrowStyle.Simple(head_length=11, head_width=9, tail_width=4) 7 | except ImportError: 8 | arrow_style = None 9 | 10 | FLEXCOMPUTE_COLORS = { 11 | "brand_green": "#00643C", 12 | "brand_tan": "#B8A18B", 13 | "brand_blue": "#6DB5DD", 14 | "brand_purple": "#8851AD", 15 | "brand_black": "#000000", 16 | "brand_orange": "#FC7A4C", 17 | } 18 | ARROW_COLOR_SOURCE = FLEXCOMPUTE_COLORS["brand_green"] 19 | ARROW_COLOR_POLARIZATION = FLEXCOMPUTE_COLORS["brand_tan"] 20 | ARROW_COLOR_MONITOR = FLEXCOMPUTE_COLORS["brand_orange"] 21 | PLOT_BUFFER = 0.3 22 | ARROW_ALPHA = 0.8 23 | ARROW_LENGTH = 0.3 24 | 25 | # stores color of simulation.structures for given index in simulation.medium_map 26 | MEDIUM_CMAP = [ 27 | "#689DBC", 28 | "#D0698E", 29 | "#5E6EAD", 30 | "#C6224E", 31 | "#BDB3E2", 32 | "#9EC3E0", 33 | "#616161", 34 | "#877EBC", 35 | ] 36 | 37 | # colormap for structure's permittivity in plot_eps 38 | STRUCTURE_EPS_CMAP = "gist_yarg" 39 | STRUCTURE_EPS_CMAP_R = "gist_yarg_r" 40 | STRUCTURE_HEAT_COND_CMAP = "gist_yarg" 41 | -------------------------------------------------------------------------------- /tidy3d/components/viz/visualization_spec.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Any, Optional 4 | 5 | import pydantic.v1 as pd 6 | 7 | from tidy3d.components.base import Tidy3dBaseModel 8 | from tidy3d.log import log 9 | 10 | MATPLOTLIB_IMPORTED = True 11 | try: 12 | from matplotlib.colors import is_color_like 13 | except ImportError: 14 | is_color_like = None 15 | MATPLOTLIB_IMPORTED = False 16 | 17 | 18 | def is_valid_color(value: str) -> str: 19 | if not MATPLOTLIB_IMPORTED: 20 | log.warning( 21 | "matplotlib was not successfully imported, but is required " 22 | "to validate colors in the VisualizationSpec. The specified colors " 23 | "have not been validated." 24 | ) 25 | else: 26 | if is_color_like is not None and not is_color_like(value): 27 | raise ValueError(f"{value} is not a valid plotting color") 28 | 29 | return value 30 | 31 | 32 | class VisualizationSpec(Tidy3dBaseModel): 33 | """Defines specification for visualization when used with plotting functions.""" 34 | 35 | facecolor: str = pd.Field( 36 | "", 37 | title="Face color", 38 | description="Color applied to the faces in visualization.", 39 | ) 40 | 41 | edgecolor: Optional[str] = pd.Field( 42 | "", 43 | title="Edge color", 44 | description="Color applied to the edges in visualization.", 45 | ) 46 | 47 | alpha: Optional[pd.confloat(ge=0.0, le=1.0)] = pd.Field( 48 | 1.0, 49 | title="Opacity", 50 | description="Opacity/alpha value in plotting between 0 and 1.", 51 | ) 52 | 53 | @pd.validator("facecolor", always=True) 54 | def validate_color(value: str) -> str: 55 | return is_valid_color(value) 56 | 57 | @pd.validator("edgecolor", always=True) 58 | def validate_and_copy_color(value: str, values: dict[str, Any]) -> str: 59 | if (value == "") and "facecolor" in values: 60 | return is_valid_color(values["facecolor"]) 61 | 62 | return is_valid_color(value) 63 | -------------------------------------------------------------------------------- /tidy3d/exceptions.py: -------------------------------------------------------------------------------- 1 | """Custom Tidy3D exceptions""" 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | 7 | from .log import log 8 | 9 | 10 | class Tidy3dError(ValueError): 11 | """Any error in tidy3d""" 12 | 13 | def __init__(self, message: Optional[str] = None): 14 | """Log just the error message and then raise the Exception.""" 15 | super().__init__(message) 16 | log.error(message) 17 | 18 | 19 | class ConfigError(Tidy3dError): 20 | """Error when configuring Tidy3d.""" 21 | 22 | 23 | class Tidy3dKeyError(Tidy3dError): 24 | """Could not find a key in a Tidy3d dictionary.""" 25 | 26 | 27 | class ValidationError(Tidy3dError): 28 | """Error when constructing Tidy3d components.""" 29 | 30 | 31 | class SetupError(Tidy3dError): 32 | """Error regarding the setup of the components (outside of domains, etc).""" 33 | 34 | 35 | class FileError(Tidy3dError): 36 | """Error reading or writing to file.""" 37 | 38 | 39 | class WebError(Tidy3dError): 40 | """Error with the webAPI.""" 41 | 42 | 43 | class AuthenticationError(Tidy3dError): 44 | """Error authenticating a user through webapi webAPI.""" 45 | 46 | 47 | class DataError(Tidy3dError): 48 | """Error accessing data.""" 49 | 50 | 51 | class Tidy3dImportError(Tidy3dError): 52 | """Error importing a package needed for tidy3d.""" 53 | 54 | 55 | class Tidy3dNotImplementedError(Tidy3dError): 56 | """Error when a functionality is not (yet) supported.""" 57 | 58 | 59 | class AdjointError(Tidy3dError): 60 | """An error in setting up the adjoint solver.""" 61 | -------------------------------------------------------------------------------- /tidy3d/material_library/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/material_library/__init__.py -------------------------------------------------------------------------------- /tidy3d/plugins/__init__.py: -------------------------------------------------------------------------------- 1 | """External plugins that have tidy3d as dependency and add functionality.""" 2 | -------------------------------------------------------------------------------- /tidy3d/plugins/adjoint/__init__.py: -------------------------------------------------------------------------------- 1 | """Imports for adjoint plugin.""" 2 | 3 | # import the jax version of tidy3d components 4 | from __future__ import annotations 5 | 6 | try: 7 | import jax 8 | 9 | jax.config.update("jax_enable_x64", True) 10 | except ImportError as e: 11 | raise ImportError( 12 | "The 'jax' package is required for adjoint plugin. We were not able to import it. " 13 | "To get the appropriate packages for your system, install tidy3d using '[jax]' option, " 14 | "for example: $pip install 'tidy3d[jax]'." 15 | ) from e 16 | 17 | from .components.data.data_array import JaxDataArray 18 | from .components.data.dataset import JaxPermittivityDataset 19 | from .components.data.monitor_data import JaxModeData 20 | from .components.data.sim_data import JaxSimulationData 21 | from .components.geometry import JaxBox, JaxComplexPolySlab, JaxGeometryGroup, JaxPolySlab 22 | from .components.medium import JaxAnisotropicMedium, JaxCustomMedium, JaxMedium 23 | from .components.simulation import JaxSimulation 24 | from .components.structure import ( 25 | JaxStructure, 26 | JaxStructureStaticGeometry, 27 | JaxStructureStaticMedium, 28 | ) 29 | from .web import run, run_async 30 | 31 | __all__ = [ 32 | "JaxAnisotropicMedium", 33 | "JaxBox", 34 | "JaxComplexPolySlab", 35 | "JaxCustomMedium", 36 | "JaxDataArray", 37 | "JaxGeometryGroup", 38 | "JaxMedium", 39 | "JaxModeData", 40 | "JaxPermittivityDataset", 41 | "JaxPolySlab", 42 | "JaxSimulation", 43 | "JaxSimulationData", 44 | "JaxStructure", 45 | "JaxStructureStaticGeometry", 46 | "JaxStructureStaticMedium", 47 | "run", 48 | "run_async", 49 | ] 50 | -------------------------------------------------------------------------------- /tidy3d/plugins/adjoint/components/__init__.py: -------------------------------------------------------------------------------- 1 | """Component imports for adjoint plugin. from tidy3d.plugins.adjoint.components import *""" 2 | 3 | # import the jax version of tidy3d components 4 | from __future__ import annotations 5 | 6 | from .data.data_array import JaxDataArray 7 | from .data.dataset import JaxPermittivityDataset 8 | from .data.monitor_data import JaxModeData 9 | from .data.sim_data import JaxSimulationData 10 | from .geometry import JaxBox, JaxComplexPolySlab, JaxPolySlab 11 | from .medium import JaxAnisotropicMedium, JaxCustomMedium, JaxMedium 12 | from .simulation import JaxSimulation 13 | from .structure import JaxStructure, JaxStructureStaticGeometry, JaxStructureStaticMedium 14 | 15 | __all__ = [ 16 | "JaxAnisotropicMedium", 17 | "JaxBox", 18 | "JaxComplexPolySlab", 19 | "JaxCustomMedium", 20 | "JaxDataArray", 21 | "JaxGeometryGroup", 22 | "JaxMedium", 23 | "JaxModeData", 24 | "JaxPermittivityDataset", 25 | "JaxPolySlab", 26 | "JaxSimulation", 27 | "JaxSimulationData", 28 | "JaxStructure", 29 | "JaxStructureStaticGeometry", 30 | "JaxStructureStaticMedium", 31 | ] 32 | -------------------------------------------------------------------------------- /tidy3d/plugins/adjoint/components/data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/plugins/adjoint/components/data/__init__.py -------------------------------------------------------------------------------- /tidy3d/plugins/adjoint/components/data/dataset.py: -------------------------------------------------------------------------------- 1 | """Defines jax-compatible datasets.""" 2 | 3 | from __future__ import annotations 4 | 5 | import pydantic.v1 as pd 6 | from jax.tree_util import register_pytree_node_class 7 | 8 | from tidy3d.components.data.dataset import PermittivityDataset 9 | from tidy3d.plugins.adjoint.components.base import JaxObject 10 | 11 | from .data_array import JaxDataArray 12 | 13 | 14 | @register_pytree_node_class 15 | class JaxPermittivityDataset(PermittivityDataset, JaxObject): 16 | """A :class:`.PermittivityDataset` registered with jax.""" 17 | 18 | _tidy3d_class = PermittivityDataset 19 | 20 | eps_xx: JaxDataArray = pd.Field( 21 | ..., 22 | title="Epsilon xx", 23 | description="Spatial distribution of the xx-component of the relative permittivity.", 24 | jax_field=True, 25 | ) 26 | eps_yy: JaxDataArray = pd.Field( 27 | ..., 28 | title="Epsilon yy", 29 | description="Spatial distribution of the yy-component of the relative permittivity.", 30 | jax_field=True, 31 | ) 32 | eps_zz: JaxDataArray = pd.Field( 33 | ..., 34 | title="Epsilon zz", 35 | description="Spatial distribution of the zz-component of the relative permittivity.", 36 | jax_field=True, 37 | ) 38 | -------------------------------------------------------------------------------- /tidy3d/plugins/adjoint/components/types.py: -------------------------------------------------------------------------------- 1 | """Special types and validators used by adjoint plugin.""" 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Any, Union 6 | 7 | import numpy as np 8 | 9 | from tidy3d.components.type_util import _add_schema 10 | 11 | # special handling if we cant import the JVPTracer in the future (so it doesn't break tidy3d). 12 | try: 13 | from jax.interpreters.ad import JVPTracer 14 | except ImportError: 15 | import tidy3d as td 16 | 17 | td.log.warning( 18 | "Could not import 'jax.interpreters.ad.JVPTracer'. " 19 | "As a temporary fix, 'jax'-traced floats will use 'typing.Any' in their type annotation. " 20 | "If you encounter this warning, please file an issue on the Tidy3D front end repository " 21 | "as it indicates that the 'adjoint' plugin will need to be upgraded." 22 | ) 23 | JVPTracer = Any 24 | 25 | from jax.numpy import ndarray as JaxArrayType 26 | 27 | """ Define schema for these jax and numpy types.""" 28 | 29 | 30 | class NumpyArrayType(np.ndarray): 31 | """Subclass of ``np.ndarray`` with a schema defined for pydantic.""" 32 | 33 | @classmethod 34 | def __modify_schema__(cls, field_schema): 35 | """Sets the schema of np.ndarray object.""" 36 | 37 | schema = { 38 | "title": "npdarray", 39 | "type": "numpy.ndarray", 40 | } 41 | field_schema.update(schema) 42 | 43 | 44 | _add_schema(JaxArrayType, title="JaxArray", field_type_str="jax.numpy.ndarray") 45 | 46 | # if the ImportError didnt occur, add the schema 47 | if JVPTracer is not Any: 48 | _add_schema(JVPTracer, title="JVPTracer", field_type_str="jax.interpreters.ad.JVPTracer") 49 | 50 | # define types usable as floats including the jax tracers 51 | JaxArrayLike = Union[NumpyArrayType, JaxArrayType] 52 | JaxFloat = Union[float, JaxArrayLike, JVPTracer, object] 53 | # note: object is included here because sometimes jax passes just `object` (i think when untraced) 54 | -------------------------------------------------------------------------------- /tidy3d/plugins/adjoint/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/plugins/adjoint/utils/__init__.py -------------------------------------------------------------------------------- /tidy3d/plugins/autograd/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from .differential_operators import grad, value_and_grad 4 | from .functions import ( 5 | add_at, 6 | convolve, 7 | grey_closing, 8 | grey_dilation, 9 | grey_erosion, 10 | grey_opening, 11 | interpn, 12 | least_squares, 13 | morphological_gradient, 14 | morphological_gradient_external, 15 | morphological_gradient_internal, 16 | pad, 17 | rescale, 18 | smooth_max, 19 | smooth_min, 20 | threshold, 21 | trapz, 22 | ) 23 | from .invdes import ( 24 | CircularFilter, 25 | ConicFilter, 26 | ErosionDilationPenalty, 27 | FilterAndProject, 28 | grey_indicator, 29 | make_circular_filter, 30 | make_conic_filter, 31 | make_curvature_penalty, 32 | make_erosion_dilation_penalty, 33 | make_filter, 34 | make_filter_and_project, 35 | ramp_projection, 36 | tanh_projection, 37 | ) 38 | from .primitives import gaussian_filter, interpolate_spline 39 | from .utilities import chain, get_kernel_size_px, make_kernel, scalar_objective 40 | 41 | __all__ = [ 42 | "CircularFilter", 43 | "ConicFilter", 44 | "ErosionDilationPenalty", 45 | "FilterAndProject", 46 | "add_at", 47 | "chain", 48 | "convolve", 49 | "gaussian_filter", 50 | "get_kernel_size_px", 51 | "grad", 52 | "grey_closing", 53 | "grey_dilation", 54 | "grey_erosion", 55 | "grey_indicator", 56 | "grey_opening", 57 | "interpn", 58 | "interpolate_spline", 59 | "least_squares", 60 | "make_circular_filter", 61 | "make_conic_filter", 62 | "make_curvature_penalty", 63 | "make_erosion_dilation_penalty", 64 | "make_filter", 65 | "make_filter_and_project", 66 | "make_kernel", 67 | "morphological_gradient", 68 | "morphological_gradient_external", 69 | "morphological_gradient_internal", 70 | "pad", 71 | "ramp_projection", 72 | "rescale", 73 | "scalar_objective", 74 | "smooth_max", 75 | "smooth_min", 76 | "tanh_projection", 77 | "threshold", 78 | "trapz", 79 | "value_and_grad", 80 | ] 81 | -------------------------------------------------------------------------------- /tidy3d/plugins/autograd/constants.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | BETA_DEFAULT = 1.0 4 | ETA_DEFAULT = 0.5 5 | -------------------------------------------------------------------------------- /tidy3d/plugins/autograd/invdes/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from .filters import ( 4 | CircularFilter, 5 | ConicFilter, 6 | make_circular_filter, 7 | make_conic_filter, 8 | make_filter, 9 | ) 10 | from .misc import grey_indicator 11 | from .parametrizations import FilterAndProject, make_filter_and_project 12 | from .penalties import ErosionDilationPenalty, make_curvature_penalty, make_erosion_dilation_penalty 13 | from .projections import ramp_projection, tanh_projection 14 | 15 | __all__ = [ 16 | "CircularFilter", 17 | "ConicFilter", 18 | "ErosionDilationPenalty", 19 | "FilterAndProject", 20 | "grey_indicator", 21 | "make_circular_filter", 22 | "make_conic_filter", 23 | "make_curvature_penalty", 24 | "make_erosion_dilation_penalty", 25 | "make_filter", 26 | "make_filter_and_project", 27 | "ramp_projection", 28 | "tanh_projection", 29 | ] 30 | -------------------------------------------------------------------------------- /tidy3d/plugins/autograd/invdes/misc.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import autograd.numpy as np 4 | from numpy.typing import NDArray 5 | 6 | 7 | def grey_indicator(array: NDArray) -> float: 8 | """Calculate the grey indicator for a given array. 9 | 10 | The grey indicator returns 1 for completely grey arrays (all 0.5) and 0 for 11 | perfectly binary arrays. It is calculated based on: 12 | Sigmund, Ole. "Morphology-based black and white filters for topology optimization." 13 | Structural and Multidisciplinary Optimization 33 (2007): 401-424. 14 | 15 | Parameters 16 | ---------- 17 | array : np.ndarray 18 | The input array for which the grey indicator is to be calculated. 19 | 20 | Returns 21 | ------- 22 | float 23 | The calculated grey indicator. 24 | """ 25 | return np.mean(4 * array * (1 - array)) 26 | -------------------------------------------------------------------------------- /tidy3d/plugins/autograd/primitives/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from .interpolate import interpolate_spline 4 | from .misc import gaussian_filter 5 | 6 | __all__ = ["gaussian_filter", "interpolate_spline"] 7 | -------------------------------------------------------------------------------- /tidy3d/plugins/autograd/primitives/misc.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import scipy.ndimage 4 | from autograd.extend import defvjp, primitive 5 | 6 | gaussian_filter = primitive(scipy.ndimage.gaussian_filter) 7 | defvjp( 8 | gaussian_filter, 9 | lambda ans, x, *args, **kwargs: lambda g: gaussian_filter(g, *args, **kwargs), 10 | ) 11 | -------------------------------------------------------------------------------- /tidy3d/plugins/autograd/types.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Literal 4 | 5 | PaddingType = Literal["constant", "edge", "reflect", "symmetric", "wrap"] 6 | KernelType = Literal["circular", "conic"] 7 | -------------------------------------------------------------------------------- /tidy3d/plugins/design/__init__.py: -------------------------------------------------------------------------------- 1 | """Imports for parameter sweep.""" 2 | 3 | from __future__ import annotations 4 | 5 | from .design import DesignSpace 6 | from .method import ( 7 | MethodBayOpt, 8 | MethodGenAlg, 9 | MethodGrid, 10 | MethodMonteCarlo, 11 | MethodParticleSwarm, 12 | ) 13 | from .parameter import ParameterAny, ParameterFloat, ParameterInt 14 | from .result import Result 15 | 16 | __all__ = [ 17 | "DesignSpace", 18 | "MethodBayOpt", 19 | "MethodGenAlg", 20 | "MethodGrid", 21 | "MethodMonteCarlo", 22 | "MethodParticleSwarm", 23 | "ParameterAny", 24 | "ParameterFloat", 25 | "ParameterInt", 26 | "Result", 27 | ] 28 | -------------------------------------------------------------------------------- /tidy3d/plugins/dispersion/__init__.py: -------------------------------------------------------------------------------- 1 | """Imports from dispersion fitter plugin.""" 2 | 3 | from __future__ import annotations 4 | 5 | from .fit import DispersionFitter 6 | from .fit_fast import AdvancedFastFitterParam, FastDispersionFitter 7 | from .web import AdvancedFitterParam, StableDispersionFitter 8 | 9 | __all__ = [ 10 | "AdvancedFastFitterParam", 11 | "AdvancedFitterParam", 12 | "DispersionFitter", 13 | "FastDispersionFitter", 14 | "StableDispersionFitter", 15 | ] 16 | -------------------------------------------------------------------------------- /tidy3d/plugins/dispersion/fit_web.py: -------------------------------------------------------------------------------- 1 | """Deprecated module""" 2 | 3 | from __future__ import annotations 4 | 5 | from tidy3d.log import log 6 | 7 | log.warning( 8 | "The module 'plugins.dispersion.fit_web' has been deprecated in favor of " 9 | "'plugins.dispersion.web' and will be removed in future versions." 10 | ) 11 | -------------------------------------------------------------------------------- /tidy3d/plugins/expressions/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from .base import Expression 4 | from .functions import Cos, Exp, Log, Log10, Sin, Sqrt, Tan 5 | from .metrics import ModeAmp, ModePower, generate_validation_data 6 | from .variables import Constant, Variable 7 | 8 | __all__ = [ 9 | "Constant", 10 | "Cos", 11 | "Exp", 12 | "Expression", 13 | "Log", 14 | "Log10", 15 | "ModeAmp", 16 | "ModePower", 17 | "Sin", 18 | "Sqrt", 19 | "Tan", 20 | "Variable", 21 | "generate_validation_data", 22 | ] 23 | 24 | # The following code dynamically collects all classes that are subclasses of Expression 25 | # from the specified modules and updates their forward references. This is necessary to handle 26 | # cases where classes reference each other before they are fully defined. The local_vars dictionary 27 | # is used to store these classes and any other necessary types for the forward reference updates. 28 | 29 | import importlib 30 | import inspect 31 | 32 | from .types import ExpressionType 33 | 34 | _module_names = ["base", "variables", "functions", "metrics", "operators"] 35 | _model_classes = set() 36 | _local_vars = {"ExpressionType": ExpressionType} 37 | 38 | for module_name in _module_names: 39 | module = importlib.import_module(f".{module_name}", package=__name__) 40 | for name, obj in inspect.getmembers(module): 41 | if inspect.isclass(obj) and issubclass(obj, Expression): 42 | _model_classes.add(obj) 43 | _local_vars[name] = obj 44 | 45 | for cls in _model_classes: 46 | cls.update_forward_refs(**_local_vars) 47 | -------------------------------------------------------------------------------- /tidy3d/plugins/expressions/types.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import TYPE_CHECKING, Annotated, Union 4 | 5 | from pydantic.v1 import Field 6 | 7 | from tidy3d.components.types import TYPE_TAG_STR, ArrayLike, Complex 8 | 9 | if TYPE_CHECKING: 10 | from .functions import Cos, Exp, Log, Log10, Sin, Sqrt, Tan 11 | from .metrics import ModeAmp, ModePower 12 | from .operators import ( 13 | Abs, 14 | Add, 15 | Divide, 16 | FloorDivide, 17 | MatMul, 18 | Modulus, 19 | Multiply, 20 | Negate, 21 | Power, 22 | Subtract, 23 | ) 24 | from .variables import Constant, Variable 25 | 26 | NumberType = Union[int, float, Complex, ArrayLike] 27 | 28 | OperatorType = Annotated[ 29 | Union[ 30 | "Add", 31 | "Subtract", 32 | "Multiply", 33 | "Divide", 34 | "Power", 35 | "Modulus", 36 | "FloorDivide", 37 | "MatMul", 38 | "Negate", 39 | "Abs", 40 | ], 41 | Field(discriminator=TYPE_TAG_STR), 42 | ] 43 | 44 | FunctionType = Annotated[ 45 | Union[ 46 | "Sin", 47 | "Cos", 48 | "Tan", 49 | "Exp", 50 | "Log", 51 | "Log10", 52 | "Sqrt", 53 | ], 54 | Field(discriminator=TYPE_TAG_STR), 55 | ] 56 | 57 | MetricType = Annotated[ 58 | Union[ 59 | "Constant", 60 | "Variable", 61 | "ModeAmp", 62 | "ModePower", 63 | ], 64 | Field(discriminator=TYPE_TAG_STR), 65 | ] 66 | 67 | ExpressionType = Union[ 68 | OperatorType, 69 | FunctionType, 70 | MetricType, 71 | ] 72 | 73 | NumberOrExpression = Union[NumberType, ExpressionType] 74 | -------------------------------------------------------------------------------- /tidy3d/plugins/invdes/__init__.py: -------------------------------------------------------------------------------- 1 | # imports from tidy3d.plugins.invdes as tdi 2 | from __future__ import annotations 3 | 4 | from . import utils 5 | from .design import InverseDesign, InverseDesignMulti 6 | from .initialization import ( 7 | CustomInitializationSpec, 8 | RandomInitializationSpec, 9 | UniformInitializationSpec, 10 | ) 11 | from .optimizer import AdamOptimizer 12 | from .penalty import ErosionDilationPenalty 13 | from .region import TopologyDesignRegion 14 | from .result import InverseDesignResult 15 | from .transformation import FilterProject 16 | 17 | __all__ = ( 18 | "AdamOptimizer", 19 | "CustomInitializationSpec", 20 | "ErosionDilationPenalty", 21 | "FilterProject", 22 | "InverseDesign", 23 | "InverseDesignMulti", 24 | "InverseDesignResult", 25 | "RandomInitializationSpec", 26 | "TopologyDesignRegion", 27 | "UniformInitializationSpec", 28 | "utils", 29 | ) 30 | -------------------------------------------------------------------------------- /tidy3d/plugins/invdes/base.py: -------------------------------------------------------------------------------- 1 | # base class for all of the invdes fields 2 | from __future__ import annotations 3 | 4 | import abc 5 | 6 | import tidy3d as td 7 | 8 | 9 | class InvdesBaseModel(td.components.base.Tidy3dBaseModel, abc.ABC): 10 | """Base class for ``invdes`` components, in case we need it.""" 11 | -------------------------------------------------------------------------------- /tidy3d/plugins/microwave/__init__.py: -------------------------------------------------------------------------------- 1 | """Imports from microwave plugin.""" 2 | 3 | from __future__ import annotations 4 | 5 | from . import models 6 | from .array_factor import ( 7 | RectangularAntennaArrayCalculator, 8 | ) 9 | from .auto_path_integrals import path_integrals_from_lumped_element 10 | from .custom_path_integrals import ( 11 | CustomCurrentIntegral2D, 12 | CustomPathIntegral2D, 13 | CustomVoltageIntegral2D, 14 | ) 15 | from .impedance_calculator import CurrentIntegralTypes, ImpedanceCalculator, VoltageIntegralTypes 16 | from .lobe_measurer import LobeMeasurer 17 | from .path_integrals import ( 18 | AxisAlignedPathIntegral, 19 | CurrentIntegralAxisAligned, 20 | VoltageIntegralAxisAligned, 21 | ) 22 | from .rf_material_library import rf_material_library 23 | 24 | __all__ = [ 25 | "AxisAlignedPathIntegral", 26 | "CurrentIntegralAxisAligned", 27 | "CurrentIntegralTypes", 28 | "CustomCurrentIntegral2D", 29 | "CustomPathIntegral2D", 30 | "CustomVoltageIntegral2D", 31 | "ImpedanceCalculator", 32 | "LobeMeasurer", 33 | "RectangularAntennaArrayCalculator", 34 | "VoltageIntegralAxisAligned", 35 | "VoltageIntegralTypes", 36 | "models", 37 | "path_integrals_from_lumped_element", 38 | "rf_material_library", 39 | ] 40 | -------------------------------------------------------------------------------- /tidy3d/plugins/microwave/models/__init__.py: -------------------------------------------------------------------------------- 1 | """Imports for transmission line models.""" 2 | 3 | from __future__ import annotations 4 | 5 | from . import coupled_microstrip, microstrip 6 | 7 | __all__ = [ 8 | "coupled_microstrip", 9 | "microstrip", 10 | ] 11 | -------------------------------------------------------------------------------- /tidy3d/plugins/microwave/rf_material_reference.py: -------------------------------------------------------------------------------- 1 | """Holds the reference materials for Tidy3D material library.""" 2 | 3 | from __future__ import annotations 4 | 5 | from tidy3d.material_library.material_reference import ReferenceData 6 | 7 | rf_material_refs = { 8 | "Rogers3003": ReferenceData( 9 | manufacturer="Rogers Corporation", 10 | datasheet_title="RO3003™ Laminates", 11 | url="https://www.rogerscorp.com/advanced-electronics-solutions/ro3000-series-laminates/ro3003-laminates", 12 | ), 13 | "Rogers3010": ReferenceData( 14 | manufacturer="Rogers Corporation", 15 | datasheet_title="RO3010™ Laminates", 16 | url="https://www.rogerscorp.com/advanced-electronics-solutions/ro3000-series-laminates/ro3010-laminates", 17 | ), 18 | "Rogers4003C": ReferenceData( 19 | manufacturer="Rogers Corporation", 20 | datasheet_title="RO4003C™ Laminates", 21 | url="https://www.rogerscorp.com/advanced-electronics-solutions/ro4000-series-laminates/ro4350b-laminates", 22 | ), 23 | "Rogers4350B": ReferenceData( 24 | manufacturer="Rogers Corporation", 25 | datasheet_title="RO4350B™ Laminates", 26 | url="https://www.rogerscorp.com/advanced-electronics-solutions/ro4000-series-laminates/ro4350b-laminates", 27 | ), 28 | "ArlonAD255C": ReferenceData( 29 | manufacturer="Rogers Corporation", 30 | datasheet_title="AD255C High Performance Polyimide Laminates", 31 | url="https://www.rogerscorp.com/advanced-electronics-solutions/ad-series-laminates/ad255c-laminates", 32 | ), 33 | "FR4_standard": ReferenceData( 34 | manufacturer="Isola", 35 | datasheet_title="Standard FR-4 Epoxy Glass Cloth Laminate", 36 | url="https://www.isola-group.com/pcb-laminates-prepreg/is410-fr-4-epoxy-laminate-and-prepreg/", 37 | ), 38 | "FR4_lowloss": ReferenceData( 39 | manufacturer="Isola", 40 | datasheet_title="Low loss FR-4 Epoxy Glass Cloth Laminate", 41 | url="https://www.isola-group.com/pcb-laminates-prepreg/is410-fr-4-epoxy-laminate-and-prepreg/", 42 | ), 43 | } 44 | -------------------------------------------------------------------------------- /tidy3d/plugins/microwave/viz.py: -------------------------------------------------------------------------------- 1 | """Utilities for plotting microwave components""" 2 | 3 | from __future__ import annotations 4 | 5 | from numpy import inf 6 | 7 | from tidy3d.components.viz import PathPlotParams 8 | 9 | """ Constants """ 10 | VOLTAGE_COLOR = "red" 11 | CURRENT_COLOR = "blue" 12 | LOBE_PEAK_COLOR = "tab:red" 13 | LOBE_WIDTH_COLOR = "tab:orange" 14 | LOBE_FNBW_COLOR = "tab:blue" 15 | PATH_LINEWIDTH = 2 16 | ARROW_CURRENT = { 17 | "arrowstyle": "-|>", 18 | "mutation_scale": 32, 19 | "linestyle": "", 20 | "lw": PATH_LINEWIDTH, 21 | "color": CURRENT_COLOR, 22 | } 23 | 24 | plot_params_voltage_path = PathPlotParams( 25 | alpha=1.0, 26 | zorder=inf, 27 | color=VOLTAGE_COLOR, 28 | linestyle="--", 29 | linewidth=PATH_LINEWIDTH, 30 | marker="o", 31 | markersize=10, 32 | markeredgecolor=VOLTAGE_COLOR, 33 | markerfacecolor="white", 34 | ) 35 | 36 | plot_params_voltage_plus = PathPlotParams( 37 | alpha=1.0, 38 | zorder=inf, 39 | color=VOLTAGE_COLOR, 40 | marker="+", 41 | markersize=6, 42 | ) 43 | 44 | plot_params_voltage_minus = PathPlotParams( 45 | alpha=1.0, 46 | zorder=inf, 47 | color=VOLTAGE_COLOR, 48 | marker="_", 49 | markersize=6, 50 | ) 51 | 52 | plot_params_current_path = PathPlotParams( 53 | alpha=1.0, 54 | zorder=inf, 55 | color=CURRENT_COLOR, 56 | linestyle="--", 57 | linewidth=PATH_LINEWIDTH, 58 | marker="", 59 | ) 60 | 61 | plot_params_lobe_peak = PathPlotParams( 62 | alpha=1.0, 63 | zorder=inf, 64 | color=LOBE_PEAK_COLOR, 65 | linestyle="-", 66 | linewidth=1, 67 | marker="", 68 | ) 69 | 70 | plot_params_lobe_width = PathPlotParams( 71 | alpha=1.0, 72 | zorder=inf, 73 | color=LOBE_WIDTH_COLOR, 74 | linestyle="--", 75 | linewidth=1, 76 | marker="", 77 | ) 78 | 79 | plot_params_lobe_FNBW = PathPlotParams( 80 | alpha=1.0, 81 | zorder=inf, 82 | color=LOBE_FNBW_COLOR, 83 | linestyle=":", 84 | linewidth=1, 85 | marker="", 86 | ) 87 | -------------------------------------------------------------------------------- /tidy3d/plugins/mode/LICENSE: -------------------------------------------------------------------------------- 1 | Some functions in the current module are derived from the ceviche package 2 | https://github.com/fancompute/ceviche 3 | 4 | MIT License 5 | 6 | Copyright (c) 2021 Flexcompute 7 | Copyright (c) 2019 Tyler Hughes 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in all 17 | copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | SOFTWARE. -------------------------------------------------------------------------------- /tidy3d/plugins/mode/README.md: -------------------------------------------------------------------------------- 1 | # Mode Solver for propagating EM modes 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /tidy3d/plugins/mode/__init__.py: -------------------------------------------------------------------------------- 1 | """Imports from mode solver plugin.""" 2 | 3 | from __future__ import annotations 4 | 5 | from .mode_solver import ModeSolver, ModeSolverData 6 | 7 | __all__ = ["ModeSolver", "ModeSolverData"] 8 | -------------------------------------------------------------------------------- /tidy3d/plugins/mode/mode_solver.py: -------------------------------------------------------------------------------- 1 | """Solve for modes in a 2D cross-sectional plane in a simulation, assuming translational 2 | invariance along a given propagation axis. 3 | """ 4 | 5 | from __future__ import annotations 6 | 7 | from tidy3d.components.data.monitor_data import ModeSolverData 8 | from tidy3d.components.mode.mode_solver import MODE_MONITOR_NAME, MODE_PLANE_TYPE, ModeSolver 9 | 10 | _ = ModeSolver 11 | _ = ModeSolverData 12 | _ = MODE_MONITOR_NAME 13 | _ = MODE_PLANE_TYPE 14 | -------------------------------------------------------------------------------- /tidy3d/plugins/mode/web.py: -------------------------------------------------------------------------------- 1 | """Web API for mode solver""" 2 | 3 | from __future__ import annotations 4 | 5 | from tidy3d.web.api.mode import run, run_batch 6 | 7 | __all__ = ["run", "run_batch"] 8 | -------------------------------------------------------------------------------- /tidy3d/plugins/polyslab/__init__.py: -------------------------------------------------------------------------------- 1 | """Imports from complex polyslab plugin.""" 2 | 3 | from __future__ import annotations 4 | 5 | from .polyslab import ComplexPolySlab 6 | 7 | __all__ = ["ComplexPolySlab"] 8 | -------------------------------------------------------------------------------- /tidy3d/plugins/pytorch/README.md: -------------------------------------------------------------------------------- 1 | # Autograd to PyTorch Wrapper for Tidy3D 2 | 3 | This wrapper allows you to seamlessly convert autograd functions to PyTorch functions, enabling the use of Tidy3D simulations within PyTorch. 4 | 5 | ## Examples 6 | 7 | ### Basic Usage 8 | 9 | This module can be used to convert any autograd function to a PyTorch function: 10 | 11 | ```python 12 | import torch 13 | import autograd.numpy as anp 14 | 15 | from tidy3d.plugins.pytorch.wrapper import to_torch 16 | 17 | @to_torch 18 | def my_function(x): 19 | return anp.sum(anp.sin(x)**2) 20 | 21 | x = torch.rand(10, requires_grad=True) 22 | y = my_function(x) 23 | y.backward() # backward works as expected, even though the function is defined in terms of autograd.numpy 24 | print(x.grad) # gradients are available in the input tensor 25 | ``` 26 | 27 | ### Usage with Tidy3D 28 | 29 | The `to_torch` wrapper can be used to convert an objective function that depends on Tidy3D simulations to a PyTorch function: 30 | 31 | ```python 32 | import torch 33 | import autograd.numpy as anp 34 | 35 | import tidy3d as td 36 | import tidy3d.web as web 37 | 38 | from tidy3d.plugins.pytorch.wrapper import to_torch 39 | 40 | @to_torch 41 | def tidy3d_objective(params): 42 | sim = make_sim(params) 43 | sim_data = web.run(sim, task_name="pytorch_example") 44 | flux = sim_data["flux"].flux.values 45 | return anp.sum(flux) 46 | 47 | params = torch.rand(10, requires_grad=True) 48 | y = tidy3d_objective(params) 49 | y.backward() 50 | print(params.grad) 51 | ``` 52 | -------------------------------------------------------------------------------- /tidy3d/plugins/pytorch/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from .wrapper import to_torch 4 | 5 | __all__ = ["to_torch"] 6 | -------------------------------------------------------------------------------- /tidy3d/plugins/resonance/__init__.py: -------------------------------------------------------------------------------- 1 | """Imports from resonance fitter plugin.""" 2 | 3 | from __future__ import annotations 4 | 5 | from .resonance import ResonanceFinder 6 | 7 | __all__ = ["ResonanceFinder"] 8 | -------------------------------------------------------------------------------- /tidy3d/plugins/smatrix/__init__.py: -------------------------------------------------------------------------------- 1 | """Imports from scattering matrix plugin.""" 2 | 3 | from __future__ import annotations 4 | 5 | import warnings 6 | 7 | from .component_modelers.modal import AbstractComponentModeler, ComponentModeler, ModalPortDataArray 8 | from .component_modelers.terminal import TerminalComponentModeler 9 | from .data.terminal import PortDataArray, TerminalPortDataArray 10 | from .ports.coaxial_lumped import CoaxialLumpedPort 11 | from .ports.modal import Port 12 | from .ports.rectangular_lumped import LumpedPort 13 | from .ports.wave import WavePort 14 | 15 | # Instantiate on plugin import till we unite with toplevel 16 | warnings.filterwarnings( 17 | "once", 18 | message="ℹ️ ⚠️ RF simulations are subject to new license requirements in the future. You have instantiated at least one RF-specific component.", 19 | category=FutureWarning, 20 | ) 21 | 22 | 23 | __all__ = [ 24 | "AbstractComponentModeler", 25 | "CoaxialLumpedPort", 26 | "ComponentModeler", 27 | "LumpedPort", 28 | "ModalPortDataArray", 29 | "Port", 30 | "PortDataArray", 31 | "TerminalComponentModeler", 32 | "TerminalPortDataArray", 33 | "WavePort", 34 | ] 35 | -------------------------------------------------------------------------------- /tidy3d/plugins/smatrix/component_modelers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/plugins/smatrix/component_modelers/__init__.py -------------------------------------------------------------------------------- /tidy3d/plugins/smatrix/data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/plugins/smatrix/data/__init__.py -------------------------------------------------------------------------------- /tidy3d/plugins/smatrix/data/terminal.py: -------------------------------------------------------------------------------- 1 | """Storing data associated with results from the TerminalComponentModeler""" 2 | 3 | from __future__ import annotations 4 | 5 | import pydantic.v1 as pd 6 | 7 | from tidy3d.components.data.data_array import DataArray 8 | from tidy3d.log import log 9 | 10 | 11 | class PortDataArray(DataArray): 12 | """Array of values over dimensions of frequency and port name. 13 | 14 | Example 15 | ------- 16 | >>> import numpy as np 17 | >>> f = [2e9, 3e9, 4e9] 18 | >>> ports = ["port1", "port2"] 19 | >>> coords = dict(f=f, port=ports) 20 | >>> data = (1+1j) * np.random.random((3, 2)) 21 | >>> pd = PortDataArray(data, coords=coords) 22 | """ 23 | 24 | __slots__ = () 25 | _dims = ("f", "port") 26 | 27 | @pd.root_validator(pre=False) 28 | def _warn_rf_license(cls, values): 29 | log.warning( 30 | "ℹ️ ⚠️ RF simulations are subject to new license requirements in the future. You have instantiated at least one RF-specific component.", 31 | log_once=True, 32 | ) 33 | return values 34 | 35 | 36 | class TerminalPortDataArray(DataArray): 37 | """Port parameter matrix elements for terminal-based ports. 38 | 39 | Example 40 | ------- 41 | >>> import numpy as np 42 | >>> ports_in = ["port1", "port2"] 43 | >>> ports_out = ["port1", "port2"] 44 | >>> f = [2e14] 45 | >>> coords = dict(f=f, port_out=ports_out, port_in=ports_in) 46 | >>> data = (1+1j) * np.random.random((1, 2, 2)) 47 | >>> td = TerminalPortDataArray(data, coords=coords) 48 | """ 49 | 50 | __slots__ = () 51 | _dims = ("f", "port_out", "port_in") 52 | _data_attrs = {"long_name": "terminal-based port matrix element"} 53 | 54 | @pd.root_validator(pre=False) 55 | def _warn_rf_license(cls, values): 56 | log.warning( 57 | "ℹ️ ⚠️ RF simulations are subject to new license requirements in the future. You have instantiated at least one RF-specific component.", 58 | log_once=True, 59 | ) 60 | return values 61 | -------------------------------------------------------------------------------- /tidy3d/plugins/smatrix/ports/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/plugins/smatrix/ports/__init__.py -------------------------------------------------------------------------------- /tidy3d/plugins/smatrix/ports/modal.py: -------------------------------------------------------------------------------- 1 | """Class and custom data array for representing a scattering matrix port based on waveguide modes.""" 2 | 3 | from __future__ import annotations 4 | 5 | import pydantic.v1 as pd 6 | 7 | from tidy3d.components.data.data_array import DataArray 8 | from tidy3d.components.geometry.base import Box 9 | from tidy3d.components.mode_spec import ModeSpec 10 | from tidy3d.components.types import Direction 11 | 12 | 13 | class ModalPortDataArray(DataArray): 14 | """Port parameter matrix elements for modal ports. 15 | 16 | Example 17 | ------- 18 | >>> import numpy as np 19 | >>> ports_in = ['port1', 'port2'] 20 | >>> ports_out = ['port1', 'port2'] 21 | >>> mode_index_in = [0, 1] 22 | >>> mode_index_out = [0, 1] 23 | >>> f = [2e14] 24 | >>> coords = dict( 25 | ... port_in=ports_in, 26 | ... port_out=ports_out, 27 | ... mode_index_in=mode_index_in, 28 | ... mode_index_out=mode_index_out, 29 | ... f=f 30 | ... ) 31 | >>> fd = ModalPortDataArray((1 + 1j) * np.random.random((2, 2, 2, 2, 1)), coords=coords) 32 | """ 33 | 34 | __slots__ = () 35 | _dims = ("port_out", "mode_index_out", "port_in", "mode_index_in", "f") 36 | _data_attrs = {"long_name": "modal port matrix element"} 37 | 38 | 39 | class Port(Box): 40 | """Specifies a port in the scattering matrix.""" 41 | 42 | direction: Direction = pd.Field( 43 | ..., 44 | title="Direction", 45 | description="'+' or '-', defining which direction is considered 'input'.", 46 | ) 47 | mode_spec: ModeSpec = pd.Field( 48 | ModeSpec(), 49 | title="Mode Specification", 50 | description="Specifies how the mode solver will solve for the modes of the port.", 51 | ) 52 | name: str = pd.Field( 53 | ..., 54 | title="Name", 55 | description="Unique name for the port.", 56 | min_length=1, 57 | ) 58 | -------------------------------------------------------------------------------- /tidy3d/plugins/smatrix/smatrix.py: -------------------------------------------------------------------------------- 1 | # backwards compatibility support for ``from tidy3d.plugins.smatrix.smatrix import `` 2 | from __future__ import annotations 3 | 4 | from .component_modelers.modal import ComponentModeler 5 | from .ports.modal import Port 6 | 7 | __all__ = ["ComponentModeler", "Port"] 8 | -------------------------------------------------------------------------------- /tidy3d/plugins/waveguide/__init__.py: -------------------------------------------------------------------------------- 1 | """Waveguide utilities module""" 2 | 3 | from __future__ import annotations 4 | 5 | from .rectangular_dielectric import RectangularDielectric 6 | 7 | __all__ = ["RectangularDielectric"] 8 | -------------------------------------------------------------------------------- /tidy3d/style.mplstyle: -------------------------------------------------------------------------------- 1 | axes.prop_cycle : cycler(color=["#176737", "#FF7B0D", "#979BAA", "#F44E6A", "#0062FF", "#26AB5B", "#6D3EF2", "#F59E0B"]) 2 | axes.grid : True 3 | grid.linestyle : : 4 | axes.edgecolor : "#ECEBEA" 5 | -------------------------------------------------------------------------------- /tidy3d/version.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import importlib.metadata 4 | 5 | __version__ = importlib.metadata.version("tidy3d") 6 | -------------------------------------------------------------------------------- /tidy3d/web/__init__.py: -------------------------------------------------------------------------------- 1 | # ruff: noqa: E402 2 | """imports interfaces for interacting with server""" 3 | 4 | from __future__ import annotations 5 | 6 | from tidy3d.log import get_logging_console, log 7 | from tidy3d.version import __version__ 8 | 9 | from .core import core_config 10 | 11 | # set logger to tidy3d.log before it's invoked in other imports 12 | core_config.set_config(log, get_logging_console(), __version__) 13 | 14 | # from .api.asynchronous import run_async # NOTE: we use autograd one now (see below) 15 | # autograd compatible wrappers for run and run_async 16 | from .api.autograd.autograd import run, run_async 17 | from .api.container import Batch, BatchData, Job 18 | from .api.webapi import ( 19 | abort, 20 | account, 21 | delete, 22 | delete_old, 23 | download, 24 | download_json, 25 | download_log, 26 | estimate_cost, 27 | get_info, 28 | get_tasks, 29 | load, 30 | load_simulation, 31 | monitor, 32 | real_cost, 33 | start, 34 | test, 35 | # run, # NOTE: use autograd one now (see below) 36 | upload, 37 | ) 38 | from .cli import tidy3d_cli 39 | from .cli.app import configure_fn as configure 40 | from .cli.migrate import migrate 41 | 42 | migrate() 43 | 44 | __all__ = [ 45 | "Batch", 46 | "BatchData", 47 | "Job", 48 | "abort", 49 | "account", 50 | "configure", 51 | "delete", 52 | "delete_old", 53 | "download", 54 | "download_json", 55 | "download_log", 56 | "estimate_cost", 57 | "get_info", 58 | "get_tasks", 59 | "load", 60 | "load_simulation", 61 | "monitor", 62 | "real_cost", 63 | "run", 64 | "run_async", 65 | "start", 66 | "test", 67 | "tidy3d_cli", 68 | "upload", 69 | ] 70 | -------------------------------------------------------------------------------- /tidy3d/web/api/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/web/api/__init__.py -------------------------------------------------------------------------------- /tidy3d/web/api/autograd/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flexcompute/tidy3d/46433a7a6ee326012ef3da9014b8039378a5bbeb/tidy3d/web/api/autograd/__init__.py -------------------------------------------------------------------------------- /tidy3d/web/api/material_libray.py: -------------------------------------------------------------------------------- 1 | """Material Library API.""" 2 | 3 | from __future__ import annotations 4 | 5 | import builtins 6 | import json 7 | from typing import Optional 8 | 9 | from pydantic.v1 import Field, parse_obj_as, validator 10 | 11 | from tidy3d.components.medium import MediumType 12 | from tidy3d.web.core.http_util import http 13 | from tidy3d.web.core.types import Queryable 14 | 15 | 16 | class MaterialLibray(Queryable, smart_union=True): 17 | """Material Library Resource interface.""" 18 | 19 | id: str = Field(title="Material Library ID", description="Material Library ID") 20 | name: str = Field(title="Material Library Name", description="Material Library Name") 21 | medium: Optional[MediumType] = Field(title="medium", description="medium", alias="calcResult") 22 | medium_type: Optional[str] = Field( 23 | title="medium type", description="medium type", alias="mediumType" 24 | ) 25 | json_input: Optional[dict] = Field( 26 | title="json input", description="original input", alias="jsonInput" 27 | ) 28 | 29 | @validator("medium", "json_input", pre=True) 30 | def parse_result(cls, values): 31 | """Automatically parsing medium and json_input from string to object.""" 32 | return json.loads(values) 33 | 34 | @classmethod 35 | def list(cls) -> builtins.list[MaterialLibray]: 36 | """List all material libraries. 37 | 38 | Returns 39 | ------- 40 | tasks : List[:class:`.MaterialLibray`] 41 | List of material libraries/ 42 | """ 43 | resp = http.get("tidy3d/libraries") 44 | return parse_obj_as(list[MaterialLibray], resp) if resp else None 45 | -------------------------------------------------------------------------------- /tidy3d/web/cli/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | tidy3d command line tool. 3 | """ 4 | 5 | from __future__ import annotations 6 | 7 | from .app import tidy3d_cli 8 | 9 | __all__ = ["tidy3d_cli"] 10 | -------------------------------------------------------------------------------- /tidy3d/web/cli/constants.py: -------------------------------------------------------------------------------- 1 | """Constants for the CLI.""" 2 | 3 | from __future__ import annotations 4 | 5 | import os 6 | from os.path import expanduser 7 | 8 | TIDY3D_BASE_DIR = os.getenv("TIDY3D_BASE_DIR", f"{expanduser('~')}") 9 | 10 | if os.access(TIDY3D_BASE_DIR, os.W_OK): 11 | TIDY3D_DIR = f"{TIDY3D_BASE_DIR}/.tidy3d" 12 | else: 13 | TIDY3D_DIR = "/tmp/.tidy3d" 14 | 15 | CONFIG_FILE = TIDY3D_DIR + "/config" 16 | CREDENTIAL_FILE = TIDY3D_DIR + "/auth.json" 17 | -------------------------------------------------------------------------------- /tidy3d/web/cli/develop/index.py: -------------------------------------------------------------------------------- 1 | """Console script subcommand for tidy3d.""" 2 | 3 | from __future__ import annotations 4 | 5 | import click 6 | 7 | __all__ = [ 8 | "develop", 9 | ] 10 | 11 | 12 | @click.group(name="develop") 13 | def develop(): 14 | """ 15 | Development related command group in the CLI. 16 | 17 | This command group includes several subcommands for various development tasks such as 18 | verifying and setting up the development environment, building documentation, testing, and more. 19 | """ 20 | -------------------------------------------------------------------------------- /tidy3d/web/cli/develop/utils.py: -------------------------------------------------------------------------------- 1 | """ 2 | Utility functions for the tidy3d develop CLI. 3 | """ 4 | 5 | from __future__ import annotations 6 | 7 | import pathlib 8 | import subprocess 9 | 10 | import tidy3d 11 | 12 | __all__ = [ 13 | "echo_and_check_subprocess", 14 | "echo_and_run_subprocess", 15 | "get_install_directory", 16 | ] 17 | 18 | 19 | def get_install_directory(): 20 | """ 21 | Retrieve the installation directory of the tidy3d module. 22 | 23 | Returns 24 | ------- 25 | pathlib.Path 26 | The absolute path of the parent directory of the tidy3d module. 27 | """ 28 | return pathlib.Path(tidy3d.__file__).parent.parent.absolute() 29 | 30 | 31 | def echo_and_run_subprocess(command: list, **kwargs): 32 | """ 33 | Print and execute a subprocess command. 34 | 35 | Parameters 36 | ---------- 37 | command : list 38 | A list of command line arguments to be executed. 39 | **kwargs : dict 40 | Additional keyword arguments to pass to subprocess.run. 41 | 42 | Returns 43 | ------- 44 | subprocess.CompletedProcess 45 | The result of the subprocess execution. 46 | """ 47 | concatenated_command = " ".join(command) 48 | print("Running: " + concatenated_command) 49 | return subprocess.run(command, cwd=get_install_directory(), **kwargs) 50 | 51 | 52 | def echo_and_check_subprocess(command: list, *args, **kwargs): 53 | """ 54 | Print and execute a subprocess command, ensuring it completes successfully. 55 | 56 | Parameters 57 | ---------- 58 | command : list 59 | A list of command line arguments to be executed. 60 | **kwargs : dict 61 | Additional keyword arguments to pass to subprocess.check_call. 62 | 63 | Returns 64 | ------- 65 | int 66 | The return code of the subprocess execution. 67 | """ 68 | concatenated_command = " ".join(command) 69 | print("Running: " + concatenated_command) 70 | return subprocess.check_call(command, *args, **kwargs, cwd=get_install_directory()) 71 | -------------------------------------------------------------------------------- /tidy3d/web/core/__init__.py: -------------------------------------------------------------------------------- 1 | """Tidy3d core package imports""" 2 | -------------------------------------------------------------------------------- /tidy3d/web/core/account.py: -------------------------------------------------------------------------------- 1 | """Tidy3d user account.""" 2 | 3 | from __future__ import annotations 4 | 5 | from datetime import datetime 6 | from typing import Optional 7 | 8 | from pydantic.v1 import Extra, Field 9 | 10 | from .http_util import http 11 | from .types import Tidy3DResource 12 | 13 | 14 | class Account(Tidy3DResource, extra=Extra.allow): 15 | """Tidy3D User Account.""" 16 | 17 | allowance_cycle_type: Optional[str] = Field( 18 | None, 19 | title="AllowanceCycleType", 20 | description="Daily or Monthly", 21 | alias="allowanceCycleType", 22 | ) 23 | credit: Optional[float] = Field( 24 | 0, title="credit", description="Current FlexCredit balance", alias="credit" 25 | ) 26 | credit_expiration: Optional[datetime] = Field( 27 | None, 28 | title="creditExpiration", 29 | description="Expiration date", 30 | alias="creditExpiration", 31 | ) 32 | allowance_current_cycle_amount: Optional[float] = Field( 33 | 0, 34 | title="allowanceCurrentCycleAmount", 35 | description="Daily/Monthly free simulation balance", 36 | alias="allowanceCurrentCycleAmount", 37 | ) 38 | allowance_current_cycle_end_date: Optional[datetime] = Field( 39 | None, 40 | title="allowanceCurrentCycleEndDate", 41 | description="Daily/Monthly free simulation balance expiration date", 42 | alias="allowanceCurrentCycleEndDate", 43 | ) 44 | daily_free_simulation_counts: Optional[int] = Field( 45 | 0, 46 | title="dailyFreeSimulationCounts", 47 | description="Daily free simulation counts", 48 | alias="dailyFreeSimulationCounts", 49 | ) 50 | 51 | @classmethod 52 | def get(cls): 53 | """Get user account information. 54 | 55 | Parameters 56 | ---------- 57 | 58 | Returns 59 | ------- 60 | account : Account 61 | """ 62 | resp = http.get("tidy3d/py/account") 63 | if resp: 64 | account = Account(**resp) 65 | return account 66 | return None 67 | -------------------------------------------------------------------------------- /tidy3d/web/core/cache.py: -------------------------------------------------------------------------------- 1 | """Local caches.""" 2 | 3 | from __future__ import annotations 4 | 5 | FOLDER_CACHE = {} 6 | S3_STS_TOKENS = {} 7 | -------------------------------------------------------------------------------- /tidy3d/web/core/constants.py: -------------------------------------------------------------------------------- 1 | """Defines constants for core.""" 2 | 3 | # HTTP Header key and value 4 | from __future__ import annotations 5 | 6 | HEADER_APIKEY = "simcloud-api-key" 7 | HEADER_VERSION = "tidy3d-python-version" 8 | HEADER_SOURCE = "source" 9 | HEADER_SOURCE_VALUE = "Python" 10 | HEADER_USER_AGENT = "User-Agent" 11 | HEADER_APPLICATION = "Application" 12 | HEADER_APPLICATION_VALUE = "TIDY3D" 13 | 14 | 15 | SIMCLOUD_APIKEY = "SIMCLOUD_APIKEY" 16 | KEY_APIKEY = "apikey" 17 | JSON_TAG = "JSON_STRING" 18 | # type of the task_id 19 | TaskId = str 20 | # type of task_name 21 | TaskName = str 22 | 23 | 24 | SIMULATION_JSON = "simulation.json" 25 | SIMULATION_DATA_HDF5 = "output/monitor_data.hdf5" 26 | SIMULATION_DATA_HDF5_GZ = "output/simulation_data.hdf5.gz" 27 | RUNNING_INFO = "output/solver_progress.csv" 28 | SIM_LOG_FILE = "output/tidy3d.log" 29 | SIM_FILE_HDF5 = "simulation.hdf5" 30 | SIM_FILE_HDF5_GZ = "simulation.hdf5.gz" 31 | MODE_FILE_HDF5_GZ = "mode_solver.hdf5.gz" 32 | MODE_DATA_HDF5_GZ = "output/mode_solver_data.hdf5.gz" 33 | SIM_ERROR_FILE = "output/tidy3d_error.json" 34 | -------------------------------------------------------------------------------- /tidy3d/web/core/core_config.py: -------------------------------------------------------------------------------- 1 | """Tidy3d core log, need init config from Tidy3d api""" 2 | 3 | from __future__ import annotations 4 | 5 | import logging as log 6 | 7 | # default setting 8 | config_setting = { 9 | "logger": log, 10 | "logger_console": None, 11 | "version": "", 12 | } 13 | 14 | 15 | def set_config(logger, logger_console, version: str): 16 | """Init tidy3d core logger and logger console. 17 | 18 | Parameters 19 | ---------- 20 | logger : :class:`.Logger` 21 | Tidy3d log Logger. 22 | logger_console : :class:`.Console` 23 | Get console from logging handlers. 24 | version : str 25 | tidy3d version 26 | """ 27 | config_setting["logger"] = logger 28 | config_setting["logger_console"] = logger_console 29 | config_setting["version"] = version 30 | 31 | 32 | def get_logger(): 33 | """Get logging handlers.""" 34 | return config_setting["logger"] 35 | 36 | 37 | def get_logger_console(): 38 | """Get console from logging handlers.""" 39 | return config_setting["logger_console"] 40 | 41 | 42 | def get_version(): 43 | """Get version from cache.""" 44 | return config_setting["version"] 45 | -------------------------------------------------------------------------------- /tidy3d/web/core/exceptions.py: -------------------------------------------------------------------------------- 1 | """Custom Tidy3D exceptions""" 2 | 3 | from __future__ import annotations 4 | 5 | from typing import Optional 6 | 7 | from .core_config import get_logger 8 | 9 | 10 | class WebError(Exception): 11 | """Any error in tidy3d""" 12 | 13 | def __init__(self, message: Optional[str] = None): 14 | """Log just the error message and then raise the Exception.""" 15 | log = get_logger() 16 | super().__init__(message) 17 | log.error(message) 18 | 19 | 20 | class WebNotFoundError(WebError): 21 | """A generic error indicating an HTTP 404 (resource not found).""" 22 | -------------------------------------------------------------------------------- /tidy3d/web/core/types.py: -------------------------------------------------------------------------------- 1 | """Tidy3d abstraction types for the core.""" 2 | 3 | from __future__ import annotations 4 | 5 | from abc import ABC, abstractmethod 6 | from enum import Enum 7 | 8 | from pydantic.v1 import BaseModel 9 | 10 | 11 | class Tidy3DResource(BaseModel, ABC): 12 | """Abstract base class / template for a webservice that implements resource query.""" 13 | 14 | @classmethod 15 | @abstractmethod 16 | def get(cls, *args, **kwargs) -> Tidy3DResource: 17 | """Get a resource from the server.""" 18 | 19 | 20 | class ResourceLifecycle(Tidy3DResource, ABC): 21 | """Abstract base class for a webservice that implements resource life cycle management.""" 22 | 23 | @classmethod 24 | @abstractmethod 25 | def create(cls, *args, **kwargs) -> Tidy3DResource: 26 | """Create a new resource and return it.""" 27 | 28 | @abstractmethod 29 | def delete(self, *args, **kwargs) -> None: 30 | """Delete the resource.""" 31 | 32 | 33 | class Submittable(BaseModel, ABC): 34 | """Abstract base class / template for a webservice that implements a submit method.""" 35 | 36 | @abstractmethod 37 | def submit(self, *args, **kwargs) -> None: 38 | """Submit the task to the webservice.""" 39 | 40 | 41 | class Queryable(BaseModel, ABC): 42 | """Abstract base class / template for a webservice that implements a query method.""" 43 | 44 | @classmethod 45 | @abstractmethod 46 | def list(cls, *args, **kwargs) -> [Queryable]: 47 | """List all resources of this type.""" 48 | 49 | 50 | class TaskType(str, Enum): 51 | FDTD = "FDTD" 52 | MODE_SOLVER = "MODE_SOLVER" 53 | HEAT = "HEAT" 54 | HEAT_CHARGE = "HEAT_CHARGE" 55 | EME = "EME" 56 | MODE = "MODE" 57 | 58 | 59 | class PayType(str, Enum): 60 | CREDITS = "FLEX_CREDIT" 61 | AUTO = "AUTO" 62 | 63 | @classmethod 64 | def _missing_(cls, value: object) -> PayType: 65 | if isinstance(value, str): 66 | key = value.strip().replace(" ", "_").upper() 67 | if key in cls.__members__: 68 | return cls.__members__[key] 69 | return super()._missing_(value) 70 | -------------------------------------------------------------------------------- /tidy3d/web/environment.py: -------------------------------------------------------------------------------- 1 | """preserve from tidy3d.web.environment import Env backward compatibility""" 2 | 3 | from __future__ import annotations 4 | 5 | from .core.environment import Env 6 | 7 | __all__ = ["Env"] 8 | --------------------------------------------------------------------------------