Giter Site home page Giter Site logo

gdsfactory / gplugins Goto Github PK

View Code? Open in Web Editor NEW
28.0 3.0 26.0 2.35 MB

gdsfactory plugins

Home Page: https://gdsfactory.github.io/gplugins/

License: MIT License

Makefile 0.08% Python 69.71% Jinja 0.32% SourcePawn 0.06% Jupyter Notebook 28.20% JavaScript 1.51% HTML 0.11%
circuit circuit-simulation eda electronics-tools klayout verification cad gds gdsii oasis

gplugins's Introduction

gplugins 0.13.0

docs PyPI PyPI Python MIT codecov

gdsfactory plugins:

  • devsim TCAD device simulator.
  • meow Eigen Mode Expansion (EME).
  • femwell Finite Element Method Solver (heaters, modes, TCAD, RF waveguides).
  • gmsh mesh structures.
  • tidy3d Finite Difference Time Domain (FDTD) simulations on the cloud using GPU.
  • lumerical For Ansys FDTD and Circuit interconnect.
  • klayout for fill, dataprep and testing.
  • ray for distributed computing and optimization.
  • sax S-parameter circuit solver.
  • schematic: for bokeh schematic editor and path_length_analysis.
  • meep for FDTD.
  • mpb for MPB mode solver.
  • elmer for electrostatic (capacitive) simulations.
  • palace for full-wave driven (S parameter) and electrostatic (capacitive) simulations.
  • vlsir for parsing GDS-extracted circuit netlists into Spice, Spectre and Xyce Schematic File formats.

Installation

You can install most plugins with:

pip install "gdsfactory[full]" --upgrade

or

pip install "gplugins[devsim,femwell,gmsh,schematic,meow,meshwell,ray,sax,tidy3d]" --upgrade

Or install only the plugins you need. For example:

pip install "gplugins[schematic,femwell,meow,sax,tidy3d]" --upgrade

Non-pip plugins

The following plugins require special installation as they can't be installed with pip:

  • For Meep and MPB you need to use conda or mamba on MacOS, Linux or Windows WSL (Windows Subsystem for Linux) with conda install pymeep=*=mpi_mpich_* -c conda-forge -y
  • For Elmer, refer to Elmer FEM โ€“ Installation for installation or compilation instructions each platform. Gplugins assumes ElmerSolver, ElmerSolver_mpi, and ElmerGrid are available in your PATH environment variable.
  • For Palace, refer to Palace โ€“ Installation for compilation instructions using Spack or Singularity. Gplugins assumes palace is available in your PATH environment variable.

Getting started

gplugins's People

Contributors

das-dias avatar dependabot[bot] avatar edieussa avatar flaport avatar heitzmann avatar helgegehring avatar joamatab avatar joelslaby avatar kdotom avatar mdecea avatar nikosavola avatar pre-commit-ci[bot] avatar qt-thomas avatar sequoiap avatar simbilod avatar tvt173 avatar yaugenst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gplugins's Issues

paralell build of notebooks

  • How to speed up? Run in parallel. Combine with jupyterbook
  • Detect failed notebooks

Expose them as an artifact for

papermill notebook.ipynb

@flaport

Bug in specifying multiple volumes for materials in Palace

Problem

There is a bug in the Palace plugin that prevents using multiple volumes for materials. That is, for example multiple substrates cannot currently be specified.
The problem happens with this dict comprehension, which will contain multiple keys of the same name without combining the values.

material_to_attributes_map = {
v["material"]: physical_name_to_dimtag_map[k][1] for k, v in bodies.items()
}

Solution

Refactor dict comprehension to combine values

Using kweb for gds visualization in jupyter book

I am trying to use the jupyter based kweb gds viewer to display chips on our local lab server. Currently we are compiling markdown and ipynb files using jupyter book. I have managed to get the kweb to display gds files within the browser. I first launch a kweb server using jupyter run and a python script that sets the KWEB port and then launches the server. However, this server is only able to display the most recently executed chip.plot() command when the notebooks are built using jupyter book. The built site is able to communicate with a python kernel using thebe but jupyter book does not currently support using a local kernel. As of right now I am not sure if it is possible to switch between different gds files within the browser.

A dropdown menu might be enough to make this work. A way for compiled jupyter books to interact with the kweb server would also help.

The notebook being compiled with jupyter book:

Purple Chip A

import gdsfactory as gf
import amf
from kweb.server_jupyter import start

chipA = gf.import_gds("/home/st4eve/purple/mask-design/purple-chip-A.gds")
chipB = gf.import_gds("/home/st4eve/purple/mask-design/purple-chip-B.gds")
start()
chipA.plot()

