Commit a43aaa9c authored by natsfr's avatar natsfr

merge

parent 562a9d99
! Infineon Technologies Discrete & RF Semiconductors
! BFR93A
! VCE = 5.0 V, IC = 30 mA
! Common Emitter S-Parameters: Nov 2015
# GHz S MA R 50
! f S11 S21 S12 S22
! GHz MAG ANG MAG ANG MAG ANG MAG ANG
0.010 0.5746 -12.5 47.832 171.0 0.0033 84.4 0.9503 -6.4
0.015 0.5628 -18.4 46.959 167.0 0.0049 80.7 0.9362 -9.4
0.020 0.5572 -24.5 46.322 162.9 0.0065 78.8 0.9248 -12.5
0.025 0.5353 -29.2 44.762 160.0 0.0077 76.2 0.8984 -14.6
0.030 0.5174 -34.3 43.327 156.9 0.0090 74.3 0.8733 -16.8
0.035 0.5038 -39.7 42.029 153.5 0.0102 72.9 0.8497 -19.2
0.040 0.4948 -45.3 40.882 150.0 0.0115 71.8 0.8275 -21.7
0.045 0.4908 -51.1 39.898 146.3 0.0127 70.9 0.8070 -24.3
0.050 0.4918 -56.9 39.090 142.4 0.0140 70.2 0.7883 -27.1
0.055 0.4754 -59.8 37.768 140.9 0.0148 69.3 0.7664 -27.9
0.060 0.4604 -63.0 36.472 139.4 0.0156 68.5 0.7447 -28.8
0.065 0.4468 -66.3 35.205 137.7 0.0164 67.7 0.7232 -29.8
0.070 0.4348 -69.8 33.970 135.9 0.0172 67.1 0.7019 -30.8
0.075 0.4245 -73.5 32.771 134.0 0.0180 66.5 0.6808 -31.8
0.080 0.4162 -77.4 31.611 131.9 0.0188 65.9 0.6600 -33.0
0.085 0.4098 -81.5 30.496 129.7 0.0197 65.4 0.6394 -34.2
0.090 0.4055 -85.6 29.431 127.3 0.0205 64.9 0.6192 -35.5
0.095 0.4033 -89.8 28.420 124.7 0.0213 64.5 0.5993 -36.8
0.100 0.4033 -94.0 27.471 122.0 0.0221 64.1 0.5797 -38.3
0.105 0.3955 -96.0 26.709 121.2 0.0227 64.1 0.5672 -38.5
0.110 0.3881 -98.0 25.952 120.3 0.0233 64.1 0.5547 -38.7
0.115 0.3813 -100.1 25.203 119.3 0.0239 64.1 0.5423 -39.0
0.120 0.3750 -102.3 24.461 118.3 0.0245 64.1 0.5298 -39.2
0.125 0.3693 -104.6 23.727 117.2 0.0250 64.1 0.5174 -39.5
0.130 0.3641 -106.9 23.002 116.1 0.0256 64.1 0.5049 -39.8
0.135 0.3596 -109.3 22.286 114.9 0.0262 64.1 0.4925 -40.0
0.140 0.3557 -111.8 21.582 113.6 0.0268 64.1 0.4801 -40.3
0.145 0.3525 -114.3 20.889 112.2 0.0274 64.1 0.4677 -40.7
0.150 0.3500 -116.8 20.209 110.7 0.0280 64.1 0.4553 -41.0
0.155 0.3466 -118.2 19.759 110.2 0.0286 64.3 0.4483 -41.0
0.160 0.3435 -119.7 19.310 109.6 0.0292 64.5 0.4413 -40.9
0.165 0.3406 -121.2 18.863 109.0 0.0298 64.7 0.4343 -40.9
0.170 0.3379 -122.7 18.419 108.4 0.0304 64.9 0.4273 -40.9
0.175 0.3355 -124.3 17.977 107.7 0.0310 65.0 0.4202 -40.9
0.180 0.3333 -125.9 17.537 107.0 0.0316 65.2 0.4132 -40.8
0.185 0.3313 -127.4 17.100 106.3 0.0322 65.4 0.4062 -40.8
0.190 0.3297 -129.0 16.666 105.5 0.0328 65.5 0.3992 -40.8
0.195 0.3283 -130.7 16.235 104.7 0.0334 65.7 0.3922 -40.7
0.200 0.3271 -132.3 15.807 103.9 0.0340 65.8 0.3852 -40.7
0.220 0.3210 -136.6 14.640 102.1 0.0363 66.3 0.3679 -40.3
0.240 0.3167 -141.0 13.490 100.0 0.0386 66.7 0.3507 -39.8
0.260 0.3137 -144.8 12.516 98.2 0.0410 67.2 0.3366 -39.3
0.280 0.3110 -147.7 11.707 96.8 0.0433 67.8 0.3255 -38.7
0.300 0.3092 -150.7 10.905 95.2 0.0457 68.4 0.3145 -38.2
0.320 0.3071 -153.2 10.376 94.3 0.0482 68.8 0.3077 -37.8
0.340 0.3056 -155.7 9.850 93.2 0.0507 69.2 0.3009 -37.4
0.360 0.3047 -158.2 9.327 92.1 0.0532 69.5 0.2941 -37.0
0.380 0.3044 -160.8 8.809 90.8 0.0557 69.8 0.2873 -36.6
0.400 0.3047 -163.3 8.295 89.4 0.0582 70.1 0.2806 -36.1
0.420 0.3041 -165.2 7.974 88.6 0.0607 70.2 0.2770 -35.9
0.440 0.3039 -167.0 7.654 87.8 0.0632 70.3 0.2734 -35.7
0.450 0.3039 -168.0 7.495 87.3 0.0645 70.4 0.2716 -35.6
0.460 0.3040 -168.9 7.336 86.8 0.0658 70.4 0.2698 -35.5
0.480 0.3044 -170.7 7.020 85.8 0.0683 70.5 0.2662 -35.3
0.500 0.3051 -172.6 6.707 84.7 0.0708 70.6 0.2626 -35.1
0.520 0.3052 -174.0 6.490 84.0 0.0733 70.6 0.2600 -35.0
0.540 0.3054 -175.4 6.274 83.3 0.0759 70.6 0.2574 -35.0
0.560 0.3059 -176.8 6.060 82.5 0.0784 70.6 0.2548 -34.9
0.580 0.3065 -178.2 5.846 81.6 0.0810 70.6 0.2522 -34.9
0.600 0.3073 -179.6 5.634 80.7 0.0835 70.6 0.2496 -34.8
0.620 0.3076 179.4 5.476 80.1 0.0860 70.5 0.2478 -34.9
0.640 0.3081 178.4 5.320 79.4 0.0886 70.5 0.2461 -35.0
0.660 0.3086 177.4 5.163 78.7 0.0911 70.4 0.2443 -35.0
0.680 0.3092 176.4 5.008 77.9 0.0937 70.4 0.2426 -35.1
0.700 0.3099 175.4 4.854 77.1 0.0962 70.3 0.2408 -35.2
0.720 0.3109 174.3 4.737 76.5 0.0987 70.1 0.2392 -35.4
0.740 0.3120 173.3 4.620 75.9 0.1012 70.0 0.2377 -35.5
0.760 0.3132 172.2 4.504 75.2 0.1037 69.9 0.2361 -35.7
0.780 0.3145 171.1 4.388 74.5 0.1062 69.7 0.2346 -35.8
0.800 0.3159 170.1 4.273 73.8 0.1087 69.6 0.2330 -36.0
0.820 0.3171 169.1 4.181 73.3 0.1112 69.4 0.2316 -36.3
0.840 0.3184 168.2 4.089 72.7 0.1137 69.3 0.2303 -36.6
0.860 0.3198 167.3 3.998 72.1 0.1162 69.1 0.2289 -36.8
0.880 0.3212 166.3 3.907 71.5 0.1187 68.9 0.2275 -37.1
0.900 0.3228 165.4 3.816 70.9 0.1212 68.8 0.2262 -37.4
0.920 0.3234 164.6 3.744 70.3 0.1237 68.6 0.2253 -37.7
0.940 0.3241 163.8 3.671 69.7 0.1262 68.4 0.2243 -37.9
0.960 0.3249 163.0 3.600 69.1 0.1286 68.2 0.2234 -38.2
0.980 0.3257 162.2 3.529 68.4 0.1311 68.1 0.2224 -38.4
1.000 0.3266 161.4 3.458 67.7 0.1336 67.9 0.2215 -38.7
1.020 0.3278 160.7 3.399 67.2 0.1361 67.7 0.2204 -39.1
1.040 0.3290 159.9 3.340 66.6 0.1386 67.5 0.2193 -39.5
1.060 0.3303 159.2 3.282 66.0 0.1410 67.3 0.2183 -39.9
1.080 0.3317 158.5 3.224 65.4 0.1435 67.2 0.2172 -40.4
1.100 0.3331 157.8 3.166 64.8 0.1460 67.0 0.2162 -40.8
1.120 0.3349 157.1 3.118 64.3 0.1485 66.8 0.2151 -41.2
1.140 0.3367 156.5 3.070 63.7 0.1509 66.5 0.2140 -41.6
1.160 0.3385 155.9 3.023 63.2 0.1534 66.3 0.2129 -42.0
1.180 0.3404 155.2 2.976 62.6 0.1558 66.1 0.2118 -42.4
1.200 0.3423 154.6 2.929 62.0 0.1583 65.9 0.2107 -42.8
1.220 0.3438 153.9 2.885 61.5 0.1606 65.6 0.2099 -43.2
1.240 0.3455 153.1 2.842 60.9 0.1630 65.4 0.2090 -43.7
1.260 0.3471 152.4 2.799 60.3 0.1653 65.2 0.2082 -44.1
1.280 0.3488 151.7 2.756 59.7 0.1677 64.9 0.2074 -44.6
1.300 0.3506 151.0 2.713 59.1 0.1700 64.7 0.2066 -45.0
1.320 0.3511 150.4 2.676 58.6 0.1724 64.5 0.2059 -45.4
1.340 0.3517 149.9 2.640 58.1 0.1748 64.3 0.2052 -45.8
1.360 0.3522 149.3 2.604 57.6 0.1771 64.1 0.2045 -46.3
1.380 0.3529 148.8 2.568 57.0 0.1795 64.0 0.2038 -46.7
1.400 0.3535 148.2 2.532 56.5 0.1819 63.8 0.2031 -47.1
1.420 0.3547 147.6 2.499 56.0 0.1843 63.6 0.2020 -47.6
1.440 0.3560 147.0 2.465 55.5 0.1867 63.3 0.2009 -48.2
1.460 0.3574 146.4 2.432 54.9 0.1890 63.1 0.1998 -48.7
1.480 0.3587 145.9 2.400 54.4 0.1914 62.9 0.1987 -49.2
1.500 0.3601 145.3 2.367 53.8 0.1938 62.7 0.1977 -49.8
1.520 0.3618 144.6 2.343 53.3 0.1961 62.4 0.1967 -50.4
1.540 0.3636 144.0 2.320 52.9 0.1985 62.2 0.1958 -51.0
1.560 0.3654 143.4 2.296 52.4 0.2008 61.9 0.1948 -51.6
1.580 0.3672 142.7 2.273 51.9 0.2032 61.6 0.1939 -52.2
1.600 0.3691 142.1 2.250 51.4 0.2055 61.4 0.1930 -52.8
1.620 0.3708 141.6 2.226 50.9 0.2078 61.2 0.1924 -53.4
1.640 0.3725 141.0 2.203 50.4 0.2101 61.0 0.1919 -53.9
1.660 0.3742 140.5 2.179 49.9 0.2123 60.8 0.1914 -54.5
1.680 0.3760 140.0 2.156 49.4 0.2146 60.6 0.1909 -55.0
1.700 0.3778 139.5 2.133 48.9 0.2169 60.4 0.1904 -55.6
1.720 0.3786 139.0 2.112 48.4 0.2193 60.1 0.1900 -56.2
1.740 0.3795 138.5 2.091 47.9 0.2216 59.9 0.1895 -56.8
1.760 0.3804 138.1 2.071 47.4 0.2240 59.6 0.1891 -57.5
1.780 0.3813 137.6 2.050 46.9 0.2263 59.3 0.1888 -58.1
1.800 0.3823 137.1 2.030 46.4 0.2287 59.1 0.1884 -58.7
1.820 0.3831 136.6 2.012 46.0 0.2310 58.9 0.1878 -59.3
1.840 0.3840 136.1 1.994 45.5 0.2332 58.6 0.1872 -59.9
1.860 0.3849 135.7 1.976 45.0 0.2355 58.4 0.1866 -60.5
1.880 0.3858 135.2 1.959 44.6 0.2377 58.2 0.1860 -61.1
1.900 0.3868 134.7 1.941 44.1 0.2400 58.0 0.1855 -61.7
1.920 0.3885 134.2 1.924 43.7 0.2422 57.8 0.1850 -62.2
1.940 0.3903 133.8 1.907 43.2 0.2444 57.5 0.1845 -62.8
1.960 0.3921 133.3 1.891 42.7 0.2466 57.3 0.1841 -63.3
1.980 0.3939 132.9 1.874 42.3 0.2489 57.1 0.1836 -63.9
2.000 0.3958 132.4 1.858 41.8 0.2511 56.9 0.1832 -64.4
2.020 0.3970 131.9 1.843 41.4 0.2534 56.7 0.1827 -65.0
2.040 0.3983 131.4 1.829 40.9 0.2556 56.4 0.1822 -65.6
2.060 0.3995 130.9 1.815 40.5 0.2579 56.2 0.1817 -66.3
2.080 0.4008 130.4 1.800 40.0 0.2602 55.9 0.1813 -66.9
2.100 0.4022 129.9 1.786 39.6 0.2624 55.7 0.1809 -67.5
2.120 0.4035 129.4 1.772 39.1 0.2647 55.5 0.1805 -68.1
2.140 0.4049 128.9 1.758 38.7 0.2670 55.2 0.1801 -68.8
2.160 0.4064 128.4 1.744 38.2 0.2693 55.0 0.1797 -69.4
2.180 0.4078 127.9 1.731 37.7 0.2716 54.8 0.1794 -70.1
2.200 0.4093 127.4 1.717 37.2 0.2739 54.6 0.1791 -70.7
2.220 0.4104 127.0 1.705 36.8 0.2761 54.3 0.1787 -71.4
2.240 0.4116 126.6 1.694 36.4 0.2783 54.0 0.1783 -72.1
2.260 0.4128 126.1 1.683 36.0 0.2806 53.8 0.1779 -72.7
2.280 0.4140 125.7 1.671 35.5 0.2828 53.5 0.1776 -73.4
2.300 0.4152 125.3 1.660 35.1 0.2850 53.2 0.1773 -74.1
2.320 0.4165 124.9 1.649 34.7 0.2873 53.0 0.1770 -74.8
2.340 0.4178 124.5 1.638 34.3 0.2895 52.7 0.1767 -75.5
2.360 0.4191 124.1 1.627 33.8 0.2918 52.5 0.1765 -76.2
2.380 0.4204 123.7 1.617 33.4 0.2940 52.2 0.1763 -76.9
2.400 0.4217 123.3 1.606 32.9 0.2963 52.0 0.1761 -77.6
2.420 0.4233 122.9 1.595 32.5 0.2984 51.7 0.1756 -78.4
2.440 0.4249 122.4 1.584 32.1 0.3006 51.5 0.1751 -79.2
2.460 0.4265 122.0 1.574 31.7 0.3027 51.2 0.1747 -80.0
2.480 0.4281 121.5 1.563 31.2 0.3049 51.0 0.1743 -80.8
2.500 0.4298 121.1 1.552 30.8 0.3071 50.7 0.1740 -81.6
2.520 0.4315 120.7 1.542 30.4 0.3093 50.5 0.1737 -82.4
2.540 0.4332 120.3 1.532 30.0 0.3114 50.2 0.1734 -83.2
2.560 0.4349 119.8 1.521 29.5 0.3136 50.0 0.1731 -84.0
2.580 0.4367 119.4 1.511 29.1 0.3158 49.7 0.1729 -84.8
2.600 0.4385 119.0 1.501 28.6 0.3180 49.5 0.1727 -85.6
2.620 0.4395 118.5 1.493 28.2 0.3201 49.2 0.1721 -86.4
2.640 0.4404 118.1 1.485 27.8 0.3223 49.0 0.1715 -87.3
2.660 0.4415 117.6 1.477 27.3 0.3244 48.7 0.1710 -88.1
2.680 0.4425 117.1 1.469 26.9 0.3265 48.5 0.1705 -89.0
2.700 0.4436 116.7 1.461 26.5 0.3287 48.3 0.1701 -89.8
2.720 0.4447 116.2 1.454 26.0 0.3308 48.0 0.1697 -90.7
2.740 0.4458 115.8 1.446 25.6 0.3330 47.8 0.1693 -91.6
2.760 0.4470 115.3 1.439 25.1 0.3352 47.6 0.1690 -92.4
2.780 0.4482 114.8 1.431 24.7 0.3373 47.3 0.1687 -93.3
2.800 0.4494 114.4 1.424 24.2 0.3395 47.1 0.1684 -94.2
2.820 0.4512 113.9 1.416 23.8 0.3416 46.8 0.1681 -95.1
2.840 0.4529 113.5 1.408 23.4 0.3438 46.5 0.1679 -96.1
2.860 0.4548 113.0 1.400 23.0 0.3459 46.3 0.1677 -97.0
2.880 0.4566 112.6 1.393 22.7 0.3481 46.0 0.1676 -98.0
2.900 0.4585 112.2 1.385 22.3 0.3503 45.7 0.1675 -98.9
2.920 0.4604 111.7 1.378 21.9 0.3524 45.4 0.1675 -99.9
2.940 0.4623 111.3 1.370 21.4 0.3546 45.2 0.1675 -100.8
2.960 0.4642 110.9 1.363 21.0 0.3568 44.9 0.1676 -101.8
2.980 0.4662 110.4 1.355 20.6 0.3590 44.7 0.1677 -102.8
3.000 0.4682 110.0 1.348 20.2 0.3612 44.4 0.1678 -103.7
!
! f NFmin Gammaopt rn/50
! GHz dB MAG ANG -
!
! noise parameter not available yet for this operation point!
!
! (c) 2015 Infineon Technologies AG, Munich
! Filename: BFR93AD.S2P Version: 2.0
! NXP part #: BFR93A Date: May 1990
! Bias condition: Vce=5V, Ic=30mA
!
# MHz S MA R 50
! Freq S11 S21 S12 S22 !GUM [dB]
40 .499 -44.2 42.811 149.9 .011 74.3 .853 -23.4 ! 39.5
100 .406 -88.8 28.622 124.9 .023 62.9 .606 -41.3 ! 31.9
200 .369 -127.6 17.097 107.9 .035 64.2 .392 -49.9 ! 26.0
300 .359 -144.5 11.934 99.3 .045 66.9 .301 -51.1 ! 22.5
400 .348 -153.5 9.173 94.3 .057 68.3 .257 -51.5 ! 20.1
500 .367 -160.2 7.512 89.4 .070 70.5 .232 -50.9 ! 18.4
600 .367 -167.0 6.297 86.7 .081 70.8 .218 -50.7 ! 16.8
700 .341 -168.3 5.464 83.7 .093 72.8 .210 -50.7 ! 15.5
800 .361 -175.7 4.781 81.3 .105 72.0 .207 -49.9 ! 14.4
900 .348 -177.4 4.317 78.8 .117 72.3 .204 -50.4 ! 13.4
1000 .349 176.8 3.861 76.0 .128 72.3 .198 -49.9 ! 12.5
1200 .352 173.4 3.286 71.2 .152 71.5 .189 -50.8 ! 11.1
1400 .371 168.3 2.852 66.7 .174 70.2 .182 -53.4 ! 9.9
1600 .358 166.1 2.548 63.4 .198 69.2 .183 -54.4 ! 8.9
1800 .345 158.4 2.273 59.3 .220 68.0 .185 -56.0 ! 7.8
2000 .352 154.7 2.126 56.0 .242 66.5 .175 -56.0 ! 7.3
2200 .367 147.1 1.932 52.6 .264 66.2 .152 -58.2 ! 6.4
2400 .390 148.6 1.810 49.5 .288 64.1 .141 -67.2 ! 6.0
2600 .391 146.3 1.694 46.1 .307 62.5 .142 -74.4 ! 5.4
2800 .388 142.6 1.628 43.3 .329 61.4 .142 -78.4 ! 5.0
3000 .407 136.2 1.537 40.6 .352 59.2 .129 -80.1 ! 4.6
\ No newline at end of file
......@@ -13,77 +13,120 @@ import sys
import math
import cmath
''' Open S2P Files and extract data '''
def parse_spar(file, freq):
f = open(file, "r")
tmpspars = []
for line in f:
tmpspars.append(line.strip().split())
class TransistorBlock:
spars = {}#[] # 1: Freq 2: S11 3: S21 4: S12 5: S22
for l in tmpspars:
if(l[0] != "!" and l[0] != "#"):
tmp = []
#tmp.append(float(l[0])) # FREQ
tmp.append(complex(float(l[1]), float(l[2]))) # S11
tmp.append(complex(float(l[3]), float(l[4]))) # S21
tmp.append(complex(float(l[5]), float(l[6]))) # S12
tmp.append(complex(float(l[7]), float(l[8]))) # S22
#spars.append(tmp)
spars[float(l[0])] = tmp
return spars
''' Calculate John Rollett stability factor '''
def calc_stab(Ds, S):
K = (1 + cmath.polar(Ds)[0] ** 2 - cmath.polar(S[11])[0] ** 2 - \
cmath.polar(S[22])[0] ** 2) / (2 * cmath.polar(S[21])[0] * cmath.polar(S[12])[0])
return K
def __init__(self, file, freq, config):
self.freq = freq
self.config = config
self.spformats = {}
self.parse_spar(file,freq)
''' Caculate Maximum Available Gain '''
def calc_mag(Ds, S, K):
B1 = 1 + cmath.polar(S[11])[0] ** 2 - cmath.polar(S[22])[0] ** 2 - cmath.polar(Ds)[0] ** 2
''' Open S2P Files and extract data '''
def parse_spar(self, file, freq):
f = open(file, "r")
tmpspars = []
for line in f:
if line.startswith("#"):
sfor = line.strip().split()
self.spformats["UNIT"] = sfor[1]
self.spformats["TYPE"] = sfor[2]
self.spformats["FORMAT"] = sfor[3]
# Apparently the nominal Impedance is splitted: R 50
self.spformats["R"] = sfor[5]
elif not line.startswith("!"):
tmpspars.append(line.strip().split())
# Parse options: we mainly need to know unit and complex format
# http://cp.literature.agilent.com/litweb/pdf/genesys200801/sim/linear_sim/sparams/touchstone_file_format.htms
self.spars = {}# 1: Freq 2: S11 3: S21 4: S12 5: S22
for l in tmpspars:
if(l[0] != "!" and l[0] != "#"):
tmp = []
if self.spformats["FORMAT"] == "RI" : # Real Imaginary
tmp.append(complex(float(l[1]), float(l[2]))) # S11
tmp.append(complex(float(l[3]), float(l[4]))) # S21
tmp.append(complex(float(l[5]), float(l[6]))) # S12
tmp.append(complex(float(l[7]), float(l[8]))) # S22
elif self.spformats["FORMAT"] == "MA" : # Magnitude Angle
tmp.append(cmath.rect(float(l[1]), float(l[2]))) # S11
tmp.append(cmath.rect(float(l[3]), float(l[4]))) # S21
tmp.append(cmath.rect(float(l[5]), float(l[6]))) # S12
tmp.append(cmath.rect(float(l[7]), float(l[8]))) # S22
else :
print("Unsupported Number Format: %s" % self.spformats["FORMAT"])
exit(-1)
# We always set freq to MHz
freq = float(l[0])
if self.spformats["UNIT"] == "GHz":
freq = freq * 1000
elif self.spformats["UNIT"] == "KHz":
freq = freq / 1000
elif self.spformats["UNIT"] == "Hz":
freq = freq / 1000000
self.spars[freq] = tmp
''' Calculate John Rollett stability factor '''
def calc_stab(self):
S = self.S
self.K = (1 + cmath.polar(self.Ds)[0] ** 2 - cmath.polar(S[11])[0] ** 2 - \
cmath.polar(S[22])[0] ** 2) / (2 * cmath.polar(S[21])[0] * cmath.polar(S[12])[0])
''' Caculate Maximum Available Gain '''
def calc_mag(self):
S = self.S
self.B1 = 1 + cmath.polar(S[11])[0] ** 2 - cmath.polar(S[22])[0] ** 2 - cmath.polar(self.Ds)[0] ** 2
ksq = 0.0
if B1 < 0 :
ksq = math.sqrt(K**2 - 1)
else :
ksq = math.sqrt(k**2 - 1) * -1
ksq = 0.0
if self.B1 < 0 :
ksq = math.sqrt(self.K**2 - 1)
else :
ksq = math.sqrt(self.K**2 - 1) * -1
self.MAG = 10 * math.log(cmath.polar(S[11])[0] / cmath.polar(S[12])[0]) + \
10 * math.log(self.K + ksq)
MAG = 10 * math.log(cmath.polar(S[11])[0] / cmath.polar(S[12])[0]) + \
10 * math.log(K + ksq)
''' Calculate Maximum Unilateral Gain (S12 = 0)'''
def calc_gum(self):
S = self.S
self.GUM = 10 * math.log(cmath.polar(S[21])[0]**2 / ((1-cmath.polar(S[11])[0]**2)*(1-cmath.polar(S[22])[0]**2)))
return MAG
def calc_value(freq, spars, config):
sparam = spars[freq]
S = {}
S[11] = sparam[0]
S[21] = sparam[1]
S[12] = sparam[2]
S[22] = sparam[3]
def set_freq(self, freq):
self.freq = freq
Ds = S[11] * S[22] - S[12] * S[21]
K = calc_stab(Ds, S)
def calc_stability_mag(self):
self.sparam = self.spars[self.freq]
self.S = {}
self.S[11] = self.sparam[0]
self.S[21] = self.sparam[1]
self.S[12] = self.sparam[2]
self.S[22] = self.sparam[3]
S = self.S
self.Ds = S[11] * S[22] - S[12] * S[21]
self.calc_stab()
if self.K < 1 :
print("Warning ! K factor %f < 1.0 , amplifier could be unstable" % self.K)
print("Undefined Maximum Available Gain")
else :
print("Stable amplifier design. K factor %f >= 1" % self.K)
self.calc_mag()
print("Maximum Available Gain: %fdB" % self.MAG)
def calc_scm(self):
S = self.S
if self.K > 1 :
self.C1 = S[11] - (self.Ds * complex.conjugate(S[22]))
self.C2 = S[22] - (self.Ds * complex.conjugate(S[11]))
# B1 is already calculated for MAG
self.B2 = 1 - cmath.polar(S[11])[0] ** 2 - cmath.polar(S[22])[0] ** 2 - cmath.polar(self.Ds)[0] ** 2
else :
print("Can't calculate SCM, K < 1, try lossy match")
if K < 1 :
print("Warning ! K factor %f < 1.0 , amplifier could be unstable" % K)
print("Undefined Maximum Available Gain")
else :
print("Stable amplifier design. K factor %f >= 1" % K)
MAG = calc_mag(Ds, S, K)
print("Maximum Available Gain: %fdB" % MAG)
#Select the kind of configuration for the amplifier
if config == 'SCM' :
# Simultaneous Conjugate Match
print("Simulaneous Conjugate Match")
elif config == 'ONF' :
# Optimum Noise Figure
print("Not yet available")
else :
print("Unknown mode")
if __name__ == '__main__':
if(len(sys.argv) < 4):
print("Error: usage\nauto_match.py spar_file.s2p frequency configuration\n")
......@@ -91,6 +134,7 @@ if __name__ == '__main__':
fname = sys.argv[1]
freq = float(sys.argv[2])
config = sys.argv[3]
spars = parse_spar(fname, freq)
calc_value(freq, spars, config)
\ No newline at end of file
q1 = TransistorBlock(fname, freq, config)
q1.calc_stability_mag()
q1.calc_gum()
print("GUM: %fdB" % q1.GUM)
......@@ -8,11 +8,14 @@ WIRE 48 0 48 -48
WIRE 240 0 240 -48
WIRE -480 48 -480 -32
WIRE 1360 96 1360 64
WIRE 1632 96 1360 96
WIRE 1520 96 1360 96
WIRE 1632 96 1520 96
WIRE 2400 96 2400 64
WIRE 2672 96 2400 96
WIRE 2592 96 2400 96
WIRE 2672 96 2592 96
WIRE 240 112 240 80
WIRE 528 112 240 112
WIRE 416 112 240 112
WIRE 528 112 416 112
WIRE 240 128 240 112
WIRE 1360 128 1360 96
WIRE 2400 128 2400 96
......@@ -30,8 +33,6 @@ WIRE 2000 176 1904 176
WIRE 2144 176 2144 64
WIRE 2144 176 2064 176
WIRE 2336 176 2144 176
WIRE 1632 192 1632 96
WIRE 2672 192 2672 96
WIRE -176 224 -176 176
WIRE 240 240 240 224
WIRE 352 240 240 240
......@@ -64,11 +65,9 @@ WIRE 2496 384 2400 384
WIRE 864 400 864 336
WIRE 1104 400 1104 352
WIRE 1360 400 1360 384
WIRE 1632 400 1632 272
WIRE 1904 400 1904 336
WIRE 2144 400 2144 352
WIRE 2400 400 2400 384
WIRE 2672 400 2672 272
WIRE -176 416 -176 304
WIRE 48 416 48 352
WIRE 240 416 240 384
......@@ -81,16 +80,17 @@ FLAG 48 -48 3.3v
FLAG 240 -48 3.3v
FLAG 1360 400 0
FLAG 1104 400 0
FLAG 1632 400 0
FLAG 864 400 0
FLAG 1104 -64 3.3v
FLAG 1360 -64 3.3v
FLAG 2400 400 0
FLAG 2144 400 0
FLAG 2672 400 0
FLAG 1904 400 0
FLAG 2144 -64 3.3v
FLAG 2400 -64 3.3v
FLAG 2592 96 BFR93A
FLAG 1520 96 PRF347
FLAG 416 112 2N2222
SYMBOL npn 176 128 R0
SYMATTR InstName Q1
SYMATTR Value 2N2222
......@@ -136,9 +136,6 @@ SYMATTR Prefix X
SYMBOL res 1344 256 R0
SYMATTR InstName R6
SYMATTR Value 100
SYMBOL res 1616 176 R0
SYMATTR InstName R7
SYMATTR Value 1k
SYMBOL res 1344 -32 R0
SYMATTR InstName R8
SYMATTR Value 115
......@@ -156,9 +153,9 @@ SYMATTR Value 10
SYMBOL voltage 864 240 R0
WINDOW 123 24 124 Left 2
WINDOW 39 0 0 Left 2
SYMATTR Value2 AC 1 1
SYMATTR InstName V3
SYMATTR Value SINE(0 0.1 1g)
SYMATTR Value2 AC 1 1
SYMBOL cap 1440 288 R0
SYMATTR InstName C4
SYMATTR Value 50p
......@@ -169,9 +166,6 @@ SYMATTR Prefix X
SYMBOL res 2384 256 R0
SYMATTR InstName R11
SYMATTR Value 100
SYMBOL res 2656 176 R0
SYMATTR InstName R12
SYMATTR Value 1k
SYMBOL res 2384 -32 R0
SYMATTR InstName R13
SYMATTR Value 115
......@@ -189,12 +183,12 @@ SYMATTR Value 10
SYMBOL voltage 1904 240 R0
WINDOW 123 24 124 Left 2
WINDOW 39 0 0 Left 2
SYMATTR Value2 AC 1 1
SYMATTR InstName V4
SYMATTR Value SINE(0 0.1 1g)
SYMATTR Value2 AC 1 1
SYMBOL cap 2480 288 R0
SYMATTR InstName C6
SYMATTR Value 50p
TEXT -512 440 Left 2 !.tran 1
TEXT -512 440 Left 2 !.ac oct 1000 1 10g
TEXT -512 528 Left 2 !.INCLUDE PRF947_nxp.lib
TEXT -512 568 Left 2 !.INCLUDE BFR93A_nxp.lib
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment