-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added functions to aid junction tuning within cells
Junction data can be extracted from a given cell hierarchy, both if the cell contains or doesn't contain PCell data. This junction data can later be added into another cell retaining junction position and orientation, with possibility to tune junction parameters and junction type using external files.
- Loading branch information
Showing
7 changed files
with
1,235 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
455 changes: 455 additions & 0 deletions
455
klayout_package/python/kqcircuits/util/replace_junctions.py
Large diffs are not rendered by default.
Oops, something went wrong.
185 changes: 0 additions & 185 deletions
185
klayout_package/python/kqcircuits/util/replace_squids.py
This file was deleted.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
klayout_package/python/scripts/macros/export/export_junction_parameters.lym
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<klayout-macro> | ||
<description>Exports junctions parameters</description> | ||
<version/> | ||
<category>pymacros</category> | ||
<prolog/> | ||
<epilog/> | ||
<doc/> | ||
<autorun>false</autorun> | ||
<autorun-early>false</autorun-early> | ||
<priority>0</priority> | ||
<shortcut/> | ||
<show-in-menu>false</show-in-menu> | ||
<group-name/> | ||
<menu-path/> | ||
<interpreter>python</interpreter> | ||
<dsl-interpreter-name/> | ||
<text># This code is part of KQCircuits | ||
# Copyright (C) 2024 IQM Finland Oy | ||
# | ||
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public | ||
# License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later | ||
# version. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along with this program. If not, see | ||
# https://www.gnu.org/licenses/gpl-3.0.html. | ||
# | ||
# The software distribution should follow IQM trademark policy for open-source software | ||
# (meetiqm.com/developers/osstmpolicy). IQM welcomes contributions to the code. Please see our contribution agreements | ||
# for individuals (meetiqm.com/developers/clas/individual) and organizations (meetiqm.com/developers/clas/organization). | ||
|
||
|
||
"""Exports all current junnction parameter values for each junction in the PCell. | ||
Assumes that a single chip exists in the top cell, and it is a PCell. | ||
Results of this macro can be used to tune junctions for cells without PCell data. | ||
""" | ||
|
||
import json | ||
from kqcircuits.klayout_view import KLayoutView | ||
from kqcircuits.util.replace_junctions import extract_junctions, get_tuned_junction_json | ||
|
||
top_cell = KLayoutView(current=True).active_cell | ||
|
||
### Set file location, or leave empty to get tuned junction JSON in the output | ||
FILE_LOCATION = "" | ||
|
||
try: | ||
junctions = extract_junctions(top_cell, {}) | ||
if len(junctions) > 0: | ||
json_str = json.dumps(get_tuned_junction_json(junctions), indent=2) | ||
|
||
if FILE_LOCATION: | ||
with open(FILE_LOCATION, 'w') as file: | ||
file.write(json_str) | ||
print(f"Wrote junction parameters to {FILE_LOCATION}") | ||
else: | ||
print(json_str) | ||
else: | ||
print("No junctions detected") | ||
except ValueError: | ||
raise ValueError("For this macro to work, the active layout must contain a chip PCell, for which PCell parameters are present") | ||
</text> | ||
</klayout-macro> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
klayout_package/python/scripts/macros/export/export_tuned_junctions.lym
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<klayout-macro> | ||
<description>Exports junctions in given chip with tuned parameters</description> | ||
<version/> | ||
<category>pymacros</category> | ||
<prolog/> | ||
<epilog/> | ||
<doc/> | ||
<autorun>false</autorun> | ||
<autorun-early>false</autorun-early> | ||
<priority>0</priority> | ||
<shortcut/> | ||
<show-in-menu>false</show-in-menu> | ||
<group-name/> | ||
<menu-path/> | ||
<interpreter>python</interpreter> | ||
<dsl-interpreter-name/> | ||
<text># This code is part of KQCircuits | ||
# Copyright (C) 2024 IQM Finland Oy | ||
# | ||
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public | ||
# License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later | ||
# version. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along with this program. If not, see | ||
# https://www.gnu.org/licenses/gpl-3.0.html. | ||
# | ||
# The software distribution should follow IQM trademark policy for open-source software | ||
# (meetiqm.com/developers/osstmpolicy). IQM welcomes contributions to the code. Please see our contribution agreements | ||
# for individuals (meetiqm.com/developers/clas/individual) and organizations (meetiqm.com/developers/clas/organization). | ||
|
||
|
||
"""Exports junctions of a chip to a separate file. Parameters of individual junctions may be tuned. | ||
Assumes that a single chip exists in the top cell. | ||
Will export a new .oas file in TMP path containing junctions of original cell, | ||
with possibly tuned junction parameters, and a "base_metal_gap" layer for reference. | ||
This new layout will also be opened in current KLayout session in new layout. | ||
Macro can be used on cells with or without PCell data. | ||
In the latter case the `tuned_junction_parameters` must include a value for every | ||
junction parameter of every junction in the cell. | ||
You can use "export_junction_parameters" macro on a PCell to get full listing of parameters, | ||
to later reuse on cells without PCell data. | ||
See kqcircuits.util.replace_junctions API docs for more technical details. | ||
""" | ||
|
||
import json | ||
from kqcircuits.defaults import TMP_PATH | ||
from kqcircuits.klayout_view import KLayoutView | ||
from kqcircuits.pya_resolver import pya | ||
from kqcircuits.util.replace_junctions import extract_junctions, place_junctions, copy_one_layer_of_cell | ||
|
||
top_cell = KLayoutView(current=True).active_cell | ||
|
||
# If there are too many parameters to tune (for example tuning junctions for file without PCells), | ||
# these can be written in a separate .json file and read from the macro | ||
EXTERNAL_TUNE_FILE = "" | ||
|
||
if EXTERNAL_TUNE_FILE: | ||
with open(EXTERNAL_TUNE_FILE) as f: | ||
tuned_junction_parameters = json.load(f) | ||
else: | ||
# Or tuned parameters can be typed up here by hand | ||
tuned_junction_parameters = {} | ||
# Example: exaggerate junction width for qubit "qb_1" for "Single Xmons" PCell | ||
# tuned_junction_parameters = {"qb_1": {"squid": {"junction_width": 2.0}}} | ||
|
||
junctions = extract_junctions(top_cell, tuned_junction_parameters) | ||
clean_cell_name = top_cell.basic_name().replace(" ", "").replace("*", "").split("$")[0] | ||
exported_file = str(TMP_PATH / f'tuned_junctions_{clean_cell_name}.oas') | ||
copy_one_layer_of_cell(exported_file, top_cell, junctions, "base_metal_gap") | ||
|
||
print(f"Extracted and tuned {len(junctions)} junctions") | ||
new_view = KLayoutView() | ||
new_view.layout.clear() | ||
new_view.layout.read(exported_file) | ||
top_cell = new_view.layout.top_cells()[-1] | ||
top_cell.flatten(True) | ||
place_junctions(top_cell, junctions) | ||
new_view.focus(top_cell) | ||
|
||
print(f"Saving tuned junctions to {exported_file}") | ||
svopt = pya.SaveLayoutOptions() | ||
svopt.set_format_from_filename(exported_file) | ||
new_view.layout.write(exported_file, svopt) | ||
</text> | ||
</klayout-macro> |
Oops, something went wrong.