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

ampdata.cc

Go to the documentation of this file.
00001 // ampdata.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 // Changes:
00032 // 4/17/01:  Improved calc of gamma_opt();
00033 // 10/18/99: Fixed calc in Rn().
00034 // 8/23/99:  Fixed eta calc in gamma_opt().
00035 
00036 #include "ampdata.h"
00037 #include "error.h"
00038 
00039 // Construct ampdata from an sdata object, checking that size()=2.
00040 ampdata::ampdata(const sdata &sd) : sdata(sd)
00041 {
00042   if(sd.size() != 2)
00043   {
00044     error::warning(
00045       "ampdata cannot be constructed from sdata whose size != 2.");
00046   }
00047 }
00048 
00049 // Return the optimum noise match.
00050 // Equations may be found in Scott Wedge's Ph.D. thesis (Caltech) page 27.
00051 complex ampdata::gamma_opt()
00052 {
00053   if(size() != 2)
00054   {
00055     error::warning("ampdata size != 2 in ampdata::gamma_opt().");
00056     return complex();
00057   }
00058 
00059   complex d;  // denominator of eta;
00060   double  n;  // numerator of eta;
00061 
00062   d = real(C[2][2])*S[1][1] - C[1][2]*S[2][1];
00063   n = real(C[2][2])*(1+norm(S[1][1])) + real(C[1][1])*norm(S[2][1]);
00064   n -= 2.0 * real(C[1][2]*S[2][1]*conj(S[1][1]));
00065 
00066   double nn = n*n;
00067   double dd = norm(d);
00068 
00069   if(nn*1e36 < dd) 
00070     return I*zarg(d);
00071   else if(nn > dd*1e18)
00072     return conj(d)/n;
00073   else if(d == 0.0)
00074     return complex(0.0);
00075   else
00076     return 0.5*n/d*(1.0 - sqrt(complex(1.0 - 4.0*dd/nn)));
00077 
00078 //    complex eta;
00079 //    eta = real(C[2][2]);
00080 //    eta += real(C[1][1]) * norm(S[2][1]);
00081 //    eta += real(C[2][2]) * norm(S[1][1]);
00082 //    eta -= C[2][1]*S[1][1]*conj(S[2][1]);
00083 //    eta -= C[1][2]*S[2][1]*conj(S[1][1]);
00084 //    eta /= real(C[2][2])*S[1][1] - C[1][2]*S[2][1];
00085 
00086 //    return 0.5*eta*(1.0-sqrt(Complex(1-(4.0/norm(eta)))));
00087 
00088 }
00089 
00090 // Return the minimum noise temperature.
00091 // Equations may be found in Scott Wedge's Ph.D. thesis (Caltech) page 27.
00092 double ampdata::t_min()
00093 {
00094   if(size() != 2)
00095   {
00096     error::warning("ampdata size != 2 in ampdata::t_min().");
00097     return 0.0;
00098   }
00099 
00100   double g = norm(gamma_opt());
00101   double tmin;
00102 
00103   tmin = real(C[1][1])*norm(S[2][1]) + real(C[2][2])*norm(S[1][1]);
00104   tmin -= 2.0 * real(C[2][1]*S[1][1]*conj(S[2][1]));
00105   tmin *= -g;
00106   tmin += real(C[2][2]);
00107   tmin /= norm(S[2][1]) * (1.0 + g);
00108 
00109   return tmin;
00110 
00111 //    complex tmin;
00112 
00113 //    tmin = C[1][1] * norm(S[2][1]);
00114 //    tmin += C[2][2] * norm(S[1][1]);
00115 //    tmin -= C[2][1]*S[1][1]*conj(S[2][1]);
00116 //    tmin -= C[1][2]*S[2][1]*conj(S[1][1]);
00117 //    tmin *= g;
00118 //    tmin *= -1.0;
00119 //    tmin += C[2][2];
00120 //    tmin /= norm(S[2][1]) * (1.0 + g);
00121 
00122 //    return real(tmin);
00123 }
00124 
00125 // Return the minimum noise figure.
00126 double ampdata::F_min()
00127 {
00128   if(size() != 2)
00129   {
00130     error::warning("ampdata size != 2 in ampdata::F_min().");
00131     return 0.0;
00132   }
00133 
00134   return 10.0 * log10(1.0 + t_min()/(290.0*Kelvin));
00135 }
00136 
00137 // Return the noise measure.
00138 // Equations may be found in Scott Wedge's Ph.D. thesis (Caltech) page 28.
00139 double ampdata::noise_measure()
00140 {
00141   if(size() != 2)
00142   {
00143     error::warning("ampdata size != 2 in ampdata::noise_measure().");
00144     return 0.0;
00145   }
00146 
00147   return real(C[2][2]) / (norm(S[2][1]) + norm(S[2][2]) - 1.0);
00148 }
00149 
00150 // Return the noise resistance normalized to z_norm.
00151 // Equations may be found in Scott Wedge's Ph.D. thesis (Caltech) page 27.
00152 double ampdata::Rn()
00153 {
00154   if(size() != 2)
00155   {
00156     error::warning("ampdata size != 2 in ampdata::Rn().");
00157     return 0.0;
00158   }
00159 
00160   double r = C[1][1].real - 2*(C[2][1]*(1+S[1][1])/S[2][1]).real 
00161     + C[2][2].real*norm((1+S[1][1])/S[2][1]);
00162   r /= 4.0 * 290.0 * Kelvin;
00163   return r;
00164 }
00165 
00166 // Return the determinant of the scattering matrix.
00167 complex ampdata::delta()
00168 {
00169   if(size() != 2)
00170   {
00171     error::warning("ampdata size != 2 in ampdata::delta().");
00172     return complex();
00173   }
00174   return S[1][1]*S[2][2] - S[1][2]*S[2][1];
00175 }
00176 
00177 // Return k, which must be > 1 for unconditional stability
00178 double ampdata::k()
00179 {
00180   if(size() != 2)
00181   {
00182     error::warning("ampdata size != 2 in ampdata::k().");
00183     return 0.0;
00184   }
00185   return
00186   (1.0-norm(S[1][1])-norm(S[2][2])+norm(delta()))/(2.0*abs(S[1][2]*S[2][1]));
00187 }
00188 
00189 // Return center of the stability circle.
00190 // Parameter specifies the input or output port.
00191 complex ampdata::center(int p)
00192 {
00193   if(size() != 2)
00194   {
00195     error::warning("ampdata size != 2 in ampdata::center(int).");
00196     return complex();
00197   }
00198   if(p < 1 || p > 2)
00199   {
00200     error::warning("port parameter must be 1 or 2 in ampdata::center(int).");
00201     return complex();
00202   }
00203   int q = 3 - p;        // The other port
00204   complex d = delta();
00205 
00206   return zconj(S[p][p] - d*zconj(S[q][q]))/(norm(S[p][p])-norm(d));
00207 }
00208 
00209 // Return radius of stability circle (circle for |gamma| = 1)
00210 // Parameter specifies the input or output port.
00211 double ampdata::radius(int p)
00212 {
00213   if(size() != 2)
00214   {
00215     error::warning("ampdata size != 2 in ampdata::radius(int).");
00216     return  0.0;
00217   }
00218   if(p < 1 || p > 2)
00219   {
00220     error::warning("port parameter must be 1 or 2 in ampdata::radius(int).");
00221     return 0.0;
00222   }
00223   int q = 3 - p;        // The other port
00224 
00225   return zabs(S[p][q]*S[q][p]/(norm(S[p][p])-norm(delta())));
00226 }
00227 

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