Skip to content

Commit

Permalink
Merge pull request #3 from LFL-Lab/shanto_dev
Browse files Browse the repository at this point in the history
Update version to 0.2.1 and handle warnings from pyaedt
  • Loading branch information
shanto268 authored Jan 10, 2024
2 parents 34c9896 + 9025d11 commit 24fd4a9
Show file tree
Hide file tree
Showing 14 changed files with 24,240 additions and 24,079 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
to_do.md
production.md
new_features.md
dev/*

# Ignore documentation files
docs/_build/html/.doctrees/


# Ignore data files
data/*
database/contrib_to_do.md
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
project = 'SQuADDS'
copyright = '2023, Sadman Ahmed Shanto & Eli Levenson-Falk'
author = 'Sadman Ahmed Shanto'
release = "0.2"
release = "0.2.1"

# General configuration
exclude_patterns = [
Expand Down
9 changes: 9 additions & 0 deletions docs/source/release_notes.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Release Notes
=============

Version 0.2.1 (2023-12-24)
--------------------------

* **Alpha Version 0.2.1**

- Bug fixes:
- change "c" to "readout" in both code and database entries
- Handled Warnings from pyaedt

Version 0.2 (2023-12-24)
--------------------------

Expand Down
12 changes: 8 additions & 4 deletions next_release.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# Bug fixes:

- [ ] change "c" to "readout" in both code and database entries
- [ ] Handle `Warnings`
- [ ] create proper train/test/splits and changing `SQuADDS_DB()` to always return all data
- [ ] handling selected_data_type in select_COMPONENT methods
- [x] change "c" to "readout" in both code and database entries
- [x] Handle `Warnings`
- [ ] fix the autodoc generator workflow

---

# Features to add:

- [ ] Versioning of the database and allowing people to download specific versions
- [ ] Contribution via HuggingFace Hub API
- [ ] HuggingFace Workflow Action for sending emails upon PR
- [ ] Standardize the way we handle units for simulated results + impmelent necessary changes in backend
Expand All @@ -26,3 +25,8 @@
- [ ] Update HF data cards

---

# Documentation requests:

- [ ] completed contribution tutorials
- [ ] documenting reliable simulation methodologies we have learned and resources
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from setuptools import setup, find_packages
from setuptools import find_packages, setup

# Read requirements from the requirements.txt file
with open('requirements.txt') as f:
required = f.read().splitlines()

setup(
name='SQuADDS',
version='0.2',
version='0.2.1',
packages=find_packages(),
description='Our project introduces an open-source database of programmatically generated and experimentally validated superconducting quantum device designs, accessible through a user-friendly interface, significantly lowering the entry barrier for research in this field.',
long_description=open('README.md').read(),
Expand Down
4 changes: 2 additions & 2 deletions squadds/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import os

__version__ = '0.2'
__version__ = '0.2.1'
__license__ = "MIT License"
__copyright__ = 'Sadman Ahmed Shanto, Eli Levenson-Falk 2023'
__author__ = 'Sadman Ahmed Shanto, Eli Levenson-Falk'
__status__ = "Alpha"
__repo_path__ = os.path.dirname(os.path.abspath(__file__))

from squadds.core.db import SQuADDS_DB
from squadds.core.analysis import Analyzer
from squadds.core.db import SQuADDS_DB
from squadds.simulations.ansys_simulator import AnsysSimulator
25 changes: 0 additions & 25 deletions squadds/components/coupled_systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,31 +96,6 @@ def make_cavity(self):
"""
self.make_coupler()
self.make_cpws()
# p = self.p

# cavity_opts = Dict()
# self.copier(cavity_opts, p.cavity_options)
# cavity_opts['cpw_options'].update({'pin_inputs':Dict(
# start_pin = Dict(
# component = self.qubit.name,
# pin = 'c'
# ),
# end_pin = Dict(
# component = '',
# pin = ''
# )
# )})
# self.cavity = CavityFeedline(self.design, "{}_cavityfeedline".format(self.name), options = cavity_opts)
# self.add_qgeometry('path', self.cavity.qgeometry_dict('path'), layer = 1, chip = p.chip)
# self.add_qgeometry('poly', self.cavity.qgeometry_dict('poly'), layer = 1, chip = p.chip)


# def make_pins(self):
# p = self.p
# start_dict = self.cavity.get_pin('prime_start')
# end_dict = self.cavity.get_pin('prime_end')
# self.add_pin('prime_start', start_dict['points'], start_dict['width'], chip = p.chip)
# self.add_pin('prime_end', end_dict['points'], end_dict['width'], chip = p.chip)

def make_coupler(self):
p = self.p
Expand Down
51 changes: 44 additions & 7 deletions squadds/core/db.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
from squadds.core.design_patterns import SingletonMeta
from datasets import get_dataset_config_names
from datasets import load_dataset
from tabulate import tabulate
import os
import platform
import pprint
import shutil
import sys
import warnings

import pandas as pd
from datasets import get_dataset_config_names, load_dataset
from tabulate import tabulate

from squadds.core.design_patterns import SingletonMeta
from squadds.core.utils import *

#* HANDLE WARNING MESSAGES
if sys.platform == "darwin": # Checks if the operating system is macOS
warnings.filterwarnings("ignore", category=UserWarning, module="pyaedt") # ANSYS is not a mac product

class SQuADDS_DB(metaclass=SingletonMeta):

def __init__(self):
Expand Down Expand Up @@ -41,8 +51,35 @@ def supported_data_types(self):
data_types.append(config.split("-")[2])
return data_types

def _delete_cache(self):
# Determine the root cache directory for 'datasets'
# Default cache directory is '~/.cache/huggingface/datasets' on Unix systems
# and 'C:\\Users\\<username>\\.cache\\huggingface\\datasets' on Windows
cache_dir = os.path.join(os.path.expanduser("~"), ".cache", "huggingface", "datasets")

# Adjust the path for Windows if necessary
if platform.system() == "Windows":
cache_dir = os.path.join(os.path.expanduser("~"), "AppData", "Local", "huggingface", "datasets")

# Define the specific dataset cache directory name
dataset_cache_dir_name = "SQuADDS___s_qu_adds_db"

# Path for the specific dataset cache
dataset_cache_dir = os.path.join(cache_dir, dataset_cache_dir_name)

# Check if the cache directory exists
if os.path.exists(dataset_cache_dir):
try:
# Delete the dataset cache directory
shutil.rmtree(dataset_cache_dir)
except OSError as e:
print(f"Error occurred while deleting cache: {e}")
else:
pass

def supported_config_names(self):
configs = get_dataset_config_names(self.repo_name)
self._delete_cache()
configs = get_dataset_config_names(self.repo_name, download_mode='force_redownload')
return configs

def get_configs(self):
Expand Down Expand Up @@ -342,7 +379,7 @@ def get_dataset(self, data_type=None, component=None, component_name=None):
# Construct the configuration string based on the provided or default values
config = f"{component}-{component_name}-{data_type}"
try:
df = load_dataset(self.repo_name, config)["train"].to_pandas()
df = load_dataset(self.repo_name, config, cache_dir=None)["train"].to_pandas()
self._set_target_param_keys(df)
return flatten_df_second_level(df)
except Exception as e:
Expand Down Expand Up @@ -372,7 +409,7 @@ def create_system_df(self):
def create_qubit_cavity_df(self, qubit_df, cavity_df, merger_terms=None):
for merger_term in merger_terms:
# process the dfs to make them ready for merger
qubit_df[merger_term] = qubit_df['design_options'].apply(lambda x: x['connection_pads']['c'][merger_term])
qubit_df[merger_term] = qubit_df['design_options'].apply(lambda x: x['connection_pads']['readout'][merger_term])
cavity_df[merger_term] = cavity_df['design_options'].apply(lambda x: x['claw_opts']['connection_pads']['readout'][merger_term])

# Merging the data frames based on merger terms
Expand Down
16 changes: 9 additions & 7 deletions squadds/interpolations/physics.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from squadds.interpolations.interpolator import Interpolator
from squadds import Analyzer
import pandas as pd
from squadds.core.utils import *
from pyEPR.calcs import Convert

from squadds import Analyzer
from squadds.core.utils import *
from squadds.interpolations.interpolator import Interpolator


def string_to_float(string):
"""
Converts a string representation of a number to a float.
Expand Down Expand Up @@ -47,7 +49,7 @@ def get_design(self) -> pd.DataFrame:

# Scale qubit and claw dimensions
updated_cross_length = string_to_float(closest_qubit_claw_design["design_options_qubit"].iloc[0]['cross_length']) * alpha_scaling.values[0]
updated_claw_length = string_to_float(closest_qubit_claw_design["design_options_qubit"].iloc[0]["connection_pads"]["c"]['claw_length']) * g_scaling.values[0] * alpha_scaling.values[0]
updated_claw_length = string_to_float(closest_qubit_claw_design["design_options_qubit"].iloc[0]["connection_pads"]["readout"]['claw_length']) * g_scaling.values[0] * alpha_scaling.values[0]

# Scaling logic for cavity-coupler designs
# Filter DataFrame based on qubit coupling claw capacitance
Expand Down Expand Up @@ -108,13 +110,13 @@ def get_design(self) -> pd.DataFrame:
# Update the qubit and cavity design options
qubit_design_options = closest_qubit_claw_design["design_options_qubit"].iloc[0]
qubit_design_options['cross_length'] = f"{updated_cross_length}um"
qubit_design_options["connection_pads"]["c"]['claw_length'] = f"{updated_claw_length}um"
qubit_design_options["connection_pads"]["readout"]['claw_length'] = f"{updated_claw_length}um"
required_Lj = Convert.Lj_from_Ej(closest_qubit_claw_design['EJ'].iloc[0], units_in='GHz', units_out='nH')
qubit_design_options['aedt_hfss_inductance'] = required_Lj*1e-9
qubit_design_options['aedt_q3d_inductance'] = required_Lj*1e-9
qubit_design_options['q3d_inductance'] = required_Lj*1e-9
qubit_design_options['hfss_inductance'] = required_Lj*1e-9
qubit_design_options["connection_pads"]["c"]['Lj'] = f"{required_Lj}nH"
qubit_design_options["connection_pads"]["readout"]['Lj'] = f"{required_Lj}nH"

cavity_design_options = closest_cavity_cpw_design["design_options_cavity_claw"].iloc[0]
cavity_design_options["cpw_opts"]['total_length'] = f"{updated_resonator_length}um"
Expand All @@ -133,6 +135,6 @@ def get_design(self) -> pd.DataFrame:

# add the device design options to the dataframe
interpolated_designs_df["design_options"] = [device_design_options]
interpolated_designs_df.iloc[0]["design_options"]["qubit_options"]["connection_pads"]["c"]["claw_cpw_length"] = "0um"
interpolated_designs_df.iloc[0]["design_options"]["qubit_options"]["connection_pads"]["readout"]["claw_cpw_length"] = "0um"

return interpolated_designs_df
19 changes: 15 additions & 4 deletions squadds/simulations/ansys_simulator.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# from utils import *
from squadds.simulations.objects import *
from qiskit_metal import draw, Dict, designs, MetalGUI
from qiskit_metal.toolbox_metal import math_and_overrides
import sys
# warn using `warnings` if os is mac that this is not supported
import warnings

import qiskit_metal as metal
from qiskit_metal import Dict, MetalGUI, designs, draw
from qiskit_metal.toolbox_metal import math_and_overrides

from squadds.simulations.objects import *


class AnsysSimulator:

Expand All @@ -16,9 +22,14 @@ def __init__(self, analyzer, design_options):
self.design = metal.designs.design_planar.DesignPlanar()
self.gui = metal.MetalGUI(self.design)
self.design.overwrite_enabled = True
self._warnings()

print(f"selected system: {self.analyzer.selected_system}")

def _warnings(self):
if sys.platform == "darwin": # Checks if the operating system is macOS
warnings.warn("`AnsysSimulator` is not supported on MacOS since Ansys does not have a Mac App. Please use Windows or Linux for simulations.")

def get_design_screenshot(self):
self.gui.rebuild()
self.gui.autoscale()
Expand Down Expand Up @@ -61,7 +72,7 @@ def get_xmon_info(self, xmon_dict):
a, fq = find_a_fq(cross2cpw, cross2ground, Lj)
print(f"qubit anharmonicity = {round(a)} MHz \nqubit frequency = {round(fq, 3)} GHz")
# return a json object
return dict("qubit_frequency_GHz": fq, "anharmonicity_MHz":a)
return {"qubit_frequency_GHz": fq, "anharmonicity_MHz": a}

def plot_device(self, device_dict):
self.design.delete_all_components()
Expand Down
Loading

0 comments on commit 24fd4a9

Please sign in to comment.