Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New example: Defining SOLT calibration standards. #663

Merged
merged 1 commit into from
Jun 3, 2022
Merged

New example: Defining SOLT calibration standards. #663

merged 1 commit into from
Jun 3, 2022

Conversation

biergaizi
Copy link
Contributor

@biergaizi biergaizi commented May 14, 2022

This example shows the method for modeling SOLT calibration standards in scikit-rf using their calibration coefficients, including offset loss, offset delay, and distributed capacitance and inductance defined by a third-degree polynomial function. Both the HP-Agilent-Keysight format and the Rohde & Schwarz / Anritsu format are included.

This example implements the request for documentation by issue #610.

This is the first draft, all the code and examples in the document are untested. Please review my calculations before merging it.

@github-actions github-actions bot added the Documentation Request/Improvement of the documentation label May 14, 2022
@jhillairet jhillairet requested review from arsenovic and Ttl May 14, 2022 08:30
@jhillairet
Copy link
Member

jhillairet commented May 14, 2022

Great introduction and tutorial, thanks !

"in most SOLT calibrations, Thru is first connected to the test cable, and all the Open, Short, Load, and Thru standards are attached to the other side of the Thru"

Interesting. Some have told me the opposite, that is, Open, Short, Load should be connected to the cables directly, not to the Thru.

This was referenced May 14, 2022
@biergaizi
Copy link
Contributor Author

biergaizi commented May 14, 2022

Interesting. Some have told me the opposite, that is, Open, Short, Load should be connected to the cables directly, not to the Thru.

Thanks for pointing it out. I was confused by the "precision port adapter" mentioned in the Keysight 85033E manuals and thought it was the Thru standard and since it's always used I thought it's a flush Thru. On second thought, it was unrelated. The Thru is defined to be zero-length because there's no Thru standard in this cal kit to begin with.

@biergaizi
Copy link
Contributor Author

biergaizi commented May 14, 2022

I just force-pushed a new commit. The transmission line attenuation section has been rewritten, the loops and polynomials are also removed is favor of numpy's broadcasting and poly1d. Please review the new revision.

Again, it's still a draft, all the code is still untested and the text has not been proofread. I'll keep working on it tomorrow. I just found Maury Microwave provides standard definitions in both Keysight and R&S format.

@biergaizi
Copy link
Contributor Author

biergaizi commented May 14, 2022

BTW, why does a force push cause the action bot to remove the existing tag Calibration? Is it a bug in the build bot script?

@biergaizi
Copy link
Contributor Author

biergaizi commented May 15, 2022

Still working on it. The calculation so far is still incorrect due to some typos in the code. But the progress so far looks promising.

For verification, I'm now comparing my result with the SignalIntegrity package (It's GPL'd so I'm obviously not copying any code, just using as a comparison). This is a package for high-speed signal integrity analysis developed by Peter J. Pupalaikis at LeCroy. He has written an entire book as its documentation to explain the derivation behind the code, S-Parameters for Signal Integrity, highly recommended. It has a built-in CalKit class. The S11 agreement for the offset transmission line is now within 0.005.

Quite unexpectedly, I believe I have now found a bug in SignalIntegrity rather than my code. When the short standard is modeled only with an offset loss and delay, SignalIntegrity's return loss is always 0 dB - which is by definition incorrect. Meanwhile the loss calculated by my code from Keysight coefficients now agrees with the numerical loss specified by R&S coefficients. Since the loss is very low (S11 within 0.005), not a big deal, I'll keep fixing and testing my implementation.

@biergaizi
Copy link
Contributor Author

biergaizi commented May 16, 2022

Quite unexpectedly, I believe I have now found a bug in SignalIntegrity rather than my code. When the short standard is modeled only with an offset loss and delay, SignalIntegrity's return loss is always 0 dB

