| 1 |
{ |
| 2 |
"cells": [ |
| 3 |
{ |
| 4 |
"cell_type": "markdown", |
| 5 |
"metadata": {}, |
| 6 |
"source": [ |
| 7 |
"# Ex2: Measured 190 GHz Active 2-Port" |
| 8 |
] |
| 9 |
}, |
| 10 |
{ |
| 11 |
"cell_type": "markdown", |
| 12 |
"metadata": {}, |
| 13 |
"source": [ |
| 14 |
"The Vector Fitting feature is demonstrated using a 2-port S-matrix of an active circuit measured from 140 GHz to 220 GHz. Additional explanations and background information can be found in the [Vector Fitting tutorial](../../tutorials/VectorFitting.ipynb)." |
| 15 |
] |
| 16 |
}, |
| 17 |
{ |
| 18 |
"cell_type": "code", |
| 19 |
"execution_count": null, |
| 20 |
"metadata": {}, |
| 21 |
"outputs": [], |
| 22 |
"source": [ |
| 23 |
"import numpy as np\n", |
| 24 |
"\n", |
| 25 |
"import skrf" |
| 26 |
] |
| 27 |
}, |
| 28 |
{ |
| 29 |
"cell_type": "markdown", |
| 30 |
"metadata": {}, |
| 31 |
"source": [ |
| 32 |
"This example is a lot more tricky to fit, because the responses contain a few \"bumps\" and noise from the measurement. In such a case, finding a good number of initial poles can take a few iterations. A good alternative for such cases is the automatic vector fitting feature, `auto_fit()`, which automatically refines the number of poles until a good fit is achieved." |
| 33 |
] |
| 34 |
}, |
| 35 |
{ |
| 36 |
"cell_type": "markdown", |
| 37 |
"metadata": {}, |
| 38 |
"source": [ |
| 39 |
"Load the Network from a Touchstone file and create the Vector Fitting instance and start the automatic fit:" |
| 40 |
] |
| 41 |
}, |
| 42 |
{ |
| 43 |
"cell_type": "code", |
| 44 |
"execution_count": null, |
| 45 |
"metadata": {}, |
| 46 |
"outputs": [], |
| 47 |
"source": [ |
| 48 |
"nw = skrf.network.Network('./190ghz_tx_measured.S2P')\n", |
| 49 |
"vf = skrf.VectorFitting(nw)\n", |
| 50 |
"vf.auto_fit()" |
| 51 |
] |
| 52 |
}, |
| 53 |
{ |
| 54 |
"cell_type": "markdown", |
| 55 |
"metadata": {}, |
| 56 |
"source": [ |
| 57 |
"The function `plot_convergence()` can be helpful to examine the convergence and see if something was going wrong. Important parameters to check are the number of iterations until convergence and the final model order." |
| 58 |
] |
| 59 |
}, |
| 60 |
{ |
| 61 |
"cell_type": "code", |
| 62 |
"execution_count": null, |
| 63 |
"metadata": {}, |
| 64 |
"outputs": [], |
| 65 |
"source": [ |
| 66 |
"vf.plot_convergence()" |
| 67 |
] |
| 68 |
}, |
| 69 |
{ |
| 70 |
"cell_type": "code", |
| 71 |
"execution_count": null, |
| 72 |
"metadata": {}, |
| 73 |
"outputs": [], |
| 74 |
"source": [ |
| 75 |
"print(f'model order = {vf.get_model_order(vf.poles)}')\n", |
| 76 |
"print(f'n_poles_real = {np.sum(vf.poles.imag == 0.0)}')\n", |
| 77 |
"print(f'n_poles_complex = {np.sum(vf.poles.imag > 0.0)}')" |
| 78 |
] |
| 79 |
}, |
| 80 |
{ |
| 81 |
"cell_type": "markdown", |
| 82 |
"metadata": {}, |
| 83 |
"source": [ |
| 84 |
"Checking the results by comparing the model responses to the original sampled data indicates a successful fit, which is also indicated by a small rms error (less than 0.05):" |
| 85 |
] |
| 86 |
}, |
| 87 |
{ |
| 88 |
"cell_type": "code", |
| 89 |
"execution_count": null, |
| 90 |
"metadata": {}, |
| 91 |
"outputs": [], |
| 92 |
"source": [ |
| 93 |
"vf.get_rms_error()" |
| 94 |
] |
| 95 |
}, |
| 96 |
{ |
| 97 |
"cell_type": "code", |
| 98 |
"execution_count": null, |
| 99 |
"metadata": {}, |
| 100 |
"outputs": [], |
| 101 |
"source": [ |
| 102 |
"# plot frequency responses\n", |
| 103 |
"vf.plot_s_db()" |
| 104 |
] |
| 105 |
}, |
| 106 |
{ |
| 107 |
"cell_type": "markdown", |
| 108 |
"metadata": {}, |
| 109 |
"source": [ |
| 110 |
"It is a good idea to also check the model response well outside the original frequency range." |
| 111 |
] |
| 112 |
}, |
| 113 |
{ |
| 114 |
"cell_type": "code", |
| 115 |
"execution_count": null, |
| 116 |
"metadata": { |
| 117 |
"scrolled": true |
| 118 |
}, |
| 119 |
"outputs": [], |
| 120 |
"source": [ |
| 121 |
"freqs = np.linspace(0, 500e9, 501) # plot model response from dc to 500 GHz\n", |
| 122 |
"vf.plot_s_db(freqs=freqs)" |
| 123 |
] |
| 124 |
} |
| 125 |
], |
| 126 |
"metadata": { |
| 127 |
"kernelspec": { |
| 128 |
"display_name": "Python 3 (ipykernel)", |
| 129 |
"language": "python", |
| 130 |
"name": "python3" |
| 131 |
}, |
| 132 |
"language_info": { |
| 133 |
"codemirror_mode": { |
| 134 |
"name": "ipython", |
| 135 |
"version": 3 |
| 136 |
}, |
| 137 |
"file_extension": ".py", |
| 138 |
"mimetype": "text/x-python", |
| 139 |
"name": "python", |
| 140 |
"nbconvert_exporter": "python", |
| 141 |
"pygments_lexer": "ipython3", |
| 142 |
"version": "3.11.2" |
| 143 |
}, |
| 144 |
"nbsphinx": { |
| 145 |
"timeout": 360 |
| 146 |
} |
| 147 |
}, |
| 148 |
"nbformat": 4, |
| 149 |
"nbformat_minor": 4 |
| 150 |
} |