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

elements.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 
00041 // ***************************************************************************
00042 //
00043 //  5/11/01:  Converted comments to javadoc format
00044 //  4/28/00:  improved comments
00045 //  1/12/00:  added series and parallel RLC classes
00046 //  11/16/99: changes to support new noise calculations
00047 //  11/1/99:   Added is_active() and is_source() support
00048 //  9/14/98:  Made many constructors explicit
00049 //  8/27/98:  Expanded comments for series_tee; changed
00050 //            branch constructors
00051 //  8/24/98:  Added additional constructors; made recalc private
00052 //            changed some void return values.
00053 //  8/21/98:  Added 1-ports zterm and yterm
00054 //  8/19/98:  Added admittance rep to spimp; improved capacitor
00055 //  8/15/98:  Fixed size returned by series_tee
00056 //
00057 // ***************************************************************************
00058 
00059 #ifndef ELEMENTS_H
00060 #define ELEMENTS_H 1
00061 
00062 #include "nport.h"
00063 #include "parameter/complex_parameter.h"
00064 
00065 // ***************************************************************************
00066 
00101 class spimp : public nport
00102 {
00103 protected:
00108   bool is_series;
00109 
00116   void calcZ(complex Z);
00117 
00124   void calcY(complex Y);
00125 
00126 public:
00132   spimp() : nport(2), is_series(true) { info.source = false; }
00133 
00134   // Virtual destructor is necessary to ensure proper subclass destruction.
00135   virtual ~spimp() { }
00136 
00142   int size() { return 2; }
00143 
00147   spimp & series()
00148   { is_series = true; return *this; }
00149 
00153   spimp & parallel()
00154   { is_series = false; return *this; }
00155 };
00156 
00157 // ***************************************************************************
00158 
00173 class resistor : public spimp
00174 {
00175 public:
00179   parameter R;
00180 
00185   parameter Temp;
00186 
00192   explicit resistor(double r = 0.0)
00193     : spimp(), R(r), Temp(&T) { R.set_min(0.0); }
00194 
00200   explicit resistor(const abstract_real_parameter * r)
00201     : spimp(), R(r), Temp(&T) { R.set_min(0.0); }
00202 
00208   resistor & set(double r)
00209   { R = r; return *this; }
00210 
00216   resistor & set(abstract_real_parameter * r)
00217   { R = r; return *this; }
00218 
00224   resistor & set_T(double t)
00225   { Temp = t; return *this; }
00226 
00232   resistor & set_T(abstract_real_parameter * t)
00233   { Temp = t; return *this; }
00234 
00238   const nport::data_info & get_data_info() 
00239   { info.active = (Temp != device::T); return info; }
00240 
00241 private:
00242   // The calculation is done here.
00243   void recalc()   { calcZ(Complex(R)); data.passive_noise(f, Temp); } 
00244   void recalc_S() { calcZ(Complex(R)); }
00245 };
00246 
00247 // ***************************************************************************
00248 
00262 class capacitor : public spimp
00263 {
00264 public:
00268   parameter C;
00269 
00273   explicit capacitor(double c = 0.0)
00274     : spimp(), C(c) { C.set_min(0.0); info.noise = info.active = false; }
00275 
00281   explicit capacitor(const abstract_real_parameter * c)
00282     : spimp(), C(c) { C.set_min(0.0); info.noise = info.active = false; }
00283 
00289   capacitor & set(double c)
00290   { C = c; return *this; }
00291 
00297   capacitor & set(abstract_real_parameter * c)
00298   { C = c; return *this; }
00299 
00300 private:
00301   // The calculation is done here.
00302   void recalc() { calcY((2 * Pi * f * C) * I); }
00303 };
00304 
00305 // ***************************************************************************
00306 
00320 class inductor : public spimp
00321 {
00322 public:
00326   parameter L;
00327 
00331   explicit inductor(double i = 0.0)
00332     : spimp(), L(i) { L.set_min(0.0); info.noise = info.active = false; }
00333 
00339   explicit inductor(const abstract_real_parameter * i)
00340     : spimp(), L(i) { L.set_min(0.0); info.noise = info.active = false; }
00341 
00347   inductor & set(double i)
00348   { L = i; return *this; }
00349 
00355   inductor & set(abstract_real_parameter * i)
00356   { L = i; return *this; }
00357 
00358 private:
00359   // The calculation is done here.
00360   void recalc() { calcZ((2 * Pi * f * L) * I); }
00361 };
00362 
00363 
00393 class series_RLC: public spimp
00394 {
00395 public:
00397   parameter R;
00398 
00400   parameter L;
00401 
00403   parameter C;
00404 
00409   parameter Temp;
00410 
00418   explicit series_RLC(double r = 0.0, double l = 0.0, double c = 0.0)
00419     : spimp(), R(r), L(l), C(c), Temp(&T)
00420       { R.set_min(0.0); L.set_min(0.0); C.set_min(0.0);
00421         info.noise = info.active = false; }
00422 
00428   series_RLC & set_R(double r)
00429   { R = r; return *this; }
00430 
00436   series_RLC & set_R(abstract_real_parameter * r)
00437   { R = r; return *this; }
00438 
00444   series_RLC & set_L(double l)
00445   { L = l; return *this; }
00446 
00452   series_RLC & set_L(abstract_real_parameter * l)
00453   { L = l; return *this; }
00454 
00460   series_RLC & set_C(double c)
00461   { C = c; return *this; }
00462 
00468   series_RLC & set_C(abstract_real_parameter * c)
00469   { C = c; return *this; }
00470 
00476   series_RLC & set_T(double t)
00477   { Temp = t; return *this; }
00478 
00484   series_RLC & set_T(abstract_real_parameter * t)
00485   { Temp = t; return *this; }
00486 
00490   const nport::data_info & get_data_info() 
00491   { info.active = (Temp != device::T); return info; }
00492 
00493 private:
00494   // The calculation is done here.
00495   void recalc_S()
00496   {
00497     if (C==0.0)
00498       calcY(0.0);   // Use admittance calculation since impedance is infinite.
00499     else
00500     {
00501       double omega = 2*Pi*f;
00502       calcZ(Complex(R, omega*L - 1/(omega*C)));
00503     }
00504   }
00505 
00506   void recalc() { recalc_S(); data.passive_noise(f, Temp); }
00507 };
00508 
00509 // ***************************************************************************
00510 
00540 class parallel_RLC : public spimp
00541 {
00542 public:
00544   parameter R;
00545 
00547   parameter L;
00548 
00550   parameter C;
00551 
00556   parameter Temp;
00557 
00565   explicit parallel_RLC(double r = 0.0, double l = 0.0, double c = 0.0)
00566     : spimp(), R(r), L(l), C(c), Temp(&T)
00567       { R.set_min(0.0); L.set_min(0.0); C.set_min(0.0);
00568         info.noise = info.active = false; }
00569 
00575   parallel_RLC & set_R(double r)
00576   { R = r; return *this; }
00577 
00583   parallel_RLC & set_R(abstract_real_parameter * r)
00584   { R = r; return *this; }
00585 
00591   parallel_RLC & set_L(double l)
00592   { L = l; return *this; }
00593 
00599   parallel_RLC & set_L(abstract_real_parameter * l)
00600   { L = l; return *this; }
00601 
00607   parallel_RLC & set_C(double c)
00608   { C = c; return *this; }
00609 
00615   parallel_RLC & set_C(abstract_real_parameter * c)
00616   { C = c; return *this; }
00617 
00623   parallel_RLC & set_T(double t)
00624   { Temp = t; return *this; }
00625 
00631   parallel_RLC & set_T(abstract_real_parameter * t)
00632   { Temp = t; return *this; }
00633 
00637   const nport::data_info & get_data_info() 
00638   { info.active = (Temp != device::T); return info; }
00639 
00640 private:
00641   // The calculation is done here.
00642   void recalc_S()
00643   {
00644     if (R==0.0 || L==0.0)    // Short circuit.
00645       calcZ(0.0);
00646     else
00647     {
00648       double omega = 2*Pi*f;
00649       // calcZ( R*L / (L + I*(R*omega*L*C - R/omega)));
00650       calcY(Complex(1/R, omega*C - 1/(omega*L)));
00651     }
00652   }
00653 
00654   void recalc() { recalc_S(); data.passive_noise(f, Temp); }
00655 };
00656 
00657 // ***************************************************************************
00658 
00687 class branch : public nport
00688 {
00689 public:
00695   explicit branch(int b = 3);
00696 
00698   int size() { return branches; }
00699 
00705   branch & set_branches(int);
00706 
00708   int get_branches() const { return branches; }
00709 
00710 private:
00712   int branches;
00713 
00718   void calc();
00719 
00721   void recalc() { }
00722 };
00723 
00724 // ***************************************************************************
00725 
00748 class series_tee : public nport
00749 {
00750 public:
00752   series_tee();
00753 
00759   int size() { return 3; }
00760 
00761 private:
00766   void recalc() { }
00767 };
00768 
00769 // ***************************************************************************
00770 
00800 class zterm : public nport
00801 {
00802 public:
00804   complex_parameter Z;
00805 
00807   parameter Temp;
00808 
00814   explicit zterm(complex z = 0.0) : nport(1), Z(z), Temp(&T)
00815   { info.source = false; }
00816 
00822   explicit zterm(abstract_complex_parameter * z) : nport(1), Z(z), Temp(&T)
00823   { info.source = false; }
00824 
00830   zterm & set(complex z)
00831   { Z = z; return *this; }
00832 
00838   zterm & set(abstract_complex_parameter * z)
00839   { Z = z; return *this; }
00840 
00846   zterm & set_T(double t)
00847   { Temp = t; return *this; }
00848 
00854   zterm & set_T(abstract_real_parameter * t)
00855   { Temp = t; return *this; }
00856 
00860   const nport::data_info & get_data_info() 
00861   { info.active = (Temp != device::T && Z != Complex(0.0)); return info; }
00862 
00863 private:
00864   // The calculation is done here.
00865   void recalc();
00866   void recalc_S();
00867 };
00868 
00872 typedef zterm short_term;
00873 
00874 // ***************************************************************************
00875 
00905 class yterm : public nport
00906 {
00907 public:
00909   complex_parameter Y;
00910 
00912   parameter Temp;
00913 
00919   explicit yterm(complex y = 0.0) : nport(1), Y(y), Temp(&T)
00920   { info.source = false; }
00921 
00927   explicit yterm(abstract_complex_parameter * y) : nport(1), Y(y), Temp(&T)
00928   { info.source = false; }
00929 
00935   yterm & set(complex y)
00936   { Y = y; return *this; }
00937 
00943   yterm & set(abstract_complex_parameter * y)
00944   { Y = y; return *this; }
00945 
00951   yterm & set_T(double t)
00952   { Temp = t; return *this; }
00953 
00959   yterm & set_T(abstract_real_parameter * t)
00960   { Temp = t; return *this; }
00961 
00965   const nport::data_info & get_data_info() 
00966   { info.active = (Temp != device::T && Y != Complex(0.0)); return info; }
00967 
00968 private:
00969   // The calculation is done here.
00970   void recalc();
00971   void recalc_S();
00972 };
00973 
00977 typedef yterm open_term;
00978 
00979 #endif /* ELEMENTS_H */

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