# This code is part of KQCircuits
# Copyright (C) 2026 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/iqm-open-source-trademark-policy). IQM welcomes contributions to the code.
# Please see our contribution agreements for individuals (meetiqm.com/iqm-individual-contributor-license-agreement)
# and organizations (meetiqm.com/iqm-organization-contributor-license-agreement).
from kqcircuits.simulations.layered_simulation import LayeredSimulation
from kqcircuits.util.load_save_layout import load_layout
from kqcircuits.util.parameters import Param, pdt
[docs]
class GdsSimulation(LayeredSimulation):
"""Base class for simulation geometries loaded from a GDS file.
The layout of the simulation is loaded from the GDS file given as the `input_gds` parameter. Subclasses are
intended to override the `build` method to create the simulation layers and ports from the loaded geometry.
"""
input_gds = Param(pdt.TypeString, "GDS file containing the simulation geometry", "")
def __init__(self, layout, input_gds, **kwargs):
"""Creates a simulation from a GDS file.
Any parameter can be passed as a keyword argument.
Args:
layout: the layout on which to create the simulation. The `input_gds` file is loaded into this layout.
input_gds: GDS file containing the simulation geometry.
"""
load_layout(input_gds, layout)
super().__init__(layout, cell=layout.top_cells()[0], input_gds=input_gds, **kwargs)
[docs]
def build(self):
"""Builds the simulation geometry from the loaded GDS layout.
This method is to be overridden by subclasses. The overriding method should create the simulation layers and
ports from the loaded geometry.
"""
[docs]
def create_geometry(self):
"""Creates the simulation geometry."""
self.build()