(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.0' Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 12456, 392]*) (*NotebookOutlinePosition[ 13990, 448]*) (* CellTagsIndexPosition[ 13759, 436]*) (*WindowFrame->Normal*) Notebook[{ Cell[TextData[{ "NormtoSZ.nb\n This code takes the ensemble of normalized z matrices \ generated form the MatLab code, along with the measured or calculated \ radiation 2x2 S matrix (", Cell[BoxData[ \(TraditionalForm\`S\_Rad\)]], "), and generates the eigenvalues of the 2x2 ", Cell[BoxData[ \(TraditionalForm\`S\_Cav\)]], " and ", Cell[BoxData[ \(TraditionalForm\`Z\_Cav\)]], " matrices. Example input files are the ensemble of 2x2 z matrices with \ loss parameter equal to 1.5 (RMTZ_1_5loss2.txt) and Srad.txt. The user must \ specify the directories of the input and output files." }], "Text"], Cell["<< Graphics`Graphics`", "Input", CellTags->"S5.33.1"], Cell["<"S1.6.7"], Cell["<< Statistics`NonlinearFit`", "Input", CellTags->"S6.8.1"], Cell["<"S6.6.1"], Cell["<"S6.7.1"], Cell["<< LinearAlgebra`MatrixManipulation`", "Input", CellTags->"S5.51.1"], Cell["<"S5.98.1"], Cell["<"S5.33.1"], Cell[BoxData[ \(\($HistoryLength[10];\)\)], "Input"], Cell["\<\ ******************************************************************************\ ****\ \>", "Text", FontWeight->"Plain", FontColor->RGBColor[1, 0, 1]], Cell["\<\ This program generates a numerical estimate for the cavity impedance and \ scattering matrix based upon the normalized impedance and the measured \ radiation impedance.\ \>", "Text", FontWeight->"Bold", FontColor->RGBColor[1, 0, 0]], Cell["\<\ ******************************************************************************\ ****\ \>", "Text", FontWeight->"Plain", FontColor->RGBColor[1, 0, 1]], Cell["[Set the Directory of Radiation Scattering Matrix file]", "Text", FontWeight->"Bold", FontColor->RGBColor[1, 0, 0]], Cell[BoxData[ RowBox[{ RowBox[{"SetDirectory", "[", "\"\<\!\(\* StyleBox[\"xxxx\",\nFontColor->RGBColor[0, 0, 1]]\)\>\"", "]"}], ";"}]], "Input"], Cell["\<\ ******************************************************************************\ ****\ \>", "Text", FontWeight->"Plain", FontColor->RGBColor[1, 0, 1]], Cell[TextData[{ "[Set Number of Frequency Samples in the measured Radiation Impedance \ Matrix. ", StyleBox["This value is for the example file Srad.txt ", FontColor->RGBColor[0, 0, 1]], "]" }], "Text", FontWeight->"Bold", FontColor->RGBColor[1, 0, 0]], Cell[BoxData[ RowBox[{ RowBox[{"freqsample", "=", StyleBox["16001", FontColor->RGBColor[0, 0, 1]]}], ";"}]], "Input"], Cell["[Set Radiation Scattering Matrix file name]", "Text", FontWeight->"Bold", FontColor->RGBColor[1, 0, 0]], Cell[BoxData[ RowBox[{ RowBox[{"s22temp1", "=", RowBox[{"OpenRead", "[", "\"\<\!\(\* StyleBox[\"Srad\",\nFontColor->RGBColor[0, 0, 1]]\).txt\>\"", "]"}]}], ";"}]], "Input"], Cell[BoxData[ \(\(sdata = ReadList[s22temp1, Number];\)\)], "Input"], Cell[BoxData[ \(\(Close[s22temp1];\)\)], "Input"], Cell["\<\ ******************************************************************************\ ****\ \>", "Text", FontWeight->"Plain", FontColor->RGBColor[1, 0, 1]], Cell[BoxData[{ \(\(res11rad = Table[sdata[\([i]\)], {i, freqsample + 1, 2*freqsample}];\)\), "\n", \(\(ims11rad = Table[sdata[\([i]\)], {i, 2*freqsample + 1, 3*freqsample}];\)\), "\n", \(\(S11rad = Table[res11rad[\([i]\)] + I*ims11rad[\([i]\)], {i, 1, Length[res11rad]}];\)\), "\n", \(\(\(Clear[res11rad, ims11rad];\)\(\n\) \)\), "\n", \(\(res12rad = Table[sdata[\([i]\)], {i, 3*freqsample + 1, 4*freqsample}];\)\), "\n", \(\(ims12rad = Table[sdata[\([i]\)], {i, 4*freqsample + 1, 5*freqsample}];\)\), "\n", \(\(S12rad = Table[res12rad[\([i]\)] + I*ims12rad[\([i]\)], {i, 1, Length[res12rad]}];\)\), "\n", \(\(\(Clear[res12rad, ims12rad];\)\(\n\) \)\), "\[IndentingNewLine]", \(\(res21rad = Table[sdata[\([i]\)], {i, 5*freqsample + 1, 6*freqsample}];\)\), "\n", \(\(ims21rad = Table[sdata[\([i]\)], {i, 6*freqsample + 1, 7*freqsample}];\)\), "\n", \(\(S21rad = Table[res21rad[\([i]\)] + I*ims21rad[\([i]\)], {i, 1, Length[res21rad]}];\)\), "\n", \(\(\(Clear[res21rad, ims21rad];\)\(\n\) \)\), "\[IndentingNewLine]", \(\(res22rad = Table[sdata[\([i]\)], {i, 7*freqsample + 1, 8*freqsample}];\)\), "\n", \(\(ims22rad = Table[sdata[\([i]\)], {i, 8*freqsample + 1, 9*freqsample}];\)\), "\n", \(\(S22rad = Table[res22rad[\([i]\)] + I*ims22rad[\([i]\)], {i, 1, Length[res21rad]}];\)\), "\n", \(\(\(Clear[res22rad, ims22rad];\)\(\n\) \)\), "\[IndentingNewLine]", \(\(Srad = Table[{{S11rad[\([i]\)], S12rad[\([i]\)]}, {S21rad[\([i]\)], S22rad[\([i]\)]}}, {i, 1, Length[S11rad]}];\)\), "\n", \(\(\(Clear[S11rad, S12rad, S21rad, S22rad];\)\(\n\) \)\), "\[IndentingNewLine]", \(\(Zrad = Table[50*\((IdentityMatrix[2] + Srad[\([i]\)])\) . Inverse[\((IdentityMatrix[2] - Srad[\([i]\)])\)], {i, 1, Length[Srad]}];\)\)}], "Input"], Cell["\<\ ******************************************************************************\ ****\ \>", "Text", FontWeight->"Plain", FontColor->RGBColor[1, 0, 1]], Cell["[Set the Directory of Normalized Impedance Matrix file]", "Text", FontWeight->"Bold", FontColor->RGBColor[1, 0, 0]], Cell[BoxData[ RowBox[{ RowBox[{"SetDirectory", "[", "\"\<\!\(\* StyleBox[\"xxxx\",\nFontColor->RGBColor[0, 0, 1]]\)\>\"", "]"}], ";"}]], "Input"], Cell["\<\ ******************************************************************************\ ****\ \>", "Text", FontWeight->"Plain", FontColor->RGBColor[1, 0, 1]], Cell["[Set Normalized Impedance Matrix file name]", "Text", FontWeight->"Bold", FontColor->RGBColor[1, 0, 0]], Cell[BoxData[ RowBox[{ RowBox[{"znormdat", "=", RowBox[{"Import", "[", RowBox[{"\"\<\!\(\* StyleBox[\"RMTZ_\",\nFontColor->RGBColor[0, 0, 1]]\)\!\(\* StyleBox[\"1\",\nFontColor->RGBColor[0, 0, 1]]\)\!\(\* StyleBox[\"_\",\nFontColor->RGBColor[0, 0, 1]]\)\!\(\* StyleBox[\"5\",\nFontColor->RGBColor[0, 0, 1]]\)\!\(\* StyleBox[\"loss2\",\nFontColor->RGBColor[0, 0, 1]]\).txt\>\"", ",", "\"\\""}], "]"}]}], ";"}]], "Input"], Cell[BoxData[ \(\(Znorm = Table[{{znormdat[\([i, 1]\)] + I*znormdat[\([i, 2]\)], znormdat[\([i, 3]\)] + I*znormdat[\([i, 4]\)]}, {znormdat[\([i, 5]\)] + I*znormdat[\([i, 6]\)], znormdat[\([i, 7]\)] + I*znormdat[\([i, 8]\)]}}, {i, 1, Length[znormdat]}];\)\)], "Input"], Cell[BoxData[ \(\(Znorm = Partition[Znorm, Length[Zrad]];\)\)], "Input"], Cell["\<\ ******************************************************************************\ **** ******************************************************************************\ **** ******************************************************************************\ ****\ \>", "Text", FontWeight->"Plain", FontColor->RGBColor[1, 0, 1]], Cell["\<\ [Generating Numerical Estimate of Cavity Impedance and Scattering \ Matrices]\ \>", "Text", FontWeight->"Bold", FontColor->RGBColor[1, 0, 0]], Cell["\<\ ******************************************************************************\ **** ******************************************************************************\ **** ******************************************************************************\ ****\ \>", "Text", FontWeight->"Plain", FontColor->RGBColor[1, 0, 1]], Cell[BoxData[{ \(\(Zcav = Table[MatrixPower[Re[Zrad[\([i]\)]], 0.5] . \((Znorm[\([j, i]\)])\) . MatrixPower[Re[Zrad[\([i]\)]], 0.5] + Im[Zrad[\([i]\)]], {j, 1, Length[Znorm]}, {i, 1, Length[Zrad]}];\)\), "\[IndentingNewLine]", \(\(Scav = Table[\((Zcav[\([i, j]\)] - 50*IdentityMatrix[2])\) . Inverse[\((50*IdentityMatrix[2] + Zcav[\([i, j]\)])\)], {i, 1, Length[Zcav]}, {j, 1, Length[Zcav[\([1]\)]]}];\)\)}], "Input"], Cell[BoxData[ \(\(eigZcav = Flatten[Table[ Eigenvalues[Zcav[\([i, j]\)]], {i, 1, Length[Zcav]}, {j, 1, Length[Zcav[\([1]\)]]}]];\)\)], "Input"], Cell[BoxData[ \(\(eigScav = Flatten[Table[ Eigenvalues[Scav[\([i, j]\)]], {i, 1, Length[Zcav]}, {j, 1, Length[Zcav[\([1]\)]]}]];\)\)], "Input"], Cell["\<\ ******************************************************************************\ **** ******************************************************************************\ **** ******************************************************************************\ ****\ \>", "Text", FontWeight->"Plain", FontColor->RGBColor[1, 0, 1]], Cell[" [Exporting Generated Files]", "Text", FontWeight->"Bold", FontColor->RGBColor[1, 0, 0]], Cell["\<\ ******************************************************************************\ **** ******************************************************************************\ **** ******************************************************************************\ ****\ \>", "Text", FontWeight->"Plain", FontColor->RGBColor[1, 0, 1]], Cell["\<\ [Set the Output Directory for Cavity Impedance and Scattering Eigenvalues \ file]\ \>", "Text", FontWeight->"Bold", FontColor->RGBColor[1, 0, 0]], Cell[BoxData[ RowBox[{ RowBox[{"SetDirectory", "[", "\"\<\!\(\* StyleBox[\"xxxx\",\nFontColor->RGBColor[0, 0, 1]]\)\>\"", "]"}], ";"}]], "Input"], Cell[BoxData[ \(\(Export["\", Table[{Re[eigZcav[\([i]\)]], Im[eigZcav[\([i]\)]]}, {i, 1, Length[eigZcav]}], "\"];\)\)], "Input"], Cell[BoxData[ \(\(Export["\", Table[{Re[eigScav[\([i]\)]], Im[eigScav[\([i]\)]]}, {i, 1, Length[eigScav]}], "\"];\)\)], "Input"], Cell["\<\ ******************************************************************************\ **** ******************************************************************************\ **** ******************************************************************************\ ****\ \>", "Text", FontWeight->"Plain", FontColor->RGBColor[1, 0, 1]] }, FrontEndVersion->"5.0 for Microsoft Windows", ScreenRectangle->{{0, 1024}, {0, 685}}, WindowSize->{913, 651}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, PrintingCopies->1, PrintingPageRange->{Automatic, Automatic} ] (******************************************************************* Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. *******************************************************************) (*CellTagsOutline CellTagsIndex->{ "S5.33.1"->{ Cell[2388, 68, 61, 1, 30, "Input", CellTags->"S5.33.1"], Cell[2911, 89, 62, 1, 30, "Input", CellTags->"S5.33.1"]}, "S1.6.7"->{ Cell[2452, 71, 74, 1, 30, "Input", CellTags->"S1.6.7"]}, "S6.8.1"->{ Cell[2529, 74, 66, 1, 30, "Input", CellTags->"S6.8.1"]}, "S6.6.1"->{ Cell[2598, 77, 76, 1, 30, "Input", CellTags->"S6.6.1"]}, "S6.7.1"->{ Cell[2677, 80, 79, 1, 30, "Input", CellTags->"S6.7.1"]}, "S5.51.1"->{ Cell[2759, 83, 76, 1, 30, "Input", CellTags->"S5.51.1"]}, "S5.98.1"->{ Cell[2838, 86, 70, 1, 30, "Input", CellTags->"S5.98.1"]} } *) (*CellTagsIndex CellTagsIndex->{ {"S5.33.1", 13109, 409}, {"S1.6.7", 13258, 414}, {"S6.8.1", 13339, 417}, {"S6.6.1", 13420, 420}, {"S6.7.1", 13501, 423}, {"S5.51.1", 13583, 426}, {"S5.98.1", 13666, 429} } *) (*NotebookFileOutline Notebook[{ Cell[1754, 51, 631, 15, 90, "Text"], Cell[2388, 68, 61, 1, 30, "Input", CellTags->"S5.33.1"], Cell[2452, 71, 74, 1, 30, "Input", CellTags->"S1.6.7"], Cell[2529, 74, 66, 1, 30, "Input", CellTags->"S6.8.1"], Cell[2598, 77, 76, 1, 30, "Input", CellTags->"S6.6.1"], Cell[2677, 80, 79, 1, 30, "Input", CellTags->"S6.7.1"], Cell[2759, 83, 76, 1, 30, "Input", CellTags->"S5.51.1"], Cell[2838, 86, 70, 1, 30, "Input", CellTags->"S5.98.1"], Cell[2911, 89, 62, 1, 30, "Input", CellTags->"S5.33.1"], Cell[2976, 92, 56, 1, 30, "Input"], Cell[3035, 95, 163, 5, 33, "Text"], Cell[3201, 102, 246, 6, 52, "Text"], Cell[3450, 110, 163, 5, 33, "Text"], Cell[3616, 117, 125, 2, 33, "Text"], Cell[3744, 121, 162, 4, 30, "Input"], Cell[3909, 127, 163, 5, 33, "Text"], Cell[4075, 134, 267, 8, 33, "Text"], Cell[4345, 144, 146, 4, 30, "Input"], Cell[4494, 150, 113, 2, 33, "Text"], Cell[4610, 154, 198, 5, 30, "Input"], Cell[4811, 161, 72, 1, 30, "Input"], Cell[4886, 164, 53, 1, 30, "Input"], Cell[4942, 167, 163, 5, 33, "Text"], Cell[5108, 174, 2141, 52, 490, "Input"], Cell[7252, 228, 163, 5, 33, "Text"], Cell[7418, 235, 125, 2, 33, "Text"], Cell[7546, 239, 162, 4, 30, "Input"], Cell[7711, 245, 163, 5, 33, "Text"], Cell[7877, 252, 113, 2, 33, "Text"], Cell[7993, 256, 470, 10, 30, "Input"], Cell[8466, 268, 357, 7, 50, "Input"], Cell[8826, 277, 76, 1, 30, "Input"], Cell[8905, 280, 333, 9, 71, "Text"], Cell[9241, 291, 163, 5, 33, "Text"], Cell[9407, 298, 333, 9, 71, "Text"], Cell[9743, 309, 511, 9, 90, "Input"], Cell[10257, 320, 183, 4, 30, "Input"], Cell[10443, 326, 183, 4, 30, "Input"], Cell[10629, 332, 333, 9, 71, "Text"], Cell[10965, 343, 129, 2, 33, "Text"], Cell[11097, 347, 333, 9, 71, "Text"], Cell[11433, 358, 160, 5, 33, "Text"], Cell[11596, 365, 162, 4, 30, "Input"], Cell[11761, 371, 176, 3, 30, "Input"], Cell[11940, 376, 176, 3, 30, "Input"], Cell[12119, 381, 333, 9, 71, "Text"] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)