scqubits / scqubits

Superconducting Qubits in Python
BSD 3-Clause "New" or "Revised" License
216 stars 89 forks source link

Multi-harmonic josephson element #230

Closed edumur closed 6 days ago

edumur commented 1 week ago

Dear all,

We work with multi-harmonic Josephson element, see https://arxiv.org/abs/2405.14695 for instance. One way of describing them is to replace the usual $$E\mathrm{J} = I\mathrm{c} \cos \left( \varphi \right)$$ By $$E\mathrm{J} = I\mathrm{c1} \cos \left( \varphi\right) + I\mathrm{c2} \cos \left( 2 \varphi\right) + I\mathrm{c3} \cos \left( 3 \varphi\right) + ... $$

I have no idea how to add such functionality in scqubit which has a quite complicated code for me ^^' . Could you guide to realize such improvement?

Thanks!

saipavanc commented 1 week ago

We did think about such a possibility, and we added this functionality a while back, though this is not documented as we weren't sure as to how many would be interested in it. In the Circuit module, you can define higher order Josephson junctions in the following way:

import scqubits as scq
circ_input = """
branches:
- [JJ2, 0, 1, 20, 2, 3]
- [L, 0, 1, 0.4]
"""
circ = scq.Circuit(circ_input, from_file=False)
circ

$$ H = 12.0 Q{1}^{2} + \left(0.2 (2πΦ{1})^{2} + 0.2 θ{1}^{2} - 3.0 \cos{\left(2.0 θ{1} \right)} - 20.0 \cos{\left(θ{1} \right)} + 0.4 (2πΦ{1}) θ_{1}\right) $$

For defining the order the format is - [JJ<order>, node_1, node_2, EJ_1, EJ_2, ..., EJ_{order}, ECJ], following the syntax as usual to define a branch. The rest of the functionality should work as expected. Please let us know if you will experience any bugs.

edumur commented 1 week ago

Great! thanks a lot!

petergthatsme commented 1 week ago

thanks @saipavanc We might consider adding this to the docs... as it seems like there is interest.

edumur commented 6 days ago

Hello again,

I came across an error using the t1_effective method. Indeed when using this code

zp_yaml ="""
# inductive transmon
branches:
- ["JJ", 0, 1, EJ1=7.4nA, ECJ1=40fF]
- ["L", 1, 2, El=300.4nH]
- ["JJ", 0, 2, EJ2=7.401nA, ECJ2=40.01fF]
"""
ti2 = scq.Circuit(zp_yaml, from_file=False, ext_basis="discretized", generate_noise_methods=True)
ti2.cutoff_n_1 = 10
ti2.ng1 = 0.5

ti2.t1_effective()

I got

72695.0438727016

But when using

zp_yaml ="""
# asymetric inductive transmon
branches:
- ["L", 0, 1, El1=250.4nH]
- ["JJ", 1, 2, EJ1=7.4nA, ECJ1=40fF]
- ["L", 2, 3, El2=250.4nH]
- ["JJ", 3, 4, EJ2=7.401nA, ECJ2=40.01fF]
- ["L", 4, 0, El3=250.4nH]
"""
ti3 = scq.Circuit(zp_yaml, from_file=False, ext_basis="discretized", generate_noise_methods=True)
ti3.cutoff_n_1 = 10
ti3.ng1 = 0.5
ti3.t1_effective()

I got

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[22], [line 1](vscode-notebook-cell:?execution_count=22&line=1)
----> [1](vscode-notebook-cell:?execution_count=22&line=1) ti3.t1_effective()

File c:\Users\ed261978\Anaconda3\envs\python311\Lib\site-packages\scqubits\core\noise.py:952, in NoisySystem.t1_effective(self, noise_channels, common_noise_options, esys, get_rate, **kwargs)
    [948](file:///C:/Users/ed261978/Anaconda3/envs/python311/Lib/site-packages/scqubits/core/noise.py:948)             max_level = max(max_level, opts.get("i", 1), opts.get("j", 1))
    [950](file:///C:/Users/ed261978/Anaconda3/envs/python311/Lib/site-packages/scqubits/core/noise.py:950)     esys = self.eigensys(evals_count=max_level + 1)  # type: ignore
--> [952](file:///C:/Users/ed261978/Anaconda3/envs/python311/Lib/site-packages/scqubits/core/noise.py:952) rate = self._effective_rate(
    [953](file:///C:/Users/ed261978/Anaconda3/envs/python311/Lib/site-packages/scqubits/core/noise.py:953)     noise_channels=noise_channels,
    [954](file:///C:/Users/ed261978/Anaconda3/envs/python311/Lib/site-packages/scqubits/core/noise.py:954)     common_noise_options=common_noise_options,
    [955](file:///C:/Users/ed261978/Anaconda3/envs/python311/Lib/site-packages/scqubits/core/noise.py:955)     esys=esys,
    [956](file:///C:/Users/ed261978/Anaconda3/envs/python311/Lib/site-packages/scqubits/core/noise.py:956)     noise_type="t1",
    [957](file:///C:/Users/ed261978/Anaconda3/envs/python311/Lib/site-packages/scqubits/core/noise.py:957) )
    [958](file:///C:/Users/ed261978/Anaconda3/envs/python311/Lib/site-packages/scqubits/core/noise.py:958) if get_rate:
    [959](file:///C:/Users/ed261978/Anaconda3/envs/python311/Lib/site-packages/scqubits/core/noise.py:959)     return rate

File c:\Users\ed261978\Anaconda3\envs\python311\Lib\site-packages\scqubits\core\noise.py:821, in NoisySystem._effective_rate(self, noise_channels, common_noise_options, esys, noise_type)
    [818](file:///C:/Users/ed261978/Anaconda3/envs/python311/Lib/site-packages/scqubits/core/noise.py:818)     options["get_rate"] = True
    [820](file:///C:/Users/ed261978/Anaconda3/envs/python311/Lib/site-packages/scqubits/core/noise.py:820)     # calculate the noise over the full param span in param_vals
--> [821](file:///C:/Users/ed261978/Anaconda3/envs/python311/Lib/site-packages/scqubits/core/noise.py:821)     rate += scale_factor * getattr(self, noise_channel_method)(
    [822](file:///C:/Users/ed261978/Anaconda3/envs/python311/Lib/site-packages/scqubits/core/noise.py:822)         esys=esys, **options
    [823](file:///C:/Users/ed261978/Anaconda3/envs/python311/Lib/site-packages/scqubits/core/noise.py:823)     )
    [825](file:///C:/Users/ed261978/Anaconda3/envs/python311/Lib/site-packages/scqubits/core/noise.py:825) # noise_channel is a tuple representing the noise method and default options
    [826](file:///C:/Users/ed261978/Anaconda3/envs/python311/Lib/site-packages/scqubits/core/noise.py:826) elif isinstance(noise_channel, tuple):
...
   [2120](file:///C:/Users/ed261978/Anaconda3/envs/python311/Lib/site-packages/scqubits/core/circuit_routines.py:2120)     )
   [2122](file:///C:/Users/ed261978/Anaconda3/envs/python311/Lib/site-packages/scqubits/core/circuit_routines.py:2122) var_index = get_trailing_number(operator_name)
   [2123](file:///C:/Users/ed261978/Anaconda3/envs/python311/Lib/site-packages/scqubits/core/circuit_routines.py:2123) assert var_index

AttributeError: 'Circuit' object has no attribute 'θ4_operator'

Any idea

saipavanc commented 6 days ago

Continued discussion in #231. Closing this issue.