Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

elements.cc

Go to the documentation of this file.
00001 // elements.cc
00002 // SuperMix version 1.0  C++ source file
00003 //
00004 // Copyright (c) 1999 California Institute of Technology.
00005 // All rights reserved.
00006 //
00007 // Redistribution and use in source and binary forms for noncommercial
00008 // purposes are permitted provided that the above copyright notice and
00009 // this paragraph are duplicated in all such forms and that any
00010 // documentation and other materials related to such distribution and
00011 // use acknowledge that the software was developed by California
00012 // Institute of Technology. Redistribution and/or use in source or
00013 // binary forms is not permitted for any commercial purpose. Use of
00014 // this software does not include a permitted use of the Institute's
00015 // name or trademark for any purpose.
00016 //
00017 // DISCLAIMER:
00018 // THIS SOFTWARE AND/OR RELATED MATERIALS ARE PROVIDED "AS-IS" WITHOUT
00019 // WARRANTY OF ANY KIND INCLUDING ANY WARRANTIES OF PERFORMANCE OR
00020 // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE OR PURPOSE (AS SET
00021 // FORTH IN UCC 23212-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
00022 // LICENSED PRODUCT, HOWEVER USED.  IN NO EVENT SHALL CALTECH/JPL BE
00023 // LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING BUT NOT LIMITED TO
00024 // INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING ECONOMIC
00025 // DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF
00026 // WHETHER CALTECH/JPL SHALL BE ADVISED, HAVE REASON TO KNOW, OR IN
00027 // FACT SHALL KNOW OF THE POSSIBILITY.  THE USER BEARS ALL RISK
00028 // RELATING TO QUALITY AND PERFORMANCE OF THE SOFTWARE AND/OR RELATED
00029 // MATERIALS.
00030 //
00031 // Change history:
00032 // 11/16/99: changes to support new noise calculations
00033 // 10/29/99: Ensured data.set_znorm() called in recalc()'s
00034 // 10/22/99: Updated for parameter device::Z0
00035 // 11/11/98: Changed table access to new syntax
00036 // 9/15/98:  Fixed a nasty bug: wrong argument order in
00037 //           passive noise calculations.
00038 // 8/27/98:  changed branch code: improved recalc, etc.
00039 // 8/24/98:  Added additional constructors; made recalc private
00040 //           changed some void return values.
00041 // 8/21/98:  Added 1-ports zterm and yterm
00042 // 8/19/98:  Added admittance rep to spimp; many improvements
00043 // 7/16/98:  changed branch to allow branches = 2
00044 // 12/30/97: fixed spimp to handle Z = 0 case
00045 // 12/29/97: modified by FR for new sdata (with znorm)
00046 // 12/19/97: modified by FR for matmath classes
00047 
00048 #include "elements.h"
00049 #include "units.h"
00050 #include "error.h"
00051 
00052 void spimp::calcZ(complex Z)
00053 {
00054   data.set_znorm(device::Z0);   // added 12/29/97
00055 
00056   if(is_series) {
00057     if (Z != 0.0) {
00058       complex zo = 2 * device::Z0;  // common coefficient      
00059       data.S[1][1] = data.S[2][2] = Z/(zo + Z);
00060       data.S[2][1] = data.S[1][2] = zo/(zo + Z);
00061     }
00062     else /* Z == 0.0 */ {
00063       data.S[1][1] = data.S[2][2] = 0.0;
00064       data.S[2][1] = data.S[1][2] = 1.0;
00065     }
00066   }
00067   else /* parallel */ {
00068     if (Z != 0.0) {
00069       complex z = 2 * Z;  // common coefficient
00070       data.S[1][1] = data.S[2][2] = -device::Z0/(z + device::Z0);
00071       data.S[2][1] = data.S[1][2] = z/(z + device::Z0);
00072     }
00073     else /* Z == 0.0 */ {
00074       data.S[1][1] = data.S[2][2] = -1.0;
00075       data.S[2][1] = data.S[1][2] = 0.0;
00076     }
00077   }
00078 }
00079 
00080 void spimp::calcY(complex Y)
00081 {
00082   data.set_znorm(device::Z0);
00083 
00084   if(is_series) {
00085     if (Y != 0.0) {
00086       complex zoy = 2 * device::Z0 * Y;  // common coefficient      
00087       data.S[1][1] = data.S[2][2] = 1/(1 + zoy);
00088       data.S[2][1] = data.S[1][2] = zoy/(1 + zoy);
00089     }
00090     else /* Y == 0.0 */ {
00091       data.S[1][1] = data.S[2][2] = 1.0;
00092       data.S[2][1] = data.S[1][2] = 0.0;
00093     }
00094   }
00095   else /* parallel */ {
00096     if (Y != 0.0) {
00097       complex zoy = device::Z0 * Y;  // common coefficient      
00098       data.S[1][1] = data.S[2][2] = -zoy/(2 + zoy);
00099       data.S[2][1] = data.S[1][2] = 2/(2 + zoy);
00100     }
00101     else /* Y == 0.0 */ {
00102       data.S[1][1] = data.S[2][2] = 0.0;
00103       data.S[2][1] = data.S[1][2] = 1.0;
00104     }
00105   }
00106 }
00107 
00108 // **************************************************************
00109 
00110 branch::branch(int b) : nport(b), branches(b)
00111 { 
00112   if(b < 2)
00113     error::fatal("Invalid number of branches in branch constructor.");
00114   info.noise = info.active = info.source = false;
00115   calc();
00116 }
00117 
00118 branch & branch::set_branches(int b)
00119 {
00120   if(b < 2)
00121     error::fatal("Branches must have at least two ports.");
00122   branches = b;
00123   calc();
00124   return *this;
00125 }
00126 
00127 void branch::calc()
00128 {
00129   data.set_znorm(0.0);   // since S is independent of device::Z0
00130   data.resize(branches);
00131 
00132   double diagonal = (2.0 - branches) / branches;
00133   double off_diagonal = 2.0 / branches;
00134 
00135   data.S.fill(off_diagonal);
00136 
00137   for(int i=1; i<=branches; i++)
00138     data.S[i][i] = diagonal;
00139 
00140   // Assume that data.C is already a zero matrix.
00141 }
00142 
00143 // **************************************************************
00144 
00145 series_tee::series_tee() : nport(3)
00146 {
00147   data.set_znorm(0.0);   // since S is independent of device::Z0
00148 
00149   data.S[1][1] = 1;
00150   data.S[2][2] = 1;
00151   data.S[3][3] = 1;
00152 
00153   data.S[2][1] = -2;
00154   data.S[1][2] = -2;
00155 
00156   data.S[3][1] = 2;
00157   data.S[3][2] = 2;
00158   data.S[1][3] = 2;
00159   data.S[2][3] = 2;
00160 
00161   data.S /= 3.0;
00162   info.noise = info.active = info.source = false;
00163 }
00164 
00165 // **************************************************************
00166 
00167 void zterm::recalc()
00168 {
00169   recalc_S();
00170   data.passive_noise(f, Temp);
00171 }
00172 
00173 void zterm::recalc_S()
00174 {
00175   data.set_znorm(device::Z0);
00176   data.S[1][1] = (Z == 0.0) ? -1.0 : (Z - double(device::Z0))/(Z + double(device::Z0));
00177 }
00178 
00179 // **************************************************************
00180 
00181 void yterm::recalc()
00182 {
00183   recalc_S();
00184   data.passive_noise(f, Temp);
00185 }
00186 
00187 void yterm::recalc_S()
00188 {
00189   data.set_znorm(device::Z0);
00190   complex y = double(device::Z0) * Y;
00191   data.S[1][1] = (y == 0.0) ? 1.0 : (1 - y)/(1 + y);
00192 }
00193 

Please direct comments and corrections to supermix@submm.caltech.edu
Go to the supermix home page
Generated by doxygen1.2.7