Found the reason - its documentation is wrong. The unit is actually in ohm/s but documented as Gohm/s (I've submitted a patch to that project). After correcting the order of magnitude, the loss calculated by SignalIntegrity makes sense now. The agreement is not exact, but I suspect it's just normal numerical errors. I'll try modeling it as a full transmission line again and compare the results with the delayed attenuator model...

Another mistake in the current version is the definition of loss. Apparently in the R&S, the loss is two-way loss, not one-way...

@biergaizi
Copy link
Contributor Author

biergaizi commented May 17, 2022

I found the reason for the disagreement between the lumped "attenuation + time delay" model and the offset transmission line equations - you can't just model the phase shift as a pure time delay, they're not equivalent. The phase constant βl is not just 2πf * offset_delay, but it's exactly 2πf * offset_delay + αl. Thus, my original understanding was completely wrong - the only proper way to do it is using the real transmission line equations. After solving this problem, I think now the agreement between my guide and SignalIntegrity is near-perfect.

I'll rewrite the guide and push a fixed version soon.

@mhuser
Copy link
Collaborator

mhuser commented May 17, 2022

Hello @biergaizi ,
Great notebook !
Have you considered using Media.DefinedGammaZ0 for a lossy line ?
You can create a lossy line media by initializing with Z0 and gamma directly with your Z0 and gamma = alpha + 1j*beta.
Where alpha is attenuation in Neper/m and beta is propagation like 2 * pi * f* sqrt(ep_reff) / c or 2 * pi * f* / (c * VF), c is speed of light. You can use 1. as relative permittivity ep_reff or velocity factor VF and define the delay when creating the line from the media.
There is a function skrf.mathFunctions.db_2_np to convert for decibels to nepers and alpha should be an array built from a computation with frequency, e.g. with sqrt(f).

@mhuser
Copy link
Collaborator

mhuser commented May 17, 2022

Alternatively with skrf.media.definedAEpTandZ0, you can set impedance and attenuation in dB/m/sqrt(Hz) straightforward.

@biergaizi
Copy link
Contributor Author

biergaizi commented May 18, 2022

@mhuser
Thanks for this suggestion. This is already similar to what I'm doing in the unpublished draft, here, I am calculating γl = αl + jβl from Keysight's formulas.

$$ \begin{gather} \alpha l = \frac{\text{offset loss} \cdot \text{offset delay}}{2 \cdot \text{ offset }Z_0} \sqrt{\frac{f}{10^9}} \\ \beta l = 2 \pi f \cdot \text{offset delay} + \alpha l \\ \gamma l = \alpha l + j\beta l \\ Z_c = \text{offset }Z_0 + (1 - j) \frac{\text{offset loss}}{2 \cdot 2 \pi f} \sqrt{\frac{f}{10^9}} \end{gather} $$

And then using that as the gamma and zc for Media.DefinedGammaZ0, then a line with a unity length of one meter is created by medium.line(d=1, unit='m') to obtain the S-parameters of this offset transmission line.

You can use 1. as relative permittivity ep_reff or velocity factor VF and define the delay when creating the line from the media.

My understanding is that the Keysight approach is explicitly made to avoid any specific assumption of any particular line length, dielectric constant or velocity factor. They're implicitly included as part of the definition in offset delay and offset loss. Then, γl and lossy Z are directly calculated.

I'm now following the derivation in Application Note 1287-11, see equation 2B.5.

@mhuser
Copy link
Collaborator

mhuser commented May 19, 2022

This sounds good ! From the equations it seems the proper relative permittivity is already embedded into the coefficient.

@biergaizi
Copy link
Contributor Author

Almost done.

@biergaizi biergaizi requested review from Ttl and jhillairet May 19, 2022 14:07
Copy link
Collaborator

@Ttl Ttl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks quite good. It would be nice to also have some plots of the generated standards. For example phase of open and short or Smith chart whichever looks nicest.

@biergaizi
Copy link
Contributor Author

Good idea. I'll add some plots soon.

@biergaizi
Copy link
Contributor Author

Plots added.

@biergaizi biergaizi requested a review from Ttl May 21, 2022 21:39
@biergaizi
Copy link
Contributor Author

biergaizi commented May 21, 2022

Tests performed:

  1. The generated SOLT standards by the step-by-step tutorial and code snippet are identical, confirming that there's no typo in the guide.
  2. The generated SOLT standards by R&S coefficients are identical to the same calibration kit (Maury Microwave 8050CK10) specified in Keysight coefficients in its datasheet, ensuring that the R&S code is correct.
  3. The offset transmission line model has been compared with the SignalIntegrity package, a package for high-speed signal integrity analysis developed by Peter J. Pupalaikis at LeCroy. When offset delay is within (1 ps, 100 ps), offset loss is within (1 Gohm/s, 25 Gohm/s), frequency is 100 MHz to 60 GHz, the generated S-parameters have an agreement better than 0.001 for both their real and imaginary parts (in calcZc = True mode, because by default SignalIntegrity uses a lossless line impedance). This is tested by running 10,000 trials with random parameters. All the previous numerical disagreements have been solved.

However, when an extremely large (and impractical) offset delay or loss is specified, e.g. 100 Gohm/s, the difference can be as high as 0.02. I believe this is due to the difference of the physical model used. SignalIntegrity calculates $\gamma$ by obtain the full RLGC transmission line parameters first, meanwhile, my implementation calculates $\gamma$ directly based on the formulas given by Keysight and it's also the model used by Federal Institute of Metrology (METAS), Switzerland, referenced in citation [1] and [2] of the guide. According to [4], the formulas are in fact a first-order expansion, so SignalIntegrity is technically more accurate. But, in any case, for practical purposes the results are the same. If it's good enough for Keysight and METAS, it's good enough for us (at least for this guide, which is only a tutorial, it should be enough - it may be desirable for the future CalKit class to use the RLGC parameters, though).

Thus, I think this guide is thoroughly checked and it's suitable for merging in its current state.

@biergaizi
Copy link
Contributor Author

The guide is ready for merging. Please give it a final review.

Copy link
Collaborator

@Ttl Ttl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good, only few minor comments.

@biergaizi
Copy link
Contributor Author

Updated.

@biergaizi biergaizi requested a review from Ttl May 22, 2022 04:50
Copy link
Collaborator

@Vinc0110 Vinc0110 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a nice guide. Great job!
I'm also looking forward to the implementation of your code snippets as a proper CalKit class (#610 (comment))

Copy link
Member

@jhillairet jhillairet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice tutorial. I appreciate the call for making additional documentation contributions ;) It also assumes that readers are not Python/Numpy experts, which is a good thing in my opinion (that we sometimes forgot).

