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

junction.h

Go to the documentation of this file.
00001 // SuperMix version 1.0  C++ source file
00002 //
00003 // Copyright (c) 1999 California Institute of Technology.
00004 // All rights reserved.
00005 //
00006 // Redistribution and use in source and binary forms for noncommercial
00007 // purposes are permitted provided that the above copyright notice and
00008 // this paragraph are duplicated in all such forms and that any
00009 // documentation and other materials related to such distribution and
00010 // use acknowledge that the software was developed by California
00011 // Institute of Technology. Redistribution and/or use in source or
00012 // binary forms is not permitted for any commercial purpose. Use of
00013 // this software does not include a permitted use of the Institute's
00014 // name or trademark for any purpose.
00015 //
00016 // DISCLAIMER:
00017 // THIS SOFTWARE AND/OR RELATED MATERIALS ARE PROVIDED "AS-IS" WITHOUT
00018 // WARRANTY OF ANY KIND INCLUDING ANY WARRANTIES OF PERFORMANCE OR
00019 // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE OR PURPOSE (AS SET
00020 // FORTH IN UCC 23212-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
00021 // LICENSED PRODUCT, HOWEVER USED.  IN NO EVENT SHALL CALTECH/JPL BE
00022 // LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING BUT NOT LIMITED TO
00023 // INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING ECONOMIC
00024 // DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF
00025 // WHETHER CALTECH/JPL SHALL BE ADVISED, HAVE REASON TO KNOW, OR IN
00026 // FACT SHALL KNOW OF THE POSSIBILITY.  THE USER BEARS ALL RISK
00027 // RELATING TO QUALITY AND PERFORMANCE OF THE SOFTWARE AND/OR RELATED
00028 // MATERIALS.
00029 //
00030 // ********************************************************************
00031 // junction.h
00032 //
00033 // contains declarations for generic nonlinear device classes:
00034 // junction; ivcurve; ckdata;
00035 //
00036 // F. Rice 6/29/98
00037 //
00038 // 6/21/00:  Added capability to read in ivcurve data after creation
00039 // 1/12/00:  Changed calling arguments to ckdata::calc(), ckdata::fillA()
00040 // 12/28/99: Removed tosymm(), fromsymm()
00041 // 4/12/99:  Changed ivcurve to use interpolator<> template class;
00042 //           changed interface to ivcurve::I_prime(); added oper()
00043 // 1/19/99:  Fixed the file name arguments to ivcurve (added const)
00044 // 12/2/98:  Mods to ivcurve for cubic spline interpolation
00045 // 11/10/98: Minor changes to support new vector accessing
00046 // 9/8/98:   Enhanced ivcurve to support more realistic iv curves
00047 // 7/17/98:  Expanded comment to ckdata class.
00048 // 7/15/98:  Changed junction state vectors to Index_C vice Index_S
00049 // 7/10/98:  Added slope to return value from ivcurve: Iprime()
00050 // 7/8/98:   Changed junction to return references; added state info
00051 // 7/7/98:   Moved ckdata declaration into this header file
00052 // 7/1/98:   Changed ivcurve to make it more generic (not SIS-specific)
00053 //
00054 // ********************************************************************
00055 
00056 #ifndef JUNCTION_H
00057 #define JUNCTION_H
00058 
00059 #include "global.h"
00060 #include "matmath.h"
00061 #include "interpolate.h"
00062 
00063 
00064 // ********************************************************************
00065 // class junction
00066 //
00067 // junction is the abstract interface to nonlinear circuit elements
00068 // (used by mixer). All nonlinear circuit elements should be derived
00069 // from this class if they are to be used with a mixer object.
00070 //
00071 // F. Rice 6/29/98
00072 //
00073 // ********************************************************************
00074 
00075 class junction
00076 {
00077 public:
00078 
00079   // junction::Y_type means the element returns currents given input
00080   // voltages, ie: has an admittance representation. Z_type means the
00081   // element returns voltages given currents, an impedance representation.
00082 
00083   enum { Y_type = 0, Z_type = 1 };     // define these symbolic constants
00084 
00085   virtual int type() const {return Y_type;}  // most junctions are of this type
00086 
00087 
00088   // The routine used to set the operating state of the nonlinear element.
00089   // The input vector is a set (indexed 0..n) of RMS signals impressed on
00090   // the element; the function sets whatever internal state variables it
00091   // maintains and then returns a set of RMS large-signal responses, also
00092   // indexed from 0 to n. Index 0 is the DC component, index n represents the
00093   // signal at n*LO_freq.
00094 
00095   virtual const Vector & large_signal(
00096                       const Vector & input,   // the vector of RMS inputs
00097                       double LO_freq,         // the LO frequency
00098                       int max_harmonics )     // the max number of harmonics
00099     = 0;
00100 
00101 
00102   // The routine that returns the small-signal response, which is a
00103   // linearized approximation about the operating state. It returns a
00104   // symmetrically-indexed square matrix representing either the small-
00105   // signal admittance matrix (if type()==Y_type) or impedance matrix
00106   // (if type()==Z_type). The client must call large_signal() before calling
00107   // this routine in order to set the device's operating state.
00108 
00109   virtual const Matrix & small_signal(
00110                       double IF_freq,         // the IF frequency
00111                       int max_harmonics )     // the max number of harmonics
00112     = 0;
00113 
00114 
00115   // The routine that returns the noise correlation matrix.  It returns a
00116   // symmetrically-indexed square matrix representing either the current
00117   // noise (type()==Y_type) or voltage noise (type()==Z_type).  The client
00118   // must call large_signal() before calling this routine to set the
00119   // device's operating state.
00120 
00121   virtual const Matrix & noise(
00122                double IF_freq,                // the IF frequency
00123                double T,                      // the temperature
00124                int max_harmonics )            // the max number of harmonics
00125     = 0;
00126 
00127 
00128   // Routines to report state data for the junction, as a result of the
00129   // most recent execution of large_signal(). Whether V() and I() represent
00130   // input or output of large_signal() depends on type(). The indexing mode
00131   // will be Index_C, with index 0 representing DC, index n the state at
00132   // frequency n*LO_freq, with LO_freq being the value of that argument in
00133   // the most recent call to large_signal().
00134 
00135   virtual const Vector & V() const = 0;  // DC and RMS harmonic voltages
00136   virtual const Vector & I() const = 0;  // DC and RMS harmonic currents
00137 
00138 
00139   // This function returns a flag which is nonzero if the junction device has
00140   // has detected a change to its parameters which invalidate its current
00141   // operating state. large_signal() must be called in order for the device
00142   // to correctly calculate a new operating state. Note that calling either
00143   // small_signal() or noise() during this condition may result in a fatal
00144   // error.
00145 
00146   virtual int call_large_signal() const { return 0; }
00147 
00148 
00149   // Virtual destructor
00150   virtual ~junction() { };
00151 
00152 }; // class junction
00153 
00154 
00155 // ********************************************************************
00156 // class ivcurve
00157 //
00158 // class ivcurve reads files with current response data and generates
00159 // I(V), a complex DC current I from a real DC voltage V
00160 //
00161 // F. Rice 2/12/98
00162 //
00163 // ********************************************************************
00164 
00165 class ivcurve
00166 {
00167 public:
00168 
00169   // creates an ivcurve object by reading and saving the file data for
00170   // the reponse to real, positive voltages. Interpolates or extrapolates using
00171   // techniques appropriate for  SIS I(V) curves: the imaginary part is the
00172   // simple, measured DC current Idc(V) (an odd function of V); the real part
00173   // is the Kramers-Kronig transform of that current response, Ikk(V) (an even
00174   // function of V).
00175 
00176   ivcurve(const char * const I_imaginary_filename, const char * const I_real_filename);
00177 
00178   ivcurve();  // just construct; wait until later to specify data files
00179 
00180   // here we can specify or change data files following construction:
00181   void data(const char * const I_imaginary_filename, const char * const I_real_filename);
00182 
00183 
00184   // We'll implement this one later...
00185   //  ivcurve(char *filename);
00186 
00187 
00188   // Return a current given a voltage.
00189   // In the case of SIS junctions, the complex current: Ikk(V) + I*Idc(V)
00190 
00191   Complex operator()(double V) const 
00192   {check(); return Complex(ikkinterp(V),idcinterp(V));}
00193   Complex I(double V) const
00194   {check(); return Complex(ikkinterp(V),idcinterp(V));}
00195 
00196 
00197   // Return I(V) in Y, I'(V) in Yp; for the value and the slope of the
00198   // I(V) curve at voltage V.
00199   
00200   void Iprime(double V, complex & Y, complex & Yp) const
00201   {
00202     check();
00203     ikkinterpslope(V, Y.real, Yp.real); 
00204     idcinterpslope(V, Y.imaginary, Yp.imaginary);
00205   }
00206 
00207 private:
00208   bool valid;                     // Are Idc and Ikk valid?
00209   interpolator<double> Idc, Ikk;  // The Idc and Ikk data interpolators
00210   double Io, c0, c2, c4;          // Extrapolation parameters for Ikk
00211   double idcinterp(double v) const;  // interpolate Idc value
00212   double ikkinterp(double v) const;  // interpolate Ikk value
00213   void idcinterpslope(double, double &, double &) const;
00214   void ikkinterpslope(double, double &, double &) const;
00215 
00216   void check() const
00217     { if(!valid) error::fatal("No IV data provided to ivcurve object."); }
00218 
00219 };  // class ivcurve
00220 
00221 
00222 // ********************************************************************
00223 // class ckdata
00224 //
00225 // ckdata calculates and holds Ck matrix values for an SIS
00226 // junction; used in the mixer analysis and harmonic balance
00227 //
00228 // Note that if the ratio of (Voltage Amplitude)/(Photon Voltage) >> 1,
00229 // then the size of the Ck vector will be on the order of 2.5 times the
00230 // value of this ratio; even this will not be large enough for accurate
00231 // convolutions, since the Ck's returned will all have values ~ 1/Sqrt(r)
00232 // where r is the above ratio, and r >~ 10. Convolution sums will be
00233 // accurate to better than ~ +/1 1e-6 for r = 20; above r ~ 30, the
00234 // accuracy degrades very rapidly, to only about +/- 0.2 at a ratio of 50.
00235 //
00236 // This behavior may be investigated using test_ck and test_ck_prompt.
00237 //
00238 // F. Rice 2/12/98
00239 // ********************************************************************
00240 
00241 class ckdata
00242 {
00243 public:
00244   Vector Ck;  // the container of the Ck vector results
00245   double Tol; // the tolerance to which the Ck results are accurate
00246               // following calc(): Tol == ZEROTOL, #defined in global.h 
00247 
00248   // constructors:
00249   ckdata()
00250     : Ck(0,Index_S), Tol(0.0),
00251       bessel_values(0,0,Index_C,Index_C), Amj_values(0,Index_C)
00252   { }
00253   ckdata(const ckdata & old)
00254     : Ck(old.Ck), Tol(old.Tol),
00255       bessel_values(0,0,Index_C,Index_C), Amj_values(0,Index_C)
00256   { }
00257 
00258   // destructor: default destructor is fine
00259 
00260   // assignment operator: only copies Ck vector data and Tol
00261   inline ckdata & operator = (const ckdata & old)
00262   { (Ck = old.Ck).resize(old.Ck); Tol = old.Tol; return *this; }
00263 
00264   // access the vector data using array indexing:
00265   inline Complex & operator [] (const int i) { return Ck.get(i); }
00266 
00267   // calculate the Ck data:
00268   ckdata & calc(
00269                 const double   fLO,  // The Large-Signal (LO) frequency
00270                 const Vector & V     // The Large-Signal (LO) harmonic RMS voltages
00271                 );
00272 
00273 private:
00274 
00275   // holds results of bessel():
00276   real_table bessel_values;
00277 
00278   // holds results of fillA():
00279   Vector Amj_values;
00280 
00281   // determines number of bessel fcns to calculate and sizes bessel_values:
00282   int find_max_bessel_n(const double);
00283 
00284   // fills bessel_values with bessel fcns and their derivatives:
00285   int bessel(const double);
00286 
00287   // converts bessel_values to Amj coefficients, in Amj_values:
00288   int fillA(const Complex a);
00289 
00290 };
00291 
00292 #endif /* JUNCTION_H */

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