Skip to content

Commit

Permalink
Implement KQC internal cross section extracting tool
Browse files Browse the repository at this point in the history
Plan is to phase out reliance on external XSection tool
  • Loading branch information
qpavsmi committed Feb 13, 2025
1 parent 0674229 commit b7415d5
Show file tree
Hide file tree
Showing 23 changed files with 1,011 additions and 318 deletions.
90 changes: 90 additions & 0 deletions docs/user_guide/cross_section.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
.. _cross_sections:

Cross sections
**************

It is possible to generate vertical cross section geometries from an arbitrary KQC layout,
by specifying two points that form a line from which a cross-section is formed.
Following are the ways to generate a cross section.

Creating cross sections with KQCircuits
=======================================

In GUI
------

There is currently no convenient way to create cross sections using this method in KLayout GUI,
therefore its better to use the XSection tool for this purpose.

In KQC code
-----------

:git_url:`klayout_package/python/kqcircuits/simulations/export/cross_section/cross_section_export.py` includes
a ``create_cross_sections_from_simulations`` function. Given list of ``Simulation`` instances and two ``DPoint``
values, a list of ``CrossSectionSimulation`` objects will be created to a separate layout. See
:git_url:`klayout_package/python/scripts/simulations/waveguides_sim_cross_section.py` for an example use case.

Cross sections are an essential part in calculating EPR for elements. See docstring in
:git_url:`klayout_package/python/kqcircuits/simulations/export/cross_section/epr_correction_export.py`
and :git_url:`klayout_package/python/scripts/simulations/swissmon_epr_sim.py` for an example use case.

XSection tool
=============

XSection tool is an external plug-in developed by KLayout developer.
To use it, install the XSection plugin from ``KLayout -> Tools -> Manage packages``.

KLayout GUI XSection tool
-------------------------

Once XSection plugin is installed in KLayout, a "XSection" ruler tool is available
as a scroll option for the Ruler tool.

1. Use the "XSection" Ruler tool in KLayout to choose the cuts along which the vertical
cross-sections are created

2. ``Tools -> XSection scripts -> Run script -> example.xs`` will open another layout
displaying the cross section geometry.

XSection call in KQC code
-------------------------

.. warning::
The use of XSection tool within KQCircuits code is deprecated, it is recommended
to use internal KQCircuits utilities instead to generate cross sections

XSection plugin can be called from python code to automate cross-section geometry
generation for simulation files.
:git_url:`klayout_package/python/kqcircuits/simulations/export/cross_section/xsection_export.py` includes

- ``create_xsections_from_simulations``, a high level method to take a cross-section
for each simulation object using two ``DPoint`` values

- ``xsection_call``, a low level method requiring a path to the input and output
OAS files, two ``DPoint`` values and, optionally, a path to a process file.
If :git_url:`xsection/kqc_process.xs` process file is used, make sure to
provide a path to the parameters json file as well.

.. note::
XSection 1.7 does not work with KQCircuits. If you have such version installed, please
update to the newest release of XSection.

Process files (.xs)
-------------------

The process by which the actual physical shapes are created from the layout
layers is defined in ``.xs`` files. The xsection folder in KQC contains two
process files:

1. Lightweight example process file :git_url:`xsection/example.xs`, intended for taking cross-sections
using a KLayout GUI tool

2. **(deprecated)** :git_url:`xsection/kqc_process.xs` intended only for use by a ``create_xsections_from_simulations``
call in KQC code

Information about writing the ``.xs`` files can be found in the following pages:

- https://klayoutmatthias.github.io/xsection/DocIntro
- https://klayoutmatthias.github.io/xsection/DocReference
- https://klayoutmatthias.github.io/xsection/DocGrow
- https://klayoutmatthias.github.io/xsection/DocEtch
11 changes: 8 additions & 3 deletions docs/user_guide/file_system_and_utilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,26 @@ High level annotated picture of KQCircuits repository's different subdirectories

KQCircuits Git repository root
├── ci
├── docs
├── klayout_package
│   └── python Salt package
│   ├── console_scripts
│   ├── drc Design Rule Checks
│   ├── kqcircuits PyPI package
│   │   ├── chips
│   │   ├── elements Basic Elements
│   │ └── ...
│   │   ├── ...
│   │   ├── layer_config Layer visualisation
│   │   ├── masks Lithography mask structure
│   │   ├── simulations Simulation utilities
│   │ └── util Other KQC library functions
│   └── requirements Listed dependencies of KQC
│   ├── linux
│   ├── mac
│   └── win
│   └── scripts
│   ├── macros
│   ├── masks
│   ├── resources
│   └── simulations
├── docs Documentation sources
├── singularity
Expand All @@ -56,7 +61,7 @@ High level annotated picture of KQCircuits repository's different subdirectories
│   ├── elements
│   ├── ...
├── util Utility scripts
└── xsection
└── xsection XSection process files, recommended to only use in GUI

In the KQCircuits root folder the most important folder for most users is the
:git_url:`klayout_package` folder, which is also all that is included in the Salt
Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ User Guide
macro_workflow
mask_export
simulations
cross_section
file_system_and_utilities
configuration
xsection
terminology
4 changes: 1 addition & 3 deletions docs/user_guide/simulation/simulation_features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,7 @@ and call the :func:`~kqcircuits.simulations.export.elmer.elmer_export.export_elm
An example for simulating coplanar-waveguide cross-section can be found in
:git_url:`klayout_package/python/scripts/simulations/cpw_cross_section_sim.py`.

There is an additional ``Xsection`` tool to create cross-sectional geometries out of the x-y-layouts.
The tool is described in more details in :ref:`Creating cross section images` and an example simulation can be found in
:git_url:`klayout_package/python/scripts/simulations/waveguides_sim_xsection.py`.
The cross sections can be generated from arbitrary geometries. See more details in :ref:`cross_sections`.

.. _py-epr:

Expand Down
67 changes: 0 additions & 67 deletions docs/user_guide/xsection.rst

This file was deleted.

4 changes: 4 additions & 0 deletions klayout_package/python/kqcircuits/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import subprocess
from pathlib import Path

from kqcircuits.simulations.export.cross_section.cross_section_profile import get_cross_section_profile
from kqcircuits.pya_resolver import pya
from kqcircuits.util.defaults_helper import find_ansys_executable
from kqcircuits.util.import_helper import module_from_file
Expand Down Expand Up @@ -63,6 +64,9 @@
SCRIPTS_PATH.joinpath("simulations").joinpath("elmer"),
SCRIPTS_PATH.joinpath("simulations").joinpath("post_process"),
]
# When taking cross sections, if profile not specified, will default to executing this function
# with signature (simulation: Simulation) -> CrossSectionProfile:
default_cross_section_profile = get_cross_section_profile
XSECTION_PROCESS_PATH = ROOT_PATH.joinpath("xsection/kqc_process.xs")

VERSION_PATHS = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class CrossSectionSimulation:
unit="m",
docstring="London penetration depth is implemented for one signal simulation only",
)
# TODO: deprecate. With internal cross section method, we can simply copy the parameters over
xsection_source_class = Param(
pdt.TypeNone,
"Simulation class XSection tool was used on",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This code is part of KQCircuits
# Copyright (C) 2023 IQM Finland Oy
# Copyright (C) 2025 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
Expand Down
Loading

0 comments on commit b7415d5

Please sign in to comment.