A minor thing: I suggest shortening the title of the notebook, which is a little long as this is the title which will be used to generate the Table of Content on the left panel of the documentation:
image

SOLT Calibration Standards should directly appear after SOLT, but Coaxial SOLT Calibration Standards or Creating SOLT Calibration Standards are nice too. Up to you.

The "confusing" part on the creation of the transmission line length may change in the future (see discussion in #654 and other)

"A series medium.capacitor() terminated by a medium.short() "

I would have used this solution first, and eventually say a word about shunt_capa terminated with open, to make it similar to the inductor case.

@biergaizi
Copy link
Contributor Author

Guide has been updated with your suggested text changes.

I changed the title to "SOLT Calibration Standards Creation", so it shows up next to SOLT.

This example shows the method for modeling SOLT calibration standards
in scikit-rf using their calibration coefficients, including offset
loss, offset delay, and distributed capacitance and inductance defined
by a third-degree polynomial function. Both the HP-Agilent-Keysight
format and the Rohde & Schwarz / Anritsu format are included.

This example implements the request for documentation by issue #610.

Signed-off-by: Yifeng Li <tomli@tomli.me>
@jhillairet
Copy link
Member

Is OK to be merged?

@biergaizi
Copy link
Contributor Author

Is OK to be merged?

Yes, I consider it finished.

@Ttl Ttl merged commit f9d0c6f into scikit-rf:master Jun 3, 2022
@jhillairet
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Request/Improvement of the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants