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 // instrument.h 00032 // 00033 // contains classes: inst_circuit 00034 // 00035 // F. Rice 8/25/98 00036 // 00037 // ******************************************************************** 00038 00039 #ifndef INSTRUMENT_H 00040 #define INSTRUMENT_H 00041 00042 #include "circuit.h" 00043 #include "elements.h" 00044 #include <vector> 00045 00046 // ******************************************************************** 00047 // class inst_circuit 00048 // 00049 // inst_circuit is used to implement a circuit object which contains 00050 // voltmeter and ampmeter ports; these ports may be accessed to determine 00051 // voltages and currents in the circuit. 00052 // 00053 // ******************************************************************** 00054 class inst_circuit : public nport 00055 { 00056 public: 00057 00058 // constructor: 00059 // 00060 // internal_circuit: the nport managed directly by inst_circuit. Its first several 00061 // ports are for connection to other external circuitry; next are the ports for 00062 // ampmeter connections, finally the ports for voltmeter connections. 00063 // 00064 // external_circuit: the external circuitry to be connected to internal_circuit 00065 // when determining the currents or voltages at the instrument ports. 00066 // 00067 // num_voltmeters: how many of the instrument ports are for voltage measurements. 00068 // the last num_voltmeters ports of internal_circuit will be used for voltmeter 00069 // connections; any remaining ports will be used for ampmeter connections. Note 00070 // the default value is 0 (no voltmeters), and any supplied value must be 00071 // nonnegative. 00072 // 00073 // example of port assignments: if internal_circuit has M ports, external_circuit 00074 // has N ports (N < M), and num_voltmeters is K, with N + K < M, then: 00075 // 00076 // (1) the ports 1 to N of internal_circuit are for connections to the external 00077 // circuitry; the constructed inst_circuit object is an nport with N ports 00078 // corresponding to ports 1 to N of internal_circuit. When the voltages or 00079 // currents are calculated, these ports will be connected to the corresponding 00080 // ports of external_circuit and the resulting combined circuit is calculated. 00081 // 00082 // (2) the ports N+1 to M-K of internal circuit are for ampmeter access. When 00083 // the circuit is calculated, these ports are terminated by inst_circuit with 00084 // short circuits. 00085 // 00086 // (3) the ports M-K+1 to M of internal circuit are for voltmeter access. When 00087 // the circuit is calculated, these ports are terminated by inst_circuit with 00088 // open circuits. 00089 00090 inst_circuit 00091 (nport & internal_circuit, nport & external_circuit, int num_voltmeters = 0); 00092 00093 // How to properly create ports in your internal_circuit: 00094 // 00095 // Use a series_tee object at the point where you need to measure a current. 00096 // The ampmeter port should be port 1 of this series_tee. The source of the 00097 // current should be connected to port 2 of the series_tee, the sink of the 00098 // current should be connected to port 3 of the series_tee. 00099 // Using the above connections will result in a positive current reading if the 00100 // actual current flows from the source to the sink. 00101 // 00102 // Use a branch object (with the default 3 ports) where you need to measure 00103 // a voltage. Since the branch is symmetrical with respect to all its ports, 00104 // any port of the branch may be used as the voltmeter port. 00105 // 00106 // When adding ports to your resulting circuit object (using circuit::add_port()), 00107 // always add all interface ports first, then add the ampmeter ports, if any, and 00108 // finally add the voltmeter ports, if any. 00109 00110 00111 // The following 2 functions access the instrument ports: each function returns a 00112 // complex_vector of current or voltage readings. Index 1 of the vector corresponds 00113 // to the value at the first instrument port for reading the given type quantity: 00114 00115 const Vector & voltages() { return volts = zdata(voltages_c.get_data()).Vs; } 00116 const Vector & currents() { return amps = ydata(currents_c.get_data()).Is; } 00117 00118 00119 private: 00120 void recalc() { data = get_data_c.get_data(); } 00121 00122 int interface_ports, amp_ports, volt_ports; 00123 nport & int_c, & ext_c; 00124 std::vector <open_term> voltmeters; 00125 std::vector <short_term> ampmeters; 00126 circuit get_data_c, voltages_c, currents_c; 00127 Vector volts, amps; 00128 }; 00129 #endif /* INSTRUMENT_H */
Please direct comments and corrections to
supermix@submm.caltech.edu
Go to the supermix home page
Generated by
1.2.7