/* Class ExampleProgramTwoISS Example Program for class ImpedSpecImpedance Circuit Model supplied via the interface ImpedSpecModel Michael Thomas Flanagan (http:\\www.ee.ucl.ac\~flanaga\java) May 2007 */ import java.util.Vector; import flanagan.complex.Complex; import flanagan.circuits.*; public class ExampleProgramTwoISS{ public static void main(String[] args){ // Create an instance of ImpedSpecSimulation ImpedSpecSimulation iss = new ImpedSpecSimulation("Example Program Two"); // Create an instance of the class, mplementing the interface ImpedSpecModel, // that contains the impedance calculation for the supplied circuit model ExampleTwoModel etm = new ExampleTwoModel(); iss.setAppliedVoltage(1.0D); // enter the applied voltage (1 V) iss.setReferenceImpedance(1.0e5); // enter the reference impedance (100000 ohms) String[] symbols = {"R1", "C1", "R2", "C2", "R3"}; // model parameters double[] parameters = {3.0e4, 5.0e-8, 1.0e5, 1.0e-6, 1.0e3}; // parameter values iss.setModel(etm, parameters, symbols); // enter the circuit model iss.setScanRangeHz(0.1, 1e10); // enter the frequency range Vector results = iss.getSimulationResults(50); // get all the simulation data for 50 points iss.plotVoltageMagnitudes(); // plot the voltage magnitude of the test circuit against frequency iss.plotVoltagePhases(); // plot the voltage phase of the test circuit against frequency iss.plotImpedanceMagnitudes(); // plot the impedance magnitude of the test circuit against frequency iss.plotImpedancePhases(); // plot the impedance phase of the test circuit against frequency iss.plotColeCole(); // plot the Cole-Cole plot (Imag[z] against Real[z] iss.print("ExampleTwo.txt",20); // print the results for 20 points to a text file iss.printForExcel("ExampleTwo.xls",20); // print the results for 20 points to an Excel file } } // Class containing the method that returns the complex impedance of the model circuit class ExampleTwoModel extends Impedance implements ImpedSpecModel{ public Complex modelImpedance(double[] parameter, double omega){ // Impedance of R1 in parallel with C1 = Z1 Complex z1 = Impedance.rInParallelWithC(parameter[0], parameter[1], omega); // Impedance of R2 in parallel with C2 = Z2 Complex z2 = Impedance.rInParallelWithC(parameter[2], parameter[3], omega); // Impedance of Z1 in series with Z2 = Z3 Complex z3 = z1.plus(z2); // Return impedance of Z3 in series with R3 return z3.plus(parameter[4]); } }