Script that starts kweb server:

from kweb.server_jupyter import start
import os
os.environ['KWEB_PORT'] = '8000'
start()

Command to start kweb server:
jupyter run jupyter_kweb.py

fix dataprep notebook

There is sill an issue with the fill script

#123

@sebastian-goeldi

AttributeError                            Traceback (most recent call last)
File ~/gplugins/gplugins/klayout/dataprep/regions.py:243
    236 fill_cell = d.get_fill(
    237     d[LAYER.FLOORPLAN] - d[LAYER.WG],
    238     size=(0.1, 0.1),
    239     spacing=(0.1, 0.1),
    240     fill_layers=(d[LAYER.WG],),
    241 )
    242 c = d.get_kcell()
--> 243 c << fill_cell
    244 fill_cell.write("fill.gds")

File ~/kfactory/src/kfactory/kcell.py:943, in KCell.__lshift__(self, cell)
    937 def __lshift__(self, cell: KCell) -> Instance:
    938     """Convenience function for [create_inst][kfactory.kcell.KCell.create_inst].
    939 
    940     Args:
    941         cell: The cell to be added as an instance
    942     """
--> 943     return self.create_inst(cell)

File ~/kfactory/src/kfactory/kcell.py:884, in KCell.create_inst(self, cell, trans, a, b, na, nb, libcell_as_static, static_name_separator)
    881 else:
    882     assert cell.layout().library() is not None
    883     lib_ci = self.kcl.layout.add_lib_cell(
--> 884         cell.kcl.library, cell.cell_index()
    885     )
    886     kcell = self.kcl[lib_ci]
    887     for port in cell.ports:

AttributeError: 'Cell' object has no attribute 'kcl'

virtual lab + sequencer

How do we define what we want to measure from gdsfactory?

it would be great to define the testing and data analysis sequence

Ideally we can also store it on the GDS itself using labels so that they remain as part of the GDS file

Support dielectric loss analysis for Palace scattering

Is your feature request related to a problem? Please describe.
Support dielectric loss analysis for Palace if materials with loss tangents are specified.
This requires changes in

# TODO list here attributes that contained LossTAN
# palace_json_data["Domains"]["Postprocessing"]["Dielectric"] = [
# ]

and
# TODO palace_json_data["Boundaries"]["Postprocessing"]["Dielectric"]

Describe the solution you'd like
Handle materials with loss tangents by adding dielectric analysis to corresponding dimtags and add some result fetching for DrivenFullWaveResults.

Employ pyvista trame backend instead of panel

Using the panel backend for pyvista the Elmer electrostatic notebook shows the following

/tmp/ipykernel_8249/763369231.py:3: PyVistaDeprecationWarning: `panel` backend is deprecated and is planned for future removal.
  pv.set_jupyter_backend("panel")

trame is preferred instead.

Necessary changes include modifying the backend in notebooks and updating dependencies for trame instead of panel.

Provide default mesh_parameters.portnames in Elmer and Palace

Currently, specifying ports for Elmer and Palace always requires specifying portnames. By default, the implementations of run_capacitive_simulation_elmer and run_capacitive_simulation_palace should set portnames=c.ports by default.

