Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/sqdlab/sqdtoolz into main
Browse files Browse the repository at this point in the history
  • Loading branch information
PP501 committed Aug 13, 2024
2 parents 88b78be + 1f9d7f0 commit 554d6f5
Show file tree
Hide file tree
Showing 28 changed files with 1,889 additions and 623 deletions.
13 changes: 11 additions & 2 deletions UnitTests/testLaboratory.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,15 @@ def test_PROCs(self):
new_proc.add_stage(CPU_FIR([{'Type' : 'low', 'Taps' : 40, 'fc' : 0.01, 'Win' : 'hamming'}]*2))
new_proc.add_stage_end(CPU_Mean('repetition'))
self.lab.HAL("dum_acq").set_data_processor(new_proc)
new_proc = ProcessorCPU('cpu_test2', self.lab)
new_proc.add_stage(CPU_DDC([0.14]))
new_proc.add_stage(CPU_FIR([{'Type' : 'low', 'Taps' : 40, 'fc' : 0.01, 'Win' : 'hamming'}]*2))
new_proc.add_stage_end(CPU_Mean('repetition'))
new_proc = ProcessorCPU('cpu_test3', self.lab)
new_proc.add_stage(CPU_DDC([0.14]))
new_proc.add_stage(CPU_FIR([{'Type' : 'low', 'Taps' : 40, 'fc' : 0.01, 'Win' : 'hamming'}]*2))
new_proc.add_stage_end(CPU_Mean('repetition'))
self.lab.HAL("dum_acq").set_extra_post_processors([self.lab.PROC('cpu_test2'), self.lab.PROC('cpu_test3')])
self.lab.CONFIG('testConf4').save_config()
#
self.lab.save_laboratory_config('UnitTests/', 'laboratory_configuration4.txt')
Expand Down Expand Up @@ -1274,6 +1283,6 @@ def test_SnakeExp(self):
self.cleanup()

if __name__ == '__main__':
temp = TestExpSweeps()
temp.test_SnakeExp()
temp = TestColdReload()
temp.test_VARs()
unittest.main()
2 changes: 1 addition & 1 deletion docs/Developer/Experiment Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The `TriggerOutputCompatible` class requires the implementation of:

### Trigger inputs

HAL objects that can accept an input trigger to synchronise their output waveforms (like acquisition or AWG modules) must implement a similar couple of classes:
HAL objects that can accept an input trigger to synchronise their output waveforms (like acquisition or AWG modules) must similarly implement a couple of classes:

- The HAL object itself must implement `TriggerInputCompatible` in order both appear in timing diagrams and to pass internal verification checks run on HAL objects by the `ExperimentConfiguration` class when using said HAL object to accept a trigger input signal.
- The individual trigger inputs are either implemented within the object itself or via a list of classes housed within the HAL object (like with AWG markers); said objects must implement `TriggerInput` to ensure that they have the right functions to interface with the `ExperimentConfiguration` class.
Expand Down
87 changes: 83 additions & 4 deletions docs/User/Data_Fitting_RF.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The following RF resonator fitting functions exist:

