00001 // sources.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 // 10/29/99: Generator R now shadows device::Z0 by default 00033 // 11/11/98: Changed table access to new syntax 00034 // 11/10/98: Removed limits on voltage and current in 00035 // voltage_source and current_sink 00036 // 9/18/98: Made constructors more efficient. 00037 // 9/15/98: Fixed a nasty bug: wrong argument order in 00038 // passive noise calculations. 00039 // 12/29/97: modified by FR for new sdata (with znorm) 00040 // 12/19/97: modified by FR for matmath classes 00041 00042 #include "sources.h" 00043 #include <math.h> 00044 #include "error.h" 00045 00046 00047 // generator: 00048 00049 generator::generator() : 00050 nport(1), 00051 R(&device::Z0), Temp(&device::T), 00052 source_f(0.0), source_width(0.0), source_power(0.0), source_phase(0.0) 00053 { 00054 R.set_min(0.0); 00055 source_f.set_min(0.0); 00056 source_width.set_min(0.0); 00057 source_power.set_min(0.0); 00058 } 00059 00060 const nport::data_info & generator::get_data_info() 00061 { 00062 info.active = (Temp != device::T && R != 0.0); 00063 info.source = source_power != 0.0; 00064 return info; 00065 } 00066 00067 void generator::recalc_S() 00068 { 00069 // Set normalization impedance. added 12/29/97 00070 data.set_znorm(Z0); 00071 00072 // Calculate S11 00073 data.S[1][1] = (R - Z0)/(R + Z0); 00074 00075 // Convert the source power to an amplitude wave and put in B1 00076 if(fabs(f - source_f) <= (source_width/2.0)) 00077 data.B[1] = polar(2.0*sqrt(Z0*R*source_power)/(Z0+R), source_phase); 00078 else 00079 data.B[1] = 0.0; 00080 } 00081 00082 void generator::recalc() 00083 { 00084 recalc_S(); 00085 00086 // Calculate C11 00087 compute_passive_noise(data, f, Temp); 00088 } 00089 00090 00091 // voltage_source: 00092 00093 voltage_source::voltage_source() : 00094 nport(1), 00095 R(0.0), Temp(&T), 00096 source_f(0.0), source_width(0.0), source_voltage(0.0), source_phase(0.0) 00097 { 00098 R.set_min(0.0); 00099 source_f.set_min(0.0); 00100 source_width.set_min(0.0); 00101 } 00102 00103 const nport::data_info & voltage_source::get_data_info() 00104 { 00105 info.active = (Temp != device::T && R != 0.0); 00106 info.source = source_voltage != 0.0; 00107 return info; 00108 } 00109 00110 void voltage_source::recalc_S() 00111 { 00112 // Set normalization impedance: 00113 data.set_znorm(Z0); 00114 00115 // Calculate S11 00116 data.S[1][1] = (R - Z0)/(R + Z0); 00117 00118 // Convert the source voltage to an amplitude wave and put in B1 00119 if(fabs(f - source_f) <= (source_width/2.0)) 00120 data.B[1] = polar(sqrt(Z0)*source_voltage/(Z0+R), source_phase); 00121 else 00122 data.B[1] = 0.0; 00123 } 00124 00125 void voltage_source::recalc() 00126 { 00127 recalc_S(); 00128 00129 // Calculate C11 00130 compute_passive_noise(data, f, Temp); 00131 } 00132 00133 00134 // current_sink: 00135 00136 current_sink::current_sink() : 00137 nport(1), 00138 Y(0.0), Temp(&T), 00139 source_f(0.0), source_width(0.0), sink_current(0.0), sink_phase(0.0) 00140 { 00141 Y.set_min(0.0); 00142 source_f.set_min(0.0); 00143 source_width.set_min(0.0); 00144 } 00145 00146 const nport::data_info & current_sink::get_data_info() 00147 { 00148 info.active = (Temp != device::T && Y != 0.0); 00149 info.source = sink_current != 0.0; 00150 return info; 00151 } 00152 00153 void current_sink::recalc_S() 00154 { 00155 // Set normalization impedance: 00156 data.set_znorm(Z0); 00157 00158 // Calculate S11 00159 data.S[1][1] = (1 - Y*Z0)/(1 + Y*Z0); 00160 00161 // Calculate C11 00162 compute_passive_noise(data, f, Temp); 00163 00164 // Convert the sink current to an amplitude wave and put in B1 00165 if(fabs(f - source_f) <= (source_width/2.0)) 00166 data.B[1] = - polar(sqrt(Z0)*sink_current/(1 + Y*Z0), sink_phase); 00167 else 00168 data.B[1] = 0.0; 00169 } 00170 00171 void current_sink::recalc() 00172 { 00173 recalc_S(); 00174 00175 // Calculate C11 00176 compute_passive_noise(data, f, Temp); 00177 }
Please direct comments and corrections to
supermix@submm.caltech.edu
Go to the supermix home page
Generated by
1.2.7