results = run_capacitive_simulation_elmer(
    c,
    ...,
    mesh_parameters=dict(
        portnames=c.ports,
        ...
    )

add pdk compiler functions

When building PDKs, there are many functions that are shared:

  • plot waveguide modes
  • save cells into separate GDS files
  • Create new PDK
  • ....

How about making a pdk compiler module?

Color the Gmsh entities according to LayerViews

Is your feature request related to a problem? Please describe.
Right now, inspecting meshes in GMSH requires manually toggling visibility of the layers, because there is no obvious coloring scheme.

Describe the solution you'd like
Layers are already associated with colors in gdsfactory, so we could simply call gmsh/model/setColor on the entities when we assign them a physical label associated with a Layer. This would require a change upstream in meshwell to support colors, which could just be another attribute of the meshwell entity.

femwell/solve_thermal.py

$ python solve_thermal.py 
Traceback (most recent call last):
  File "/Users/lukasc/Downloads/solve_thermal.py", line 219, in <module>
    from gplugins.gmsh.mesh2D import mesh2D
ModuleNotFoundError: No module named 'gplugins.gmsh.mesh2D'
  • Mac OSX 11.6.7, Intel processor
  • pip install: gdsfactory, gplugins, femwell

I have the latest version of gplugins (0.5.0)

$ pip install gplugins[gmsh,femwell]
Collecting gplugins
  Obtaining dependency information for gplugins from https://files.pythonhosted.org/packages/b9/dd/c790baea29ff148805030d562cbc63f6c0eaa4b428f7d672b5f8ddb7f847/gplugins-0.5.0-py3-none-any.whl.metadata
  Using cached gplugins-0.5.0-py3-none-any.whl.metadata (6.0 kB)
Requirement already satisfied: gdsfactory[cad]>=7.4.0 in /usr/local/lib/python3.10/site-packages (from gplugins) (7.4.6)

Seems like mesh2D is missing:

$ python 
Python 3.10.9 (main, Dec 15 2022, 18:20:40) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import gplugins.gmsh
>>> dir(gplugins.gmsh)
['MeshTracker', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', 'annotations', 'break_geometry', 'cleanup_component', 'create_physical_mesh', 'fuse_polygons', 'get_layer_overlaps_z', 'get_layers_at_z', 'get_u_bounds_layers', 'get_u_bounds_polygons', 'get_uz_bounds_layers', 'list_unique_layerstack_z', 'map_unique_layerstack_z', 'mesh', 'mesh_from_polygons', 'meshtracker', 'order_layerstack', 'parse_component', 'parse_gds', 'parse_layerstack', 'refine', 'round_coordinates', 'tile_shapes', 'to_polygons', 'uz_xsection_mesh', 'xy_xsection_mesh']

Hoping that mesh2D was simply replaced by mesh, I made the change:

from gplugins.gmsh import mesh as mesh2D

And it runs, but then there is another error:

$ python solve_thermal.py 
dict_keys(['substrate', 'box', 'core', 'shallow_etch', 'deep_etch', 'clad', 'slab150', 'slab90', 'nitride', 'ge', 'undercut', 'via_contact', 'metal1', 'heater', 'via1', 'metal2', 'via2', 'metal3'])
2023-09-09 14:10:55.633 | WARNING  | gdsfactory.pdk:get_active_pdk:721 - No active PDK. Activating generic PDK.

2023-09-09 14:10:55.765 | INFO     | gdsfactory.technology.layer_views:__init__:790 - Importing LayerViews from YAML file: '/usr/local/lib/python3.10/site-packages/gdsfactory/generic_tech/layer_views.yaml'.
2023-09-09 14:10:55.766 | INFO     | gdsfactory.pdk:activate:334 - 'generic' PDK is now active
Traceback (most recent call last):
  File "/Users/lukasc/Downloads/solve_thermal.py", line 227, in <module>
    heater2 = gf.components.straight_heater_metal(length=50, heater_width=2).move(
  File "/usr/local/lib/python3.10/site-packages/gdsfactory/component.py", line 2153, in move
    raise ValueError(move_error_message)
ValueError: 
You cannot move a Component. You can create a new Component, add a reference to the other Component and then move the reference.

For example:

# BAD
c = gf.components.straight()
c.xmin = 10

# GOOD
c = gf.Component()
ref = c.add_ref(gf.components.straight()) # or ref = c << gf.components.straight()
ref.xmin = 10

Adaptive meshing for capacitive Elmer

Electrostatic simulations for Elmer support adaptive meshing and there is part of an API for it implemented in gplugins. However, I could not get it working yet. This issue would be to get it working and edit the .sif.j2 file accordingly.

Infer portname delimiter in Elmer electrostatics

The portname delimiter is now assumed to be port_delimiter = "__". The default value of # does not work in Elmer, as it tries to evaluate a statement with the symbol. Supporting the default value should be done by converting layers using it automatically to Elmer supported ones.

Support waveports in Palace scattering

Is your feature request related to a problem? Please describe.

Handle adding waveports to ports at the edge of the simulation area automatically.

Blocked by simbilod/meshwell#20

Describe the solution you'd like
Automatically add a waveport to ports at the edges of the simulation area when running run_scattering_simulation_palace.

Elmer notebook not rendering in docs

Describe the bug
Elmer notebook fails to run in docs

This is caused by Pyvista recently deprecating the panel backend from pip install pyvista[jupyter] install dependency. pyvista/pyvista@0cd21cc

Suggested fix
Change the backend to trame, which is recommended by pyvista.

Support distributing Palace scattering simulations excitations with Ray

Is your feature request related to a problem? Please describe.
For solving the full S matrix, Palace requires a different simulation for each excitation. These are currently run in parallel with asyncio but could additionally be distributable with Ray similarly to Automated model extraction

tasks = []
for json_file, n_processes_json in zip(json_files, n_processes_per_json):
tasks.append(
execute_and_stream_output(
(
[palace, str(json_file)]
if n_processes == 1
else [palace, "-np", str(n_processes_json), str(json_file)]
),
shell=False,
log_file_dir=json_file.parent,
log_file_str=json_file.stem + "_palace",
cwd=simulation_folder,
)
)
await asyncio.gather(*tasks)

Describe the solution you'd like
Support distribution with Ray

enable CDL schematic conversion

At the moment gplugins support YAML schematic representation but recently some users asked for CDL support to use gdsfactory to generate cadence compatible schematics

How about suppor converting from YAML to CDL?

Run Palace tests in CI

Run Palace tests in CI. This requires installing Palace in GitHub Actions and adding palace to GITHUB_PATH. This currently requires compilation, hence taking a long time. Pre-compiling in let's say a Docker image or Singularity container seems like a good approach.

Unified geometry interface for simulation components

Is your feature request related to a problem? Please describe.
Currently, most device simulators derive their simulation properties (in particular geometries) from a patchwork of logic, e.g. from functionality contained in gdsfactory proper, from other gplugins, and self-implemented ones. This leads to a duplication of efforts and makes things harder to maintain.

Describe the solution you'd like
Ideally, there should be a single "source of truth" when it comes to simulated geometries. This could be implemented as a component base class that combines a layerstack and a component (and whatever else might be necessary that I'm not aware of currently) and provides a single interface from which all relevant attributes can be extracted easily. Developers could then implement whatever additional logic is necessary for a particular simulator on top of this interface.

I have implemented a draft of this base component in the tidy3d plugin rework (WIP) in #138 (see here). It's currently very incomplete and I've submitted it mostly because I am seeing a lot of issues crop up recently along similar lines (e.g. #119, #121, #122, #131) that could all be addressed with a common interface and I think it would be good to have a discussion.

Some considerations:

  • Immutability: A simulation component should be immutable. It is derived from a particular layerstack and device, and if any of that information changes, it should be considered a new component.
  • Owing to immutability, a component class should be hashable (implemented). This makes it easy to identify components for e.g. caching of simulation results for particular components or comparisons.
  • The base component should have a fixed interface (allow_extra=False) to provide a strong guarantee of what is and isn't provided by this class. Children should modify their own behavior as needed.
  • Ports: Since components have ports (usually), the component base should be able to provide information on port placement and sizing. I have started to implement this, and especially port sizing can (and probably should) be automated, i.e. I think one should be able to just ask the simulation component for the port sizes and it should provide them while handling spacing between ports and simulation boundaries automatically.
  • Material properties: I am undecided whether this should be done in the base component or in the derived components that different simulators use. Probably the latter because material definitions differ greatly between different simulators.
  • Visualization: Since all the geometry information is already contained in the component, there should be a way to visualize the component independent of different simulators. I have plotting implemented for the derived tidy3d component, but ideally this should live in the component base.

Long term this would enable us to add new simulators with relative ease and add new functionalities to existing ones, e.g. fabrication corner analysis is something that can simply extend the functionality of a base component (either via direct implementation or mix-ins) with little to no changes required to existing simulators (that already use the SimulationComponentBase)

If you agree that this is something that we should try to pursue, then it would be good to have a discussion on the actual interface that this component should provide. The one I've implemented is relatively bare-bones. It implements everything that's needed for tidy3d simulations, so there are very likely to be things that I've missed.

@joamatab @nikosavola @simbilod @HelgeGehring @mdecea

Allow arbitrary lumped port directions

Is your feature request related to a problem? Please describe.
awslabs/palace#75 is now merged and arbitrary rotation ports are supported. The implementation for Palace scattering in gplugins however supports only an orientation from ["+X", "+Y", "-X", "-Y"].

Describe the solution you'd like
Generalise inferring the lumped port direction and use new Palace format for arbitrary orientation

def _xy_plusminus_direction(point_1, point_2):
# TODO update after https://github.com/awslabs/palace/pull/75 is merged
delta_x = point_2[0] - point_1[0]
delta_y = point_2[1] - point_1[1]
angle = atan2(delta_y, delta_x)
angle_deg = degrees(angle) + 360
directions = ["+X", "+Y", "-X", "-Y"]
index = round(angle_deg / 90) % 4 # TODO check if shift is correct
return directions[index]
lumped_two_port_directions = {
ports[0]: _xy_plusminus_direction(
*[component.get_ports_dict()[port].center for port in ports]
)
for ports in itertools.chain(
lumped_two_port_pairs, [tuple(reversed(e)) for e in lumped_two_port_pairs]
)
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.