- [RF notch resonance](#rf-notch-resonance) - used for **transmission spectra** of resonators side-coupled to a transmission line.
- RF reflectance
- [RF reflectance](#rf-reflectance) - used for **reflection spectra** of resonators terminating a transmission line.


## RF notch resonance
Expand All @@ -25,9 +25,6 @@ Note that:
The syntax is as follows:

```python
from sqdtoolz.Utilities.DataFitting import*
import numpy as np

from sqdtoolz.Utilities.DataFitting import DFitNotchResonance

#Assuming that the data is given as freqs, i_vals, q_vals
Expand Down Expand Up @@ -80,3 +77,85 @@ Now computing the fitted function (on the detrended data - so taking $I_0=Q_0=\a
Note that the final fit is done on the detrended data (thus, setting $\alpha=\tau=0$). The fit may still readjust and find finite values for $\alpha$ and $\tau$. Simply add these fitted values to the previous values of $\alpha$ and $\tau$ found it the detrending step to get the final fitting parameters.

In addition, it is noteworthy that least-squares residual used in circle fits can be easily skewed by the resonance datasets as many points tend to bunch up in a single region. To alleviate this bias, the data is first interpolated in equal arc-lengths. Then to combat the possibility of data going back and forth (due to noise), points that are close by are culled. The resulting dataset is used in the circle fitting procedures.


## RF reflectance

This applies to a **reflection spectra for resonators terminating transmission line**. The corresponding equation can be shown to be (c.f. [appendix D in thesis](https://unsworks.unsw.edu.au/entities/publication/6d9ea387-bc52-49d2-b5c2-6979779f4d30)):

$$
S_{11}(f)=-A\cdot\frac{1-\tfrac{\text{Q}_ \text{ext}}{\text{Q}_ \text{int}}\left(1+j\text{Q}_ \text{int}\left(\tfrac{f}{f_0}-\tfrac{f_0}{f}\right)\right)}
{1+\tfrac{\text{Q}_ \text{ext}}{\text{Q}_ \text{int}}\left(1+j\text{Q}_ \text{int}\left(\tfrac{f}{f_0}-\tfrac{f_0}{f}\right)\right)}\cdot \exp\left({j\frac{4\pi L}{c}f+j\phi}\right)
$$

Note that:
- The loaded quality factor is defined in terms of the internal and external quality factors as $Q_L^{-1}=Q_{\textnormal{int}}^{-1}+Q_{\textnormal{ext}}^{-1}$
- The complex exponential factor represents the phase trend that occurs due to the finite cable lengths ($L$ given the speed of light $c$)


### General usage

The syntax is as follows:

```python
from sqdtoolz.Utilities.DataFitting import DFitReflectanceResonance

#Assuming that the data is given as freqs, i_vals, q_vals
dFit = DFitReflectanceResonance()
dpkt = dFit.get_fitted_plot(freqs, i_vals, q_vals)
```

The returned data packet `dpkt` contains the fitted parameters mapped as:

- `'fres'`: $f_0$ (resonant frequency)
- `'Qint'`: $Q_\textnormal{int}$
- `'Qext'`: $Q_\textnormal{ext}$
- `'Qeff'`: $Q_L$
- `'Length'`: $L$
- `'Amplitude'`: $A$
- `'Phase'`: $\phi$

The `get_fitted_plot` function has optional arguments:

- `phase_slope_smooth_num` - The number of taps in the filter used to smooth out the phase derivative when fitting the maximum phase derivative (at the resonant frequency). Defaults to `25`. Increasing it will smoothen the phase derivative prior to fitting.
- `prop_detrend_start` - The proportion (defaults to `0.05`) of data from the beginning (lower end of the frequencies) to use in fitting the detrending line.
- `prop_detrend_end` - The proportion (defaults to `0.05`) of data in the end (higher end of the frequencies) to use in fitting the detrending line.
- `dont_plot` - Defaults to `False`. If `True`, nothing is plotted (just the fitted parameters are returned)
- `dont_plot_estimates` - Defaults to `False`. If `True`, the row of estimated plots is omitted and only the final amplitude, phase and IQ curves are drawn.

### Methodology

The fitting function requires accurate estimates of the final parameters. This section highlights the methods used to compute good initial guesses.

The first step is to remove any phase trends due to the finite length of the probing cables. The idea is to fit a line to the phase trend off-resonant from the main peak. The gradient and y-intercept of the linear fit readily gives $L$ and $\phi$. Now by multiplying $\exp\left({-j\frac{4\pi L}{c}f-j\phi}\right)$ to negate the phase slope, the detrended phase slope at resonance is given by:

$$
p_0=\left.\frac{d\phi}{df}\right|_ {f=f_0}=\frac{\text{Q}_ \text{ext}\text{Q}_ \text{int}^2}{2\pi f_0(\text{Q}_ \text{ext}^2-\text{Q}_ \text{int}^2)}.
$$

Now looking at the amplitude, the resulting trough will have a height (that is, the vertical size when viewing the amplitude plot - found by fitting a Lorentzian to the amplitude response $|S_{11}|$):

$$
h=\frac{2A\text{Q}_ \text{int}}{\text{Q}_ \text{int}+\text{Q}_ \text{ext}}.
$$

Now algebraically solve the equations to get:

$$
\begin{align}
\text{Q}_ \text{ext}&=\left\lbrace
\begin{array}{lc}
-\tfrac{2\pi(h-1)f_0}{h^2}\cdot\tfrac{d\phi}{df} & \tfrac{d\phi}{df}>0 \\
\tfrac{2\pi(h-1)f_0}{(h-2)^2}\cdot\tfrac{d\phi}{df} & \tfrac{d\phi}{df}<0
\end{array}
\right.\\
\text{Q}_ \text{int}&=\left\lbrace
\begin{array}{lc}
\tfrac{2\pi(h-1)f_0}{h(h-2)}\cdot\tfrac{d\phi}{df} & \tfrac{d\phi}{df}>0 \\
-\tfrac{2\pi(h-1)f_0}{h(h-2)}\cdot\tfrac{d\phi}{df} & \tfrac{d\phi}{df}<0
\end{array}
\right..
\end{align}
$$

The resonance phase slope be found by smoothing a finite difference taken over $\arg(S_{11})$.
24 changes: 20 additions & 4 deletions docs/User/InstrumentSpecific/ETH_FPGA_Card.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ETH FPGA (Driver:ACQ_ETH_FPGA)
# ETH FPGA (Driver: ACQ_ETH_FPGA)

The ETH FPGA card was developed for ETH (by a now defunc company). Its operations are highlighted in detail in [Deniz Bozyigit's 2010 Masters Thesis](https://qudev.phys.ethz.ch/static/content/science/Documents/master/Bozyigit_Deniz_MasterThesis.pdf). The card has:

Expand All @@ -25,8 +25,9 @@ Currently, to connect to card:
- Monitor the QTLab console for any potential error messages.

If during operation, the card throws an error, reset the FPGA using any/all of the following commands in the QTLab console:
- fpga.reload()
- fpga.reset()
- `fpga.reload()`
- `fpga.reset()`



## Setting up the client
Expand All @@ -40,7 +41,22 @@ YAML entry:
uri: 'Z:/DataAnalysis/Notebooks/qcodes/FPGA_Rack1_URI.txt'
```
Make sure to set the correct path for the URI.
Make sure to set the correct path for the URI. The typical connection setup looks like:
![My Diagram3](ETH_FPGA_setup.drawio.svg)
The frequency multiplier box is required to provide the 100MSPS sample clock.
## Maintaining the connectors
There is a jumper header that connects to the four BNC ports in the FPGA card on `J10`. Check the integrity of this connector regularly during maintenance:

![My Diagram3](ETH_FPGA_connector.drawio.svg)

The ground pins are tied together internally and can be connected to the BNC shields of all 4 BNC connectors.


## Test setup

The AWG can be used to check the working of and to reprogram the fpga, the wiring for which is shown below

Expand Down
Loading

0 comments on commit 554d6f5

Please sign in to comment.