Skip to content

Commit

Permalink
updating for v3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jkochNU committed Jul 30, 2023
1 parent 39bb128 commit 867b6c2
Show file tree
Hide file tree
Showing 12 changed files with 32,075 additions and 70,648 deletions.
10 changes: 3 additions & 7 deletions examples/demo-jaynes-cummings.ipynb
Expand Up @@ -28,9 +28,6 @@
},
"outputs": [],
"source": [
"%matplotlib inline\n",
"%config InlineBackend.figure_format = 'svg'\n",
"\n",
"import numpy as np\n",
"\n",
"import scqubits as scq\n",
Expand Down Expand Up @@ -182,8 +179,7 @@
"--------------------------------\n",
"InteractionTerm----------| [Interaction_1]\n",
" | g_strength: 0.1\n",
" | operator_list: [(0, array([[0., 0.],\n",
" [1., 0.]])), (1, arra ...\n",
" | operator_list: [(0, <bound method GenericQubit.sm_operator of Gen ...\n",
" | add_hc: True\n",
"\n",
"\n"
Expand Down Expand Up @@ -241,7 +237,7 @@
"metadata": {
"celltoolbar": "Initialisation Cell",
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -255,7 +251,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.9.16"
},
"toc": {
"base_numbering": 1,
Expand Down
17,184 changes: 4,324 additions & 12,860 deletions examples/demo_cos2phi_qubit.ipynb

Large diffs are not rendered by default.

121 changes: 78 additions & 43 deletions examples/demo_customcircuit.ipynb

Large diffs are not rendered by default.

183 changes: 51 additions & 132 deletions examples/demo_explorer.ipynb
Expand Up @@ -12,39 +12,17 @@
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**SCQUBITS RELEASE V2.2 CHANGES:** The `Explorer` has been adapted to the new `ParameterSweep` class with scqubits release v2.2. The old `Explorer` is still intact but will be removed in future versions of scqubits. The following illustrates the up-to-date use."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2020-02-13T14:26:06.207526Z",
"start_time": "2020-02-13T14:26:03.363950Z"
}
},
"outputs": [],
"source": [
"import numpy as np\n",
"import scqubits as scq"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# The Explorer Class\n",
"\n",
"Sometimes, exploring the properties of coupled quantum systems benefits from visual aides, and the possibility to see how properties change when system parameters are changed. The `Explorer` class in scqubits provides an interactive plot with multiple panels collecting an important set of information. \n",
"Sometimes, exploring the properties of coupled quantum systems benefits from visual aides, and the possibility to see how properties change when system parameters are changed. The `Explorer` class in scqubits provides an interactive plot with multiple panels. \n",
"\n",
"The idea behind the `Explorer` class is simple: the user selects an external parameter that they wish to sweep, e.g., an external magnetic flux. The composite system is user-defined through the `HilbertSpace` and `InteractionTerm` classes, allowing flexibility to include different types and numbers of superconducting qubits and harmonic modes.\n",
"\n",
"Once defined, the parameter sweep is computed by means of the `ParameterSweep` class, and spectral data is stored in memory to allow efficient, interactive display of data. The `Explorer` plots are currently fixed to:\n",
"Once defined, the parameter sweep is computed by means of the `ParameterSweep` class, and spectral data is stored in memory to allow efficient, interactive display of data. The `Explorer` supports plots of:\n",
"\n",
"1. Bare spectra of the individual qubits\n",
"2. Wave functions of the bare qubits\n",
Expand All @@ -54,105 +32,18 @@
"6. Charge matrix elements for any of the qubits, using the same initial state as in point 4.\n",
"\n",
"## Example 1: fluxonium coupled to resonator\n",
"As a first example, we consider a system composed of a fluxonium qubit, coupled through its charge operator to the voltage inside a resonator.\n",
"\n",
"### HilbertSpace setup\n",
"The initialization of the composite Hilbert space proceeds as usual; we first define the individual two subsystems that will make up the Hilbert space:"
"As a first example, we consider a system composed of a fluxonium qubit, coupled through its charge operator to the voltage inside a resonator."
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2020-02-13T14:26:06.228141Z",
"start_time": "2020-02-13T14:26:06.213556Z"
}
},
"outputs": [],
"source": [
"qbt = scq.Fluxonium(\n",
" EJ=2.55,\n",
" EC=0.72,\n",
" EL=0.12,\n",
" flux=0.0,\n",
" cutoff=110,\n",
" truncated_dim=9\n",
")\n",
"\n",
"osc = scq.Oscillator(\n",
" E_osc=4.0,\n",
" truncated_dim=5\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here, the `truncated_dim` parameters are important. For the fluxonium, with `cutoff` set to 110, the internal Hilbert space dimension is 110. Once diagonalized, we will only keep a few eigenstates going forward - in the above example 9. Similarly, we keep 5 levels for the resonators, i.e., photon states n=0,1,...,4 are included in the following.\n",
"\n",
"Next, the two subsystems are declared as the two components of a joint Hilbert space:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"ExecuteTime": {
"end_time": "2020-02-13T14:26:06.252987Z",
"start_time": "2020-02-13T14:26:06.235033Z"
}
},
"outputs": [],
"source": [
"hilbertspace = scq.HilbertSpace([qbt, osc])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The interaction between fluxonium and resonator is of the form $H_\\text{int} = g n (a+a^\\dagger)$, where $n$ is the fluxonium's charge operator: `qbt.n_operator()`. This structure is captured by creating an `InteractionTerm` object via `add_interaction`:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"hilbertspace.add_interaction(\n",
" g_strength=0.2,\n",
" op1=qbt.n_operator,\n",
" op2=osc.creation_operator,\n",
" add_hc=True\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Parameter sweep setup\n",
"We consider sweeping the external flux through the fluxonium loop. To create the necessary `ParameterSweep` object, we specify:\n",
"1. `param_name`: the name of the sweep parameter (below expressed in LaTeX format as the flux in units of the flux quantum)\n",
"2. `param_vals_by_name`: a dictionary that names our parameter and associates the array of flux values with it\n",
"3. `subsys_update_info` (optional): a dictionary listing the particular Hilbert space subsystems that change as each parameter (here the flux) is varied\n",
"4. `update_hilbertspace(param_val)`: a function that shows how a change in the sweep parameter affects the Hilbert space; here only the `.flux` attributed of the fluxonium qubit needs to be changed\n",
"\n",
"These ingredients all make it into the initialization of the `ParameterSweep` object. Once initialized, spectral data is generated and stored. Here, we additionally generate data for dispersive shifts and charge matrix elements."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"ExecuteTime": {
"end_time": "2020-02-13T14:26:13.431122Z",
"start_time": "2020-02-13T14:26:09.721855Z"
}
},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -198,7 +89,33 @@
}
],
"source": [
"param_name = r'$\\Phi_{ext}/\\Phi_0$'\n",
"import numpy as np\n",
"import scqubits as scq\n",
"\n",
"qbt = scq.Fluxonium(\n",
" EJ=2.55,\n",
" EC=0.72,\n",
" EL=0.12,\n",
" flux=0.0,\n",
" cutoff=110,\n",
" truncated_dim=9\n",
")\n",
"\n",
"osc = scq.Oscillator(\n",
" E_osc=4.0,\n",
" truncated_dim=5\n",
")\n",
"\n",
"hilbertspace = scq.HilbertSpace([qbt, osc])\n",
"\n",
"hilbertspace.add_interaction(\n",
" g_strength=0.2,\n",
" op1=qbt.n_operator,\n",
" op2=osc.creation_operator,\n",
" add_hc=True\n",
")\n",
"\n",
"param_name = 'Φext/Φ0'\n",
"param_vals = np.linspace(-0.5, 0.5, 101)\n",
"\n",
"subsys_update_list = [qbt]\n",
Expand All @@ -210,7 +127,7 @@
"\n",
"sweep = scq.ParameterSweep(\n",
" paramvals_by_name={param_name: param_vals},\n",
" evals_count=10,\n",
" evals_count=20,\n",
" hilbertspace=hilbertspace,\n",
" subsys_update_info={param_name: [qbt]},\n",
" update_hilbertspace=update_hilbertspace,\n",
Expand All @@ -222,36 +139,31 @@
"metadata": {},
"source": [
"### Starting the Explorer class\n",
"At this point, everything is prepared to start the interactive `Explorer` and play with the interactive display!"
"At this point, everything is prepared to start the interactive `Explorer` display!"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"ExecuteTime": {
"end_time": "2020-02-13T14:26:20.251368Z",
"start_time": "2020-02-13T14:26:17.313557Z"
}
},
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f6b015493ae44dbaaf01167de8ed8d68",
"model_id": "a8abbe67076148c9818a965331f367dd",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(Tab(children=(HBox(children=(HBox(children=(VBox(children=(Dropdown(layout=Layout(width='165px'"
"Container(children=[Sheet(children=[Card(children=[Img(layout=None, src='data:image/png;base64,iVBORw0KGgoAAAA"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"explorer = scq.Explorer(sweep=sweep)"
"xp = scq.Explorer(sweep)"
]
},
{
Expand All @@ -266,7 +178,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -319,7 +231,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 4,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -409,18 +321,18 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "621f8abdfa5640179bf379fa49f985ea",
"model_id": "853d55effe1743afb95b71b5f9011f65",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(Tab(children=(HBox(children=(HBox(children=(VBox(children=(Dropdown(layout=Layout(width='165px'"
"Container(children=[Sheet(children=[Card(children=[Img(layout=None, src='data:image/png;base64,iVBORw0KGgoAAAA"
]
},
"metadata": {},
Expand All @@ -430,6 +342,13 @@
"source": [
"explorer = scq.Explorer(sweep=sweep)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -448,7 +367,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.15"
"version": "3.9.16"
},
"pycharm": {
"stem_cell": {
Expand Down
7 changes: 2 additions & 5 deletions examples/demo_flux_qubit.ipynb
Expand Up @@ -28,9 +28,6 @@
},
"outputs": [],
"source": [
"%matplotlib inline\n",
"%config InlineBackend.figure_format = 'svg'\n",
"\n",
"import numpy as np\n",
"import scqubits as scq"
]
Expand Down Expand Up @@ -13154,7 +13151,7 @@
"metadata": {
"celltoolbar": "Initialisation Cell",
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -13168,7 +13165,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.9.16"
},
"pycharm": {
"stem_cell": {
Expand Down

0 comments on commit 867b6c2

Please sign in to comment.