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

makeiv.cc

Go to the documentation of this file.
00001 // makeiv.cc
00002 // Generate a simulated SIS DC IV curve suitable for use with supermix.
00003 // The output IV curve will be normalized such that Vgap = Rn = 1.
00004 // The output will be written to the standard output stream.
00005 
00006 #include "supermix.h"
00007 #include "numerical.h"
00008 
00009 // ---------------------------------------------------------------------------
00010 // Function to print a usage prompt, with definitions of the parameters
00011 
00012 const int cmd_line_params = 4;    // the expected number of command line params
00013 
00014 void prompt(const char *const *const argv)
00015 {
00016   cerr << argv[0] << ": construct a simulated, normalized SIS IV curve for"
00017        << endl << "use with SuperMix." << endl << endl;
00018   cerr << "Usage: " << argv[0] << "  R_subgap  Gap_width  I_leakage  I_defect"
00019        << endl << endl;
00020 
00021   cerr << "Where:" << endl
00022        << "       Parameter    Description                         Valid Range \n"
00023        << "       ---------    ---------------------------------   ----------- \n"
00024        << "       R_subgap     Subgap/Normal resistance ratio      > 1.0       \n"
00025        << "       Gap_width    Width of the gap relative to Vgap   0.0 - 1.0   \n"
00026        << "       I_leakage    Leakage current just above V = 0    0.0 - 1.0   \n"
00027        << "       I_defect     Current defect just above gap       0.0 - 1.0   \n"
00028        << endl
00029        << "       The output is normalized so that Vgap = Rn = 1.0.            \n"
00030        << "       Currents (I_leakage and I_defect) are normalized to Vgap/Rn. \n"
00031        << "       I_defect is the amount that the current just above Vgap      \n"
00032        << "       falls short of being equal to V/Rn. It rerpesents a constant \n"
00033        << "       offset below the I=V/Rn line for all currents with V>Vgap.   \n"
00034        << endl
00035        << "       Typical values for a fairly good SIS might be:  \n"
00036        << "          R_subgap  = 20          \n"
00037        << "          Gap_width = 0.02        \n"
00038        << "          I_leakage = 0.01        \n"
00039        << "          I_defect  = 0.1         \n"
00040        << endl;
00041 }
00042 
00043 // ---------------------------------------------------------------------------
00044 // Global parameters:
00045 
00046 double  G_subgap;      // Subgap/Normal conductance ratio  (0.0 - 1.0)
00047 double  Gap_width;     // Relative width of the gap        (0.0 - 1.0)
00048 double  I_leakage;     // Leakage current/(Vgap/Rn)        (0.0 - 1.0)
00049 double  I_defect;      // Current defect above gap         (0.0 - 1.0)
00050 
00051 const char *comment = "#";
00052 
00053 // ---------------------------------------------------------------------------
00054 // Functions used to simulate a simple SIS dc IV response:
00055 
00056 // output a straight line fit: y = mx+b:
00057 inline double line(double x, double m, double b) { return m*x + b; }
00058 
00059 // a hyperbolic tangent step function with some parameter checking
00060 double sym_step(double x, double w)
00061 {
00062   if (w > 0.0) return tanh(x/w);
00063   else {
00064     if (x  < 0.0) return -1.0;
00065     else if (x == 0.0) return  0.0;
00066     else return  1.0;
00067   }
00068 }
00069 
00070 // output a finite-width generalization of the Heaviside step function:
00071 inline double step(double x, double w) { return 0.5*(sym_step(x,w)+1.0); }
00072 
00073 // the full simulation of the iv curve, using the curve parameters:
00074 double f(double v)
00075 {
00076   double av     = fabs(v);
00077   double i_sg   = line(av, G_subgap, I_leakage * sym_step(v, sqrt(Gap_width)));
00078   double i_ag   = line(av, 1.0, -I_defect) * sym_step(v, Gap_width);
00079   double weight = step(av - 1.0, Gap_width);
00080   return weight*i_ag + (1.0-weight)*i_sg;
00081 }
00082 
00083 // ---------------------------------------------------------------------------
00084 int main(int argc, char ** argv)
00085 {
00086   // Input command line parameters; print a usage prompt if needed
00087   bool bad_param = false;
00088   if (argc != 1+cmd_line_params) bad_param = true;
00089   else {
00090     Gap_width = atof(argv[2]);
00091     G_subgap  = 1/atof(argv[1]);
00092     I_leakage = atof(argv[3]);
00093     I_defect  = atof(argv[4]);
00094 
00095     if (Gap_width <= 0.0 || Gap_width >  1.0) bad_param = true;
00096     if (G_subgap  <  0.0 || G_subgap  >  1.0) bad_param = true;
00097     if (I_leakage <  0.0 || I_leakage >  1.0) bad_param = true;
00098     if (I_defect  <  0.0 || I_defect  >  1.0) bad_param = true;
00099   }
00100 
00101   if (bad_param) {
00102     prompt(argv);
00103     return 1;
00104   }
00105 
00106 
00107   // Adaptively fill an interpolator with simulated IV curve points. We use
00108   // an interpolator here, since the SuperMix class ivcurve does. We want to
00109   // ensure that the points we output will allow an interpolator to accurately
00110   // match the desired IV curve response. See interpolate.h and adaptive.h
00111 
00112   interpolator<double> idc;
00113   adaptive_fill(idc, f, 0, 2, .0001, .01);
00114 
00115 
00116   // Now output the (V,I) points in the interpolator.
00117 
00118   cout << fixed << setprecision(10);
00119   cout << comment << " Normalized simulated SIS DC IV characteristic curve" << endl;
00120   cout << comment << " Parameter values used in the simulation:" << endl;
00121   cout << comment << "  Gap Width                = " << Gap_width << endl;
00122   cout << comment << "  Subgap Resistance Ratio  = " << 1/G_subgap  << endl;
00123   cout << comment << "  Subgap Current Leakage   = " << I_leakage << endl;
00124   cout << comment << "  Normal Current Defect    = " << I_defect  << endl;
00125   cout << comment << endl;
00126   cout << comment << " V:         " << "\t" << "I:" << endl;
00127 
00128   for(unsigned i = 0; i < idc.size(); ++i)
00129     cout << idc.x(i) << "\t" << idc[i] << endl;
00130 }
00131 

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