kqcircuits.simulations.simulation¶
- class kqcircuits.simulations.simulation.Simulation(layout, **kwargs)[source]¶
Bases:
object
Base class for simulation geometries.
Generally, this class is intended to be subclassed by a specific simulation implementation; the implementation defines the simulation geometry ad ports in build.
A convenience class method Simulation.from_cell is provided to create a Simulation from an existing cell. In this case no ports will be added.
Initialize a Simulation.
The initializer parses parameters, creates a top cell, and then calls self.build to create the simulation geometry, followed by self.create_simulation_layers to process the geometry so it is ready for exporting.
- Parameters
layout – the layout on which to create the simulation
- Keyword Arguments
**kwargs –
Any parameter can be passed as a keyword argument.
In addition, cell can be passed as keyword argument. If cell is supplied, it will be used as the top cell for the simulation. Otherwise, a new cell will be created. See Simulation.from_cell for creating simulations from existing cells.
- LIBRARY_NAME = None¶
- ports: List[kqcircuits.simulations.port.Port]¶
- classmethod from_cell(cell, margin=300, grid_size=1, **kwargs)[source]¶
Create a Simulation from an existing cell.
- Parameters
cell – existing top cell for the Simulation
margin – distance (μm) to expand the simulation box (ground plane) around the bounding box of the cell If the box keyword argument is given, margin is ignored.
grid_size – size of the simulation box will be rounded to this resolution If the box keyword argument is given, grid_size is ignored.
**kwargs – any simulation parameters passed
- Returns
Simulation instance
- abstract build()[source]¶
Build simulation geometry.
This method is to be overridden, and the overriding method should create the geometry to be simulated and add any ports to self.ports.
- classmethod get_schema(noparents=False)¶
Returns the combined parameters of the class “cls” and all its ancestor classes.
- Parameters
noparents – If True then only return the parameters of “cls”, not including ancestors.
- face(face_index=0)¶
Returns the face dictionary corresponding to self.face_ids[face_index].
The face dictionary contains key “id” for the face ID and keys for all the available layers in that face.
- Parameters
face_index – index of the face_id in self.face_ids, default=0
- insert_cell(cell, trans=None, inst_name=None, label_trans=None, align_to=None, align=None, rec_levels=0, **parameters)¶
Inserts a subcell into the present cell.
It will use the given cell object or if cell is an Element class’ name then directly take the provided keyword arguments to first create the cell object.
If inst_name given, the refpoints of the cell are added to the self.refpoints with inst_name as a prefix, and also adds a label inst_name to “`”labels layer” at the base refpoint and label_trans transformation.
- Parameters
cell – cell object or Element class name
trans – used transformation for placement. None by default, which places the subcell into the coordinate origin of the parent cell. If align and align_to arguments are used, trans is applied to the cell before alignment transform which allows for example rotation of the cell before placement.
inst_name – possible instance name inserted into subcell properties under id. Default is None
label_trans – relative transformation for the instance name label
align_to – location in parent cell coordinates for alignment of cell. Can be either string indicating the parent refpoint name, DPoint or DVector. Default is None
align – name of the cell refpoint aligned to argument align_to. Default is None
rec_levels – recursion level when looking for refpoints from subcells. Set to 0 to disable recursion.
**parameters – PCell parameters for the element, as keyword argument
- Returns
tuple of placed cell instance and reference points with the same transformation
- get_refpoints(cell, cell_transf=<klayout.dbcore.DTrans object>, rec_levels=None)¶
See get_refpoints.
- add_element(cls, **parameters)¶
Create a new cell for the given element in this layout.
- Parameters
cls – Element subclass to be created
**parameters – PCell parameters for the element as keyword arguments
- Returns
the created cell
- get_layer(layer_name, face_id=0)¶
Returns the specified Layer object.
- Parameters
layer_name – layer name text
face_id – index of the face id, default=0
- pcell_params_by_name(whitelist=None, **parameters)¶
Give PCell parameters as a dictionary.
- Parameters
whitelist – A classname. Its parameter names are used for filtering.
**parameters – Optionally update with other keyword arguments
- Returns
A dictionary of all PCell parameter names and corresponding current values.
- create_simulation_layers()[source]¶
Create the layers used for simulation export.
Based on any geometry defined on the relevant lithography layers.
This method is called from __init__ after build, and should not be called directly.
- Geometry is added to the following layers:
For each face
b
andt
, the inverse ofbase_metal_gap_wo_grid
is divided intosimulation_ground
, containing any metalization not galvanically connected to a portsimulation_signal
, containing the remaining metalization.
simulation_airbridge_pads
, containing the geometry ofairbridge_pads
simulation_airbridge_flyover
, containing the geometry ofairbridge_flyover
In the simulation layers, all geometry has been merged and converted to simple polygons (that is, polygons without holes).
- produce_ground_on_face_grid(box, face_id)[source]¶
Produces ground grid in the given face of the chip.
- Parameters
box – pya.DBox within which the grid is created
face_id (str) – ID of the face where the grid is created
- produce_waveguide_to_port(location, towards, port_nr, side=None, use_internal_ports=None, waveguide_length=None, term1=0, turn_radius=None, a=None, b=None, over_etching=None, airbridge=False, face=0)[source]¶
Create a waveguide connection from some location to a port, and add the corresponding port to simulation.ports.
- Parameters
location (pya.DPoint) – Point where the waveguide connects to the simulation
towards (pya.DPoint) – Point that sets the direction of the waveguide. The waveguide will start from location and go towards towards
port_nr (int) – Port index for the simulation engine starting from 1
side (str) – Indicate on which edge the port should be located. Ignored for internal ports. Must be one of left, right, top or bottom
use_internal_ports (bool, optional) – if True, ports will be inside the simulation. If False, ports will be brought out to an edge of the box, determined by side. Defaults to the value of the use_internal_ports parameter
waveguide_length (float, optional) – length of the waveguide (μm), used only for internal ports Defaults to the value of the waveguide_length parameter
term1 (float, optional) – Termination gap (μm) at location. Default 0
turn_radius (float, optional) – Turn radius of the waveguide. Not relevant for internal ports. Defaults to the value of the r parameter
a (float, optional) – Center conductor width. Defaults to the value of the a parameter
b (float, optional) – Conductor gap width. Defaults to the value of the b parameter
over_etching (float, optional) – Expansion of gaps. Defaults to the value of the over_etching parameter
airbridge (bool, optional) – if True, an airbridge will be inserted at location. Default False.
face – face to place waveguide and port on. Either 0 (default) or 1, for bottom or top face.
- etched_line(p1: klayout.dbcore.DPoint, p2: klayout.dbcore.DPoint)[source]¶
Return the end points of line segment after extending it at both ends by amount of over_etching. This function must be used when initializing InternalPort.
- Parameters
p1 (pya.DPoint) – first end of line segment
p2 (pya.DPoint) – second end of line segment
- Returns
list of extended end points.
- Return type
[p1 - d, p2 + d]
- get_port_data()[source]¶
Return the port data in dictionary form and add the information of port polygon
- Returns
list of port data dictionaries
Items from Port instance
polygon: point coordinates of the port polygon
signal_edge: point coordinates of the signal edge
ground_edge: point coordinates of the ground edge
- Return type
port_data(list)
- get_simulation_data()[source]¶
Return the simulation data in dictionary form.
- Returns
simulation_data
gds_file(str): self.name + ‘.gds’,
stack_type(str): self.wafer_stack_type,
units(str): ‘um’, # hardcoded assumption in multiple places
substrate_height(float): self.substrate_height,
airbridge_height(float): self.airbridge_height,
box_height(float): self.box_height,
permittivity(float): self.permittivity,
box(pya.DBox): self.box,
ports(list): dictionary (see self.get_port_data)
parameters(dict): dictionary (see self.get_parameters),
if wafer stack type is ‘multiface data’, simulation_data contains also
substrate_height_top(float): simulation.substrate_height_top,
chip_distance(float): simulation.chip_distance,
- Return type
dict
box (Shape) - Border, default=
(0,0;10000,10000)
ground_grid_box (Shape) - Border, default=
(0,0;10000,10000)
with_grid (Boolean) - Make ground plane grid, default=
False
name (String) - Name of the simulation, default=
Simulation
use_ports (Boolean) - Turn off to disable all ports (for debugging), default=
True
use_internal_ports (Boolean) - Use internal (lumped) ports. The alternative is wave ports., default=
True
port_size (Double) - Width (um) of wave ports, default=
400.0
box_height (Double) - Height (um) of vacuum above chip in case of single chip., default=
1000.0
substrate_height (Double) - Height (um) of the bottom substrate., default=
550.0
permittivity (Double) - Permittivity of the substrates., default=
11.45
wafer_stack_type (Double) - Defines whether to use single chip (‘planar’) or flip chip (‘multiface’)., default=
planar
chip_distance (Double) - Height (um) of vacuum between two chips in case of flip chip., default=
8.0
substrate_height_top (Double) - Height (um) of the substrate of the top chip in case of flip chip., default=
375.0
airbridge_height (Double) - Height (um) of airbridges., default=
3.4
waveguide_length (Double) - Length of waveguide stubs or distance between couplers and waveguide turning point, default=
100
over_etching (Double) - Expansion of metal gaps (negative to shrink the gaps)., default=
0
, unit=μm
minimum_point_spacing (Double) - Tolerance (um) for merging adjacent points in polygon, default=
0.01
polygon_tolerance (Double) - Tolerance (um) for merging adjacent polygons in a layer, default=
0.004
a (Double) - Width of center conductor, default=
10
, unit=μm
b (Double) - Width of gap, default=
6
, unit=μm
n (Int) - Number of points on turns, default=
64
r (Double) - Turn radius, default=
100
, unit=μm
margin (Double) - Margin of the protection layer, default=
5
, unit=μm
face_ids (List) - Chip face IDs, list of b | t | c, default=
['b', 't', 'c']
display_name (String) - Name displayed in GUI (empty for default), default=
protect_opposite_face (Boolean) - Add opposite face protection too, default=
False
