Authors: Dipl.-Ing. Thomas Halfmann Dr.-Ing. Eckhard Hennig Dr.-Ing. Manfred Thole Dipl.-Math. Tim Wichmann Copyright 2000–2001 by Fraunhofer-Institut für Techno- und Wirtschaftsmathematik (ITWM) Gottlieb-Daimler-Strasse, D-67663 Kaiserslautern, Germany Fax: +49-631-205-4139 Email: analog.insydes@itwm.fhg.de WWW: http://www.analog-insydes.de This document is furnished by Fraunhofer-ITWM to licensed users of Analog Insydes for information purposes only. All information in this document is subject to change without notice. This document is provided as is without any express or implied warranties. No part of this document may be reproduced or redistributed, on any media or by any means, without prior written permission of Fraunhofer-ITWM. This document was typeset using the WRILaTeX Document System provided under license by Wolfram Research, Inc. The sparse matrix routines used in the Analog Insydes MathLink applications are copyright 1985, 86, 87, 88 by Kenneth S. Kundert and the University of California. Analog Insydes and the Analog Insydes logo are trademarks of Fraunhofer-ITWM. Mathematica and MathLink are registered trademarks of Wolfram Research, Inc. All other product names are trademarks of their respective owners. Printed by Rohr Druck GmbH Kaiserslautern. Printed in Germany. Table of Contents Part 1. 1.1 A Short Introduction Welcome to Analog Insydes.........................................................................................................................6 How to Read this Book 1.2 Getting Started............................................................................................................................................8 Command Overview Palette 1.3 Feature List The First Step Part 2. New Features: A More Detailed Description Compatibility Preface......................................................................................................................................................32 Loading Analog Insydes Netlists.......................................................................................................................................................33 The Netlist Format 2.3 The Analog Insydes Tutorial How to Read this Tutorial 2.2 The Online Help System What’s New?.............................................................................................................................................25 New Features: An Overview 2.1 An Example Application Circuit Elements A Brief Preview on Circuit Analysis More about Netlists Circuits and Subcircuits..............................................................................................................................46 Circuits, Netlists, and Subcircuits Defining Subcircuits and Device Models Referencing Subcircuits Expansion Subcircuit Parameters The Scope Argument The Translation Argument 2.4 Setting up and Solving Circuit Equations....................................................................................................70 Naming Conventions CircuitEquations 2.5 Circuit Equations Circuit Equation Formulations Nyquist Plots Nichol Plots Root Locus Plots Transient Waveforms Modeling and Analysis of Nonlinear Circuits.............................................................................................90 Behavioral Models Defining Behavioral Models Referencing Behavioral Models Multi-Dimensional Models Nonlinear DC Circuit Analysis References 2.7 Additional Options for Graphics....................................................................................................................................................81 Bode Plots 2.6 Nonlinear Circuit Equations Time-Domain Analysis of Nonlinear Dynamic Circuits...............................................................................104 Transient Circuit Analysis Analysis of a Differential Amplifier Flow of Transient Circuit Analysis Options Transient Analysis with Initial Conditions TransientPlot Options 2.8 NDAESolve Linear Symbolic Approximation................................................................................................................127 Introduction to Symbolic Approximation Approximation Combining SBG and SAG 2.9 Subcircuit Solution-Based Symbolic Approximation Options for ApproximateMatrixEquation Equation-Based Symbolic Frequency-Domain Analysis of Linear Circuits..........................................................................................142 Transistor Models Transfer Functions Device Mismatch Input and Output Impedances Advanced Transistor Modeling AC Analysis of the CMOS Amplifier Two-Port Parameters 2.10 Nonlinear Symbolic Approximation..........................................................................................................164 Introduction to Nonlinear Approximation Analyzing a Square Root Function Block 2 Part 3. 3.1 Reference Manual Netlist Format..........................................................................................................................................178 Netlist Circuit Netlist Entries Netlist Entry Options ElementTypes Value Specifications for Independent Sources Time and Frequency Model References Model and Subcircuit ModelParameters GlobalParameters 3.2 Subcircuit and Device Model Definition....................................................................................................190 Model 3.3 Subcircuit Model Library Management.....................................................................................................................211 ListLibrary FindModel FindModelParameters GlobalSubcircuits LoadModelParameters RemoveSubcircuit RemoveModelParameters 3.4 GlobalModelParameters LoadModel Expanding Subcircuits and Device Models................................................................................................221 ExpandSubcircuits 3.5 Setting Up and Solving Circuit Equations.................................................................................................227 CircuitEquations 3.6 ACEquations DCEquations Solve Circuit and DAEObject Manipulation........................................................................................................255 AddElements DeleteElements GetElements RenameNodes GetEquations GetMatrix GetVariables GetRHS GetParameters GetDAEOptions SetDAEOptions GetDesignPoint ApplyDesignPoint UpdateDesignPoint MatchSymbols ShortenSymbols Statistics 3.7 Numerical Analyses.................................................................................................................................280 Analog Insydes Numerical Data Format 3.8 Parameter Sweeps ACAnalysis NoiseAnalysis Pole/Zero Analysis..................................................................................................................................304 GeneralizedEigensystem GeneralizedEigenvalues PolesAndZerosByQZ RootLocusByQZ LREigenpair ApproximateDeterminant 3.9 NDAESolve PolesByQZ ZerosByQZ Graphics Functions...................................................................................................................................330 BodePlot FourierPlot NicholPlot NyquistPlot RootLocusPlot TransientPlot 3.10 Interfaces.................................................................................................................................................365 ReadNetlist WriteModel Simulator-Specific Remarks on ReadNetlist ReadSimulationData WriteSimulationData 3.11 Linear Simplification Techniques...............................................................................................................385 ComplexityEstimate ApproximateTransferFunction ApproximateMatrixEquation CompressMatrixEquation 3.12 Nonlinear Simplification Techniques..........................................................................................................401 NonlinearSetup CompressNonlinearEquations ShowLevel ShowCancellations CancelTerms SimplifySamplePoints NonlinearSettings 3.13 Miscellaneous Functions...........................................................................................................................418 ConvertDataTo2D DXFGraphics MathLink Module MSBG MathLink Module QZ 3.14 Global Options........................................................................................................................................425 Options[AnalogInsydes] InstanceNameSeparator UseExternals Option Inheritance LibraryPath ModelLibrary Protocol Simulator 3.15 The Analog Insydes Environment..............................................................................................................432 The Initialization Procedure ReleaseInfo ReleaseNumber License Version Info Table of Contents Part 4. 4.1 Appendix Stimuli Sources........................................................................................................................................438 AMWave 4.2 3 ExpWave PulseWave PWLWave SFFMWave SinWave Netlist Elements........................................................................................................................................446 Resistor Conductance Admittance Impedance Capacitor Inductor OpenCircuit ShortCircuit CurrentSource VoltageSource CCCSource CCVSource VCCSource VCVSource OPAmp OTAmp Nullator Norator Fixator SignalSource Amplifier Integrator Differentiator TransmissionLine TransferFunction 4.3 Model Library..........................................................................................................................................460 Diode Bipolar Junction Transistor MOS Field-Effect Transistor Junction Field-Effect Transistor Credits..............................................................................................................................................................492 Index................................................................................................................................................................493 A Short Introduction 1.1 Welcome to Analog Insydes . . . . . . . . . . . . . . . . . 6 1.2 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . 8 1.3 What’s New? . . . . . . . . . . . . . . . . . . . . . . . . . 25 1. A Short Introduction 6 1.1 Welcome to Analog Insydes Welcome to Analog Insydes, a Mathematica toolbox for symbolic modeling, analysis, and design of analog electronic circuits. With Analog Insydes you can model and analyze linear and nonlinear circuits, manipulate analysis results mathematically, produce graphical visualizations of circuit characteristics, exchange data with commercial circuit simulators, and document your solutions all in one integrated environment. You will always get the latest information concerning Analog Insydes at our home page http://www.analog−insydes.de There you will also find a collection of demo notebooks, which show the application of Analog Insydes on different tasks from the field of electrical engineering. If you have questions concerning Analog Insydes, please send an email to: analog.insydes@itwm.fhg.de If you want to register to the Analog Insydes newsletter, please write an email to the above mentioned email address with subject line "Newsletter " and body text "subscribe". You can find the list of previous newsletters at: http://www.analog−insydes.de/newsletter.html 1.1.1 How to Read this Book This book is divided into four parts: an introduction (Part 1), a tutorial (Part 2), a reference manual (Part 3), and an appendix (Part 4). The introduction part gives an overview of Analog Insydes’ functionality, highlights the new features of version 2, and shows the application of Analog Insydes on an practical example. We recommend to read this part, especially Section 1.2.1 and Section 1.2.3, before working with Analog Insydes. The tutorial part explains dedicated topics of Analog Insydes in detail. Although entitled Tutorial, it is not meant to be read completely before working with Analog Insydes. Rather, each chapter can be read separately as soon as you need a closer look at special topics. The reference part explains each Analog Insydes command, shows its argument list, describes the available options, and shows the application on small examples. If you need information on a certain command, the reference manual is the preferred source. The appendix part explains all stimuli sources defined in Analog Insydes, shows all available netlist elements, and finally describes the content of the predefined symbolic device model library. 1.1.2 Feature List The list below shows a summary of Analog Insydes’ main program features. 1.1 Welcome to Analog Insydes 7 Netlist-based input of electronic circuits and control systems Available linear circuit elements: resistor, impedance, conductance, admittance, capacitor, inductor, independent current and voltage source, all four types of controlled sources (VCVS, CCVS, VCCS, CCCS), operational amplifier (OP), operational transconductance amplifier (OTA), nullator, norator, fixator Available control network elements: proportional amplifier, differentiator, integrator, ideal transmission line, generic transfer function, signal source Hierarchical netlist entry and device modeling by means of subcircuits and behavioral model definitions User-extendible device model library which includes bipolar (full Gummel-Poon small-signal and large-signal) and MOS (full Level 1-3 and BSIM3v3 small-signal, Level 1 large-signal) transistor models Automatic setup of symbolic or mixed symbolic/numeric circuit equations by modified nodal (MNA), sparse tableau (STA), and extended sparse tableau analysis (ESTA) from netlists for linear and nonlinear circuits Automatic equation setup for AC, DC, transient, and noise analysis Symbolic calculation of transfer functions, input impedances, two-port parameters, etc. Design formula extraction by approximation of linear symbolic circuit equations and transfer functions Simplification techniques for the approximation of nonlinear circuit descriptions Support for automated generation of behavioral models for nonlinear circuits Numerical AC, noise, and pole/zero analysis Numerical DC, DC-transfer, and transient analysis of nonlinear circuits Solution of circuit equations not only for currents and voltages but also for design parameters Graphics functions for Bode, Nyquist, Nichol, Fourier, and root locus plots, transient waveforms, DC-transfer, and parametric analyses Netlist import for PSpice, Eldo, and Saber netlist files, including small-signal, operating-point, and model-card parameters Import filter for PSpice, Eldo, and Saber simulation data Export filter of Analog Insydes simulation data for PSpice and Saber Export filter for Saber MAST model templates Import filter for circuit schematics and other line graphics from DXF files 1. A Short Introduction 8 1.2 Getting Started If this is your first contact with Analog Insydes, this chapter will help you to get familiar with the system. To get an overview of the functionality of Analog Insydes, the first section provides a list of the most important commands (Section 1.2.1). Next, it is described how to load Analog Insydes into the Mathematica kernel (Section 1.2.2), and an example application shows one possible way to use Analog Insydes for solving a specific analysis task (Section 1.2.3). If you have never seen Analog Insydes before, reading this example will give you a first impression of the system. Finally, Section 1.2.4 explains how to access the Analog Insydes online help system. 1.2.1 Command Overview The most important Analog Insydes commands are listed in this section. For each command, references are given where to find more information. A link to the reference manual (Part 3 of this book) is given first, followed by links to related topics described in the tutorial (Part 2 of this book). Interfaces Analog Insydes provides import and export filters to PSpice, Eldo, and Saber (Chapter 3.10): ReadNetlist (Section 3.10.1, Section 2.9.2) translates external netlist files (including model cards, small-signal data, and operating-point information) into the Analog Insydes netlist language. ReadSimulationData (Section 3.10.3, Section 2.10.2) allows for importing and transforming numerical simulation data into Mathematica InterpolatingFunction objects. WriteSimulationData (Section 3.10.4) exports numerical data calculated with Analog Insydes for further postprocessing in external waveform viewers. WriteModel (Section 3.10.5) generates behavioral model descriptions of symbolic (approximated) equation systems. Netlists, Circuits, and Models In Analog Insydes, analog circuits are expressed in terms of Netlist, Circuit, and Model objects: Netlist (Section 3.1.1, Chapter 2.2) is the basic data structure which contains the elements of a flat netlist. Circuit (Section 3.1.2, Chapter 2.3, Section 2.3.1) is a data structure which combines netlists, models, model parameters, and global parameters. Model (Section 3.2.1, Section 2.3.2, Section 2.6.2) is a data structure which defines netlist-based or equations-based models or subcircuits. AddElements (Section 3.6.1, Section 2.9.4), DeleteElements (Section 3.6.2, Section 2.9.4), GetElements (Section 3.6.3), and RenameNodes (Sec- 1.2 Getting Started 9 tion 3.6.4) allow for adding, deleting, or extracting netlist entries and changing node names, respectively, in a comfortable way. Statistics (Section 3.6.17) prints information on the contents of a Netlist or Circuit object. Analog Insydes provides a predefined symbolic device model library (Chapter 4.3), which can be extended by the user. Several commands allow for accessing the model data base (Chapter 3.3): LoadModel (Section 3.3.6) loads a specific model from a given model library. FindModel (Section 3.3.2) searches the default model library for a given name/selector pair. GlobalSubcircuits (Section 3.3.4, Section 2.3.6) prints the name/selector pairs of all global models currently loaded. ListLibrary (Section 3.3.1) prints the contents of a specific model library. Equations Starting from Circuit or Netlist objects, circuit equations can be set up automatically in different formulations and analysis modes. They are stored (together with additional information) in a DAEObject. CircuitEquations (Section 3.5.1, Chapter 2.4, Section 2.4.2, Section 2.6.4) sets up circuit equations from a Circuit or Netlist object and returns a DAEObject. Solve (Section 3.5.4, Section 2.4.2) can be used to symbolically solve the equations stored in a DAEObject. GetEquations (Section 3.6.5, Section 2.10.2), GetVariables (Section 3.6.7, Section 2.10.2), GetDesignPoint (Section 3.6.12, Section 2.9.6), and GetParameters (Section 3.6.9, Section 2.10.2) give easy access to the data stored in a DAEObject. ApplyDesignPoint (Section 3.6.13), UpdateDesignPoint (Section 3.6.14, Section 2.10.2), and MatchSymbols (Section 3.6.15, Section 2.9.3) allow for modifying the contents of a DAEObject. GetDAEOptions (Section 3.6.10) and SetDAEOptions (Section 3.6.11) allow for accessing or modifying the options stored in a DAEObject. Statistics (Section 3.6.17, Section 2.9.7) prints information on the complexity of a DAEObject. Numerical Analyses The standard numerical circuit analyses can be carried out by the following commands (Chapter 3.7): NDAESolve (Section 3.7.5, Chapter 2.7) is used to solve nonlinear differential-algebraic equation systems. It calculates the DC (Section 2.6.6), DC-transfer (Section 2.7.2), and transient solution (Section 2.7.1), also parametric (Section 2.7.2). ACAnalysis (Section 3.7.3, Section 2.9.7) computes the small-signal solution of a linear equation system. 1. A Short Introduction 10 NoiseAnalysis (Section 3.7.4) computes the output noise and the equivalent input noise of a linear equation system. Poles and Zeros Besides the standard numerical analyses, Analog Insydes provides functions for numerically computing poles and zeros as well as root loci of linear systems (Chapter 3.8): PolesAndZerosByQZ (Section 3.8.3), PolesByQZ (Section 3.8.4), and ZerosByQZ (Section 3.8.5) numerically compute poles and zeros of a linear system using the QZ algorithm. RootLocusByQZ (Section 3.8.6) computes the root locus of a linear system. Graphical Postprocessing Analog Insydes provides special graphics functions for the most important electrical engineering plots: BodePlot (Section 3.9.1, Section 2.5.1) FourierPlot (Section 3.9.2) NicholPlot (Section 3.9.3, Section 2.5.3) NyquistPlot (Section 3.9.4, Section 2.5.2) RootLocusPlot (Section 3.9.5, Section 2.5.4) TransientPlot (Section 3.9.6, Section 2.7.1, Section 2.7.6) Symbolic Approximation One of the most important features of Analog Insydes is its capability to reduce the complexity of symbolic equations and expressions with automatic error control. For linear circuits, Analog Insydes provides SBG and SAG methods (Chapter 2.8): ApproximateTransferFunction (Section 3.11.2, Chapter 2.8, Section 2.8.2) approximates a symbolic transfer function by removing insignificant terms. ApproximateMatrixEquation (Section 3.11.3, Chapter 2.8, Section 2.8.3) approximates a symbolic matrix equation with respect to a certain output variable. ApproximateDeterminant (Section 3.8.8) approximates a symbolic matrix equation with respect to a certain pole. As of Analog Insydes Version 2 there are also simplification routines for nonlinear equations (Chapter 3.12): CompressNonlinearEquations (Section 3.12.2, Section 2.10.2) algebraically simplifies nonlinear equations by eliminating irrelevant variables. 1.2 Getting Started 11 CancelTerms (Section 3.12.3, Section 2.10.2) approximates a symbolic nonlinear equation system with respect to a certain output variable. The command NonlinearSetup (Section 3.12.1, Section 2.10.2) prepares the application of CancelTerms . Miscellaneous DXFGraphics (Section 3.13.2) translates DXF files into Mathematica graphics objects. It can be used to display circuit schematics in a Mathematica notebook for documentation purposes. Options[Analog Insydes] (Chapter 3.14) returns the list of global Analog Insydes options. See Section 3.14.8 for a description of the option inheritance mechanism in Analog Insydes. Info[AnalogInsydes] (Section 3.15.6) prints the exact location of your Analog Insydes installation and lists all loaded init files. For a description of init file loading see Section 3.15.1. For further information on the Analog Insydes environment see Chapter 3.15. 1.2.2 The First Step To work with Analog Insydes start Mathematica and open a new notebook window. Then load Analog Insydes by evaluating the command <<AnalogInsydes‘ in the first command line (please do not forget to type the quote character "‘"). The above command reads in the Analog Insydes context and sets up autoload declarations for all other Analog Insydes packages. If you have not launched a Mathematica kernel yet, you will have to wait a few extra seconds until the kernel is loaded. If Mathematica complains that it cannot find the master package check your context search path by inspecting the value of the Mathematica variable $Path. The directory in which the Analog Insydes subdirectory resides should be on this list. If this is not the case then add the package path to $Path by typing AppendTo[$Path, pathspec] and try loading Analog Insydes again. Another common error is to type the wrong quote character, thus be sure to use "‘". If you are already familiar with Analog Insydes 1 you probably want to test the new version before reading the manual. Almost all commands of version 1 are also available in version 2, but please note that the function patterns may have changed (see Section 1.3.3 for more details). If you are not familiar with Analog Insydes, please at least go through the example in Section 1.2.3 before using Analog Insydes. This section will give you a first impression how to work with Analog Insydes. Additionally, we recommend to take a look at the demo notebooks which are available for download at http://www.analog−insydes.de/demos2.html There you will find a number of different problems and tasks from the field of electrical engineering and how to solve them using Analog Insydes 2. 1. A Short Introduction 12 Once you have loaded Analog Insydes into the Mathematica kernel you can obtain detailed information concerning your local Analog Insydes installation by means of the following commands: ReleaseInfo[AnalogInsydes] ReleaseNumber[AnalogInsydes] prints information about your Analog Insydes license type returns the release number of your Analog Insydes installation License[AnalogInsydes] returns your Analog Insydes license number Version[AnalogInsydes] prints a detailed description of your Analog Insydes version Info[AnalogInsydes] prints the location of your Analog Insydes installation and the list of loaded init files Obtaining Analog Insydes release information. If you encounter any bug in Analog Insydes, please send a bug report to: analog.insydes@itwm.fhg.de When reporting problems, please proceed as follows: Evaluate all commands in a Mathematica notebook until your problem occurs and describe it as detailed as possible. Whenever possible, print Netlist and Circuit objects as well as DAEObjects in InputForm . Afterwards, please add the information concerning your Analog Insydes installation by evaluating each of the following commands in separate cells of the Mathematica notebook and attach this notebook to your problem report: $VersionId $Path $LicenseID ReleaseInfo[AnalogInsydes] Version[AnalogInsydes] License[AnalogInsydes] Info[AnalogInsydes] Please be sure to evaluate the commands after your problem occurs, because otherwise some modules might not be loaded during the evaluation of Version[AnalogInsydes] . If possible, attach additional data such as netlist or data files to the email as well. 1.2.3 An Example Application This example describes the standard way how to use Analog Insydes. It can easily be adapted to different analysis tasks and applications. The usage of many different commands, from netlist import to linear simplification techniques, is explained and cross references are given where to find more information. Reading this section should give you a first overview of the capabilities of Analog Insydes. 1.2 Getting Started 13 Analysis Task Following, we want to analyze the ΜA741 operational amplifier. The task is to find an interpretable symbolic formula for the corner frequency of the small-signal voltage transfer function. This is useful to identify those circuit elements and parasitics, which have a dominant influence on it. In addition, the symbolic transfer function can be utilized for further investigation, such as the extraction of its poles and zeros, to find methods for the compensation of certain effects. Importing Schematics To import the schematics picture of the operational amplifier, we use the Analog Insydes command DXFGraphics (Section 3.13.2). This command translates two-dimensional DXF data into Mathematica graphics objects which can be displayed in a Mathematica notebook. Most schematics entries of commercial circuit simulators support the export of schematics in DXF format. DXFGraphics allows for importing your schematics into Mathematica for documentation purposes. Before using DXFGraphics , of course we have to load the Analog Insydes master package as described in Section 1.2.2. In[1]:= <<AnalogInsydes‘ In[2]:= DXFGraphics["AnalogInsydes/DemoFiles/OP−741.dxf"] + - + - 5 Vic Vos 0 1 + 4 Q8 Q9 QPNP741 QPNP741 Vid 2 Q1 QNPN741 QNPN741 6 Q3 QPNP741 Q12 Q131 QPNP741 QPNP741 Q132 QPNP741 Q15 R5 40k 7 Q4 QPNP741 Q14 22 16 Q2 QNPN741 Q18 QNPN741 Q19 QNPN741 17 23 R10 R6 27 C1 30p V1 25 V 26 R13 1k R7 Q21 22 QPNP741 27 Q222 24 Q20 Q221 8 Q7 QNPN741 9 R12 QPNP741 18Q16 QNPN741 QPNP741 QPNP741 15 Q11 Q17 300 Q10 Q5 Q6 QNPN741 QNPN741 QNPN741 QNPN741 19 QNPN741 10 20 21 Q23 11 12 QNPN741 14 R8 R3 R2 R4 Q24 R9 QNPN741 R1 R11 50k 1k 5k 50k 100 1k 50k 3 + - QNPN741 0 0 50k + - V2 13 Out[2]= Graphics DXFGraphics provides many options for altering the appearance of imported DXF files. They are described in Section 3.13.2. Importing Netlist Data For the application of symbolic analysis, especially symbolic approximation, the next step is to generate a netlist including the numerical reference information. The netlist of the operational amplifier ΜA741 consists of 45 elements. Writing the complete circuit in the Analog Insydes netlist language (which is described in Chapter 2.2 and Chapter 2.3) by hand would be a tedious and error-prone task. Therefore, Analog Insydes provides the command ReadNetlist (Section 3.10.1), which auto- 1. A Short Introduction 14 matically translates an external netlist description into the Analog Insydes netlist format. You can import netlists written for or generated by PSpice, Eldo, and Saber. The first argument to ReadNetlist is the simulator input file. Since this file (*.cir in our case) only contains the numerical values of the elements, the operating-point information and the values for the small-signal parameters of the transistors have to be extracted from the simulator output file (*.out in our case). This is performed automatically by ReadNetlist , too. All we have to do is specifying the corresponding simulator output file as second argument. In[3]:= op741 = ReadNetlist[ "AnalogInsydes/DemoFiles/OP−741.cir", "AnalogInsydes/DemoFiles/OP−741.out", Simulator −> "PSpice", KeepPrefix −> False] Out[3]= Circuit As the syntax of external netlist files varies for each simulator, you have to specify from which external format you are reading by means of the Simulator option of ReadNetlist . The return value of ReadNetlist is a Circuit object which contains symbolic values for each netlist element as well as the corresponding numerical reference information. By default, the Circuit object is displayed as a single line in your output cell. To view the complete netlist apply the command DisplayForm to the Circuit object (we will not evaluate the command since the output is too big to be shown here): DisplayForm[op741] Additionally, you can use the command Statistics (Section 3.6.17) to get an impression of the circuit complexity. This command prints the number of different element types occuring in the circuit. In[4]:= Statistics[op741] Number of Resistors : 13 Number of Capacitors : 1 Number of VoltageSources : 5 Number of models BJT/QNPN741 : 15 Number of models BJT/QPNP741 : 11 Total number of elements : 45 Setting Up Circuit Equations Once the netlist is imported, the next step is to set up the symbolic circuit equations. In Analog Insydes this can be done automatically using the command CircuitEquations (Section 3.5.1). The Analog Insydes netlist read by ReadNetlist contains generic model references for each transistor and does not specifiy a concrete model implementation. Thus, we have to instruct Analog Insydes which model to use during equation setup by means of the option ModelLibrary . Analog Insydes comes with a predefined SPICE-compatible, symbolic model library in three different complexity levels called "FullModels‘" , "SimplifiedModels‘" , and "BasicModels‘" (the implemented models are explained in detail in Chapter 4.3. For special tasks the model library can be extended by the user; this topic is discussed in Chapter 2.3). In the following, we choose a complexity-reduced BJT model 1.2 Getting Started 15 from the Analog Insydes model library by setting the option ModelLibrary −> "BasicModels‘" . Note that a quote mark ("‘") is following the word BasicModels . In[5]:= mnaAC741 = CircuitEquations[op741, ElementValues −> Symbolic, ModelLibrary −> "BasicModels‘"] Out[5]= DAEAC, 33 33 The additional option ElementValues −> Symbolic tells Analog Insydes to set up equations using the symbolic element values instead of the numerical ones. By default, CircuitEquations sets up small-signal equations in matrix formulation, but DC or transient equations can be set up, too. See Section 3.5.1 and Chapter 2.4 for details. CircuitEquations returns a DAEObject which contains the equation system as well as additional data which is used and extracted automatically by other Analog Insydes commands. As for Circuit objects, a DAEObject is printed in short notation only and can be displayed using DisplayForm (we once more omit evaluating the command since the equation system is too big to be printed here): DisplayForm[mnaAC741] Again, you can use Statistics (Section 3.6.17) to get an impression of the equation size. In[6]:= Statistics[mnaAC741] Number of equations : 33 Number of variables : 33 Number of entries : 1089 Number of non−zero entries : 171 Complexity estimate : 1.6e21 Importing Simulation Data When using netlists from external simulators we always have to verify that the models used during equation setup are compatible to the ones used by the simulator. This is done by comparing the numerical solution calculated by the external simulator with the solution calculated by Analog Insydes. If both solutions do not coincide within a tolerable error range, we have to go back one step and choose different models during equation setup before going on with the symbolic analysis. To simplify this procedure, Analog Insydes provides the command ReadSimulationData (Section 3.10.3) for importing numerical data generated by an external simulator. As for ReadNetlist we have to specify from which format we are reading by means of the Simulator option. The list of supported formats is shown in Section 3.10.1. In[7]:= op741data = ReadSimulationData[ "AnalogInsydes/DemoFiles/OP−741.csd", Simulator −> "PSpice"] Out[7]= V26 InterpolatingFunction0.1, 1. 106 , ReadSimulationData returns the result according to the Analog Insydes numerical data format which is described in Section 3.7.1. It consists of a list of rules, where the variables (which are returned as strings) are assigned InterpolatingFunction objects. 1. A Short Introduction 16 Graphically Displaying Simulation Data We can use Mathematica’s ReplaceAll operator (or /. in short notation) to extract a single interpolating function from the numerical data and assign it to a new variable. In[8]:= vout741PSpice = "V(26)" /. First[op741data] Out[8]= InterpolatingFunction0.1, 1. 106 , The variable vout741PSpice now contains the numerical data for the output voltage at node 26. Its waveform can be graphically displayed in a Bode diagram using the function BodePlot (Section 3.9.1). In[9]:= BodePlot[vout741PSpice[f], {f, 0.1, 10^6}] Magnitude (dB) 1.0E-1 1.0E3 1.0E5 1.0E1 1.0E3 Frequency 1.0E5 1.0E1 1.0E3 1.0E5 1.0E1 1.0E3 Frequency 1.0E5 80 60 40 20 0 1.0E-1 1.0E-1 0 Phase (deg) 1.0E1 100 -20 -40 -60 -80 1.0E-1 Out[9]= Graphics Analog Insydes provides several standard graphic functions for visualizing numerical analysis results, see Chapter 2.5 and Chapter 3.9. Performing Reference Simulation A numerical reference simulation is performed applying the Analog Insydes function ACAnalysis (Section 3.7.3) in the frequency range of interest. The first argument of ACAnalysis is the DAEObject created by CircuitEquations , which contains the system of equations. The second argument denotes the output variable to solve for. We are interested in the node voltage at node and according to the automatic naming mechanism (which is described in Section 2.4.1) the corresponding variable is called V$26. In[10]:= reference = ACAnalysis[mnaAC741, V$26, {f, 0.1, 10^6}] Out[10]= V$26 InterpolatingFunction0.1, 1. 106 , Next, the frequency response calculated with Analog Insydes and the simulation data imported from PSpice are compared graphically, using the capability of the command BodePlot to display several transfer functions within one plot. 1.2 Getting Started 17 In[11]:= BodePlot[reference, {vout741PSpice[f], V$26[f]}, {f, 0.1, 10^6}, ShowLegend −> False] Magnitude (dB) 1.0E-1 1.0E3 1.0E5 1.0E1 1.0E3 Frequency 1.0E5 1.0E1 1.0E3 1.0E5 1.0E1 1.0E3 Frequency 1.0E5 80 60 40 20 0 1.0E-1 1.0E-1 0 Phase (deg) 1.0E1 100 -20 -40 -60 -80 1.0E-1 Out[11]= Graphics The curves match perfectly in the frequency range of interest. Hence, the simplified BJT model is sufficient for being used in the next step of the symbolic analysis flow. Calculating the Complexity of the Symbolic Transfer Function Recall that the task is to calculate the symbolic transfer function in order to extract a formula for the corner frequency. Thus, at this point it is useful to estimate the complexity of the symbolic transfer function to find out whether the number of its terms is manageable. This can be done with the help of the function ComplexityEstimate (Section 3.11.1). In[12]:= ComplexityEstimate[mnaAC741] // N Out[12]= 1.61868 1021 ComplexityEstimate returns an integer value. We use Mathematica‘s N operator to transform this integer into a real number. The result shows that the number of terms forming the fully expanded symbolic transfer function is greater than and thus too large to be handled. Therefore, we will now apply a routine which removes all those terms whose influence on the behavior of the transfer function is negligible. This drastically reduces the complexity. Setting Up Circuit Equations for Approximation To prepare the simplification process we set up the system of circuit equations again. As against the previous call to the function CircuitEquations , where the circuit equations were given in the modified nodal analysis format, they are set up in sparse tableau formulation this time. Sparse tableau is the preferred equation formulation when performing linear approximation tasks. Details about the Formulation option are given in Section 3.5.1. 1. A Short Introduction 18 In[13]:= staAC741 = CircuitEquations[op741, ElementValues −> Symbolic, Formulation −> SparseTableau, ModelLibrary −> "BasicModels‘"] Out[13]= DAEAC, 402 402 The returned equation system is a DAEObject with equations and variables. In[14]:= Statistics[staAC741] Number of equations : 402 Number of variables : 402 Number of entries : 161604 Number of non−zero entries : 1392 Complexity estimate : 1.6e21 Although this sparse tableau system is more than 10 times bigger than the modified nodal system, it usually produces better approximation results. Performing Matrix Approximation Now we call the matrix approximation routine on the symbolic circuit equations of the ΜA741 circuit. This routine simplifies the equations based on numerical constraints with respect to a given output variable. The required information is provided in form of several sampling points, specified in combination with a maximum error constraint each. The approximation routine then processes the matrix such that the sought output function is located within the defined error range around the given sampling points. For further information please refer to Section 3.11.3. To capture the first corner frequency, we place sampling points at Hz and at Hz with a maximum error of each. In[15]:= samplingpoints = {{s −> 2. Pi I 1., MaxError −> 0.3}, {s −> 2. Pi I 10., MaxError −> 0.3}} Out[15]= s 6.28319 I, MaxError 0.3, s 62.8319 I, MaxError 0.3 With the given setup, the approximation routine can be called. The computation is carried out with respect to the output voltage across the load resistor R13, which in this case is equivalent to the sought transfer function. Again, based on the automatic naming scheme (Section 2.4.1), the corresponding variable is called V$R13 (note that sparse tableau equations consist of branch voltages instead of node voltages). In[16]:= op741approx = ApproximateMatrixEquation[staAC741, V$R13, samplingpoints] Out[16]= DAEAC, 402 402 1.2 Getting Started 19 In[17]:= Statistics[op741approx] Number of equations : 402 Number of variables : 402 Number of entries : 161604 Number of non−zero entries : 455 Complexity estimate : 14 As another call to the function Statistics shows, the approximation routine could considerably reduce the complexity of the DAEObject (i.e. the number of non-zero entries), although its equation size did not change. With just a small number of terms remaining, a symbolic computation of the transfer function is now possible. Calculating the Transfer Function To calculate the transfer function, we now solve the approximated system of equations for the output voltage: In[18]:= approximation = Solve[op741approx, V$R13] Out[18]= V$R13 gm$Q1 gm$Q16 gm$Q17 gm$Q2 gm$Q3 2 gm$Q4 gm$Q5 R9 Ro$Q131 Ro$Q17 Ro$Q4 Rpi$Q16 Rpi$Q17 VID gm$Q3 gm$Q1 gm$Q2 gm$Q1 gm$Q4 gm$Q5 Ro$Q131 Ro$Q17 gm$Q16 gm$Q17 R8 R9 Ro$Q4 Rpi$Q16 Rpi$Q17 Ro$Q4 R9 Ro$Q4 gm$Q17 R8 Ro$Q4 Rpi$Q17 C1 gm$Q16 gm$Q17 gm$Q3 gm$Q1 gm$Q2 gm$Q1 gm$Q4 gm$Q5 R9 2 Ro$Q131 Ro$Q17 Ro$Q4 Rpi$Q16 Rpi$Q17 s Again, we use Mathematica’s ReplaceAll operator to extract the calculated solution and assign it to a new variable. In[19]:= vout741 = V$R13 /. First[approximation] // Simplify Out[19]= gm$Q16 gm$Q17 gm$Q2 gm$Q4 R9 Ro$Q131 Ro$Q17 Ro$Q4 Rpi$Q16 Rpi$Q17 VID gm$Q2 gm$Q4 gm$Q17 R8 Ro$Q131 Ro$Q17 Ro$Q4 Rpi$Q17 R9 Ro$Q17 Ro$Q4 gm$Q16 gm$Q17 R8 Rpi$Q16 Rpi$Q17 Ro$Q131 Ro$Q4 gm$Q16 gm$Q17 R8 Rpi$Q16 Rpi$Q17 C1 gm$Q16 gm$Q17 Ro$Q17 Ro$Q4 Rpi$Q16 Rpi$Q17 s This expression now represents the approximated symbolic transfer function of the ΜA741 circuit. It contains only those circuit elements and parasitics that were not removed by the matrix approximation routine. Thus, they have been identified as those elements, which have a major influence on the behavior of the transfer function. Verifying Approximation Results The quality of the approximation can be determined by performing a numerical comparison between the simplified transfer function and the data imported from the numerical simulator (PSpice in this case). Therefore, we need to extract the design point from the DAEObject first using the command 1. A Short Introduction 20 GetDesignPoint (Section 3.6.12). The design point specifies those numerical values for each one of the circuit elements that were given in the netlist. In[20]:= designpoint = GetDesignPoint[staAC741] Out[20]= Rpi$Q1 755999.9999999999, Ro$Q1 2.19 107 , Cbc$Q1 3.7 1013 , Cbe$Q1 1.47 1012 , gm$Q1 0.00029, Cbx$Q1 0., Rpi$Q2 753000., Ro$Q2 2.18 107 , Cbc$Q2 3.7 1013 , Cbe$Q2 1.47 1012 , gm$Q2 0.000291, Cbx$Q2 0., Rpi$Q3 218999.9999999999, Ro$Q3 8.46 106 , Cbc$Q3 3.85 1013 , Cbe$Q3 1.42 1012 , gm$Q3 0.000287, Cbx$Q3 0., Rpi$Q4 216999.9999999999, Ro$Q4 8.4 106 , Cbc$Q4 3.87 1013 , Cbe$Q4 1.42 1012 , gm$Q4 0.0002879999999999999, Cbx$Q4 0., Rpi$Q5 704999.9999999999, Ro$Q5 2.04 107 , Cbc$Q5 8.28 1013 , Cbe$Q5 1.47 1012 , gm$Q5 0.000285, Cbx$Q5 0., Rpi$Q6 704999.9999999999, Ro$Q6 2.04 107 , Cbc$Q6 7.93 1013 , Cbe$Q6 1.47 1012 , gm$Q6 0.000285, Cbx$Q6 0., Rpi$Q7 533000., Ro$Q7 1.55 107 , Cbc$Q7 2.97 1013 , Cbe$Q7 1.48 1012 , gm$Q7 0.0004469999999999999, Cbx$Q7 0., Rpi$Q8 89499.99999999999, 86, Cbe$Q19 1.57 1012 , gm$Q19 0.00787, Cbx$Q19 0., Rpi$Q20 5809.999999999999, Ro$Q20 225000., Cbc$Q20 1.11 1012 , Cbe$Q20 4.48 1012 , gm$Q20 0.0111, Cbx$Q20 0., Rpi$Q21 3.34 1013 , Ro$Q21 6.24 1011 , Cbc$Q21 3.66 1013 , Cbe$Q21 1. 1012 , gm$Q21 3.43 1013 , Cbx$Q21 0., Rpi$Q24 1.86 1014 , Ro$Q24 9.28 1011 , Cbc$Q24 1. 1012 , Cbe$Q24 1. 1012 , gm$Q24 3.77 1018 , Cbx$Q24 0., Rpi$Q23 1.86 1014 , Ro$Q23 9.82 1011 , Cbc$Q23 7.13 1013 , Cbe$Q23 1. 1012 , gm$Q23 6.91 1014 , Cbx$Q23 0., C1 3. 1011 , Rpi$Q222 7549.999999999999, Ro$Q222 291999.9999999999, Cbc$Q222 3.75 1013 , Cbe$Q222 1.52 1012 , gm$Q222 0.008449999999999999, Cbx$Q222 0., Rpi$Q221 5. 1013 , Ro$Q221 7.67 1011 , Cbc$Q221 3.75 1013 , Cbe$Q221 3.88 1013 , gm$Q221 2.68 1014 , Cbx$Q221 0., R13 1000., VID 1., Simulator PSpice The numerical representation of the approximated transfer function depending on the Laplace variable s is now found by applying the numerical design point data to the symbolic transfer function. In[21]:= vout741N[s_] = vout741 /. designpoint // Simplify 7.32152 1022 Out[21]= 2.90287 1017 1.51745 1016 s Another Bode plot shows the PSpice simulation data compared with the approximated numeric transfer function in the frequency range from Hz to MHz. 1.2 Getting Started 21 In[22]:= BodePlot[{vout741PSpice[f], vout741N[2. Pi I f]}, {f, 0.1, 10^6}, ShowLegend −> False] Magnitude (dB) 1.0E-1 1.0E3 1.0E5 1.0E1 1.0E3 Frequency 1.0E5 1.0E1 1.0E3 1.0E5 1.0E1 1.0E3 Frequency 1.0E5 80 60 40 20 0 1.0E-1 1.0E-1 0 Phase (deg) 1.0E1 100 -20 -40 -60 -80 1.0E-1 Out[22]= Graphics It is apparent that although the number of terms occuring in the transfer function has been reduced from almost to (!), the curves still match perfectly in the frequency range of interest. Therefore, the approximation is qualified to replace the actual transfer function for further computations. Further Processing From the approximated transfer function we can now extract additional information, such as the calculation and graphical representation of its poles and zeros. The poles of the approximated symbolic transfer function can be found by calculating the zeros of its denominator. In[23]:= poles1 = Solve[Denominator[vout741] == 0, s] // Simplify Out[23]= s Ro$Q131 Ro$Q17 gm$Q17 R8 Ro$Q4 Rpi$Q17 R9 Ro$Q4 gm$Q16 gm$Q17 R8 Rpi$Q16 Rpi$Q17 C1 gm$Q16 gm$Q17 R9 Ro$Q131 Ro$Q17 Ro$Q4 Rpi$Q16 Rpi$Q17 This single pole of the approximated transfer function corresponds to the dominant pole of the original transfer function. To achieve its value, we have to insert the given design-point information. In[24]:= p1 = poles1 /. designpoint Out[24]= s 19.1299 We now verify the above result by computing the exact pole locations, employing the function PolesByQZ (Section 3.8.4) on the original equation system. 1. A Short Introduction 22 In[25]:= poles = PolesByQZ[mnaAC741] Out[25]= 4.19822 1010 , 3.02054 1010 , 3.97873 107 7.96404 107 I, 3.97873 107 7.96404 107 I, 6.47642 106 , 8.33125 107 1.17 108 I, 8.33125 107 1.17 108 I, 2.53983 108 , 2.04133 108 , 2.02066 108 , 3.85479 108 , 6.26147 108 , 8.75148 108 , 19.5077, 9.68714 108 , 1.2364 109 , 2.15863 109 6.82302 108 I, 2.15863 109 6.82302 108 I, 2.63327 109 , 7.93728 109 , 9.89724 109 , 1.58287 1010 , 1.46898 1010 Now we sort the poles in ascending order of their absolute values. In[26]:= Sort[poles, Abs[#1] < Abs[#2] &] Out[26]= 19.5077, 6.47642 106 , 3.97873 107 7.96404 107 I, 3.97873 107 7.96404 107 I, 8.33125 107 1.17 108 I, 8.33125 107 1.17 108 I, 2.02066 108 , 2.04133 108 , 2.53983 108 , 3.85479 108 , 6.26147 108 , 8.75148 108 , 9.68714 108 , 1.2364 109 , 2.15863 109 6.82302 108 I, 2.15863 109 6.82302 108 I, 2.63327 109 , 7.93728 109 , 9.89724 109 , 1.46898 1010 , 1.58287 1010 , 3.02054 1010 , 4.19822 1010 This yields a list, whose first entry represents the equivalent to the numerical solution which was found before with the help of the approximated transfer function. Since both values match well, this is another indication that the extracted formula for the pole indeed describes the dominant pole of the operational amplifier. For further insights, there are various graphics functions available to visualize the extracted information, such as the functions RootLocusPlot (Section 3.9.5) or NyquistPlot (Section 3.9.4). For details please refer to the respective sections. Conclusion This example showed the application of Analog Insydes on the analysis of the ΜA741 operational amplifier for extracting a formula for the corner frequency of the small-signal transfer function. In a first step we imported the netlist and simulation data files from PSpice, set up the equations in Analog Insydes and verified the numerical solution. A complexity estimation showed that calculating the transfer function for the original equation system is not possible, thus we applied an approximation routine to achieve a simplified equation system. Using this system it was possible to symbolically calculate its transfer function. Finally, we achieved a symbolic formula describing the pole of the simplified transfer function and the dominant pole of the original transfer function. An additional comparison of the numerical pole values showed that indeed the formula represents the dominant pole. This symbolic formula now provides deeper insight into the corner frequency location. 1.2 Getting Started 23 1.2.4 The Online Help System Because Analog Insydes is a complex system, it comes with a detailed online documentation: For quick information, a compact help text is available for each Analog Insydes symbol. This text can be displayed using the Mathematica ? operator (which is also called Information ). For Analog Insydes commands, the purpose and function patterns are printed, for Analog Insydes options, the purpose and possible values are given. For example: Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Get help text for the command LoadModel . In[2]:= ?LoadModel LoadModel[name, selector] or LoadModel[{{name1, selector1}, ...}] loads one or several models from the model library. LoadModel[name, selector, Scope −> scope] assigns local or global scope to the loaded model. Get help text for the option Protocol . In[3]:= ?Protocol Protocol is a global Analog Insydes option used by several functions. It specifies if and where protocols should be printed. Option values are StatusLine, Notebook, All, or None, or a list of these symbols. For more detailed information, the complete Analog Insydes documentation including tutorial and appendix is available in the standard Mathematica online help system. Launch the help browser and select the category Add-ons. In the left column then appears a row labeled Analog Insydes. By choosing this item you enter the Analog Insydes online documentation. For searching a certain keyword, select the Master Index category and type the keyword in the Go To: field. One or more hyperlinks to corresponding sections in the Analog Insydes documentation will then be given. Note that for the documentation to appear in the help browser, Analog Insydes has to be properly installed on your system and the help index has to be recalculated. For the latter choose the menu item Help->Rebuild Help Index. 1.2.5 The Analog Insydes Palette Analog Insydes provides a palette window which allows you to enter nearly all Analog Insydes commands by simply pressing a button. The palette is divided into subgroups which can be opened by clicking on the triangle symbol. Clicking on a button pastes the corresponding text into your session notebook. Clicking on a button marked with a blue star pastes a more complex skeleton into your notebook. The status line of the palette window indicates which skeleton is pasted. 1. A Short Introduction 24 The Analog Insydes palette By choosing the menu item File->Palettes->AnalogInsydes you launch the Analog Insydes palette window. Alternatively, you can find the Analog Insydes palette in the file aidir/FrontEnd/Palettes/AnalogInsydes.nb of your Analog Insydes installation. Use the command Info (Section 3.15.6) to obtain the path of your Analog Insydes installation directory. 1.3 What’s New? 25 1.3 What’s New? Since the first release in 1998, Analog Insydes has been successfully applied to real-world problems by our customers. The key algorithms implemented in Analog Insydes – particularly the symbolic approximation methods – proved to be very effective, but it turned out that improvements regarding tool functionality, user-friendliness, interfaces, processing speed, and the device model library would be desirable. After three years of development, here is the result: Analog Insydes Version 2. This chapter guides you through the most noticable enhancements of the new version. 1.3.1 New Features: An Overview New Interfaces for PSpice, Eldo, and Saber Netlist import including small-signal and model-card parameters Behavioral model writer Simulation data import and export New Device Model Library PSpice and Eldo compatible models for R, L, C, D, BJT, MOS, and JFET BJT: full Gummel-Poon small-signal and large-signal models MOS: full Level 1-3 + BSIM3v3 small-signal models, Level 1 large-signal model Extended Circuit Description and Modeling Language Model parameter sets, global parameters, multiple source values Enhanced modeling language for nonlinear dynamic systems Improved Circuit Equation Setup Automatic model library search Automatic design-point extraction for linear and nonlinear circuits Consistent data handling through DAEObjects New and Improved Analysis Modes AC, noise, pole/zero, DC, DC transfer, temperature, transient, parametric, root locus 1. A Short Introduction 26 New and Improved Symbolic Approximation Techniques New and improved linear approximation techniques for AC and pole/zero analysis New approximation techniques for nonlinear circuits Full Integration of High-Performance MathLink Binaries For symbolic matrix approximation and numerical pole/zero analysis (QZ algorithm) Multi-platform support (Solaris, Linux, HP-UX, Windows) Graphics Functions New and improved graphics functions Improved command interfaces for a more comfortable use Improved User Interface Improved user interface allows for setting up and running circuit analyses from PSpice, Eldo, or Saber netlists with as few as three Analog Insydes commands 1.3.2 New Features: A More Detailed Description The most noticeable changes between Analog Insydes versions 1 and 2 were made to the circuit description and modeling language and to the way circuit equations are set up, stored, and presented to the user: Netlist Format The circuit description language (netlist format) was extended by functionality for managing device model parameter sets (model cards), global parameter settings, initial conditions, and multiple source values for different analysis modes (AC, DC, transient). With these enhancements it is now possible to represent all netlist and device model information contained in a SPICE circuit description consistently in an Analog Insydes Circuit object. The netlist fragment shown below illustrates the use of some new language features. Note that the unspecific arguments of the keywords Model, Selector, and Parameters in the value field of the device reference Q1 permit an easy selection of device models and parameter sets at run time using Mathematica’s pattern rewriting functionality. The model expansion mechanism of Analog Insydes 2 makes use of this approach to automatically select appropriate device models according to the specified analysis mode. 1.3 What’s New? Analog Insydes 2 netlist fragment 27 amplifier = Circuit[ Netlist[ {V1, {1, 0}, Symbolic −> V1, Value −> {AC −> 1, DC −> 2.5, Transient−>SinWave[Time, 2.5, 0.1, 1000]}}, {Q1, {2 −> C, 1 −> B, 3 −> E}, Model−>Model[BJT, NDEF, Q1], Selector −> Selector[BJT, NDEF, Q1], Parameters −> Parameters[BJT, NDEF, Q1], GM$ac −> 0.02, RPI$ac −> 5.0*10^3, }, ], ModelParameters[Name −> NDEF, Type −> NPN, IS −> 10^−16, BF −> 100, BR −> 1, VAF −> 150], GlobalParameters[TEMP −> 300, GMIN −> 10^−12] ] Circuit Equations In Analog Insydes 1, symbolic circuit equations and corresponding numerical information (design point, initial conditions, etc.) were not handled in a consistent fashion. To prevent errors due to potentially inconsistent data and to provide a unified and more user-friendly mechanism for managing all additional data associated with a system of symbolic circuit equations, the internal representation of circuit equations was fundamentally changed in version 2. Now, all equation setup and circuit analysis functionality is centered around a common data structure, the DAEObject. A DAEObject is generated by means of the command CircuitEquations . It represents a linear or nonlinear system of differential-algebraic equations (DAE) along with numerical data needed for numerical analysis or symbolic approximation. In addition, a DAEObject contains information about the type of equations it represents (AC/DC/transient, MNA/STA) plus a snapshot of all relevant option settings taken at the point of time when the equations were set up. This data encapsulation approach ensures the consistency of all data belonging to a particular circuit analysis context and reduces the number of parameters that need to be passed to functions which operate on circuit equations. Interfaces Analog Insydes 2 provides several new or improved modules for interfacing with commercial circuit design environments. Platform-independent netlist converters with small-signal data and modelcard import functionality are now available for a variety of widely used circuit simulators, including PSpice, Saber, and Eldo. Waveforms can be imported from PSpice, Saber, and Eldo data files. Circuit schematics can be imported into Mathematica via a DXF file converter. Moreover, Analog Insydes 2 features a model writer which is capable of generating behavioral model templates (e.g. Saber MAST) automatically from a DAEObject. 28 1. A Short Introduction Modeling Language As a consequence of the requirements identified during recent work on symbolic modeling and analysis of nonlinear circuits, the behavioral modeling capabilities for nonlinear dynamic systems were substantially extended. With the enhanced model description format of Analog Insydes 2, it is now possible to designate model port nodes as optional, to specify default values for model parameters as well as initial conditions and guesses for model variables, and to control how design-point information is generated for symbolic parameters of model equations. Library Concept Based on the modeling language extensions described above, a completely new device model library concept was designed for Analog Insydes 2. PSpice and Eldo compatible models are available for R, L, C, D, BJT, MOS, and JFET devices. Three model simplification levels can be selected when setting up circuit equations to control the complexity of symbolic analysis. Nonlinear Symbolic Analysis Completely new functionality has been implemented for symbolic analysis and approximation of nonlinear circuits. Based on a flexible user interface, the approximation routines allow an arbitrary choice of analysis and error-control functions. In combination with the new model writer, Analog Insydes 2 can be used for automated generation of nonlinear behavioral models. Pole/Zero Analysis Efficient numerical pole/zero and root locus analysis is now supported through two different generalized eigenvalue problem solvers: an enhanced version of the QZ algorithm and a variant of the Jacobi orthogonal correction method (JOCM). The introduction of the DAEObject concept reduces the amount of parameters passed to functions. In addition, a new matrix-based method for symbolic pole/zero analysis has been implemented. The algorithm simplifies a symbolic generalized eigenvalue problem with respect to a selected root, using the JOCM for efficient iterative error tracking. User Interface The use of Analog Insydes 2 has been considerably simplified by combining many frequently used steps in powerful macro commands and providing more default actions. With as few as three Analog Insydes commands it is possible to set up and run circuit analyses from PSpice, Eldo, or Saber netlists. In addition, the external binaries (QZ algorithm, matrix approximation) have been fully integrated into Analog Insydes 2 and can be used transparently like built-in commands. 1.3 What’s New? 29 Multi-Platform Support Multi-platform support is available for all binaries: One Analog Insydes installation can be accessed from different platforms. Transparently for the user the correct binaries are automatically chosen. This allows for installing Analog Insydes on a site-wide file server and simultaneously using it from different platforms. 1.3.3 Compatibility To realize the improvements made in version 2 of Analog Insydes, drastic changes on the internal data format had to be performed, such that we could not keep 100% compatibility with version 1. As a consequence, version 1 notebooks may not evaluate without errors using Analog Insydes 2. But fortunately, only some minor changes (like modifying function arguments) are usually sufficient to evaluate with version 2. These changes are listed below. ApproximateMatrixEquation altered pattern according to ApproximateTransferFunction former option PrintProtocol now called Protocol, option values changed CircuitEquations option DefaultModelLibrary now called ModelLibrary option DifferentialOperator now called FrequencyVariable option setting SparseTableauVariant −> Basic | Extended now obtained by Formulation −> SparseTableau | ExtendedTableau option setting SymbolicValues −> True | False now obtained by ElementValues −> Symbolic | Value option setting TimeDomain −> True | False now obtained by AnalysisMode −> Transient | AC option UnitValues is obsolete CSDFRead former command CSDFRead substituted by new implementation called ReadSimulationData DXFGraphics option FillColor now called FillColors , option values modified options LineThickness , LineAbsoluteThickness , PolylineWidthScale , PrimitivesOut , TextOffsetX , TextOffsetY , and TextAlignBottom are obsolete 1. A Short Introduction 30 NDAESolve, NDAESolveDC former command NDAESolveDC substituted by additional pattern for NDAESolve option AnalysisMethod now called AnalysisMode modified values for option Protocol RootLocusPlot modified values for options PoleStyle and ZeroStyle SolveCircuitEquations former command SolveCircuitEquations substituted by Solve spice2ai.exe, SpiceToAI, WhereIsSpice2ai former external executable spice2ai.exe and wrapper function SpiceToAI substituted by new implementation ReadNetlist options Spice2aiOptions and Spice2aiPath are obsolete command WhereIsSpice2ai is obsolete CheckedCircuit, CheckedNetlist, FlatNetlist replaced by NetlistObject[Checked | Flat] Tutorial 2.1 Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 2.2 Netlists . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 2.3 Circuits and Subcircuits 2.4 Setting up and Solving Circuit Equations . . . . . . . . . . 70 2.5 Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 2.6 Modeling and Analysis of Nonlinear Circuits . . . . . . . . 90 2.7 Time-Domain Analysis of Nonlinear Dynamic Circuits . . 104 2.8 Linear Symbolic Approximation . . . . . . . . . . . . . . 127 2.9 Frequency-Domain Analysis of Linear Circuits . . . . . . 142 . . . . . . . . . . . . . . . . . . . 46 2.10 Nonlinear Symbolic Approximation . . . . . . . . . . . . 164 2. Tutorial 32 2.1 Preface 2.1.1 How to Read this Tutorial Whereas Part 3 of this book serves as a reference manual for all Analog Insydes commands, Part 2 explains dedicated topics of Analog Insydes in a tutorial manner. Although this part is entitled Tutorial, it is not meant to be read entirely at once by the novice user before working with Analog Insydes. Rather, each chapter can be read separately to get a more detailed insight into the corresponding topic. For example, Chapter 2.3 describes how to write your own subcircuits and models and how to use them during equation setup. However, in the usual application, netlists are imported automatically using the command ReadNetlist , and equations are set up using predefined models of the Analog Insydes model library. Thus, in most cases there is no need to write netlists and models by hand. Nevertheless, you may encounter a task that requires a special hand-written device model. In this case it is recommended to consult Chapter 2.3 (and perhaps Chapter 2.2 as well) to learn more about the fine points of Analog Insydes’ modeling capabilities. For the novice user we recommend to read Chapter 2.4, Chapter 2.5, Chapter 2.7, and Chapter 2.9. 2.1.2 Loading Analog Insydes The first thing we need to do before we can use any circuit analysis function is to load the Analog Insydes master package. This file reads in the context AnalogInsydes‘Main‘ which contains all function definitions for working with netlists. In addition, the master package sets up autoload declarations for other Analog Insydes functions which are not defined in the Main context. Loading of Analog Insydes is performed by evaluating the command <<AnalogInsydes‘ in a Mathematica notebook window. If this command fails then check if your package directory is on Mathematica’s list of search paths. For this, evaluate the expression $Path in a Mathematica notebook and inspect the result. If the path to your Analog Insydes directory is not listed then append it to the list with the command AppendTo[$Path, "your Analog Insydes path"] and re-execute the above command. Besides loading the Analog Insydes context and installig autoloaders, the above command additionally reads several init files which allow for adapting Analog Insydes to your local needs. Section 3.15.1 describes the location of the init files, the loading order, and how to suppress loading of init files. An init file can for example be used to permanently change default values of options. Once Analog Insydes is loaded, you can obtain information on your local Analog Insydes installation using the commands described in Chapter 3.15. 2.2 Netlists 33 2.2 Netlists 2.2.1 The Netlist Format Analog Insydes provides functions which can automatically set up several types of circuit equations from the netlist description of a circuit. Netlists are sequences of Mathematica lists encapsulated by the Analog Insydes command Netlist (Section 3.1.1). There must be one such list, or netlist entry, for each element in a circuit. Netlist entries are not required to be listed in any particular order. netlistname = Netlist[ netlist entry 1, netlist entry 2, ] A Netlist object is the Analog Insydes data structure for representing flat netlists. For hierarchical circuit descriptions using subcircuits, the Circuit object is used which is discussed in Chapter 2.3. For a simple example refer to the voltage divider circuit shown in Figure 2.1. 1 R1 V0 2 R2 Figure 2.1: Voltage divider circuit An Analog Insydes netlist desribing the circuit looks as follows: In[1]:= <<AnalogInsydes‘ In[2]:= voltageDivider = Netlist[ {V0, {1, 0}, 10}, {R1, {1, 2}, R1}, {R2, {2, 0}, R2} ] Out[2]= NetlistRaw, 3 2. Tutorial 34 The Netlist command returns a raw netlist object which prints its content in short notation, i.e. only the number of elements is shown. To get a more detailed view of the netlist content use the command DisplayForm : In[3]:= DisplayForm[voltageDivider] Out[3]//DisplayForm= Netlist Raw, 3 Entries: V0, 1, 0, 10 R1, 1, 2, R1 R2, 2, 0, R2 The netlist entry format (see Section 3.1.3) bears some remote similarity to that of the well-known and widely used numerical circuit simulator SPICE in that circuit elements are specified by an individual name, a list of nodes, and a value. In Analog Insydes, netlist entries must be lists of three fields which are called the reference designator, the connectivity list, and the value field: {reference designator, {connectivity list}, value field} This global scheme describes the only valid syntax for netlist entries – there is no exception to this format. Reference Designators The reference designator is a unique name by which a particular circuit element can be distinguished from all other elements in the same netlist. Typically, the leading one, two, or three characters of a reference designator implicitly determine the type of the corresponding element. Hence, V0 denotes a voltage source (type tag V), R1 and R2 denote resistors (type tag R), and VCCS a voltage-controlled current source (type tag VC). There are mechanisms to override automatic type detection from reference designators explicitly but this and other related advanced topics will be discussed later. Unlike Mathematica variables, type tags are not case sensitive. Therefore, two circuit elements with reference designators R1 and r1 are both recognized as resistors. However, the symbols R1 and r1 represent two entirely different elements. Connectivity Lists and Node Identifiers The connectivity list specifies the nodes of the circuit to which the terminals of an element are connected. For that purpose, every node in a circuit must be given a unique name, a node identifier, by which it can be referenced. While some circuit simulators require the nodes to be enumerated by consecutive nonnegative integers, Analog Insydes lets you choose node identifiers quite freely. You do not have to number your nodes consecutively, nor do you need to use numbers as node identifiers at all. In addition to nonnegative integers, you may also use symbols or strings as node labels. The only requirement is that the circuit’s ground node must be identified by the label 0 (zero). Internally all node identifiers are converted to strings. Thus, the node identifiers OUT and "OUT" refer to the same node. Moreover, node identifiers are case sensitive. Thus, OUT and Out refer to different nodes. 2.2 Netlists 35 out1 4 1 V1 R gm*V1 6 2 out2 Figure 2.2: Resistor and voltage-controlled current source For a two-terminal element, such as a resistor (Section 4.2.1), the connectivity list must contain exactly two node identifiers whereas a controlled source, i.e. a four-terminal element, requires four node identifiers: two for the controlling branch and two for the controlled branch. Netlist entries for the resistor and the voltage-controlled current source (Section 4.2.13) shown in Figure 2.2 thus have to be written as follows: {R1, {1, 2}, R} {VC2, {4, 6, out1, out2}, gm} Reference Directions for Currents and Voltages In Analog Insydes netlists, the order of the nodes in a connectivity list determines the positive reference direction for both the associated branch voltage and the branch current. In other words, the reference directions for voltages and currents always have the same orientation. 1 I$V0 V0 2 Figure 2.3: Voltage source, reference directions for branch voltage and current In Figure 2.3, the positive terminal of the voltage source (Section 4.2.10) is connected to node 1, and the negative terminal is connected to node 2. The corresponding netlist entry then defines the positive reference direction for the branch voltage as well as for the current I$V0 to be oriented from node 1 to node 2: 2. Tutorial 36 {V0, {1, 2}, V0} Hence, a positive value for the branch current, I$V0 , denotes a current flowing from node 1 to node 2. So whenever a circuit analysis yields a negative result for I$V0 there is nothing wrong. This just means that the current is in fact flowing into the opposite direction, i.e. from node 2 to node 1. Element Values As opposed to SPICE, the values of circuit elements need not be purely numerical quantities. Since Mathematica is capable of performing mathematical calculations symbolically, the element values may also be any symbolic or mixed symbolic/numeric expressions. In the voltage-divider example (see Figure 2.1) we assigned a numerical value of 10 (Volts) to the voltage source whereas we used the symbolic values R1 and R2 for the two resistors. (Note that you don’t have to specify any units like Volts for numerical values.) In this case, the symbols used for the values of the resistors are identical to the reference designators, but we could also have supplied any other valid Mathematica expression. 1 R1=R V0 out R2=2*R Figure 2.4: Voltage divider circuit with different node names and resistor values Let’s make use of some of the facts presented in the preceding paragraphs by renaming node 2 of the voltage divider to out, arbitrarily making the assignments R1 R and R2 R, and rewriting the netlist accordingly (see Figure 2.4): In[4]:= voltageDivider2 = Netlist[ {V0, {1, 0}, 10}, {R1, {1, out}, R}, {R2, {out, 0}, 2 R} ] Out[4]= NetlistRaw, 3 2.2 Netlists 37 2.2.2 Circuit Elements Element Types Having learned the basics about the netlist format we will now take a look at the circuit element types (see Chapter 4.2) which are supported by Analog Insydes. The names of all available types are stored in a globally accessible list named ElementTypes (Section 3.1.5): In[5]:= ElementTypes Out[5]= Resistor, Conductance, Admittance, Impedance, Capacitor, Inductor, CurrentSource, VoltageSource, CCCSource, CCVSource, VCCSource, VCVSource, Nullator, Norator, Fixator, OpAmp, OTAmp, ABModel, OpenCircuit, ShortCircuit, SignalSource, Amplifier, Integrator, Differentiator, TransmissionLine, TransferFunction To obtain information about the netlist format for a particular circuit element, type ?element. This will print the corresponding usage message to the screen. For example, let’s find out more about the elements Capacitor (Section 4.2.5) and VCCSource (Section 4.2.13): In[6]:= ?Capacitor Capacitor (type tag "C") denotes a linear capacitor. The netlist format is {Cname, {N1, N2}, value}. Network equation setup for capacitors is influenced by the value field option Pattern. In[7]:= ?VCCSource VCCSource (type tag "VC") denotes a linear voltage−controlled current source. The netlist format is {VCname, {C1, C2, N1, N2}, value}. Note that the nodes of the controlling branch, C1 and C2, are listed before those of the controlled branch, N1 and N2. As compared to Spice, the order is reversed! You may have noticed that there are no such elements as diodes, bipolar or MOS transistors contained in ElementTypes . Nevertheless, Analog Insydes comes with a predefined library of symbolic semiconductor device models (see Chapter 4.3), which contains full-precision SPICE-compatible models for the most important devices such as Diodes, BJTs, MOSFETs, and JFETs. In addition to the linear electric circuit elements like resistors and capacitors the list of element types contains six elements from control theory, namely signal sources, amplifiers, integrators, etc. This is because Analog Insydes is capable of analyzing linear control circuits as well. You can even perform symbolic analyses of systems which contain both electrical and control components, allowing you to do behavioral circuit modeling across different levels of abstraction. 2. Tutorial 38 Controlled Sources: Some Caveats If you have worked with SPICE netlists before you will see some differences in the way you have to formulate the netlist entries for controlled sources in an Analog Insydes netlist. Apart from the more meaningful type tags (VV, CC, VC, CV as opposed to E, F, G, H), Analog Insydes uses a uniform scheme for all four types of controlled sources, i.e. you have to specify two nodes for the controlling branch and two nodes for the controlled branch for both voltage-controlled and current-controlled sources. N1 C1 I1 r*I1 1 3 V1 gm*V1 C2 N2 2 4 Figure 2.5: Current-controlled voltage source (left) and voltage-controlled current source (right) For the two controlled sources shown in Figure 2.5 the netlist entries must be written as follows. Note, that the nodes of the controlling branches are listed first. {CV1, {C1, C2, N1, N2}, r} {VC2, {1, 2, 3, 4}, gm} Analog Insydes treats controlled sources as true two-port elements, so every controlled source adds two electrical branches to a circuit, a controlling and a controlled branch. In the case of currentcontrolled sources you have to keep in mind that the controlling branch is nothing else than a short circuit (Section 4.2.8). Therefore, do not connect the controlling branch of a current-controlled source in parallel to another circuit element. Instead, always use a series connection of the controlling branch and the circuit element whose branch current controls the source. Let’s clarify this important point by writing a netlist for the circuit shown in Figure 2.6. The currentcontrolled current source is controlled by the current flowing through the resistor RB. If we wrote the netlist entry for the CCCS (Section 4.2.11) as {CC1, {1, 0, 2, 0}, beta} the controlling branch would be inserted in parallel to RB and thus short-circuit the resistor. 2.2 Netlists 39 CM 2 1 V0 RL RB beta*IB IB Figure 2.6: Result of incorrectly inserted current-controlled current source The correct solution to this problem is to add another node to the circuit and connect the controlling branch in series with RB as shown in Figure 2.7. CM 2 1 RB V0 3 IB RL beta*IB Figure 2.7: CCCS circuit with correctly inserted controlling branch We can then write a correct netlist as follows: In[8]:= cccsCircuit = Netlist[ {V0, {1, 0}, {RB, {1, 3}, {CM, {1, 2}, {CC1, {3, 0, {RL, {2, 0}, ] V0}, RB}, CM}, 2, 0}, beta}, RL} Out[8]= NetlistRaw, 5 2.2.3 A Brief Preview on Circuit Analysis There is much more to learn about netlists, but before going into the details let’s get an impression of Analog Insydes’ basic symbolic circuit analysis functionality. Computing voltages and currents in a circuit requires essentially two steps: Setting up a system of circuit equations and then solving these equations. Circuit equations can be set up automatically by applying the function CircuitEquations (Section 3.5.1) to a netlist description. We set up equations for the voltage divider circuit defined in Section 2.2.1 (see Figure 2.1): 2. Tutorial 40 In[9]:= vdeqs = CircuitEquations[voltageDivider] Out[9]= DAEAC, 3 3 By default, CircuitEquations sets up a system of modified nodal, or MNA, equations (Modified Nodal Analysis) in the frequency domain. The return value is a DAEObject which contains the three components of the linear matrix equation A x b, where A is the coefficient matrix, x the vector of unknown voltages and currents, and b the vector of independent sources. To display the system of equations in a more readable form we can apply the command DisplayForm to the DAEObject vdeqs: In[10]:= DisplayForm[vdeqs] Out[10]//DisplayForm= 1 1 1 V$1 0 R1 R1 1 1 1 0 V$2 . 0 R1 R1 R2 10 I$V0 0 0 1 Here, the vector of unknowns comprises the node voltages V$1 and V$2 at nodes 1 and 2, plus the current I$V0 flowing through the voltage source V0. We can solve the MNA equations by using the function Solve (Section 3.5.4). Given the system of equations and no additional arguments, Solve solves for all voltages and currents listed in the vector of unknowns. In[11]:= Solve[vdeqs] 10 10 R2 Out[11]= I$V0 , V$2 , V$1 10 R1 R2 R1 R2 The values of V$1 and V$2 correspond to what we would expect from a voltage divider. If you wonder about the negative sign of I$V0 remember what has been said about positive reference directions of branch voltages and currents in Section 2.2.1. As a second example we will compute the node voltage at node 2 of the CCCS circuit (see Figure 2.7) as a symbolic function of the circuit parameters in the frequency domain. In[12]:= cccseqs = CircuitEquations[cccsCircuit]; DisplayForm[cccseqs] Out[13]//DisplayForm= 1 1 CM s RB CM s RB 1 0 CM s RL CM s 1 1 0 RB RB 1 0 0 0 0 1 1 0 0 0 0 0 V$1 0 V$2 beta 0 . V$3 1 V0 I$V0 0 IC$CC1 0 0 0 The last variable in the vector of unknowns, IC$CC1, denotes the controlling current of the controlled source CC1 (see Section 2.4.1). We can solve for V$2 by explicitly passing this variable as a second argument to Solve. In[14]:= Solve[cccseqs, V$2] RL beta CM RB s V0 Out[14]= V$2 RB 1 CM RL s 2.2 Netlists 41 The result represents the Laplace transform of the zero-state response of the voltage at node 2, expressed in terms of the complex frequency variable s. The zero-state response is the response of a system which was in the zero state at the time just prior to the application of the input signal. Zero state means that all initial conditions, i.e. capacitor voltages and inductor currents, are zero. 2.2.4 More about Netlists The General Value-Field Format As indicated in the previous section, some aspects regarding the netlist format have not yet been mentioned. So far, we have used only the simplest form of writing netlist entries (see Section 2.2.1). In general, however, the value field of a netlist entry does not need to be a single Mathematica expression but may also be a nonempty sequence of options. Netlist entries may thus look like this: {name, {nodes}, option1 −> value1 , option2 −> value2 , } There are several value-field option keywords which Analog Insydes understands (see Section 3.1.4): Value, Symbolic , Type, Pattern, InitialCondition , Model (Section 3.2.1), and Subcircuit (Section 3.2.2). Their meanings will be discussed in the following subsections. Value If the value field is written in its general sequence-of-options form then all of its components must be options. This necessitates an option which specifies the value of the circuit element, namely Value (see Section 3.1.4). With the Value option we can rewrite a netlist entry such as {R1, {1, 2}, R1} in the following semantically equivalent general form: {R1, {1, 2}, Value −> R1} Of course, as long as the value field contains no more information than only the element value the simple form is the preferred form. Note that if the value field is written in option form, then the Value option must be present. Symbolic The Symbolic option (see Section 3.1.4) is closely related to the Value option. It allows you to specify an alternative symbolic element value in addition to a numerical value given as argument to the Value option, for instance: {R1, {1, 2}, Value −> 100, Symbolic −> R1} By default, circuit equations are set up using the arguments of the Value options as element values, but CircuitEquations (Section 3.5.1) can be instructed to use the symbolic values instead wherever 2. Tutorial 42 the Symbolic option is given. This allows for assigning both a numerical as well as a symbolic value to a circuit element. You will be able to assess the value of this feature better once you have learned more about the topics described in Chapter 2.3 and Chapter 2.8. Type The value field option Type (see Section 3.1.4) allows you to specify the type of an element explicitly, thus overriding the automatic type detection from an element’s reference designator. The argument to the Type option must be the full name of a circuit element type supported by Analog Insydes (see Chapter 4.2). The available types are listed in the global variable ElementTypes . Using the Type option we could write a netlist entry for a resistor in the following way even though the name Shunt does not begin with the type tag R. {Shunt, {1, 2}, Type −> Resistor, Value −> R1} Moreover, as Analog Insydes generates voltage and current identifiers (see Section 2.4.1) by adding the prefixes "V$" and "I$" to the reference designators, the Type option gives us some more influence on the names of voltages and currents. In this example, the resistor current would be named I$Shunt , whereas it would be named I$R1 for the netlist entries from the previous two subsections. The example below shows a more convincing application of the Type option. Assume that you have an amplifier circuit with an output load connected between nodes out and ground, and that you wish to calculate the amplifier’s frequency responses for both resistive and capacitive loads. You could, of course, write two separate netlists for this purpose. On the other hand, the Type option offers you the alternative to set up only one single netlist but with a variable load type: amplifier = Netlist[ {Load, {out, 0}, Type −> loadtype, Value −> loadval}, ] Then, by replacing the type variable with a concrete type name, you can set up circuit equations for a particular type of load, e.g. for a capacitor: CircuitEquations[ amplifier /. {loadtype −> Capacitor, loadval −> CL}] Note that in both cases the identifier for the load current will be I$Load, regardless of the load element type eventually selected. Finally, the Type option helps us to correct a frequently made mistake, which usually occurs when a netlist contains a supply voltage source named VCC. If we relied on automatic type detection from the reference designator VCC, Analog Insydes would give us the error message "Netlist::numnode: Expected 4 nodes but received 2 for VCCSource VCC". The reason for this error is that VC is the type tag for voltage-controlled current sources, so Analog Insydes interprets VCC as (VC)C and not as a voltage source V(CC). This problem can be easily solved by means of the Type directive: 2.2 Netlists 43 {VCC, {1, 0}, Type −> VoltageSource, Value −> VCC} Pattern The Pattern option (see Section 3.1.4) can be used only in conjunction with two-terminal immittances, i.e. impedance and admittance elements such as resistors (Section 4.2.1), conductances (Section 4.2.2), capacitors (Section 4.2.5), and inductors (Section 4.2.6). With this directive you can explicitly choose whether the contribution of an immittance element to a system of modified nodal equations is entered into the matrix using the fill-in pattern for admittances or the pattern for impedances. The two associated values of the Pattern option are Impedance and Admittance . When setting up modified nodal equations, Analog Insydes automatically converts impedance elements such as resistors into their admittance equivalents in order to keep the matrix size as small as possible. In other words, a resistor with the value R will be treated as an admittance with the value R and will be entered into the modified nodal matrix using the fill-in pattern for admittances (see the example in Section 2.2.3). However, if we are interested in computing the current through a particular resistor it would be better to use the fill-in pattern for impedances as this would augment the MNA system by the corresponding branch current. So if we want to calculate the load current of the above-mentioned amplifier using the MNA formulation we would have to select the impedance pattern for the load resistor in order to introduce the branch current I$Load: {Load, {out, 0}, Type −> Resistor, Value −> RL, Pattern −> Impedance} Let’s experiment with some value-field options using the CCCS circuit from Section 2.2.2 (see Figure 2.7). We replace the resistor RL by a variable load type and select the fill-in pattern for impedances. In[15]:= cccsCircuit2 = Netlist[ {V0, {1, 0}, V0}, {RB, {1, 3}, RB}, {CM, {1, 2}, CM}, {CC1, {3, 0, 2, 0}, beta}, {Load, {2, 0}, Type −> loadtype, Value −> loadval, Pattern −> Impedance} ] Out[15]= NetlistRaw, 5 We choose a resistive load with the symbolic value RL and set up the MNA equations. Due to the Pattern directive, the load current I$Load now appears as an additional variable for which we can solve directly. 2. Tutorial 44 In[16]:= cccseqs2 = CircuitEquations[ cccsCircuit2 /. {loadtype −> Resistor, loadval −> RL}]; DisplayForm[cccseqs2] Out[17]//DisplayForm= 1 1 RB CM s CM s RB CM s CM s 0 1 1 0 RB RB 1 0 0 0 0 1 0 1 0 1 0 0 0 V$1 0 0 beta 1 V$2 0 V$3 0 1 0 . V0 I$V0 0 0 0 0 IC$CC1 0 0 0 0 0 0 RL I$Load In[18]:= Solve[cccseqs2, I$Load] beta CM RB s V0 Out[18]= I$Load RB 1 CM RL s Next, we select a capacitive load CL and solve for the load current again. In[19]:= cccseqs3 = CircuitEquations[ cccsCircuit2 /. {loadtype −> Capacitor, loadval −> CL}]; DisplayForm[cccseqs3] Out[20]//DisplayForm= 1 1 RB CM s CM s RB CM s CM s 0 1 1 0 RB RB 1 0 0 0 0 1 0 1 0 1 0 0 beta 0 1 0 0 0 0 0 0 0 1 0 0 0 1 CL s 0 V$1 0 V$2 0 V$3 . V0 I$V0 0 IC$CC1 I$Load 0 In[21]:= Solve[cccseqs3, I$Load] CL beta CM RB s V0 Out[21]= I$Load CL CM RB InitialCondition With the InitialCondition option (see Section 3.1.4), you can specify initial currents and voltages for the dynamic elements Inductor (Section 4.2.6) and Capacitor (Section 4.2.5), respectively. If no initial condition is given explicitly, it will be assumed to be zero (AC analysis) or will be calculated automatically from the operating-point data (transient analysis). As an example, we set an initial capacitor voltage of V0 for the netlist entry C1 of the following filter circuit: In[22]:= filter = Netlist[ {V1, {1, 0}, V1}, {R1, {1, 2}, R1}, {C1, {2, 0}, Value −> C1, InitialCondition −> V0} ] Out[22]= NetlistRaw, 3 2.2 Netlists 45 In[23]:= filtereqs = CircuitEquations[filter, InitialConditions −> Automatic]; DisplayForm[filtereqs] Out[24]//DisplayForm= 1 1 1 0 R1 R1 V$1 1 1 . C1 V0 V$2 C1 s 0 R1 R1 V1 0 0 I$V1 1 See Section 2.7.5 for a description of initial condition handling during equation setup. Model, Subcircuit The purpose of the Model and Subcircuit directives is to mark a netlist entry as being a reference to a device model or subcircuit definition. Chapter 2.3 deals with the details. 2. Tutorial 46 2.3 Circuits and Subcircuits 2.3.1 Circuits, Netlists, and Subcircuits Hierarchical Netlist Entry The flat netlist representation we used so far is usually sufficient for small analysis tasks with no more than a handful of circuit elements. Now imagine that we want to analyze active circuits like the transistor amplifier shown in Figure 3.1, and want to do several transfer function calculations with different transistor models. It would be rather inconvenient if we had to edit the netlist every time we select another semiconductor device model. Therefore, Analog Insydes provides a hierarchical netlist entry scheme which allows us to regard the transistor object as a black box with three terminals and lets us write a netlist for the circuit containing only a reference to the box but no specification of what’s inside. Separately from this netlist, we can define one or more concrete realizations of the box in the form of equivalent (sub)circuits and let Analog Insydes automatically replace the reference by one of the subcircuit definitions. 2 RC R1 1 3 4 V1 VCC Q1 R2 Vout RE Figure 3.1: Common-emitter transistor amplifier The Circuit Object When structured hierarchically, a circuit description comprises a top-level netlist with subcircuit or model references, and a set of subcircuit definitions. 2.3 Circuits and Subcircuits 47 Throughout this text, the terms "subcircuit" and "model" shall be used as synonyms because small-signal device models are effectively implemented as subcircuits composed of circuit primitives like resistors and controlled sources. Keeping all netlist and subcircuit components of a circuit together is the task of the Analog Insydes data structure Circuit (Section 3.1.2), whose content sequence may be any number of netlist and subcircuit definitions. Circuit[ Netlist[top-level netlist with subcircuit references], Model[subcircuit/model definition], Model[subcircuit/model definition] ] A Circuit object additionally may contain model parameters and global parameters, see ModelParameters (Section 3.1.10) and GlobalParameters (Section 3.1.11). When a Circuit object is defined, it is printed in short notation only. To view the entire circuit structure use the command DisplayForm . 2.3.2 Defining Subcircuits and Device Models The Model Object Let’s start to work with hierarchically structured netlists by learning how to define subcircuits using the Analog Insydes objects Model (Section 3.2.1) or Subcircuit (Section 3.2.2). This section describes how to write netlist-based models or subcircuits. Section 2.6.2 shows how to write equation-based models. Model and Subcircuit are semantically equivalent symbols. In fact, Subcircuit is just an alias name for Model. You may want to use both names in a Circuit if you wish to give visual cues as to which subcircuits represent device models by using the Model directive for these and the Subcircuit object for all other subcircuits. The Model object takes several arguments which must all be written in Mathematica’s option syntax keyword −> value. Four of the arguments must always be present whereas the remaining ones are optional or have default values. Below, the optional arguments are printed in slanted typewriter font. For now, we will restrict ourselves to the discussion of the required arguments. The optional ones will be introduced later in a step-by-step fashion, as this will help you to better understand why and when they are needed. 2. Tutorial 48 Model[ Name −> subcircuit class name, Selector −> selector, Scope −> scope, Ports −> {port nodes}, Parameters −> {parameters}, Defaults −> {defaults}, Translation −> {parameter translation rules}, Definition −> Netlist[subcircuit netlist] ] The value of the Name argument must be a symbol which identifies an entire group, or class, of different subcircuit implementations of a non-primitive object, such as a transistor. The value of the Selector argument, which must also be a symbol, then selects one particular member from this class. The Ports argument defines the port nodes of a subcircuit structure. Its value must be a list of the identifiers of the subcircuit nodes which serve as external connection points. Finally, the netlist of the subcircuit must be specified by means of the Definition argument. There is no built-in limit for the nesting depth of subcircuits, so the netlist may itself contain references to other Model definitions. However, you may only reference but not define subcircuits within subcircuits. Small-Signal Transistor Models To fully understand this abstract description of the Model function, let’s examine a practical example. Assume that we want to calculate the AC voltage transfer function of the common-emitter amplifier from Section 2.3.1 (see Figure 3.1) and want to replace the transistor by either one of the two small-signal equivalent circuits shown in Figure 3.2. 2.3 Circuits and Subcircuits 49 C B E CM B C B C IB IB X X R0 RB RB E beta*IB E beta*IB E E Figure 3.2: Different transistor small-signal models: simple (left), dynamic (right) Both circuits have in common that they represent the same object, namely an NPN transistor. Thus, they are two members of a subcircuit class we shall name NPNTransistor : Name −> NPNTransistor Within this class, each member must have a unique selector by which it can be identified. We will denote the simple small-signal model on the left-hand side of Figure 3.2 by Selector −> ACsimple and the one on the right-hand side by Selector −> ACdynamic From now on we will adopt the notation name/selector for denoting a subcircuit definition. For instance, we will refer to the model defined with Name −> NPNTransistor and Selector −> ACsimple as NPNTransistor/ACsimple . Both subcircuits contain four nodes: B, C, E, and X, where B, C, and E represent the transistor’s base, collector, and emitter terminal respectively. The node X is an internal subcircuit node which is needed for properly connecting the controlling branch of the current-controlled current source in series with the base resistor RB (see also Section 2.2.2). Therefore, we declare only B, C, and E as port nodes of the subcircuits in order to make X invisible from the outside: Ports −> {"B", "C", "E"} Note that we use strings to denote the port nodes instead of symbols. Although this requires some more typing this is the recommended way for specifying nodes: If we would have used symbols 2. Tutorial 50 in the above example, the symbol for the emitter node E could have been mixed up with the Mathematica symbol E which denotes the exponential constant e. Connections to subcircuits can only be made through designated port nodes. Any attempt to interface directly with an internal node will cause the generation of an error message when the netlist hierarchy is flattened. However, there is one exception: since the ground node (0) is considered to be global, elements in subcircuit definitions may be connected directly with global ground without the need to specify 0 as a port node. In fact, 0 cannot be used as port node identifier in Analog Insydes. Finally, all which remains to do is to write the netlists of the two subcircuits and set up the Model definitions as follows: Model[ Name −> NPNTransistor, Selector −> ACsimple, Ports −> {"B", "C", "E"}, Definition −> Netlist[ {RB, {"X", "E"}, RB}, {CC, {"B", "X", "C", "E"}, beta} ] ] Model[ Name −> NPNTransistor, Selector −> ACdynamic, Ports −> {"B", "C", "E"}, Definition −> Netlist[ {RB, {"X", "E"}, RB}, {CM, {"B", "C"}, CM}, {CC, {"B", "X", "C", "E"}, beta}, {RO, {"C", "E"}, RO} ] ] In this example, we used node names for all subcircuit nodes given by strings ("B", "C", "E", "X") but we could have used positive integers just as well. However, using symbolic names is usually preferable. The reason is that during subcircuit expansion all internal nodes of subcircuit objects will be instantiated and labeled with unique identifiers such as X$Q1, which are automatically generated from the node names and the reference designator of the subcircuit instance. If an internal node identifier is an integer, e.g. 2, the generated instance identifier 2$Q1 could be confused easily with the product 2*$Q1. 2.3 Circuits and Subcircuits 51 2.3.3 Referencing Subcircuits The Netlist Entry Format for Subcircuit References Subcircuits or device models defined with the Model command can be referenced from a netlist on a higher hierarchy level by a netlist entry whose value field contains the options Model and Selector: {subcircuit instance name, {port connections}, Model −> subcircuit class name, Selector −> selector} To reference a subcircuit object (see Section 3.1.8) the subcircuit class name and the selector must be the same identifiers as those given as arguments to the Name and Selector parameters in the corresponding Model statement. The subcircuit instance name may be any symbol or string which can serve as the unique identifier of this instance of the subcircuit object. You can even use subcircuit instance names which begin with an element type tag known to Analog Insydes. A subcircuit reference with an instance identifier such as RX will never be confused with a resistor because the reference will have been expanded before circuit equations are set up. A netlist entry which marks a reference to an instance of the NPN transistor model NPNTransistor/ACsimple , using the instance identifier Q1, would be written as follows: {Q1, {connectivity}, Model −> NPNTransistor, Selector −> ACsimple} This line does not yet specify how the instance Q1 of NPNTransistor/ACsimple should be embedded into the surrounding circuit structure, i.e. which nodes of the latter should be connected to the subcircuit’s port nodes. Associating external nodes with subcircuit port nodes is done by means of a special format of the connectivity field. All entries of this field must be written as rules of the form external node −> subcircuit port node In our common-emitter amplifier (see Figure 3.1 in Section 2.3.1), node 1 of the top-level netlist is connected to the base node "B" of the transistor, node 3 to the collector node "C", and node 4 to the emitter node "E", resulting in a node-to-port mapping such as this: {Q1, {1 −> "B", 3 −> "C", 4 −> "E"}, Model −> NPNTransistor, Selector −> ACsimple} Since the mapping is defined by names, the relative positions of the entries in the connectivity field are not important. We could have written the connectivity field as {3 −> "C", 1 −> "B", 4 −> "E"} equally well. A Hierarchical Netlist Description of the Amplifier Having learned how to define and how to make references to subcircuits (see Section 3.1.8), we can now write a hierarchically structured netlist for the common-emitter amplifier from Section 2.3.1 (see Figure 3.1). 2. Tutorial 52 In[1]:= <<AnalogInsydes‘ In[2]:= commonEmitterAmplifier= Circuit[ Netlist[ {V1, {1, 0}, inputVoltage}, {VCC, {2, 0}, Type −> VoltageSource, Value −> supplyVoltage}, {R1, {2, 1}, R1}, {R2, {1, 0}, R2}, {RC, {2, 3}, RC}, {RE, {4, 0}, RE}, {Q1, {1 −> "B", 3 −> "C", 4 −> "E"}, Model −> NPNTransistor, Selector −> BJTModel} ], Model[ Name −> NPNTransistor, Selector −> ACsimple, Ports −> {"B", "C", "E"}, Definition −> Netlist[ {RB, {"X", "E"}, RB}, {CC, {"B", "X", "C", "E"}, beta} ] ], Model[ Name −> NPNTransistor, Selector −> ACdynamic, Ports −> {"B", "C", "E"}, Definition −> Netlist[ {RB, {"X", "E"}, RB}, {CM, {"B", "C"}, CM}, {CC, {"B", "X", "C", "E"}, beta}, {RO, {"C", "E"}, RO} ] ] ] Out[2]= Circuit Note that in the top-level netlist of this circuit description we used a generic subcircuit selector BJTModel and not ACsimple or ACdynamic . This allows us to select the model at run time by replacing BJTModel with ACsimple or ACdynamic just before the subcircuit hierarchy is expanded. In addition, for reasons which will become apparent in the next section, we have used the variables inputVoltage and supplyVoltage to denote the values of the voltage sources V1 and VCC. Remember that the Type directive in the value field of VCC prevents Analog Insydes from falsely interpreting the netlist entry as belonging to a voltage-controlled current source. 2.3 Circuits and Subcircuits 53 2.3.4 Subcircuit Expansion The ExpandSubcircuits Command Before we can set up circuit equations we must resolve all references to subcircuit objects. Subcircuit instantiation and flattening the netlist is done by the command ExpandSubcircuits (Section 3.4.1) which accepts a Circuit (Section 3.1.2) or a Netlist (Section 3.1.1) object as argument and returns a flat netlist object.Such a flat netlist is similar to a Netlist, except that it is guaranteed to contain only circuit primitives and no subcircuit references. Please note that subcircuit expansion is taken care of automatically by CircuitEquations, so that there is usually no need to call ExpandSubcircuits explicitly, except for inserting models into the global data base. Section 2.3.6 deals with this topic. We can now use ExpandSubcircuits to generate one flat netlist of the common-emmitter amplifier from Section 2.3.1 (see Figure 3.1) for each of the two transistor models we have defined. As the circuit description is still generic we must first personalize it by replacing its variables according to the specific analysis task. Our task was to calculate the small-signal voltage transfer function, so besides choosing an appropriate transistor model we must set the value of the supply voltage source VCC to zero and the value of the input signal source to (see Section 2.9.2). Then, the node voltage at the output node 3 will be identical to the transfer function. We apply these variable settings to the netlist with the Mathematica command ReplaceAll (or /. in short notation) and pass the resulting netlist to ExpandSubcircuits . In[3]:= flatAmpSimple = ExpandSubcircuits[ commonEmitterAmplifier /. {supplyVoltage −> 0, inputVoltage −> 1, BJTModel −> ACsimple}]; DisplayForm[flatAmpSimple] Out[4]//DisplayForm= Netlist Flat, 8 Entries: V1, 1, 0, 1 VCC, 2, 0, Type VoltageSource, Value 0 R1, 2, 1, R1 R2, 1, 0, R2 RC, 2, 3, RC RE, 4, 0, RE RB$Q1, X$Q1, 4, RB CC$Q1, 1, X$Q1, 3, 4, beta 2. Tutorial 54 In[5]:= flatAmpDyn = ExpandSubcircuits[ commonEmitterAmplifier /. {supplyVoltage −> 0, inputVoltage −> 1, BJTModel −> ACdynamic}]; DisplayForm[flatAmpDyn] Out[6]//DisplayForm= Netlist Flat, 10 Entries: V1, 1, 0, 1 VCC, 2, 0, Type VoltageSource, Value 0 R1, 2, 1, R1 R2, 1, 0, R2 RC, 2, 3, RC RE, 4, 0, RE RB$Q1, X$Q1, 4, RB CM$Q1, 1, 3, CM CC$Q1, 1, X$Q1, 3, 4, beta RO$Q1, 3, 4, RO As we can see from the flattened netlists, ExpandSubcircuits has not simply replaced the subcircuit references by the original netlists from the Model definitions. The function has also generated unique symbols for all internal reference designators and node identifiers in the subcircuit netlists by appending a separator character ($) and the subcircuit instance name (Q1) to the original identifiers. This eliminates possible name conflicts with reference designators from the top-level netlist and allows for using multiple instances of a subcircuit definition. Analysis of the Common-Emitter Amplifier Now we can analyze the circuit by means of the functions CircuitEquations (Section 3.5.1) and Solve (Section 3.5.4). We start by setting up the modified nodal equations for the simple AC model from the flattened netlist. Note that we could call CircuitEquations on the Circuit object equally well. We used ExpandSubcircuits for demonstrating the subcircuit expansion mechanism. 2.3 Circuits and Subcircuits 55 In[7]:= eqAmpSimple = CircuitEquations[flatAmpSimple]; DisplayForm[eqAmpSimple] Out[8]//DisplayForm= 1 1 1 R1 R2 R1 1 1 1 R1 R1 RC 1 0 RC 0 0 0 0 1 0 0 1 1 0 0 0 0 1 0 1 RC 1 RC 0 0 0 1 0 0 0 1 RB 1 RB 0 0 0 0 0 0 0 0 1 RB 1 RE 1 RB 0 0 0 0 0 1 0 0 0 0 0 0 0 0 beta beta . 1 0 0 0 1 0 0 V$1 0 V$2 0 V$3 0 V$4 0 V$X$Q1 1 I$V1 0 I$VCC 0 IC$CC$Q1 To compute the small-signal voltage transfer function we must solve the MNA equations for the node voltage V$3 at the output node 3. In[9]:= v3 = Solve[eqAmpSimple, V$3] beta RC Out[9]= V$3 RB RE beta RE The following command extracts the symbolic transfer function expression from the return value of Solve. In[10]:= vtf = V$3 /. First[v3] beta RC Out[10]= RB RE beta RE Now, let’s see what happens when we make the (usually realistic) assumption that the transistor current gain is very large: In[11]:= Limit[vtf, beta −> Infinity] RC Out[11]= RE The above result is indeed identical to the well-known approximate formula for the voltage gain of a common-emitter amplifier. Doing the same calculations for the other transistor model shall be left to the reader as an exercise. 2. Tutorial 56 2.3.5 Subcircuit Parameters Instantiating Element Values in Subcircuit Definitions Although reference designators and internal node identifiers in subcircuit netlists are always uniquely instantiated we still have to cope with one difficulty that arises when working with multiple references to the same model definition. Consider the following small-signal equivalent circuit of a Darlington amplifier (see Figure 3.3) for which we shall have to compute the overall current gain as a function of the individual current gains of the two transistors Q1 and Q2. The gain can be obtained by calculating the output response to a unit current I1 applied at the input. 2 1 Q1 I1 Iload Q2 3 RL Figure 3.3: Darlington amplifier (small-signal equivalent circuit) Let’s decide to use the transistor model NPNTransistor/ACsimple from Section 2.3.2 (see Figure 3.2) for both transistors. We would then write the circuit description and expand the model references as follows. Remember that the Pattern option in the value field of the netlist entry Load causes the current through the load resistor to be introduced into the modified nodal equations, allowing us to compute the current directly. Alternatively, we could have inserted a short circuit in between RL and node 2 for measuring the current. 2.3 Circuits and Subcircuits 57 In[12]:= Circuit[ Netlist[ {I1, {0, 1}, 1}, {Q1, {1 −> "B", 2 −> "C", 3 −> "E"}, Model −> NPNTransistor, Selector −> ACsimple}, {Q2, {3 −> "B", 2 −> "C", 0 −> "E"}, Model −> NPNTransistor, Selector −> ACsimple}, {Load, {0, 2}, Type −> Resistor, Value −> RL, Pattern −> Impedance} ], Model[ Name −> NPNTransistor, Selector −> ACsimple, Ports −> {"B", "C", "E"}, Definition −> Netlist[ {RB, {"X", "E"}, RB}, {CC, {"B", "X", "C", "E"}, beta} ] ] ] // ExpandSubcircuits // DisplayForm Out[12]//DisplayForm= Netlist Flat, 6 Entries: I1, 0, 1, 1 RB$Q1, X$Q1, 3, RB CC$Q1, 1, X$Q1, 2, 3, beta RB$Q2, X$Q2, 0, RB CC$Q2, 3, X$Q2, 2, 0, beta Load, 0, 2, Type Resistor, Value RL, Pattern Impedance While ExpandSubcircuits (Section 3.4.1) has generated unique identifiers for the base resistor RB and the current-controlled current source CC for each instance of the transistor model, it has not made any changes to the associated symbolic element values RB and beta. Obviously, these have been regarded as global symbols, resulting in identical base resistances and current gains of both transistors. This is certainly not the result we wanted because the individual current gains of the transistors in a Darlington stage may be quite different. Instead, ExpandSubcircuits should instantiate the element values as well, and thus generate the symbols RB$Q1, RB$Q2, beta$Q1 , and beta$Q2 for the two resistors and the two current gains respectively. The reason behind the unwanted behavior exhibited here is that ExpandSubcircuits has not been explicitly instructed to treat RB and beta as what they really are, namely as parameters of the model. We can solve this problem by adding the parameter declaration Parameters −> {RB, beta} to our Model definition, which instructs ExpandSubcircuits to replace all occurrences of these symbols in the value fields of the subcircuit netlist by different identifiers for each subcircuit instance. 2. Tutorial 58 In[13]:= darlington = Circuit[ Netlist[ {I1, {0, 1}, 1}, {Q1, {1 −> "B", 2 −> "C", 3 −> "E"}, Model −> NPNTransistor, Selector −> ACsimple}, {Q2, {3 −> "B", 2 −> "C", 0 −> "E"}, Model −> NPNTransistor, Selector −> ACsimple}, {Load, {0, 2}, Type −> Resistor, Value −> RL, Pattern −> Impedance} ], Model[ Name −> NPNTransistor, Selector −> ACsimple, Ports −> {"B", "C", "E"}, Parameters −> {RB, beta}, Definition −> Netlist[ {RB, {"X", "E"}, RB}, {CC, {"B", "X", "C", "E"}, beta} ] ] ] Out[13]= Circuit In[14]:= ExpandSubcircuits[darlington] // DisplayForm Out[14]//DisplayForm= Netlist Flat, 6 Entries: I1, 0, 1, 1 RB$Q1, X$Q1, 3, RB$Q1 CC$Q1, 1, X$Q1, 2, 3, beta$Q1 RB$Q2, X$Q2, 0, RB$Q2 CC$Q2, 3, X$Q2, 2, 0, beta$Q2 Load, 0, 2, Type Resistor, Value RL, Pattern Impedance After having been defined as parameters, the base resistances and current gains appear properly instantiated in the flat netlist. We can now complete our analysis of the Darlington amplifier by solving the MNA equations for the load current I$Load. 2.3 Circuits and Subcircuits 59 In[15]:= eqDarlington = CircuitEquations[darlington]; DisplayForm[eqDarlington] Out[16]//DisplayForm= 0 0 0 0 0 0 0 0 1 1 0 0 RB$Q1 RB$Q1 1 1 0 0 RB$Q1 RB$Q1 0 0 0 0 1 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 1 RB$Q2 0 1 0 1 0 0 beta$Q1 beta$Q2 1 beta$Q1 1 0 1 0 0 . 0 1 0 0 0 0 0 0 0 0 0 RL 1 V$1 0 V$2 0 V$3 0 V$X$Q1 0 V$X$Q2 0 IC$CC$Q1 0 IC$CC$Q2 0 I$Load In[17]:= Solve[eqDarlington, I$Load] Out[17]= I$Load beta$Q1 beta$Q2 beta$Q1 beta$Q2 For large current gains beta$Q1 and beta$Q2, the contribution of the product beta$Q1 beta$Q2 dominates this sum, resulting in the known current-gain formula for a Darlington stage. Later, in Chapter 2.8, we will learn how to let Analog Insydes extract such dominant contributions automatically in order to provide compact and interpretable symbolic analysis results. A Remark on Local and Global Symbols Critical reading of the preceding text may give rise to the following question: Why are identifiers of internal nodes always instantiated even though they are not explicitly declared as local symbols while symbolic element values are assumed to be global symbols unless they are explicitly declared as parameters? The logic behind this behavior is that it hardly makes sense to regard any internal node identifier in a generic subcircuit definition as a global symbol – except for rare cases in which the global ground node is involved. Whenever we need to connect a subcircuit to a global node we must make the connection via a port node. Otherwise, from the point of view of the subcircuit definition, we would have to exploit bottom-up knowledge about the set of node names in the top-level netlist, either to be sure that a certain global node is present or in order to prevent name clashes. Consequently, the only reasonable option is that all nodes which are not ports must be local, hence they are instantiated individually. On the other hand, there are some applications where the element values of multiple subcircuit instances are supposed to be identical, for example in repetitive circuit structures like RLC ladder networks. If the element values in the subcircuit definition were generally treated as local parameters then, after subcircuit expansion, we would have to go through the tedium of manually 2. Tutorial 60 assigning the same global symbols to all instances of the corresponding subcircuit element values. This would not be very convenient as it would require typing something along the line of R$X1 R$X2 R$X3 R for every group of identical elements. By explicitly declaring which symbols in a subcircuit denote parameters and quietly assuming all others to be global quantities, cases like that of the Darlington amplifier as well as that of the ladder circuit are both dealt with most easily. However, Analog Insydes provides the command MatchSymbols which applies matching information on a DAEObject. Thus, you can decide which parameters to match even after setting up the equation system. Passing Parameter Values to Subcircuit Instances Though intentional and useful, the automatic instantiation of symbolic subcircuit parameters is only a side effect of the parameter declaration. The original purpose of the Parameters argument in a Model definition is to declare the set of local model variables which can be replaced by instancespecific values given in the value fields of subcircuit references (see Section 3.1.8). In other words, we can pass parameter values to a subcircuit in a similar way as we can pass arguments to a function defined in Mathematica. Since we do not have to specify values for model parameters, automatic instantiation comes into effect whenever a default value is needed for a parameter which has not been assigned a value. If we need to pass parameter values to instances of subcircuit objects we must append a sequence of replacement rules of the form parameter symbol −> value to the value field of the corresponding subcircuit references. The full netlist format of a subcircuit reference is thus {subcircuit instance name, {port connections}, Model −> subcircuit class name, Selector −> selector, parameter1 −> value1 , parameter2 −> value2 , } To illustrate the possible cases consider the netlist of the Darlington amplifier from Section 2.3.5 (see Figure 3.3) once again. Let’s assign the symbolic value RB1 and a numerical value of to the parameters RB and beta of Q1, respectively. In the case of Q2, we assign the symbol beta2 to the current gain whereas we leave the parameter RB unspecified. 2.3 Circuits and Subcircuits 61 In[18]:= Circuit[ Netlist[ {I1, {0, 1}, 1}, {Q1, {1 −> "B", 2 −> "C", 3 −> "E"}, Model −> NPNTransistor, Selector −> ACsimple, RB −> RB1, beta −> 150}, {Q2, {3 −> "B", 2 −> "C", 0 −> "E"}, Model −> NPNTransistor, Selector −> ACsimple, beta −> beta2}, {Load, {0, 2}, Type −> Resistor, Value −> RL, Pattern −> Impedance} ], Model[ Name −> NPNTransistor, Selector −> ACsimple, Ports −> {"B", "C", "E"}, Parameters −> {RB, beta}, Definition −> Netlist[ {RB, {"X", "E"}, RB}, {CC, {"B", "X", "C", "E"}, beta} ] ] ] // ExpandSubcircuits // DisplayForm Out[18]//DisplayForm= Netlist Flat, 6 Entries: I1, 0, 1, 1 RB$Q1, X$Q1, 3, RB1 CC$Q1, 1, X$Q1, 2, 3, 150 RB$Q2, X$Q2, 0, RB$Q2 CC$Q2, 3, X$Q2, 2, 0, beta2 Load, 0, 2, Type Resistor, Value RL, Pattern Impedance During subcircuit expansion, the model parameters have now been replaced by the values from the top-level netlist. As we did not assign a value to the base resistor of Q2, the automatic instantiation mechanism has created the symbol RB$Q2 in order to provide a default value for RB. 2.3.6 The Scope Argument Local and Global Subcircuit Definitions In all the preceding examples, the top-level netlist is immediately followed by the definitions of the subcircuits referenced from within the netlist. These subcircuit definitions are local and volatile because they are neither visible outside the scope of the enclosing Circuit statement nor do they "survive" subcircuit expansion. When doing multiple circuit analyses with a number of frequently used device models it would be rather tedious if we always had to include all potentially selected models in the circuit description together with the top-level netlist. Therefore, we have the option to make any subcircuit definition permanent and accessible from within other netlists by providing an 2. Tutorial 62 appropriate Scope argument (see Section 3.2.1). Scope has two possible values, Local and Global. To make a subcircuit available globally, we need to set the scope as follows: Scope −> Global By expanding a circuit which contains only model definitions with global scope we can implement a globally accessible model library in our current Mathematica environment. For example, let’s set up a model library from the two NPN transistor models NPNTransistor/ACsimple and NPNTransistor/ACdynamic from Section 2.3.2 (see Figure 3.2). In[19]:= Circuit[ Model[ Name −> NPNTransistor, Selector −> ACsimple, Scope −> Global, Ports −> {"B", "C", "E"}, Parameters −> {RB, beta}, Definition −> Netlist[ {RB, {"X", "E"}, RB}, {CC, {"B", "X", "C", "E"}, beta} ] ], Model[ Name −> NPNTransistor, Selector −> ACdynamic, Scope −> Global, Ports −> {"B", "C", "E"}, Parameters −> {RB, CM, beta, RO}, Definition −> Netlist[ {RB, {"X", "E"}, RB}, {CM, {"B", "C"}, CM}, {CC, {"B", "X", "C", "E"}, beta}, {RO, {"C", "E"}, RO} ] ] ] // ExpandSubcircuits; Both models are now stored in the global subcircuit database and can thus be referenced by any other netlist. Note that simply defining the models is not sufficient for storing them in the global database – we have to call ExpandSubcircuits in order to store them into the global database. If the Circuit object contains a top-level Netlist , a call to CircuitEquations stores the models in the global database, too. We can check the contents of the database using the command GlobalSubcircuits (Section 3.3.4), which will return a list of the names and selectors of the global subcircuits. In[20]:= GlobalSubcircuits[] Out[20]= NPNTransistor, ACdynamic, NPNTransistor, ACsimple 2.3 Circuits and Subcircuits 63 The global definition of the transistor models allows us to write the circuit description of the Darlington amplifier from Section 2.3.5 (see Figure 3.3) without the Model commands. Then, during subcircuit expansion, the global database will be searched for models which are not defined locally. In[21]:= darlWithoutModels = Circuit[ Netlist[ {I1, {0, 1}, 1}, {Q1, {1 −> "B", 2 −> "C", 3 −> "E"}, Model −> NPNTransistor, Selector −> ACsimple, RB −> RB1, beta −> 150}, {Q2, {3 −> "B", 2 −> "C", 0 −> "E"}, Model −> NPNTransistor, Selector −> ACsimple, beta −> beta2}, {Load, {0, 2}, Type −> Resistor, Value −> RL, Pattern −> Impedance} ] ]; In[22]:= ExpandSubcircuits[darlWithoutModels] // DisplayForm Out[22]//DisplayForm= Netlist Flat, 6 Entries: I1, 0, 1, 1 RB$Q1, X$Q1, 3, RB1 CC$Q1, 1, X$Q1, 2, 3, 150 RB$Q2, X$Q2, 0, RB$Q2 CC$Q2, 3, X$Q2, 2, 0, beta2 Load, 0, 2, Type Resistor, Value RL, Pattern Impedance Redefining and Removing Global Subcircuits If ExpandSubcircuits or CircuitEquations is called on a Circuit object containing a global model definition, any previously stored model in the global database with the same Name and Selector arguments is replaced by the new one. To remove a particular subcircuit from the global database we can use the command RemoveSubcircuit (Section 3.3.8). Its arguments must be the name and the selector of the subcircuit definition to be deleted. The return value is a list of the names and selectors of the remaining subcircuit definitions. For example, let’s remove the transistor model NPNTransistor/ACdynamic . The only remaining model is then NPNTransistor/ACsimple : In[23]:= RemoveSubcircuit[NPNTransistor, ACdynamic] Out[23]= NPNTransistor, ACsimple Locally Overriding Global Subcircuit Definitions One further application of the Scope argument is that we can locally override a global subcircuit definition. Local subcircuits always take precedence over global definitions with the same name and selector without overwriting the global definition. To illustrate this, let’s temporarily replace the NPNTransistor/ACsimple model with the subcircuit shown in Figure 3.4. The difference between the original implementation of NPNTransistor/ACsimple and this model is that the latter contains a 2. Tutorial 64 voltage-controlled current source VCCS (Section 4.2.13) instead of a current-controlled current source CCCS (Section 4.2.11). B C RB gm*VBE E E Figure 3.4: Transistor model with voltage-controlled current source Although the global subcircuit database still contains a definition of NPNTransistor/ACsimple we can safely use the same name and selector for a local subcircuit without changing the global definition, provided we specify Scope −> Local. Upon subcircuit expansion, Analog Insydes first looks for a local subcircuit with the requested name and selector. The global definition is retrieved only if no matching local definition is present. In[24]:= darlWithLocalModel = Circuit[ Netlist[ {I1, {0, 1}, 1}, {Q1, {1 −> "B", 2 −> "C", 3 −> "E"}, Model −> NPNTransistor, Selector −> ACsimple}, {Q2, {3 −> "B", 2 −> "C", 0 −> "E"}, Model −> NPNTransistor, Selector −> ACsimple}, {Load, {0, 2}, Type −> Resistor, Value −> RL, Pattern −> Impedance} ], Model[ Name −> NPNTransistor, Selector −> ACsimple, Scope −> Local, Ports −> {"B", "C", "E"}, Parameters −> {RB, gm}, Definition −> Netlist[ {RB, {"B", "E"}, RB}, {VC, {"B", "E", "C", "E"}, gm} ] ] ]; Now, ExpandSubcircuits will use the local definition of NPNTransistor/ACsimple . The global definition has not been altered, as we can see by expanding the netlist of the Darlington amplifier from Section 2.3.5 (see Figure 3.3) without models again. 2.3 Circuits and Subcircuits 65 In[25]:= ExpandSubcircuits[darlWithLocalModel] // DisplayForm Out[25]//DisplayForm= Netlist Flat, 6 Entries: I1, 0, 1, 1 RB$Q1, 1, 3, RB$Q1 VC$Q1, 1, 3, 2, 3, gm$Q1 RB$Q2, 3, 0, RB$Q2 VC$Q2, 3, 0, 2, 0, gm$Q2 Load, 0, 2, Type Resistor, Value RL, Pattern Impedance In[26]:= ExpandSubcircuits[darlWithoutModels] // DisplayForm Out[26]//DisplayForm= Netlist Flat, 6 Entries: I1, 0, 1, 1 RB$Q1, X$Q1, 3, RB1 CC$Q1, 1, X$Q1, 2, 3, 150 RB$Q2, X$Q2, 0, RB$Q2 CC$Q2, 3, X$Q2, 2, 0, beta2 Load, 0, 2, Type Resistor, Value RL, Pattern Impedance 2.3.7 The Translation Argument Implicit Translation of Parameter Values Another argument of the Model function which remains to be discussed is the Translation keyword. We can use it to define functional relations between formal subcircuit parameters and internal element values when there is no one-to-one correspondence between both. The syntax is: Translation −> {symbol1 −> value1 , symbol2 −> value2 , } The purpose of the Translation argument is best explained by an example. Assume that we wish to analyze the Darlington amplifier from Section 2.3.5 (see Figure 3.3) using the VCCS transistor model from Section 2.3.6 (see Figure 3.4) instead of a CCCS model. For nodal analysis, the former is usually a better choice than the latter because the VCCS model does not increase the matrix size by introducing additional controlling currents into the modified nodal equations. However, even with a VCCS model we might like to describe the transistors in terms of their current gains beta instead of their transconductances gm by making use of the well-known relation gm = beta/RB. With the help of the Translation argument we can define a translation rule which maps the formal model parameters RB and beta to the transconductance gm used internally as the element value of the VCCS: 2. Tutorial 66 In[27]:= Circuit[ Model[ Name −> NPNTransistor, Selector −> ACgm, Scope −> Global, Ports −> {"B", "C", "E"}, Parameters −> {RB, beta}, Translation −> {gm −> beta / RB}, Definition −> Netlist[ {RB, {"B", "E"}, RB}, {VC, {"B", "E", "C", "E"}, gm} ] ] ] // ExpandSubcircuits; In[28]:= darlNumParams = Circuit[ Netlist[ {I1, {0, 1}, 1}, {Q1, {1 −> "B", 2 −> "C", 3 −> "E"}, Model −> NPNTransistor, Selector −> ACgm, RB −> 400.0, beta −> 150.0}, {Q2, {3 −> "B", 2 −> "C", 0 −> "E"}, Model −> NPNTransistor, Selector −> ACgm, RB −> 100.0, beta −> 50.0}, {Load, {0, 2}, Type −> Resistor, Value −> RL, Pattern −> Impedance} ] ]; Just before subcircuit expansion the right-hand sides of the translation rules are evaluated with the parameter values specified in the value fields of the subcircuit references. The evaluated parameter translation rules are then applied to all value fields in the subcircuit netlist, resulting in the replacement of all symbols appearing on the left-hand side of the translations. Thus, gm is automatically calculated from RB and beta. In[29]:= ExpandSubcircuits[darlNumParams] // DisplayForm Out[29]//DisplayForm= Netlist Flat, 6 Entries: I1, 0, 1, 1 RB$Q1, 1, 3, 400. VC$Q1, 1, 3, 2, 3, 0.375 RB$Q2, 3, 0, 100. VC$Q2, 3, 0, 2, 0, 0.5 Load, 0, 2, Type Resistor, Value RL, Pattern Impedance Delayed Translation Rules In this simple example, using the Translation argument is not absolutely necessary. We could have achieved the same effect without a translation rule by writing the netlist entry for the VCCS like this: 2.3 Circuits and Subcircuits 67 {VC, {"B", "E", "C", "E"}, beta / RB} So why should we use translation rules at all? The answer is that parameter value translations can also be specified by means of delayed rules, i.e. the RuleDelayed lhs :> rhs instead of the Rule lhs −> rhs. Since delayed rules are left unevaluated until the very moment they are needed, their right-hand sides also contain calls to external functions which perform calculations depending on the model parameter values. For instance, let’s define a function which, given values for beta and RB, calculates the transconductance of a transistor by solving the formula gm RB beta numerically for gm, using gm as initial guess. In[30]:= Transconductance[b_Real, r_Real] := Module[ {g}, Print["Computing gm for beta = ", b, " and RB = ", r]; g /. FindRoot[g * r == b, {g, 1.0}] ] By means of a delayed translation rule for gm we can instruct Mathematica not to execute the function call at the time the transistor model is defined but to wait until the rule is used to compute gm for a particular subcircuit instance. In[31]:= Circuit[ Model[ Name −> NPNTransistor, Selector −> ACgm, Scope −> Global, Ports −> {"B", "C", "E"}, Parameters −> {RB, beta}, Translation −> {gm :> Transconductance[beta, RB]}, Definition −> Netlist[ {RB, {"B", "E"}, RB}, {VC, {"B", "E", "C", "E"}, gm} ] ] ] // ExpandSubcircuits; If we had used an immediate rule above, gm −> Transconductance[beta, RB], Mathematica would have already called Transconductance with the symbolic arguments beta and RB at the time of model definition. On the other hand, the delayed rule permits Analog Insydes to replace the arguments with instance-specific values before making the function call. This is done once per subcircuit instance as can be seen from the following output: In[32]:= ExpandSubcircuits[darlNumParams] // DisplayForm Computing gm for beta = 150. and RB = 400. Computing gm for beta = 50. and RB = 100. Out[32]//DisplayForm= Netlist Flat, 6 Entries: I1, 0, 1, 1 RB$Q1, 1, 3, 400. VC$Q1, 1, 3, 2, 3, 0.375 RB$Q2, 3, 0, 100. VC$Q2, 3, 0, 2, 0, 0.5 Load, 0, 2, Type Resistor, Value RL, Pattern Impedance 2. Tutorial 68 An advanced application of such a parameter translation scheme would be the calculation of transistor smallsignal parameters from given operating-point voltages and currents via a set of predefined device equations. Alternative Ways to Assign Values to Parameters In combination with the Parameters setting there is one further useful application of the argument Translation . Specifying a translation rule for a symbol which is also designated as a parameter of the same subcircuit definition allows us to choose whether we let the instance value of the symbol be calculated from other parameters or whether we assign a value to this symbol directly. For example, let’s add the transconductance gm to the list of model parameters while leaving the translation rule for gm unchanged: Parameters −> {RB, beta, gm}, Translation −> {gm :> Transconductance[beta, RB]}, The value field of a reference to the transistor model can now be written in two alternative ways. Just as in the previous subsection we can assign values to RB and beta only and let Analog Insydes calculate gm from the two quantities automatically. Alternatively, we can bypass the translation rule by directly assigning a value to gm, such as gm −> 0.5. Any value given for beta is then effectively ignored because it is not needed anywhere else than in the argument list of the translation rule. In the netlist below, we let gm$Q1 be computed from RB and beta by means of the translation rule. In the case of Q2, however, we do not specify a value for beta but make a direct assignment to gm: gm −> gm2. Therefore, the parameter translation function Transconductance is not called for gm$Q2: 2.3 Circuits and Subcircuits 69 In[33]:= Circuit[ Netlist[ {I1, {0, 1}, 1}, {Q1, {1 −> "B", 2 −> "C", 3 −> "E"}, Model −> NPNTransistor, Selector −> ACgm, RB −> 400.0, beta −> 150.0}, {Q2, {3 −> "B", 2 −> "C", 0 −> "E"}, Model −> NPNTransistor, Selector −> ACgm, RB −> 100.0, gm −> gm2}, {Load, {0, 2}, Type −> Resistor, Value −> RL, Pattern −> Impedance} ], Model[ Name −> NPNTransistor, Selector −> ACgm, Scope −> Global, Ports −> {"B", "C", "E"}, Parameters −> {RB, beta, gm}, Translation −> {gm :> Transconductance[beta, RB]}, Definition −> Netlist[ {RB, {"B", "E"}, RB}, {VC, {"B", "E", "C", "E"}, gm} ] ] ] // ExpandSubcircuits // DisplayForm Computing gm for beta = 150. and RB = 400. Out[33]//DisplayForm= Netlist Flat, 6 Entries: I1, 0, 1, 1 RB$Q1, 1, 3, 400. VC$Q1, 1, 3, 2, 3, 0.375 RB$Q2, 3, 0, 100. VC$Q2, 3, 0, 2, 0, gm2 Load, 0, 2, Type Resistor, Value RL, Pattern Impedance 2. Tutorial 70 2.4 Setting up and Solving Circuit Equations 2.4.1 Naming Conventions Automatically Generated Voltage and Current Identifiers From the small circuit analysis examples already presented in the previous chapters you will have noticed that Analog Insydes automatically creates variables for voltages and currents when setting up circuit equations from a netlist. In order to interpret the equations correctly you need to know everything about the identifier naming scheme employed by Analog Insydes. By default, identifiers for branch voltages and currents associated with two-terminal elements are generated by attaching the prefixes V$ and I$ to the reference designator (Section 3.1.3) of the corresponding circuit element, respectively. For instance, the branch voltage across and branch current through a resistor R1 would be named V$R1 and I$R1. Similarly, identifiers for node voltages are generated by prefixing the node names with the tag V$, so the node voltage at node 1 would be named V$1. Although the prefix is used for branch voltages you will not experience any name clashes among branch and node voltage identifiers, provided that your netlists do not contain any symbolic node identifiers (Section 3.1.3) which are identical to some reference designators. However, if you would rather like different prefixes to be used for branch and node voltages then read the following sections to learn how to change the standard settings. In the case of a controlled source we need to distinguish between the voltages and currents at the controlling and at the controlled branch. While the latter quantities are given names according to the same convention as applied to two-terminal elements, controlling voltages and currents are marked with the prefixes VC$ and IC$. For example, the voltage across and current through the controlled branch of a controlled source VC1 would be called V$VC1 and I$VC1 whereas the corresponding quantities at the controlling branch would be called VC$VC1 and IC$VC1. Changing the Default Identifier Prefixes All identifier prefix settings can be customized by changing the corresponding option. The current option settings can be displayed using the command Options[CircuitEquations] and can be changed using the Mathematica command SetOptions . For instance, the command SetOptions[CircuitEquations, BranchVoltagePrefix −> "E$"] would change the prefix used for branch voltages from V$ to E$. The names of the prefix options and their default settings are listed below. NodeVoltagePrefix −> "V$" BranchVoltagePrefix −> "V$" BranchCurrentPrefix −> "I$" ControllingVoltagePrefix −> "VC$" ControllingCurrentPrefix −> "IC$" 2.4 Setting up and Solving Circuit Equations 71 The values of all these options must be strings which can be converted to a single symbol by means of the command ToExpression . Strings such as "V_" or "@I" cannot be converted to valid symbols and may therefore not be used for this purpose. Changing the Instance Name Separator for Reference Designators Related to the identifier prefix options is the option InstanceNameSeparator (Section 3.14.2). This option determines the character (or string) which Analog Insydes uses to separate name components of reference designators generated for instantiated subcircuit elements. With the default setting InstanceNameSeparator −> "$" a resistor RB in a subcircuit instance Q1 would be named RB$Q1. Using SetOptions you can change the separator character to (almost) anything you like, with the same restrictions that apply to the choice of the prefix options. 2.4.2 Circuit Equations The Command CircuitEquations Setting up systems of symbolic circuit equations is done by the Analog Insydes command CircuitEquations (Section 3.5.1), which takes a Netlist or Circuit object as first argument. In addition, the function may be called with a variety of options – to be introduced later – with which many aspects of equation setup can be influenced individually: CircuitEquations[circuit, options] If the type of the netlist argument is not a flat netlist, then the function ExpandSubcircuits (Section 3.4.1) is automatically applied to the circuit description in order to produce a flat netlist object before proceeding with equation setup. This section describes how to set up equations of linear circuits in the Laplace domain. CircuitEquations can also be used to set up DC or transient equations for nonlinear circuits. This topic is discussed in Section 2.6.4. 1 V0 RA 2 L1 3 C1 Figure 4.1: RLC filter circuit C2 RB 2. Tutorial 72 To illustrate equation setup let’s write down the netlist of the RLC filter circuit displayed in Figure 4.1. In[1]:= <<AnalogInsydes‘ In[2]:= rlcfilter = Netlist[ {V0, {1, {RA, {1, {C1, {2, {L1, {2, {C2, {3, {RB, {3, ] 0}, 2}, 0}, 3}, 0}, 0}, V0}, RA}, C1}, L1}, C2}, RB} Out[2]= NetlistRaw, 6 By default, CircuitEquations sets up a system of modified nodal (MNA) equations in the frequency domain, or, more precisely, the Laplace domain. In the Laplace domain, all linear dynamic elements are described by frequency-dependent complex admittances or impedances, obtained by Laplace-transforming the corresponding constitutive equations. For instance, a linear capacitance C with a constitutive equation it C dutdt is represented by its complex admittance s C, where s denotes the complex Laplace frequency. Unless specified otherwise (see netlist option Pattern in Section 3.1.4), all impedances, i.e. resistors and inductors, are automatically converted to their admittance equivalents. Therefore, the complex impedance s L of an inductor L will be treated as an admittance with the reciprocal value s L. In[3]:= rlceqs = CircuitEquations[rlcfilter] Out[3]= DAEAC, 4 4 The return value of CircuitEquations is a DAEObject which contains the three components of the linear matrix equation A x b, where A is the MNA matrix, x the vector of unknown node voltages and impedance branch currents, and b the vector of independent source voltages and source currents. To display the system of equations in a more readable form we can apply the command DisplayForm to the DAEObject rlceqs: In[4]:= DisplayForm[rlceqs] Out[4]//DisplayForm= 1 1 RA RA 1 1 1 RA RA L1 s C1 s 1 0 L1 s 0 1 0 1 L1 s 1 1 RB L1 s 0 1 V$1 0 0 V$2 0 . 0 V$3 C2 s 0 I$V0 V0 0 Solving Circuit Equations Systems of circuit equations generated by Analog Insydes can be solved symbolically by means of the command Solve (Section 3.5.4). The sequence of arguments may have one of the following three forms, depending on which variable or set of variables the equations should be solved for: Solve[dae] Solve[dae, var] Solve[dae, {var , var , }] 2.4 Setting up and Solving Circuit Equations 73 If Solve is called with a DAEObject only and no second argument is given then the solutions for all variables contained in the vector x are computed. If, in addition to the DAEObject, one single variable of x is specified as second argument then only this variable is solved for. To compute the solutions for a subset of x containing more than only one variable, the second argument must be a list of the variables of interest. Solve finds all solutions of an equation system only for linear equations. For nonlinear (dynamic) equations it is in general not possible to find symbolic solutions. Thus, Analog Insydes provides the command NDAESolve (Section 3.7.5) to compute the solution of nonlinear DAE systems numerically. See Chapter 2.7 for details. Just like Mathematica’s built-in Solve function, Solve[dae] returns a list of rules {{var −> solution, † † † }} which associate the variables with the corresponding solutions. Individual solutions can be extracted from the list by using Mathematica’s ReplaceAll operator (or /. in short notation). Let’s solve the MNA equations of the RLC filter for the node voltages at nodes 1 and 3. Since we are only interested in solving for two out of all four variables, we must use the third calling format: In[5]:= rlcsol = Solve[rlceqs, {V$1, V$3}] Out[5]= V$3 RB V0 RA RB L1 s C1 RA RB s C2 RA RB s C1 L1 RA s2 C2 L1 RB s2 C1 C2 L1 RA RB s3 , V$1 V0 As indicated above, we can retrieve the solution for a particular variable using the /.-operator. The following input line serves to extract the value of V$3. The Mathematica command First removes the outer level of list brackets from the set of solutions, so the result is returned as a single expression and not as a list. In[6]:= rlcv3 = V$3 /. First[rlcsol] Out[6]= RB V0 RA RB L1 s C1 RA RB s C2 RA RB s C1 L1 RA s2 C2 L1 RB s2 C1 C2 L1 RA RB s3 Quite frequently, the raw solutions computed from symbolic circuit equations are not presented in an immediately comprehensible form. It usually takes some additional mathematical postprocessing to transform the results into something which is easier to read or technically more meaningful. Mathematica provides several commands for rearranging expressions, such as Simplify , Factor, Together , Apart, or Collect. The choice of which function to use depends heavily on the particular application, and often some experimenting is required until the results are satisfactory. For example, in the case of the above expression for V$3, we may want to combine all coefficients belonging to the same power of s into one single coefficient each. For this purpose, we apply a rewrite rule to all Plus subexpressions (i.e. sums) which groups the terms by corresponding powers of s and then pulls out the si . This yields a transfer function with coefficients in the canonical sum-of-products form. 2. Tutorial 74 In[7]:= rlcv3 /. p_Plus :> Collect[p, s] Out[7]= RB V0 RA RB L1 C1 RA RB C2 RA RB s C1 L1 RA C2 L1 RB s2 C1 C2 L1 RA RB s3 2.4.3 Circuit Equation Formulations Modified Nodal Analysis The modified nodal analysis method (MNA) has already been introduced as the default formulation by which Analog Insydes sets up circuit equations. The MNA formulation is general, yields relatively compact systems of equations, and is easy to implement on a computer. These and a few other favorable properties have made it the most widely used analysis method in electrical circuit simulators, including Analog Insydes. There are a number of user-settable options which have an influence on the way Analog Insydes sets up MNA equations. You have already encountered the netlist option Pattern which specifies explicitly whether to use the impedance or admittance fill-in pattern for an immittance element, i.e. a two-terminal admittance or impedance. This option allows, for instance, to prevent the implicit conversion of an impedance to an admittance, thereby augmenting the MNA system by the branch current of the impedance. However, the Pattern option pertains only to the element in whose value field it is given. To prevent implicit impedance conversion globally you can set the value of the CircuitEquations option ConvertImmittances to False, either permanently by modifying Options[CircuitEquations] using the SetOptions directive, or temporarily by passing the option ConvertImmittances −> False to the function CircuitEquations : In[8]:= CircuitEquations[rlcfilter, ConvertImmittances −> False] // DisplayForm Out[8]//DisplayForm= 0 0 0 0 C1 s 0 0 0 C2 s 1 0 0 1 1 0 0 1 1 0 1 0 1 1 0 0 V$1 0 0 1 1 0 0 V$2 0 0 1 1 0 V$3 0 0 0 0 . V0 I$V0 0 RA 0 0 0 I$RA 0 0 L1 s 0 0 I$L1 0 0 0 RB I$RB 0 The Formulation Option With modified nodal analysis being the default analysis method there is usually no need to request this formulation explicitly. However, if you have changed the default settings in Options[CircuitEquations] or if you wish to use one of the analysis methods to be discussed in the following subsections you need to specify the formulation as an option to CircuitEquations . The option keyword is Formulation , and the option value can be either ModifiedNodal, SparseTableau , or ExtendedTableau . Hence, modified nodal analysis can be explicitly selected by this command: 2.4 Setting up and Solving Circuit Equations 75 In[9]:= CircuitEquations[rlcfilter, Formulation −> ModifiedNodal] // DisplayForm Out[9]//DisplayForm= 1 1 RA RA 1 1 1 RA RA L1 s C1 s 1 0 L1 s 0 1 0 1 L1 s 1 1 RB L1 s 0 1 0 V$1 0 V$2 0 . 0 V$3 C2 s 0 I$V0 V0 0 Sparse Tableau Analysis: The Basic Formulation In addition to nodal analysis, Analog Insydes also offers the possibility to set up circuit equations according to two variants of the sparse tableau formulation (STA). For an electrical network containing n electrical branches, the basic variant of the sparse tableau comprises the n topological node and loop equations resulting from Kirchhoff’s voltage law (KVL) and current law (KCL), plus the n voltage-current relations of the circuit elements. Hence, the basic sparse tableau forms the following n n matrix equation in terms of the branch voltages v and the branch currents i. 0 B 0 v 0 A 0 i Y Z s Here, A denotes the nodal incidence matrix of the network graph and B a loop incidence matrix of maximum rank. B is derived automatically from A by an algorithm which searches for a tree in the network graph and then extracts the fundamental loop matrix defined by that tree. The matrices Y and Z in the third row of the tableau represent the coefficient matrices of the element relations. On the right-hand side, s denotes the contribution of the independent sources. All remaining tableau entries are structurally zero (0). 2. Tutorial 76 In[10]:= CircuitEquations[rlcfilter, Formulation −> SparseTableau] // DisplayForm Out[10]//DisplayForm= 1 1 1 0 0 0 1 1 0 1 1 0 1 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 C1 s 0 0 0 0 0 0 1 0 0 0 0 0 C2 s 0 0 0 0 0 0 1 0 0 0 0 0 0 0 V$V0 0 0 0 0 0 0 V$RA 0 0 0 0 0 0 V$C1 1 1 0 0 0 0 V$L1 0 1 1 1 0 0 V$C2 0 0 0 1 1 1 V$RB . 0 0 0 0 0 0 I$V0 0 RA 0 0 0 0 I$RA 0 0 1 0 0 0 I$C1 0 0 0 L1 s 0 0 I$L1 0 0 0 0 1 0 I$C2 0 0 0 0 0 RB I$RB 0 0 0 0 0 0 V0 0 0 0 0 0 Sparse Tableau Analysis: The Extended Formulation Analog Insydes also supports an extended sparse tableau formulation in which the vector of unknowns comprises the branch voltages v, the branch currents i, and the node voltages vn . With I denoting an identity matrix of rank n and AT the transpose of the nodal incidence matrix A, Kirchhoff’s voltage law is expressed indirectly in terms of the node voltages as I v AT vn 0. Therefore, the extended sparse tableau formulation does not require the calculation of a loop matrix, though at the expense of a larger matrix size than that of the basic variant: T I 0 A v 0 0 I 0 0 A 0 vn s Y Z The extended variant is selected by the option setting Formulation −> ExtendedTableau : 2.4 Setting up and Solving Circuit Equations 77 In[11]:= rlcstaext = CircuitEquations[rlcfilter, Formulation −> ExtendedTableau]; DisplayForm[rlcstaext] Out[12]//DisplayForm= 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 C1 s 0 0 0 0 1 0 0 0 0 0 0 C2 s 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 . 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 RA 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 L1 s 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 RB 0 0 0 0 V$V0 0 V$RA 0 V$C1 0 V$L1 V$C2 0 V$RB 0 0 I$V0 0 I$RA I$C1 0 V0 I$L1 0 I$C2 0 I$RB 0 V$1 0 V$2 0 V$3 Of course, the solution for a particular quantity in a circuit does not depend on the type of equations from which the solution is computed. So the value for V$3 obtained by an extended sparse tableau analysis is identical to the one computed by modified nodal analysis: In[13]:= V$3 /. First[Solve[rlcstaext, V$3]] Out[13]= L1 RB s V0 RA RB RA L1 s 1 C1 RA s RB L1 s 1 C2 RB s 2. Tutorial 78 2.4.4 Additional Options for CircuitEquations All Analog Insydes options which have an influence on circuit equation setup by the function CircuitEquations can be accessed through Options[CircuitEquations] . The current option settings can be inspected by retrieving the value of this variable: In[14]:= Options[CircuitEquations] Out[14]= AnalysisMode AC, BranchCurrentPrefix I$, BranchVoltagePrefix V$, ControllingCurrentPrefix IC$, ControllingVoltagePrefix VC$, ConvertImmittances True, DefaultSelector Automatic, DesignPoint Automatic, ElementValues Value, Formulation ModifiedNodal, FrequencyVariable s, IgnoreMissingGround False, IndependentVariable Automatic, InitialConditions None, InitialGuess Automatic, InitialTime 0, InstanceNameSeparator InheritedAnalogInsydes, LibraryPath InheritedAnalogInsydes, MatrixEquation True, ModelLibrary InheritedAnalogInsydes, ModeValues None, NodeVoltagePrefix V$, Protocol InheritedAnalogInsydes, Symbolic All, TimeVariable t, Value None Some of these options are discussed in more detail below. AnalysisMode CircuitEquations sets up circuit equations for the analysis modes AC, DC, and transient. Which mode to use is determined by the option AnalysisMode , whose value is one of the symbols AC, DC, and Transient . The default value is AC. Up to now, we used CircuitEquations to create smallsignal equations. Section 2.6.4 describes how to set up DC equations and Section 2.7.1 describes how to set up transient equations. MatrixEquation Using the option MatrixEquation −> False, we can force CircuitEquations not to use a matrix representation when setting up small-signal circuit equations but to return a list of scalar equations instead. In[15]:= CircuitEquations[rlcfilter, MatrixEquation −> False] // DisplayForm Out[15]//DisplayForm= V$1 V$2 V$1 V$2 V$2 V$3 I$V0 0, C1 s V$2 0, RA RA L1 s V$3 V$2 V$3 C2 s V$3 0, V$1 V0, RB L1 s V$1, V$2, V$3, I$V0, DesignPoint When the matrix representation is turned off, the value returned by CircuitEquations is a DAEObject containing the circuit equations as a list of two elements, the first being the system of circuit equations and the second the vector of unknowns. The advantage of the scalar representation is that it consumes less memory than the matrix representation because Mathematica does not have a special 2.4 Setting up and Solving Circuit Equations 79 storage mechanism for sparse matrices. Nevertheless, some commands (e.g. ACAnalysis ) rely on the fact that the equation system is formulated in matrix representation. FrequencyVariable The option FrequencyVariable −> symbol specifies the symbol which Analog Insydes uses to denote the differential operator, i.e. the complex frequency, in the Laplace domain. By default, this is the symbol s, but if you prefer to use another symbol for this purpose, for instance p, you can replace s by p as follows: In[16]:= CircuitEquations[rlcfilter, FrequencyVariable −> p] // DisplayForm Out[16]//DisplayForm= 1 1 RA RA 1 1 1 RA L1 p C1 p RA 1 0 L1 p 0 1 0 1 L1 p 1 1 L1 p C2 p RB 0 1 0 V$1 0 0 V$2 . 0 V$3 0 I$V0 V0 0 ElementValues With ElementValues −> Symbolic we can instruct CircuitEquations to use the symbolic values from the value fields of netlist entries in which a Symbolic option is given. To demonstrate the effect of this option let’s make some enhancements to the netlist of the RLC filter circuit from Section 2.4.2 (see Figure 4.1). Using the extended value-field format (see Section 3.1.4) we specify a numerical as well as a symbolic value for the circuit elements. In[17]:= rlcfilter2 = Netlist[ {V0, {1, 0}, {RA, {1, 2}, {C1, {2, 0}, {L1, {2, 3}, {C2, {3, 0}, {RB, {3, 0}, ]; Value Value Value Value Value Value −> −> −> −> −> −> V0, Symbolic −> V0}, 1000., Symbolic −> RA}, 4.7*10^−6, Symbolic −> C1}, 1.0*10^−3, Symbolic −> L1}, 2.2*10^−5, Symbolic −> C2}, 1000., Symbolic −> RB} Note that the value of the Symbolic option needs not to coincide with the reference designator as this is the case in the example above. You can use any Mathematica expression as value to the Symbolic field. A call to CircuitEquations without any additional options (i.e. the default value of the ElementValues option is used, which is Value) will then cause the numerical values to be entered into the matrix as these are given as arguments to the Value rules. 2. Tutorial 80 In[18]:= rlc2eqs = CircuitEquations[rlcfilter2]; DisplayForm[rlc2eqs] Out[19]//DisplayForm= 0.001 0.001 0 6 1000. 1000. 0.001 0.001 4.7 10 s s s 1000. 1000. 0.001 0.000022 s 0 s s 1 0 0 1 0 . 0 0 V$1 0 0 V$2 0 V$3 I$V0 V0 Alternatively, we can select the symbolic values by means of the option ElementValues −> Symbolic . Note that ElementValues affects only those netlist entries in whose value field a Symbolic rule is present. In[20]:= rlc2eqs2 = CircuitEquations[rlcfilter2, ElementValues −> Symbolic]; DisplayForm[rlc2eqs2] Out[21]//DisplayForm= 1 1 RA RA 1 1 1 RA RA L1 s C1 s 1 0 L1 s 0 1 1 0 V$1 0 V$2 0 . 1 1 0 V$3 RB L1 s C2 s 0 V0 I$V0 0 0 0 1 L1 s 2.5 Graphics 81 2.5 Graphics Mathematica has proven to be a powerful problem-solving environment for a large variety of engineering tasks. One of many reasons which make Mathematica such a useful tool is that it provides excellent support for visualizing the results of technical computations. Due to its freely programmable graphics functionality the flexibility of adapting the graphics display to individual applications is virtually unlimited. Analog Insydes extends Mathematica’s basic graphic capabilities by adding special plotting functions for circuit analysis and design, including Bode, Nyquist, Nichol, root locus plots, and transient waveforms. 2.5.1 Bode Plots The Bode plot is perhaps the most commonly used graphing scheme for visualizing frequency responses of linear analog systems. It consists of two separate charts which display magnitude and phase of a transfer function on a logarithmic and a linear scale vs. frequency, the latter being scaled logarithmically. The magnitude values are usually given in decibels (dB) and the phase values in degrees. In Analog Insydes, Bode plots are displayed using the command BodePlot (Section 3.9.1). With the basic syntax BodePlot[tfunc, frange] you can plot the transfer function tfunc within the frequency range frange. The transfer function must be a complex-valued function of the frequency variable fvar, and the frequency range a list of the form {fvar, fstart, fend}. BodePlot also allows to plot several transfer functions simultaneously. For this purpose, the first argument of BodePlot must be specified as a list of transfer functions. BodePlot[{tfunc , tfunc , }, frange] To demonstrate the Bode plot facility we define the following transfer function in terms of the frequency variable s. In[1]:= <<AnalogInsydes‘ In[2]:= H1[s_] := 1000./(1. + 10.1*s + s^2) We then display a Bode plot of the frequency response by evaluating H1 along the imaginary axis, s I Ω, for a frequency range of sec to sec. 2. Tutorial 82 Magnitude (dB) In[3]:= BodePlot[H1[I w], {w, 0.001, 1000.}] 1.0E-3 60 1.0E-1 1.0E0 1.0E1 1.0E2 1.0E3 1.0E-2 1.0E-1 1.0E0 Frequency 1.0E1 1.0E2 1.0E3 20 0 -20 -40 -60 1.0E-3 Phase (deg) 1.0E-2 40 1.0E-3 0 -25 -50 -75 -100 -125 -150 -175 1.0E-3 1.0E-2 1.0E-1 1.0E0 1.0E1 1.0E2 1.0E3 1.0E-2 1.0E-1 1.0E0 Frequency 1.0E1 1.0E2 1.0E3 Out[3]= Graphics BodePlot Options The output generated by BodePlot is influenced by a number of options listed in Options[BodePlot] , many of which are inherited from Options[LogLinearListPlot] from Mathematica’s standard package Graphics‘Graphics‘ . Here, we will discuss only some of those options which pertain exclusively to BodePlot or which must be used with a different syntax as compared to LogLinearListPlot . The relevant options and their default settings are listed below. Defaults are listed first, followed by the possible alternatives printed in slanted typewriter font. MagnitudeDisplay −> Decibels | AbsoluteValues | Linear PhaseDisplay −> Degrees | Radians PlotRange −> {Automatic, Automatic} The option MagnitudeDisplay controls the display of the magnitude values. When set to AbsoluteValues , magnitude values are not converted to decibels. Instead the absolute numerical values are displayed on a logarithmic scale. When MagnitudeDisplay is set to Linear, magnitude values are displayed on a linear scale. In a strict sense, the latter does no longer constitute a true Bode plot, but there exist a few applications where linear magnitude scaling is useful. With the value of the option PhaseDisplay we can choose whether phase values are shown as degrees or as radians. The meaning of the PlotRange option is slightly different for BodePlot than for other Mathematica plotting commands. Here, the value of PlotRange must be a list of two elements, {rangem , rangep }, specifying the plot ranges of the y-axes of the magnitude and the phase chart respectively. PlotRange has no effect on the ranges of the x-axes as these are determined by the given frequency range. The format for both y-ranges is the usual one as documented in the Mathematica manual, so any of the forms below are valid syntax: 2.5 Graphics 83 Automatic {ymin, ymax} {ymin, Automatic} Let’s graph H1 together with a second transfer function H2 and watch the effects of some BodePlot options. Other common graphics options such as PlotStyle can be applied just as usual. In[4]:= H2[s_] := 100./(1.6 + 8.2*s + s^2) Phase (rad) Magnitude (dB) In[5]:= BodePlot[{H1[I w], H2[I w]}, {w, 0.001, 1000.}, PhaseDisplay −> Radians, PlotRange −> {{−60, 80}, Automatic}, PlotStyle −> {{RGBColor[0, 0, 1], Dashing[{0.05}]}, {RGBColor[0, 1, 0]}}] 1.0E-3 80 60 40 20 0 -20 -40 1.0E-2 1.0E-1 1.0E0 1.0E1 1.0E2 1.0E3 1.0E-3 1.0E-2 1.0E-1 1.0E0 Frequency 1.0E1 1.0E2 1.0E3 1.0E-3 0 -0.5 -1 -1.5 -2 -2.5 -3 1.0E-3 1.0E-2 1.0E-1 1.0E0 1.0E1 1.0E2 1.0E3 1.0E-2 1.0E-1 1.0E0 Frequency 1.0E1 1.0E2 1.0E3 Out[5]= Graphics 2.5.2 Nyquist Plots Another widely used graphical representation of transfer functions is the Nyquist plot. It is a parametric plot of the real and imaginary part of a transfer function in the complex plane as the frequency parameter sweeps through a given interval. Nyquist plots are particularly useful for stability analysis in control system design because one can immediately check whether a negative feedback loop meets Nyquist’s stability criterion: If the Nyquist curve of the open loop system wraps around the point on the real axis then the corresponding closed loop system is unstable. Nyquist plots are produced by the command NyquistPlot (Section 3.9.4) whose argument sequence is the same as that of BodePlot (Section 3.9.1). Just as in the case of the latter you can plot one single transfer function or several transfer functions simultaneously. Let’s make a Nyquist plot of the frequency response of a system which is formed by a series connection of the two transfer functions H1 and H2, followed by a dB attenuator ( dB ). The overall transfer function of the resulting system is given by the product of the individual transfer functions. 2. Tutorial 84 In[6]:= H12a[s_] := H1[s] * H2[s] * 0.002 To make the curve look smoother we increase the number of plot points to . In[7]:= NyquistPlot[H12a[I w], {w, 0.001, 1000.}, PlotPoints −> 100] Im 20 40 60 80 100 120 Re -20 -40 -60 -80 Out[7]= Graphics We determine whether the corresponding closed-loop system is stable or unstable by taking a closer look at the region around the point using the PlotRange option. In[8]:= NyquistPlot[H12a[I w], {w, 0.1, 1000.}, PlotPoints −> 100, PlotRange −> {{−3, 1}, {−1, 1}}] Im 1 0.75 0.5 0.25 -3 -2.5 -2 -1.5 -1 -0.5 -0.25 0.5 1 Re -0.5 -0.75 -1 Out[8]= Graphics This plot reveals that the point is located to the right of the Nyquist curve, i.e. the curve wraps around the critical point. Hence the closed-loop system is unstable. 2.5 Graphics 85 NyquistPlot Options NyquistPlot inherits its plot options, which are accessible through Options[NyquistPlot] , from Mathematica’s standard function ListPlot . See the Mathematica book for detailed explanations of these options. NyquistPlot has additional options like, for example FrequencyScaling which controls the spacing of the frequency points at which the transfer function is sampled. FrequencyScaling can be set to Linear or Exponential , resulting in equidistant or exponentially spaced sampling points respectively. The default is Exponential . 2.5.3 Nichol Plots Yet another method of visualizing frequency responses is Nichol’s chart. A Nichol plot is similar to a Nyquist plot but shows gain on a logarithmic scale (dB) vs. phase on a linear scale (degrees), with an axis origin at the point dB . The advantage of Nichol’s chart is the ease by which gain and phase margins can be determined graphically. The gain margin is simply the negative value of the gain axis intersect. The phase margin is equal to the distance between the axis origin and the phase axis intersect. Nichol charts are computed by the function NicholPlot (Section 3.9.3). The argument sequence is the same as for NyquistPlot (Section 3.9.4) or BodePlot (Section 3.9.1). Let’s use a Nichol chart to determine the gain and phase margins of a system which is characterized by the following transfer function. In[9]:= H3[s_] := 20*(3 + s)/(s*(5 + s)*(20 + 5*s + 2*s^2)) We draw a Nichol chart of H3[I w] for an angular frequency Ω varying from sec to sec . Again, we increase the number of plot points to produce a smooth curve. In[10]:= NicholPlot[H3[I w], {w, 0.1, 5.}, AspectRatio −> 0.8, PlotPoints −> 100] dB 15 10 5 -360 -300 -240 -120 -60 0 deg -5 -10 -15 -20 Out[10]= Graphics Now, in order to read off the margins better, we zoom in on the part of the curve located in the fourth quadrant. 2. Tutorial 86 In[11]:= NicholPlot[H3[I w], {w, 0.1, 5.}, AspectRatio −> 0.8, PlotPoints −> 100, PlotRange −> {{−200, −80}, {−15, 2}}] dB -150 -120 -90 deg -2.5 -5 -7.5 -10 -12.5 -15 Out[11]= Graphics The curve crosses the gain axis at a gain of dB, so we have a gain margin of dB. At the phase axis intersect we have a phase value of approximately which is away from the axis origin. Hence, the phase margin is . NicholPlot Options Like NyquistPlot , NicholPlot inherits its options from ListPlot . NicholPlot has additional options like, for example, PhaseDisplay (see Section 2.5.1) and FrequencyScaling (see Section 2.5.2). 2.5.4 Root Locus Plots Let Hs k denote a rational transfer function whose coefficients depend on the real parameter k. A root locus plot shows the locus of the poles and zeros of Hs k in the complex plane as k varies within an interval k k . To draw a root locus plot use the command RootLocusPlot (Section 3.9.5). The calling format is RootLocusPlot[tfunc, {k, k , k }] where tfunc is a transfer function in the frequency variable s and one real parameter k. Of course, the parameter does not necessarily have to be named k. We can also use any other symbol to denote the parameter. Below, we define the transfer function H4[s, a] with coefficients which are functions of the parameter a. In[12]:= H4[s_, a_] := (a + 2*s + s^2)/(10 + 3*a*s + 4*s^2 + s^3) Then we graph the root locus of H4 as a varies from to . By default, RootLocusPlot samples the parameter interval at five equally spaced points. This number can be increased or decreased by 2.5 Graphics 87 means of the PlotPoints option. The poles and zeros of the transfer function are displayed as red crosses and green circles, respectively. In[13]:= RootLocusPlot[H4[s, a], {a, 3, 5}] a = 3.000e0 .. 5.000e0 (0% .. 100%) Im s Poles 0% 2.0E0 1. 2.0E0 -1. 100 Re s -0.5 -1. Zeros 0% -2.0E0 100 Out[13]= Graphics RootLocusPlot Options RootLocusPlot inherits its options from Graphics and adds its own options like PoleStyle and ZeroStyle to Options[RootLocusPlot] . With these options you can customize the display of poles and zeros, e.g. for better black-and-white printouts. The syntax of the PoleStyle option is PoleStyle −> mark[size, colorfunc, grstyle] where mark specifies the marker symbol (e.g. CrossMark , PlusMark , CircleMark , SquareMark , and PointMark ), size denotes the size of the marker in scaled coordinates, colorfunc is a pure function that returns a color value for an argument between and , and grstyle is a Mathematica graphics style or a sequence of styles, such as Hue or Thickness . Note that everything mentioned above applies to the ZeroStyle option as well. In the following command line we instruct RootLocusPlot to modify the styles for the pole and zero markers: 2. Tutorial 88 In[14]:= RootLocusPlot[H4[s, a],{a, 3, 5}, PoleStyle −> PlusMark[0.03, Hue[1−0.3*#] &, Thickness[0.012]], ZeroStyle −> PointMark[0.03, Hue[0.5−0.3*#] &, Thickness[0.005]]] a = 3.000e0 .. 5.000e0 (0% .. 100%) Im s Poles 0% 2.0E0 1. 2.0E0 -1. 100 Re s -0.5 Zeros 0% -1. -2.0E0 100 Out[14]= Graphics Pole-Zero Plots of Transfer Functions Without Parameters The RootLocusPlot function can also be used to display the pole and zero locations of transfer functions without parameters. For this purpose, RootLocusPlot must be called with a univariate transfer function, and no parameter interval must be passed as a second argument. In[15]:= RootLocusPlot[H3[s]] Im s 2.0E0 1. .0E0 -2.0E0 -1. Re s -0.5 -1. -2.0E0 Out[15]= Graphics 2.5 Graphics 89 Animating Root Locus Plots Sometimes it is helpful to animate a root locus plot because this shows the orientations of the pole and zero trajectories better than a static plot. Let’s demonstrate root locus plot animation on the transfer function H4[s, a] from above. To prepare the animation we compute a sequence of pole-zero plots with identical plot ranges by mapping the following RootLocusPlot function to a table of parameter values ranging from to in steps of . This is necessary because we want to produce one separate plot in every parameter step instead of one single plot in which the solutions from all steps are superimposed. In[16]:= RootLocusPlot[H4[s, a], {a, #, #}, PoleStyle −> CrossMark[0.03, Hue[0.7] &, Thickness[0.007]], ZeroStyle −> CircleMark[0.03, Hue[0.3] &, Thickness[0.007]], PlotRange −> {{−6, 1}, {−4, 4}}, ShowLegend −> False, LinearRegionStyle −> RGBColor[1, 1, 1] ] & /@ Table[x, {x, −3, 5, 2}] a = 5.000e0 Im s 2.0E0 1. -5.0E0 -2.0E0 -1. 1. Re s -1. -2.0E0 Out[16]= Graphics , Graphics , Graphics , Graphics , Graphics We show only one plot here; several plots are generated if the command is evaluated in a Mathematica notebook. To animate the root locus plot double-click on one of the images. Alternatively, you can select the resulting group of notebook cells containing the images with your mouse and then click on Cell | Animate Selected Graphics in Mathematica’s frontend menu. 2.5.5 Transient Waveforms For displaying transient waveforms, Analog Insydes provides the command TransientPlot (Section 3.9.6). The usage of this function is demonstrated in Section 2.7.1 and Section 2.7.6. 2. Tutorial 90 2.6 Modeling and Analysis of Nonlinear Circuits 2.6.1 Behavioral Models In Chapter 2.3 we implemented small-signal equivalent circuits for semiconductor devices as subcircuit objects composed of the available linear circuit primitives. We cannot use this approach to model the electrical characteristics of nonlinear elements, such as diodes or transistors. However, particularly for nonlinear circuit analysis, Analog Insydes provides special support for modeling arbitrary circuit element characteristics by specifying device equations directly. Models which are based on sets of mathematical equations describing the behavior of a circuit element or an analog building block are frequently called (analog) behavioral models, or ABMs. A behavioral model is similar to a subcircuit object in that it constitutes a box which is connected to a circuit through electrical ports. As indicated above, the difference is that the interior of a behavioral model box is implemented in terms of symbolic equations rather than a netlist. With Analog Insydes’ behavioral modeling capabilities you can model a large variety of nonlinear element characteristics. You can then use the function CircuitEquations (Section 3.5.1), with which you are already familiar, to set up symbolic systems of nonlinear modified nodal or sparse tableau equations. 2.6.2 Defining Behavioral Models The Argument Sequence of the Model Command for ABM Definitions Behavioral models are defined using the Model (Section 3.2.1) command, just like subcircuits (see Section 2.3.2). Analog Insydes recognizes a request to define a behavioral model by the presence of the named parameter Variables and the absence of a subcircuit Netlist on the right-hand side of the Definition argument in a Model call. The full syntax for an ABM definition is shown below. Again, slanted typewriter font denotes optional arguments. Model[ Name −> subcircuit class name, Selector −> selector, Scope −> scope, Ports −> {port nodes}, Parameters −> {parameters}, Symbolic −> {symbolic parameters}, Defaults −> {defaults}, InitialConditions −> {initial conditions}, InitialGuess −> {initial guess}, Translation −> {parameter translation rules}, Variables −> {variables}, Definition −> Equations[equations] ] 2.6 Modeling and Analysis of Nonlinear Circuits 91 Except for the additional arguments and the keyword Definition , all other named arguments of the Model function have the same meaning as for subcircuit definitions. Following, we discuss the two arguments Definition and Variables . Example: A Diode Let’s illustrate the steps which are necessary to define a behavioral model by implementing a nonlinear device model for a junction diode. A vd/vt id(vd)=Is (e VD -1) ID C Figure 6.1: Junction diode The diode shown in Figure 6.1 has two terminals, the anode and the cathode, denoted by the node identifiers A and C, respectively. The branch voltage vD and the branch current iD satisfy the device equation iD IS evD Vt where IS denotes the reverse-bias saturation current and Vt the thermal voltage. Typical values for IS are A A. Vt is given by k Tq where k denotes Boltzmann’s constant (k WsK). T is the absolute temperature (in Kelvin), and q is the charge of an electron (q As). In[1]:= <<AnalogInsydes‘ In[2]:= ThermalVoltage[T_] := 1.381*10^−23 * T / (1.602*10^−19) At a temperature of K ( C), Vt is approximately mV: In[3]:= ThermalVoltage[300.] Out[3]= 0.0258614 Since the thermal voltage is only defined in terms of constants and the global quantity temperature, Vt is a global parameter. Thus, we have a local parameter of the diode device equation which is IS , and a global parameter which is Vt . Note that a global parameter param is defined by setting Global[param] in the Parameters argument. Assuming Scope −> Local and no Translation rules, the first half of the Model definition is thus given by 2. Tutorial 92 Model[ Name −> Diode, Selector −> DC, Ports −> {A, C}, Parameters −> {Is, Global[Vt]}, ] The Definition Argument For behavioral model definitions, the Definition parameter must be of the form Definition −> Equations[eq1 , eq2 , ] where eq1 , eq2 , denote the symbolic device equations. (For compatibility reasons the right hand side of the Definition parameter may also be a list of equations.) When specifying an arbitrary set of equations we must tell Analog Insydes how the unknowns of the equations relate to the port currents and voltages of a model object. node+ Voltage[node+, node-] Current[node+, node-] nodeFigure 6.2: Voltage and current identifiers at a model port branch Ports of behavioral models are defined in terms of electrical port branches. Every unique pair of node identifiers [node+, node−] introduces an electrical port branch in between the model port nodes node+ and node−. For the associated port voltage and current the positive reference direction is defined to be oriented from node+ to node−, which is illustrated in Figure 6.2. Port variables in behavioral model equations can be referred to by means of two special keywords which are recognized by Analog Insydes and replaced by the corresponding global current or voltage identifiers during model instantiation and expansion. The keywords provided to make references to port currents and voltages are, respectively: Current[node+, node-] Voltage[node+, node-] Note that the above definition of positive reference directions implies that Current[nodeA, nodeB] and Current[nodeB, nodeA] are two different quantities and refer to different port branches. Similarly, Current[nodeA, nodeB] and Voltage[nodeB, nodeA] do not refer to the same port branch. 2.6 Modeling and Analysis of Nonlinear Circuits 93 In the case of the diode we have two port nodes A and C, which are connected by an electrical port branch [A, C]. The port current, i.e. iD , is thus designated by Current[A, C] and the port voltage, i.e. vD , is designated by Voltage[A, C]. Hence, the model equation must be written as Definition −> Equations[Current[A, C] == Is (Exp[Voltage[A, C]/Vt] − 1)] In this example, the Definition contains only one single equation, but there is no limit to the number of equations. We will discuss some more advanced examples in which this will become apparent later in this chapter. A note on interfacing: Some numerical circuit simulators with behavioral model simulation capabilities use the currents into the pins (port nodes) of a model object and the node voltages at the pins as symbolic quantities by which the model equations are interfaced with the exterior circuit. This approach is not well suited for other analysis methods than modified nodal analysis. Using port branches with associated currents and voltages facilitates setting up other formulations which involve loop equations, such as the sparse tableau. The Variables Argument The Variables argument serves to specify the symbols which are unknowns of the model equations. The diode equation contains two unknowns, Current[A, C] and Voltage[A, C], so the Variables argument is Variables −> {Current[A, C], Voltage[A, C]} The need for the Variables specification may not be entirely obvious here. One might argue that Analog Insydes should know that port current and voltage identifiers are unknowns. However, port currents and voltages are not always the only variables of a set of model equations. Similarly to a subcircuit which may have internal nodes, a behavioral model may also contain internal variables which are not of the form Voltage[node+, node−] or Current[node+, node−]. Without the Variables argument, Analog Insydes would not be able to distinguish between internal variables and global parameters, such as Vt in the diode equation. So, by convention, you must specify all identifiers in a set of model equations which are neither local nor global parameters, including the port branch quantities. The complete ABM definition for the diode is then given by Model[ Name −> Diode, Selector −> DC, Ports −> {A, C}, Parameters −> {Is, Global[Vt]}, Variables −> {Current[A, C], Voltage[A, C]}, Definition −> Equations[Current[A, C] == Is (Exp[Voltage[A, C]/Vt] − 1)] ] 2. Tutorial 94 2.6.3 Referencing Behavioral Models Behavioral models are referenced exactly like subcircuits. Since we have already learned in Chapter 2.3 how to write hierarchical netlists we can start immediately with an example. Let’s write a netlist for the diode circuit in Figure 6.3 using the diode model developed above. 1 R1 V0 2 D1 Figure 6.3: Diode circuit In[4]:= diodeNetwork = Circuit[ Netlist[ {V0, {1, 0}, V0}, {R1, {1, 2}, R1}, {D1, {2 −> A, 0 −> C}, Model −> Diode, Selector −> DC} ], Model[ Name −> Diode, Selector −> DC, Ports −> {A, C}, Parameters −> {Is, Global[Vt]}, Variables −> {Current[A, C], Voltage[A, C]}, Definition −> Equations[ Current[A, C] == Is (Exp[Voltage[A, C]/Vt] − 1) ] ] ] Out[4]= Circuit 2.6.4 Nonlinear Circuit Equations Setting up Nonlinear Equations Using the command CircuitEquations you can set up modified nodal or sparse tableau equations for nonlinear circuits just as for linear circuits. The only restriction is that nonlinear systems of 2.6 Modeling and Analysis of Nonlinear Circuits 95 equations cannot be set up in matrix form. Therefore, whenever a netlist contains behavioral models, you must call CircuitEquations with the option MatrixEquation −> False, or as in our case, you need to switch the AnalysisMode to e.g. DC for setting up nonlinear static equations which automatically implies the setting MatrixEquation −> False. In[5]:= dnwmna = CircuitEquations[diodeNetwork, AnalysisMode −> DC]; DisplayForm[dnwmna] Out[6]//DisplayForm= V$1 V$2 V$1 V$2 I$V0 0, I$AC$D1 0, V$1 V0, R1 R1 V$2 Vt Is$D1, V$1, V$2, I$V0, I$AC$D1, I$AC$D1 1 E DesignPoint Here, we have set up a system of nonlinear modified nodal equations in the unknowns V$1, V$2, I$V0, and I$AC$D1 . The latter symbol has been created automatically from the port current identifier Current[A, C] in the definition of the diode model. All port branch voltages have been replaced by corresponding differences of node voltages. Generally, a port current Current[x, y] in a model instance MX will be denoted by symbols of the form I$xy$MX. A port voltage Voltage[x, y] will be denoted by V$xy$MX, provided that branch voltages appear as unknowns in the selected analysis method. To examine both effects we set up the sparse tableau equations. In[7]:= CircuitEquations[diodeNetwork, Formulation −> SparseTableau, AnalysisMode −> DC ] // GetVariables Out[7]= V$V0, V$R1, V$AC$D1, I$V0, I$R1, I$AC$D1 We use the command GetVariables (Section 3.6.7) to extract the list of variables from the equation system. As you can see, the corresponding variables are called V$AC$D1 and I$AC$D1 Solving Nonlinear Equations Solving nonlinear circuit equations analytically is, unfortunately, mathematically impossible in the general case. However, in many applications it is possible to reduce the original set of equations by eliminating a number of variables. This may already yield some qualitative insight into the behavior of a nonlinear circuit. On the other hand, we can always assign values to symbolic parameters and solve the equations numerically using NDAESolve (Section 3.7.5). Let’s derive an expression which relates the diode current I$AC$D1 to the input voltage V0 by eliminating all other variables. For this task, Analog Insydes provides the function CompressNonlinearEquations (Section 3.12.2) which removes equations and variables from a nonlinear DAEObject that are irrelevant for solving for a set of given variables. The option setting EliminateVariables −> All additionally allows for eliminating variables that occur linear somewhere in the equations. 2. Tutorial 96 In[8]:= dnwsol = CompressNonlinearEquations[dnwmna, I$AC$D1, EliminateVariables −> All]; DisplayForm[dnwsol] Out[9]//DisplayForm= I$AC$D1 R1V0 Vt I$AC$D1 1 E Is$D1, I$AC$D1, DesignPoint The implicit equation is what we have been looking for. Without resorting to approximation methods such as Taylor series we cannot simplify the result any further and solve for the diode current analytically. 2.6.5 Multi-Dimensional Models The Ebers-Moll Transistor Model The procedure for modeling one-dimensional nonlinear element characteristics can be easily extended to the multi-dimensional case. Let’s demonstrate multi-dimensional device modeling on a practical example by defining nonlinear DC models for a bipolar junction transistor (see Figure 6.4). IC VBC C B VCE IB E VBE IE Figure 6.4: NPN transistor Our considerations will be based on the BJT model introduced by Ebers and Moll which expresses the relations between the transistor currents and voltages IC , IE , VBE , and VBC as IC IS eVBE Vt IE IS eVBC Vt Αr IS eVBE Vt IS eVBC Vt Αf In these equations, the parameter IS represents the transport saturation current, Αr and Αf denote the large-signal reverse and forward current gains of the common base configuration, and Vt designates the thermal voltage. In integrated circuit design, the saturation current is usually expressed as the product of the transport saturation current density JS , which is a process parameter, and the emitter area A, which is a design parameter: 2.6 Modeling and Analysis of Nonlinear Circuits 97 IS JS A The remaining two unknown voltages and currents at the transistor’s terminals, IB and VCE can be computed from KCL and KVL (see Figure 6.5) as IB IC IE VCE VBE VBC IC VBC IB C B VBE VCE E C Voltage[B,C] Current[B,C]=-IC B Current[B,E]=-IE Voltage[B,E] E IE Figure 6.5: NPN transistor and corresponding ABM port branch definition In most linear applications, bipolar transistors are typically operated in the forward active region which is roughly characterized by VBE V and VBC V. Under these assumptions we can simplify the Ebers-Moll model to IC IS eVBE Vt IS IE eVBE Vt Αf because as compared to the terms involving eVBE Vt , all other terms are smaller by several orders of magnitude. A BJT operating in the forward active region acts as a good current amplifier from the base current IB to the collector current IC with the gain relationship I C Βf I B The parameter Βf denotes the large-signal forward current gain in common-emitter configuration. It is often more convenient to think in terms of forward and reverse current gains with respect to 2. Tutorial 98 the base current, i.e. Βf and Βr , than in terms of the model parameters Αf and Αr in the original Ebers-Moll equations. The relationship between Αf and Βf , as well as between Αr and Βr is given by Β Α Α Α Β Β or, equivalently, By making use of parameter translation rules in the model definition (see Section 2.3.7), we can let Analog Insydes compute the values for Αf and Αr automatically from given values for Βf and Βr . Implementation of Nonlinear DC Transistor Models With the above background information on transistor models we are now ready to define a largesignal BJT model for DC circuit analysis. We start by implementing a global DC model for an NPN transistor using the unsimplified device equations after Ebers and Moll from the previous subsection. Name −> NPNBJT, Selector −> EbersMoll, Scope −> Global, Ports −> {C, B, E}, Let’s decide that we do not want to characterize a transistor by the Ebers-Moll model parameters Is, alphaf, alphar, and Vt but want to use the parameters Js, Area, betaf, betar, and Temperature instead. We do not need to rewrite the model equations if we specify translation rules which translate our model parameters to those of the Ebers-Moll model. Remember that the function ThermalVoltage has already been defined in Section 2.6.2. Parameters −> {betaf, betar, Js, Area, Global[Temperature]}, Translation −> {alphaf −> betaf/(1+betaf), alphar −> betar/(1+betar), Is −> Js*Area, Vt :> ThermalVoltage[Temperature]}, The Ebers-Moll equations describe the functional relations between the voltages and currents at two electrical branches, the base-collector branch and the base-emitter branch, which we use as the port branches of our model. Associated with the port branches are the variables Voltage[B, E], Current[B, E], Voltage[B, C], and Current[B, C], which must be specified as 2.6 Modeling and Analysis of Nonlinear Circuits 99 Variables −> {Current[B, C], Voltage[B, C], Current[B, E], Voltage[B, E]}, in the model definition. It remains to write the model equations in terms of the port branch variables, paying attention to the different positive reference directions assumed for the port currents as compared to IC and IE in the Ebers-Moll equations. While the latter are defined to be positive for currents flowing into the collector and emitter, positive values of Current[B, C] and Current[B, E] denote currents flowing out of these terminals. We account for this difference by changing the sign on the right-hand side of the model equations. Definition −> Equations[ Current[B, C] == −Is*(Exp[Voltage[B, E]/Vt] − 1) + Is/alphar*(Exp[Voltage[B, C]/Vt] − 1), Current[B, E] == Is/alphaf*(Exp[Voltage[B, E]/Vt] − 1) − Is*(Exp[Voltage[B, C]/Vt] − 1) ], To store the transistor model in the global database we wrap the complete Model definition into a Circuit structure and expand it with ExpandSubcircuits (Section 3.4.1). In[10]:= Circuit[ Model[ Name −> NPNBJT, Selector −> EbersMoll, Scope −> Global, Ports −> {C, B, E}, Parameters −> {betaf, betar, Js, Area, Global[Temperature]}, Translation −> {alphaf −> betaf/(1+betaf), alphar −> betar/(1+betar), Is −> Js*Area, Vt :> ThermalVoltage[Temperature]}, Variables −> {Current[B, C], Voltage[B, C], Current[B, E], Voltage[B, E]}, Definition −> Equations[ Current[B, C] == −Is*(Exp[Voltage[B, E]/Vt] − 1) + Is/alphar*(Exp[Voltage[B, C]/Vt] − 1), Current[B, E] == −Is*(Exp[Voltage[B, C]/Vt] − 1) + Is/alphaf*(Exp[Voltage[B, E]/Vt] − 1) ] ] ] // ExpandSubcircuits; 2. Tutorial 100 Similarly, we define a simplified Ebers-Moll model for transistors operating in the forward active region. In[11]:= Circuit[ Model[ Name −> NPNBJT, Selector −> EbersMollForwardActive, Scope −> Global, Ports −> {C, B, E}, Parameters −> {betaf, Js, Area, Global[Temperature]}, Translation −> {alphaf −> betaf/(1+betaf), Is −> Js*Area, Vt :> ThermalVoltage[Temperature]}, Variables −> {Current[B, C], Voltage[B, C], Current[B, E], Voltage[B, E]}, Definition −> Equations[ Current[B, C] == −Is*(Exp[Voltage[B, E]/Vt]), Current[B, E] == Is/alphaf*(Exp[Voltage[B, E]/Vt]) ] ] ] // ExpandSubcircuits; Both models are now stored in the global database: In[12]:= GlobalSubcircuits[] Out[12]= NPNBJT, EbersMoll, NPNBJT, EbersMollForwardActive 2.6.6 Nonlinear DC Circuit Analysis Calculating the Bias Point of a Transistor Circuit Analog Insydes’ nonlinear modeling capabilities and numeric equation solver allow for solving circuit analysis problems quickly and reliably without tedious and error-prone hand calculations. Let’s demonstrate one such application: Determine the operating-point currents and voltages IB, IC, VBE, VCE for the circuit shown in Figure 6.6, if (a) RB k and (b) RB k . Assume that the transistor has an emitter area of mil , Βf , Βr , JS ΜAmil , and that it operates at a temperature of K. The values of the supply voltage and the collector resistance are VCC V and RC k . 2.6 Modeling and Analysis of Nonlinear Circuits 101 1 RC RB IB IC VCC 3 Q1 2 VCE VBE Figure 6.6: Bipolar transistor circuit For didactic reasons we do not use ReadNetlist to automatically import the netlist, but rather write the circuit by hand. Moreover, instead of using a BJT transistor model from the predefined Analog Insydes model library, we select a suitable model from the global database which contains the two NPNBJT models defined in the previous section. By leaving the model selector unspecified, Selector −> BJTModel, we can postpone the final choice of the underlying model equations until we set up circuit equations. The option Pattern −> Impedance in the value field of RB introduces the current I$RB into the MNA equations. The current I$RB is identical to the base current IB, so we can compute the latter directly from the equations without having to determine it manually from IC and IE by KCL. In[13]:= bjtbias = Circuit[ Netlist[ {VCC, {1, 0}, Type −> VoltageSource, Symbolic −> VCC, Value −> 12.}, {RB, {1, 2}, Pattern −> Impedance, Symbolic −> RB, Value −> 500.*10^3}, {RC, {1, 3}, Symbolic −> RC, Value −> 4000.}, {Q1, {3 −> C, 2 −> B, 0 −> E}, Model −> NPNBJT, Selector −> BJTModel, betaf −> 100., betar −> 0.2, Js −> 6.*10^−16, Area −> 4., Temperature −> 300.} ] ] Out[13]= Circuit In order to keep model complexity as low as possible, we make the initial assumption that Q1 operates in the forward active region and set up a system of symbolic static circuit equations using the simplified Ebers-Moll model by setting the options AnalysisMode −> DC and ElementValues −> Symbolic. 2. Tutorial 102 In[14]:= mnaeqsfa = CircuitEquations[ bjtbias /. BJTModel −> EbersMollForwardActive, AnalysisMode −> DC, ElementValues −> Symbolic]; DisplayForm[mnaeqsfa] Out[15]//DisplayForm= V$1 V$3 I$RB I$VCC 0, I$BC$Q1 I$BE$Q1 I$RB 0, RC V$1 V$3 I$BC$Q1 0, V$1 VCC, RC I$RB RB V$1 V$2 0, I$BC$Q1 2.4 1015 E38.6676 V$2 , I$BE$Q1 2.424 1015 E38.6676 V$2 , V$1, V$2, V$3, I$VCC, I$RB, I$BC$Q1, I$BE$Q1, DesignPoint VCC 12., RB 500000., RC 4000. This system of equations can be solved by Analog Insydes’ numerical root finding function NDAESolve (Section 3.7.5), which starts from an initial guess for the values of the variables. By default, initial values of for all unknowns are chosen which is very often close enough to ensure convergence. In[16]:= NDAESolve[mnaeqsfa, {t, 0}] Out[16]= V$1 12., V$2 0.712996, V$3 2.9704, I$VCC 0.00227997, I$RB 0.000022574, I$BC$Q1 0.0022574, I$BE$Q1 0.00227997 From the result we can immediately read off the operating point. We have VBE VCE IB IC V$2 V V$3 V I$RB mA I$BC$Q1 mA Next, we repeat the same calculation for RB k using the command UpdateDesignPoint (Section 3.6.14) to alter the numeric element value for RB. In[17]:= mnaeqsfa = UpdateDesignPoint[mnaeqsfa, RB −> 1.*10^5]; NDAESolve[mnaeqsfa, {t, 0}] Out[18]= V$1 12., V$2 0.75452, V$3 32.9819, I$VCC 0.0113579, I$RB 0.000112455, I$BC$Q1 0.0112455, I$BE$Q1 0.0113579 This time, we obtain a physically nonsensical value of V for VCE which indicates that our initial assumption about the operating condition of Q1 has been violated. Indeed, for RB k , Q1 operates in deep saturation. We must therefore select the full Ebers-Moll model to take these effects into account. 2.6 Modeling and Analysis of Nonlinear Circuits 103 In[19]:= mnaeqssat = CircuitEquations[ bjtbias /. BJTModel −> EbersMoll, AnalysisMode −> DC, ElementValues −> Symbolic]; DisplayForm[mnaeqssat] Out[20]//DisplayForm= V$1 V$3 I$RB I$VCC 0, I$BC$Q1 I$BE$Q1 I$RB 0, RC V$1 V$3 I$BC$Q1 0, V$1 VCC, RC I$RB RB V$1 V$2 0, I$BC$Q1 2.4 1015 1 E38.6676 V$2 1.44 1014 1 E38.6676 V$2V$3 , I$BE$Q1 2.424 1015 1 E38.6676 V$2 2.4 1015 1 E38.6676 V$2V$3 , V$1, V$2, V$3, I$VCC, I$RB, I$BC$Q1, I$BE$Q1, DesignPoint VCC 12., RB 500000., RC 4000. Solving these enhanced equations will now deliver a proper result for RB k . In[21]:= mnaeqssat = UpdateDesignPoint[mnaeqssat, RB −> 1.*10^5]; NDAESolve[mnaeqssat, {t, 0}] Out[22]= V$1 12., V$2 0.720901, V$3 0.13522, I$VCC 0.00307899, I$RB 0.000112791, I$BC$Q1 0.0029662, I$BE$Q1 0.00307899 We finally obtain: VBE VCE IB IC V$2 V V$3 V I$RB mA I$BC$Q1 mA 2.6.7 References The BJT circuit DC analysis example was adapted from the book by R. L. Geiger, P. E. Allen, and N. R. Strader: VLSI Design Techniques for Analog and Digital Circuits, Mc-Graw Hill, 1990. 2. Tutorial 104 2.7 Time-Domain Analysis of Nonlinear Dynamic Circuits In Chapter 2.6 it was shown how to model and analyze circuits with nonlinear element characteristics. In this chapter, we extend these considerations to the analysis of circuits containing not only nonlinear but also dynamic components, such as capacitors and inductors. From a mathematical point of view this means that a system of equations which describes a nonlinear dynamic circuit involves linear and nonlinear algebraic constraints as well as time derivatives of some circuit variables. Equations with these properties are called system of nonlinear Differential and Algebraic Equations, or DAE. When analyzing a dynamic circuit we are usually interested in finding the response of the circuit to a given input signal as a function of time. This analysis mode is commonly referred to as transient analysis. Computing a transient response requires solving an implicit DAE system numerically, starting from an initial solution for the voltages and currents known as the DC operating point. With Mathematica’s built-in command NDSolve we cannot handle this type of problem because solving differential equations with algebraic constraints is not supported. Therefore, Analog Insydes includes a special DAE solver for circuit simulation called NDAESolve which will be introduced in the following section. 2.7.1 Transient Circuit Analysis A Diode Rectifier Circuit Let’s start to demonstrate transient analysis on the half-wave diode rectifier circuit shown in Figure 7.1. This circuit contains both nonlinear as well as dynamic components, namely the diode D1 and the capacitor C1. Given numerical element values and input voltage waveform V Vin t we shall compute the transient response Vout t across the load resistor R1. D1 1 V0 2 C1 R1 Figure 7.1: Diode rectifier circuit Vout 2.7 Time-Domain Analysis of Nonlinear Dynamic Circuits 105 As usual, we prepare our circuit analysis by writing a netlist description of the circuit. For the diode, we use the model from the Analog Insydes model data base (Chapter 4.3). The model parameters Is (saturation current) and Vt (thermal voltage) are set to Is pA and Vt mV. The values of the circuit elements are assumed to be R1 and C1 nF. In[1]:= <<AnalogInsydes‘ In[2]:= rectifier = Circuit[ Netlist[ {V0, {1, 0}, Vin}, {R1, {2, 0}, Symbolic −> R1, Value −> 100.}, {C1, {2, 0}, Symbolic −> C1, Value −> 1.*10^−7}, {D1, {1 −> A, 2 −> C}, Model −> "Diode", Selector −> "Spice", IS −> 1.*10^−12} ] ] Out[2]= Circuit Next, we use the function CircuitEquations (Section 3.5.1) to set up a system of nonlinear differential MNA equations in the time domain. In oder to express all voltages and currents as functions of time f t and to include time derivatives f ! t introduced by dynamic components the option AnalysisMode −> Transient must be specified in the function call. AnalysisMode −> Transient implies MatrixEquation −> False, therefore the equations are written as list of equations regardless of the current setting of MatrixEquation . CircuitEquations returns a Transient DAEObject which can be displayed via the command DisplayForm . In[3]:= rectifierMNA = CircuitEquations[rectifier, AnalysisMode −> Transient]; DisplayForm[rectifierMNA] Out[4]//DisplayForm= I$AC$D1t I$V0t 0, I$AC$D1t 0.01 V$2t 1. 107 V$2 t 0, V$1t Vin, I$AC$D1t 1. 1012 1 E38.6635 V$1tV$2t 1. 1012 V$1t V$2t, V$1t, V$2t, I$V0t, I$AC$D1t, DesignPoint This set of modified nodal equations is a typical DAE system. It comprises implicit differential equations as well as both linear and nonlinear algebraic constraints. The NDAESolve Command Analog Insydes provides the function NDAESolve (Section 3.7.5) for solving DAE systems numerically. NDAESolve[dae, {tvar, t , t } , params , opts ] where dae is a DC or Transient DAEObject containing the circuit equations and variables. The argument tvar denotes the time variable for which the solutions are computed in the time interval tvar " t t , or at the time instant tvar t . Additionally, params allows for carrying out a parametric analysis. For possible parameter specifications please refer to Section 3.7.2. Finally, opts is a sequence of zero or more solver options of the form option −> value (see Section 2.7.4). 2. Tutorial 106 Let’s use NDAESolve to compute the transient response Vout t of the diode circuit to a sinusoidal input voltage Vin t V sinΩt. We choose Ω s , replace the symbol Vin which denotes the input voltage by the sine function, and integrate the circuit equations numerically with respect to the time variable t from t to t Μs. In[5]:= solutions = NDAESolve[rectifierMNA /. Vin −> Sin[10^6 t], {t, 0., 2.*10^−5}] Out[5]= V$2 InterpolatingFunction0, 0.00002, , V$1 InterpolatingFunction0, 0.00002, , I$V0 InterpolatingFunction0, 0.00002, , I$AC$D1 InterpolatingFunction0, 0.00002, Like Mathematica’s NDSolve, NDAESolve returns the solutions for the node voltages and currents in terms of InterpolatingFunction objects. This allows for accessing the numerical values of all variables at any point of time in the simulation interval. To obtain the voltages and currents at a certain point of time ti , we first have to rewrite the interpolating functions as functions of time. In[6]:= functions = First[solutions] /. Rule[a_, b_] −> Rule[a, b[t]] Out[6]= V$2 InterpolatingFunction0, 0.00002, t, V$1 InterpolatingFunction0, 0.00002, t, I$V0 InterpolatingFunction0, 0.00002, t, I$AC$D1 InterpolatingFunction0, 0.00002, t Then we replace t by a particular value, here t Μs. This yields the solution vector as a list of rules. In[7]:= functions /. t −> 10^−5 Out[7]= V$2 0.337585, V$1 0.543881, I$V0 1.88147 1012 , I$AC$D1 1.88147 1012 From the result we can immediately extract the voltage values for V (t Μs) and Vout (t Μs), as well as the value for the diode current ID1 (t Μs) V V$1 V Vout V$2 V ID1 I$AC$D1 pA Plotting Transient Waveforms For graphical display of transient waveforms computed with NDAESolve , Analog Insydes provides the function TransientPlot (Section 3.9.6). With TransientPlot , several interpolating functions can be plotted in a single diagram or displayed as graphics array. The command syntax is TransientPlot[numericaldata, vars, {tvar, t , t } , opts ] where numericaldata is a list of rules of interpolating functions. The format is compatible to the return value of e.g. NDSolve and NDAESolve (see Section 3.7.1). The argument vars is a list of the variables to be plotted. Besides the variables themselves, this list may also contain mathematical expressions 2.7 Time-Domain Analysis of Nonlinear Dynamic Circuits 107 in terms of these variables. The symbol tvar denotes the time variable for which the waveforms are plotted from tvar t to tvar t . Zero or more options opts can be specified as sequence of rules of the form option −> value (see Section 2.7.6). To visualize the transient waveforms of the node voltages V$1 and V$2 in the simulated time interval we can use TransientPlot as shown below. By default, all waveforms are superimposed in one single graph. In[8]:= TransientPlot[solutions, {V$1[t], V$2[t]}, {t, 0., 2.*10^−5}] 1 0.5 V$1[t] -6 5. 10 0.00001 0.000015 t 0.00002 V$2[t] -0.5 -1 Out[8]= Graphics Quasi-DC Analysis To demonstrate the influence of the capacitor C1 on the output voltage we rerun the simulation, but this time we neglect the dynamic components of the circuit equations. This can be achieved by setting the NDAESolve option AnalysisMode from its default value Transient to DC. The DC analysis method replaces all time derivatives in the circuit equations by zero. Thus, inductors are replaced by short circuits because all inductor voltages are set to zero, and capacitors are replaced by open circuits because all capacitor currents are set to zero. Inductor: Capacitor: #IL t #t #UC t IC t C #t VL t L $ DC VL t DC IC t $ % % Short Circuit Open Circuit Let’s apply quasi-DC analysis to our rectifier circuit by specifying the above-mentioned option in the call to NDAESolve . In[9]:= solDC = NDAESolve[rectifierMNA /. Vin −> Sin[10^6 t], {t, 0., 10^−5}, AnalysisMode −> DC] Out[9]= V$1 InterpolatingFunction0, 0.00001, , V$2 InterpolatingFunction0, 0.00001, , I$V0 InterpolatingFunction0, 0.00001, , I$AC$D1 InterpolatingFunction0, 0.00001, 2. Tutorial 108 The influence of the capacitor C1 can be clearly recognized from the plot of the node voltages V$1 and V$2. In[10]:= TransientPlot[solDC, {V$1[t], V$2[t]}, {t, 0., 10^−5}] 1 0.5 V$1[t] -6 2. 10 -6 4. 10 -6 6. 10 -6 8. 10 t 0.00001 V$2[t] -0.5 -1 Out[10]= Graphics 2.7.2 Analysis of a Differential Amplifier Transient Analysis In this section, we want to examine a more complicated circuit to demonstrate the features and capabilities of the DAE solver. Consider the differential amplifier circuit shown in Figure 7.2 consisting of four bipolar junction transistors. We shall compute the transient response Vout t to a rectangular voltage pulse applied at node 1. 2.7 Time-Domain Analysis of Nonlinear Dynamic Circuits 109 8 VCC RC1 5 4 Cload 1 RBIAS RC2 RS1 Q1 Q2 Vout 3 2 V1 RS2 6 7 Q3 Q4 9 VEE Figure 7.2: Differential amplifier circuit Again we start by writing a netlist (of course we could have used ReadNetlist as well). Let the values of the circuit elements be given as RS1 RS2 k , RC1 RC2 k , RBIAS k , and CLOAD pF. The supply voltages are VCC V and VEE V. For all transistors Q1, , Q4, we use the full Gummel-Poon transistor model implemented in the Analog Insydes model library (see Section 4.3.2). We assume the following model parameter values: transport saturation current IS A, large-signal forward and reverse current gains BF and BR , and the global temperature TEMP K. 2. Tutorial 110 In[11]:= diffAmp = Circuit[ Netlist[ {RS1, {1, 2}, Symbolic −> RS1, Value −> 1.*10^3}, {RS2, {3, 0}, Symbolic −> RS2, Value −> 1.*10^3}, {RC1, {4, 8}, Symbolic −> RC1, Value −> 1.*10^4}, {RC2, {5, 8}, Symbolic −> RC2, Value −> 1.*10^4}, {RBIAS, {7, 8}, Symbolic −> RBIAS, Value −> 2.*10^4}, {CLOAD, {4, 5}, Symbolic −> CLOAD, Value −> 5.*10^−12}, {Q1, {4 −> C, 2 −> B, 6 −> E}, Model −> BJT, Selector −> GummelPoon, Parameters −> BJTNPN}, {Q2, {5 −> C, 3 −> B, 6 −> E}, Model −> BJT, Selector −> GummelPoon, Parameters −> BJTNPN}, {Q3, {6 −> C, 7 −> B, 9 −> E}, Model −> BJT, Selector −> GummelPoon, Parameters −> BJTNPN}, {Q4, {7 −> C, 7 −> B, 9 −> E}, Model −> BJT, Selector −> GummelPoon, Parameters −> BJTNPN}, {VCC, {8, 0}, Type −> VoltageSource, Symbolic −> VCC, Value −> 12.}, {VEE, {9, 0}, Symbolic −> VEE, Value −> −12.}, {V1, {1, 0}, V1} ], ModelParameters[Name −> BJTNPN, Type −> "NPN", BF −> 255.9, BR −> 6.092, IS −> 14.34*10^−15], GlobalParameters[TEMP −> 300.15] ] Out[11]= Circuit Setting up the circuit equations in the time-domain yields the following DAE system of 32 equations in 32 variables. In[12]:= diffAmpMNA = CircuitEquations[diffAmp, AnalysisMode −> Transient] Out[12]= DAETransient, 32 32 Next, we define the input signal V t. We choose a rectangular voltage pulse with an amplitude of V, a duration of Μs and a delay of Μs. This waveform can be set by the Analog Insydes command PulseWave (Section 4.1.3). In[13]:= Vpulse[t_] := PulseWave[t, 0, 2, 2.5*10^−6, 0, 0, 4.*10^−6, 10^−5] A graphical representation of the stimulus signal is shown below. 2.7 Time-Domain Analysis of Nonlinear Dynamic Circuits 111 In[14]:= TransientPlot[Vpulse[t], {t, 0., 10^−5}, PlotRange −> {−1, 3}] 3 2.5 2 1.5 Vpulse[t] 1 0.5 -6 2. 10 -6 4. 10 -6 6. 10 -6 8. 10 t 0.00001 -0.5 -1 Out[14]= Graphics Then, we call NDAESolve to simulate the transient behavior of the differential amplifier for t " Μs. The NonlinearMethod option allows for choosing between different algorithms for solving systems of nonlinear algebraic equations numerically. By default, Mathematica’s numerical solver FindRoot is applied, whereas in this example we want to make use of another implementation of Newton’s method called NewtonIteration . In[15]:= transient = NDAESolve[diffAmpMNA /. V1 −> Vpulse[t], {t, 0., 10^−5}, NonlinearMethod −> NewtonIteration]; Now, we use TransientPlot to plot the waveforms of the input and output voltages V$1 and V$5. In[16]:= TransientPlot[transient, {V$1[t], V$5[t]}, {t, 0., 10^−5}] 12 10 8 V$1[t] 6 V$5[t] 4 2 -6 2. 10 -6 4. 10 -6 6. 10 -6 8. 10 t 0.00001 Out[16]= Graphics DC-Transfer Analysis Next, we shall compute the DC-transfer characteristic Vout Vin V$5[V1] of the differential amplifier circuit as the input voltage is swept from V to V. Therefore, we first set up the static circuit equations by calling CircuitEquations with the option setting AnalysisMode −> DC. 2. Tutorial 112 Additionally, we formulate symbolic equations by setting ElementValues −> Symbolic. The option setting Symbolic −> None causes all device model parameters to be replaced by their numerical values. In[17]:= staticequations = CircuitEquations[diffAmp, AnalysisMode −> DC, ElementValues −> Symbolic, Symbolic −> None]; DisplayForm[staticequations] Out[18]//DisplayForm= V$1 V$2 V$1 V$2 I$V1 0, I$BS$Q1 0, RS1 RS1 V$3 V$4 V$8 I$BS$Q2 0, I$CS$Q1 0, RS2 RC1 V$5 V$8 I$CS$Q2 0, I$CS$Q3 I$ES$Q1 I$ES$Q2 0, RC2 V$7 V$8 I$BS$Q3 I$BS$Q4 I$CS$Q4 0, RBIAS V$4 V$8 V$5 V$8 V$7 V$8 I$VCC 0, RC1 RC2 RBIAS I$ES$Q3 I$ES$Q4 I$VEE 0, I$BS$Q1 I$CS$Q1 I$ES$Q1 0, I$BS$Q1 ib$Q1, I$BS$Q1 I$ES$Q1 ic$Q1, ic$Q1 1.434 1014 1. E38.6635 V$2V$6 1.16415 1.434 1014 1. E38.6635 V$2V$4 1. 1012 V$2 V$4 1. 1012 V$2 V$6, ib$Q1 0.16415 1.434 1014 1. E38.6635 V$2V$4 1. 1012 V$2 V$4 0.00390778 1.434 1014 1. E38.6635 V$2V$6 1. 1012 V$2 V$6, I$BS$Q2 I$CS$Q2 I$ES$Q2 0, I$BS$Q2 ib$Q2, I$BS$Q2 I$ES$Q2 ic$Q2, ic$Q2 1.434 1014 1. E38.6635 V$3V$6 1.16415 1.434 1014 1. E38.6635 V$3V$5 1. 1012 V$3 V$5 1. 1012 V$3 V$6, ib$Q2 0.16415 1.434 1014 1. E38.6635 V$3V$5 1. 1012 V$3 V$5 0.00390778 1.434 1014 1. E38.6635 V$3V$6 1. 1012 V$3 V$6, I$BS$Q3 I$CS$Q3 I$ES$Q3 0, I$BS$Q3 ib$Q3, I$BS$Q3 I$ES$Q3 ic$Q3, ic$Q3 1.434 1014 1. E38.6635 V$7V$9 1.16415 1.434 1014 1. E38.6635 V$6V$7 1. 1012 V$6 V$7 1. 1012 V$7 V$9, ib$Q3 0.16415 1.434 1014 1. E38.6635 V$6V$7 1. 1012 V$6 V$7 0.00390778 1.434 1014 1. E38.6635 V$7V$9 1. 1012 V$7 V$9, I$BS$Q4 I$CS$Q4 I$ES$Q4 0, I$BS$Q4 ib$Q4, I$BS$Q4 I$ES$Q4 ic$Q4, ic$Q4 0. 1.434 1014 1. E38.6635 V$7V$9 1. 1012 V$7 V$9, ib$Q4 0. 0.00390778 1.434 1014 1. E38.6635 V$7V$9 1. 1012 V$7 V$9, V$8 VCC, V$9 VEE, V$1 V1, 1, DesignPoint 1 Then, we run NDAESolve sweeping the parameter V1 in the interval V V. Note that the sweep variable can be any network parameter, for instance a voltage or current source parameter, a model parameter, or even any unknown in the system of equations. 2.7 Time-Domain Analysis of Nonlinear Dynamic Circuits 113 In[19]:= dctransfer = NDAESolve[staticequations, {V1, −0.5, 0.5}]; To display the DC-transfer curve graphically we again apply the function TransientPlot . For our DC-transfer analysis we want to plot the output voltage V$5 versus the input voltage V1: In[20]:= TransientPlot[dctransfer, {V$5[V1]}, {V1, −0.5, 0.5}] 12 10 8 V$5[V1] 6 4 2 -0.4 -0.2 0.2 0.4 V1 Out[20]= Graphics The resulting plot shows the typical tanh-shaped transfer characteristic of this type of differential amplifier. Parametric Analyses Finally, we demonstrate the usage of NDAESolve for carrying out parametric analyses. As an example, we perform a parametric analysis of the above computed DC-transfer characteristic V$5[V1] . As additional sweep parameter we choose the positive reference voltage VCC which shall take the values VCC " V V V. Note that for parametric analyses NDAESolve returns a multi-dimensional data object (see Section 3.7.1). 2. Tutorial 114 In[21]:= paramdctransfer = NDAESolve[staticequations, {V1, −0.5, 0.5}, {VCC, {10, 11, 12}}] Out[21]= V$1 InterpolatingFunction0.5, 0.5, , V$2 InterpolatingFunction0.5, 0.5, , V$3 InterpolatingFunction0.5, 0.5, , V$4 InterpolatingFunction0.5, 0.5, , V$5 InterpolatingFunction0.5, 0.5, , V$6 InterpolatingFunction0.5, 0.5, , V$7 InterpolatingFunction0.5, 0.5, , V$8 InterpolatingFunction0.5, 0.5, , V$9 InterpolatingFunction0.5, 0.5, , I$BS$Q1 InterpolatingFunction0.5, 0.5, , I$CS$Q1 InterpolatingFunction0.5, 0.5, , I$ES$Q1 InterpolatingFunction0.5, 0.5, , ib$Q1 InterpolatingFunction0.5, 0.5, , 8, I$ES$Q3 InterpolatingFunction0.5, 0.5, , ib$Q3 InterpolatingFunction0.5, 0.5, , ic$Q3 InterpolatingFunction0.5, 0.5, , I$BS$Q4 InterpolatingFunction0.5, 0.5, , I$CS$Q4 InterpolatingFunction0.5, 0.5, , I$ES$Q4 InterpolatingFunction0.5, 0.5, , ib$Q4 InterpolatingFunction0.5, 0.5, , ic$Q4 InterpolatingFunction0.5, 0.5, , I$VCC InterpolatingFunction0.5, 0.5, , I$VEE InterpolatingFunction0.5, 0.5, , I$V1 InterpolatingFunction0.5, 0.5, , SweepParameters VCC 10., 1, 1 The above generated multi-dimensional data format is supported by TransientPlot . Thus, we can display all sweep traces of the DC-transfer characteristic in a single plot. In[22]:= TransientPlot[paramdctransfer, {V$5[V1]}, {V1, −0.5, 0.5}] 12 10 8 V$5[V1] 6 4 2 -0.4 -0.2 Out[22]= Graphics 0.2 0.4 V1 2.7 Time-Domain Analysis of Nonlinear Dynamic Circuits 115 2.7.3 Flow of Transient Circuit Analysis A Summary of the Transient Analysis Procedure In this subsection, we summarize the steps which are necessary to perform a transient analysis of a dynamic circuit with Analog Insydes. 1) Write a netlist of the circuit to be simulated, specifying numerical values for all circuit elements or use ReadNetlist (Section 3.10.1) for automatically importing netlists from external simulator files. circuit = Circuit[ Netlist[ ], Model[ ], ] 2) Set up a system of time-domain circuit equations using CircuitEquations with the option setting AnalysisMode −> Transient . For numerical circuit simulation you should use modified nodal analysis, which is the default formulation. Modified nodal equations are smaller in size and therefore require less simulation time. mnaequations = CircuitEquations[circuit, AnalysisMode −> Transient] 3) Apply the command NDAESolve to the circuit equations to calculate the transient solution in the time interval t " t t , where t is usually zero. transient = NDAESolve[mnaequations, {t, t , t }] 4) Use TransientPlot for transient waveform display. Select the variables to be plotted by means of the list vars and specify the display time interval ta tb . The latter need not be the same as the simulation time interval t t . You can use any other values for ta and tb to zoom in onto a particular section of a trace as long as the condition t & ta tb & t holds. TransientPlot[transient, vars, {t, ta , tb }] NDAESolve Program Flow Now, let’s take a closer look at the strategy NDAESolve employs to integrate a system of differential and algebraic equations. The main idea behind the algorithm is to transform the problem of solving a nonlinear system of differential and algebraic equations into a sequence of linear and purely algebraic problems which can be solved rather easily. The transformation is carried out in two stages. In the first step, the differential equations are discretized by replacing all time derivatives with a finite difference approximation. The differential equations are thus evaluated and solved at discrete time steps only. The finite difference approximation scheme used by NDAESolve is an implicit integration method known as the trapezoidal rule. In a second step the resulting nonlinear algebraic system of 116 2. Tutorial equations is then solved for the voltages and currents using the multi-dimensional Newton-Raphson method. Circuit equations are usually stiff, which means that their solutions involve both very rapid and very slow transients. To avoid loss of accuracy and convergence problems during rapid transients as well as excessive computation time requirements for slow transients the step size is chosen adaptively at each time step according to the curvature of the waveform. Whenever a waveform changes quickly the step size is cut back whereas it is increased during periods of latency. The behavior of the step size control algorithm depends on the values of five parameters which will be discussed in the following section. The associated NDAESolve options by which the default parameter settings can be changed are StartingStepSize , MaxStepSize , MinStepSize , StepSizeFactor , and MaxDelta . Figure 7.3 shows a flow graph of the algorithm implemented in NDAESolve . 2.7 Time-Domain Analysis of Nonlinear Dynamic Circuits 117 input of circuit netlist set up timedomain circuit equations compute initial transient solution DC operating point substitute time derivatives at time step t using trapezoidal method solve nonlinear system of equations at time step t using Newton’s method iteration i no convergence AND iimax Y N iimax step size control Y N store solution at time step t ttmax time step th Y N interpolation of data output of solutions as interpolated functions Figure 7.3: NDAESolve program flow h StepSizeFactor or h StepSizeFactor 2. Tutorial 118 2.7.4 NDAESolve Options Options[NDAESolve] Several options are available for NDAESolve most of which need not be changed unless there are problems with the default settings, such as convergence problems. To list all options associated with NDAESolve inspect the value of Options[NDAESolve] : In[23]:= Options[NDAESolve] Out[23]= AccuracyGoal 6, AnalysisMode Transient, BreakOnError False, Compiled True, CompressEquations False, DesignPoint Automatic, InitialConditions Automatic, InitialGuess Automatic, InitialSolution Automatic, InterpolationOrder 1, MaxDelta 1., MaxIterations 100, 20, MaxSteps Automatic, MaxStepSize Automatic, MinStepSize Automatic, NonlinearMethod FindRoot, OutputVariables All, Protocol InheritedAnalogInsydes, RandomFunction RandomReal, 0., 0.1&, ReturnDerivatives False, Simulator InheritedAnalogInsydes, SimulatorExecutable Automatic, StartingStepSize Automatic, StepSizeFactor 1.5, WorkingPrecision 16 Below, a set of NDAESolve options is explained in more detail: InitialGuess With the default setting InitialGuess −> Automatic , zero is used as initial guess for all variables when solving a system of nonlinear equations by means of Newton iterations. Whenever this setting causes numerical problems, such as division-by-zero errors or failure to converge, you can use InitialGuess to specify your own initial guess as a list of rules of the form: InitialGuess −> {var −> value , , varn −> valuen } Note that the variables vari are specified without the time variable tvar. InitialSolution With the option InitialSolution we can force NDAESolve to use a certain DC solution as initial operating point for a transient analysis. A set of initial values must be provided as a list of rules which associate a numerical value with a variable from the system of equations. Missing variables are then computed consistently. InitialSolution −> {var −> value , , varn −> valuen } Note that the variables vari are specified without the time variable tvar. MaxDelta One of the conditions that are checked by the integration step size control mechanism is whether the values of some variables change abruptly from one time step to the next. The maximum allowed 2.7 Time-Domain Analysis of Nonlinear Dynamic Circuits 119 difference between two successive values is controlled by the option MaxDelta. The default setting is MaxDelta −> 1.0. This value is large enough to allow sudden steps of input voltages which are quite usual in the case of pulse excitations. MaxIterations The option MaxIterations specifies the maximum number of steps that the nonlinear equation solver should use in attempting to find a solution. The option setting can either be an integer int or a list of two integers int int . If it is specified as a single integer int then it is equivalent to the list int int. The first integer value defines the iteration limit for finding a DC operating point and the second integer value the iteration limit for transient computations, respectively. If the number of iterations for the operating-point computation exceeds the limit, an error message is generated and the computation is interrupted. If the iteration limit for transient computations is exceeded, the step size is reduced by the factor given by the option StepSizeFactor . The default setting is MaxIterations −> {100, 20}. MaxSteps The option MaxSteps limits the total number of integration steps. The simulation is stopped immediately if the limit is exceeded. The default setting is MaxSteps −> Automatic , which means MaxSteps /t t / StartingStepSize . MaxStepSize It is sometimes possible to speed up simulations by allowing a larger maximum integration step size. With the option MaxStepSize the present step size limit can be extended or reduced. The default setting is MaxStepSize −> Automatic , which means MaxStepSize /t t / . MinStepSize The lower limit of the integration step size can be specified by the option MinStepSize . NDAESolve stops a simulation immediately if the integration step size falls below this limit. The default setting is MinStepSize −> Automatic , which means MinStepSize /t t / . NonlinearMethod The option NonlinearMethod chooses among different numerical algorithms for solving the nonlinear algebraic systems of equations which arise due to the discretization of DAEs. By default, Mathematica’s numerical solver FindRoot is used for this purpose. Alternatively, you can employ Analog Insydes’ own implementation of the multi-dimensional Newton-Raphson method by specifying NonlinearMethod −> NewtonIteration . 120 2. Tutorial Protocol With the option setting Protocol −> Notebook, NDAESolve can be instructed to print protocol information to your notebook as the computation proceeds. The protocol includes an output of the initial guess, the initial transient solution, shows the percentage of the computation completed, and the number of time steps which were necessary to carry out the computation. The default setting is Protocol −> Inherited[AnalogInsydes] which means that NDAESolve inherits the option setting from the global setting specified in Options[AnalogInsydes] . See also Section 3.14.5. StartingStepSize The option StartingStepSize helps to overcome convergence problems at the beginning of a simulation. If NDAESolve fails to converge during the first time step you can use StartingStepSize to specify a smaller value for the initial integration step size. The default setting is StartingStepSize −> Automatic , which means StartingStepSize /t t / . StepSizeFactor To reduce computation time and increase simulation accuracy NDAESolve employs an automatic step size control scheme. If the estimated simulation error in between two integration time steps is very low then the step size is increased. On the other hand, if the estimated error is too large the step size is cut back. Increasing and reducing the step size is performed by multiplying or dividing the current step size by a factor given by the value of the option StepSizeFactor . The default setting is StepSizeFactor −> 1.5. 2.7.5 Transient Analysis with Initial Conditions Circuits with Initial Conditions The handling of initial conditions was rather complicated with version 1 of Analog Insydes. Therefore, the netlist format was extended to treat initial conditions of dynamic circuit elements such as capacitors or inductors. This is done by specifying the setting InitialCondition −> value in the option field of the particular netlist entry (see Section 3.1.4). Consider the RLC circuit shown in Figure 7.4. The initial voltage VC1 across the capacitor C1 at t is given as VC1 Vic . Assume that the following numerical values are given for the circuit elements: R1 , L1 ΜH, C1 ΜF, and Vic mV. 2.7 Time-Domain Analysis of Nonlinear Dynamic Circuits 121 Vic 2 1 L1 C1 R1 Iout Figure 7.4: Oscillator circuit with initial condition We start with writing a circuit netlist which includes the initial condition of the capacitor C1. In[24]:= oscillator = Netlist[ {L1, {0, 1}, Symbolic {C1, {1, 2}, Symbolic InitialCondition −> {R1, {2, 0}, Symbolic ] −> L1, Value −> 1.*10^−5}, −> C1, Value −> 3.*10^−7, 0.002}, −> R1, Value −> 1.} Out[24]= NetlistRaw, 3 Following, we distinguish two alternatives for considering initial conditions of dynamic circuit elements. Initial Conditions for some Dynamic Elements With the option setting InitialConditions −> Automatic the function CircuitEquations can be instructed to use initial conditions for those elements for which such a condition has been specified in the netlist entry. All others are then computed consistently by NDAESolve . For our example, we set up a system of modified nodal equations from the circuit configuration at the time t . In[25]:= oscillatorMNA1 = CircuitEquations[oscillator, AnalysisMode −> Transient, ElementValues −> Symbolic, InitialConditions −> Automatic]; DisplayForm[oscillatorMNA1] Out[26]//DisplayForm= I$L1t C1 V$1 t V$2 t 0, V$2t C1 V$1 t V$2 t 0, V$1t L1 I$L1 t 0, R1 V$10 V$20 0.002, V$1t, V$2t, I$L1t, DesignPoint L1 0.00001, C1 3. 107 , R1 1. 2. Tutorial 122 Note that the initial condition for the capacitor C1 is given by the node voltage difference V$1[0] V$2[0] and is included in the set of time-domain equations. Applying NDAESolve yields the following DC operating-point values for the node voltages and the initial inductor current I$L1: In[27]:= NDAESolve[oscillatorMNA1, {t, 0.}] Out[27]= V$1 0., V$2 0.002, I$L1 0.002 For the DC analysis the inductor was replaced by a short circuit, therefore V$1 is zero. I$L1 has the same numerical value as V$2 because the resistor has the unit value . Now, we compute the transient response: In[28]:= transient1 = NDAESolve[oscillatorMNA1, {t, 0., 10^−4}] Out[28]= V$1 InterpolatingFunction0, 0.0001, , V$2 InterpolatingFunction0, 0.0001, , I$L1 InterpolatingFunction0, 0.0001, Finally, we plot the transient waveform of the output current Iout (given by the inductor current I$L1) in the simulated time interval. In[29]:= TransientPlot[transient1, {I$L1[t]}, {t, 0., 10^−4}, PlotRange −> All] 0.0015 0.001 0.0005 0.00002 0.00004 0.00006 0.00008 t 0.0001 I$L1[t] -0.0005 -0.001 -0.0015 -0.002 Out[29]= Graphics Initial Conditions for all Dynamic Elements Alternatively, the function CircuitEquations can be instructed to use initial conditions for all dynamic elements by applying the option setting InitialConditions −> All. Initial conditions which are not explicitly specified in the netlist are then assumed to be zero. For our example, we again set up a system of modified nodal equations from the circuit configuration at the time t . 2.7 Time-Domain Analysis of Nonlinear Dynamic Circuits 123 In[30]:= oscillatorMNA2 = CircuitEquations[oscillator, AnalysisMode −> Transient, ElementValues −> Symbolic, InitialConditions −> All]; DisplayForm[oscillatorMNA2] Out[31]//DisplayForm= I$L1t C1 V$1 t V$2 t 0, V$2t C1 V$1 t V$2 t 0, R1 V$1t L1 I$L1 t 0, I$L10 0, V$10 V$20 0.002, V$1t, V$2t, I$L1t, DesignPoint L1 0.00001, C1 3. 107 , R1 1. Note that this time the time-domain equations contain not only the initial condition for the capacitor C1 (given by the node voltage difference V$1[0] V$2[0]) but also an initial condition for the inductor current I$L1[0] . Now, we compute the DC operating point and the transient response by applying NDAESolve . In[32]:= NDAESolve[oscillatorMNA2, {t, 0.}] Out[32]= V$1 0.002, V$2 0., I$L1 0. In[33]:= transient2 = NDAESolve[oscillatorMNA2, {t, 0., 10^−4}] Out[33]= V$1 InterpolatingFunction0, 0.0001, , V$2 InterpolatingFunction0, 0.0001, , I$L1 InterpolatingFunction0, 0.0001, Finally, we plot the output current. In[34]:= TransientPlot[transient2, {I$L1[t]}, {t, 0., 10^−4}, PlotRange −> All] 0.0002 0.0001 0.00002 0.00004 0.00006 0.00008 t 0.0001 I$L1[t] -0.0001 -0.0002 -0.0003 Out[34]= Graphics Please note the different transient waveforms dependent on the usage of initial conditions. 2. Tutorial 124 2.7.6 TransientPlot Options Options[TransientPlot] As was shown previously, the function TransientPlot provides a convenient way for displaying results of NDAESolve or NDSolve computations. The appearance of TransientPlot graphics can be changed with the following set of options: In[35]:= Options[TransientPlot] Out[35]= 1 AspectRatio , Axes True, GoldenRatio AxesLabel None, AxesOrigin Automatic, AxesStyle Automatic, Background GrayLevel0.92, ColorOutput Automatic, Compiled True, DefaultColor Automatic, Epilog , Frame False, FrameLabel None, FrameStyle Automatic, FrameTicks Automatic, GridLines None, ImageSize Automatic, MaxBend 10., PlotDivision 30., PlotLabel None, PlotPoints 30, PlotRange Automatic, PlotRegion Automatic, PlotStyle RGBColor1., 0., 0., AbsoluteThickness1., AbsolutePointSize3., RGBColor0., 0., 1., AbsoluteThickness1., AbsoluteDashing10., 8., AbsolutePointSize3., RGBColor0., 0.8, 0., AbsoluteThickness1., AbsoluteDashing4., 8., AbsolutePointSize3., RGBColor0.7, 0., 0.9, AbsoluteThickness1., AbsoluteDashing10., 8., 4., 8., AbsolutePointSize3., Prolog , RotateLabel True, Ticks Automatic, DefaultFont $DefaultFont, DisplayFunction $DisplayFunction, FormatType $FormatType, TextStyle $TextStyle, GraphicsSpacing 0.1, Parametric False, ShowLegend True, ShowSamplePoints False, SingleDiagram True, SweepParameters Automatic Most options are standard options of Graphics objects. Therefore, we will restrict ourselves to the discussion of the remaining keywords Parametric , ShowSamplePoints , and SingleDiagram . Parametric With Parametric −> True parametric plots of two interpolating functions can be displayed. In this case, TransientPlot requires a list of two display variables xvar and yvar, where xvar denotes the x-axis variable and yvar the y-axis variable. TransientPlot then shows a trace of the points {xvar[par], yvar[par]} as the parameter par is swept from par to par . TransientPlot[numericaldata, {xvar[par], yvar[par]}, {par, par , par }, Parametric −> True] The axes are automatically labeled by the specified variable names. As an example we perform a parametric plot of the transient response of the diode rectifier circuit introduced in Section 2.7.1 (see Figure 7.1). 2.7 Time-Domain Analysis of Nonlinear Dynamic Circuits 125 In[36]:= TransientPlot[solutions, {V$1[t], V$2[t]}, {t, 10^−6, 10^−5}, Parametric −> True] V$2[t] 0.4 0.35 0.3 0.25 -1 -0.5 0.5 1 V$1[t] Out[36]= Graphics ShowSamplePoints Changing the default setting of the option ShowSamplePoints from False to True allows for visualizing the sample points stored in InterpolatingFunction objects. By this, the variation of the step size in a computed interval can be observed. The simulation data is displayed via Mathematica’s ListPlot . In[37]:= TransientPlot[solutions, {V$1[t], V$2[t]}, {t, 0., 2.*10^−5}, ShowSamplePoints −> True] 1 0.5 V$1[t] -6 5. 10 0.00001 0.000015 t 0.00002 V$2[t] -0.5 -1 Out[37]= Graphics SingleDiagram With the option SingleDiagram you can choose whether to combine the traces of several interpolating functions in a single diagram or display them in a separate plot each. The default SingleDiagram −> True causes all traces to be combined. To display an array of plots use SingleDiagram −> False. Note that it is possible to generate not only plots of circuit variables, but also plots of expressions involving these variables. For example, the following graphics array contains 2. Tutorial 126 a plot of the voltage across the capacitor Cload of the differential amplifier circuit from Section 2.7.2 (see Figure 7.2). The capacitor voltage is given by the difference of the node voltages V$5 and V$4. In[38]:= TransientPlot[transient, {V$4[t], V$5[t] − V$4[t]}, {t, 0., 10^−5}, SingleDiagram −> False] 6 5 V$4[ 4 3 -6 2. 10 -6 4. 10 -6 6. 10 -6 t 0.00001 8. 10 10 8 6 V$5[ 4 2 -6 2. 10 -6 4. 10 -6 6. 10 Out[38]= GraphicsArray -6 8. 10 t 0.00001 2.8 Linear Symbolic Approximation 127 2.8 Linear Symbolic Approximation 2.8.1 Introduction to Symbolic Approximation The Complexity Problem If you have previous experiences with symbolic circuit analysis programs or if you have done some experiments with Analog Insydes before reading this chapter you may have already become aware of a major obstacle which is inherent to symbolic computations. While the carefully selected example circuits analyzed in the preceding chapters all yield transfer functions of no more than a few lines in length minor modifications such as adding an element or two to the circuit or choosing a slightly more complex transistor model may already lead to expressions of incredible size. In fact, expression complexity increases exponentially with the number of symbols in your circuit descriptions, allowing for full symbolic analysis of very small circuits only. 6 RC 2.2k R1 100k C2 3 5 C1 1u 2 1 RL 4 100n V1 VCC Q1 R2 RE 47k 1k 47k Vout Figure 8.1: Common-emitter amplifier with coupling capacitors and resistive load Let us demonstrate this effect by computing the symbolic voltage transfer function of the commonemitter amplifier displayed in Figure 8.1. This circuit is essentially the same as the common-emitter amplifier from Section 2.3.1 (see Figure 3.1) except that coupling capacitors and a resistive load have been added. 2. Tutorial 128 Following, the netlist description of the circuit is imported via the Analog Insydes command ReadNetlist (Section 3.10.1) from already existing simulator files. For more details refer to Section 2.9.2. In[1]:= <<AnalogInsydes‘ In[2]:= ceamp = ReadNetlist[ "AnalogInsydes/DemoFiles/emitter.cir", "AnalogInsydes/DemoFiles/emitter.out", KeepPrefix −> False, Simulator −> "PSpice"] Out[2]= Circuit From the netlist description, we set up a system of symbolic sparse tableau equations. We use a complexity-reduced transistor model from the Analog Insydes model library by specifying the option ModelLibrary (Section 3.14.4). In[3]:= ceampsta = CircuitEquations[ceamp, ElementValues −> Symbolic, Formulation −> SparseTableau, ModelLibrary −> "BasicModels‘"] Out[3]= DAEAC, 32 32 Then we solve the equations for the output voltage V$RL and extract the expression for V$RL from the result. In[4]:= ceampvout = Together[ V$RL /. First[Solve[ceampsta, V$RL]]] Out[4]= C1 R1 R2 s2 C2 RC RE RL C2 gm$Q1 RC RL Ro$Q1 Rpi$Q1 C2 Cbc$Q1 RC RE RL Ro$Q1 s C2 Cbx$Q1 RC RE RL Ro$Q1 s C2 Cbc$Q1 RC RE RL Rpi$Q1 s C2 Cbe$Q1 RC RE RL Rpi$Q1 s C2 Cbx$Q1 RC RE RL Rpi$Q1 s C2 Cbc$Q1 RC RL Ro$Q1 Rpi$Q1 s C2 Cbx$Q1 RC RL Ro$Q1 Rpi$Q1 s C2 Cbc$Q1 gm$Q1 RC RE RL Ro$Q1 Rpi$Q1 s C2 Cbx$Q1 gm$Q1 RC RE RL Ro$Q1 Rpi$Q1 s C2 Cbc$Q1 Cbe$Q1 RC RE RL Ro$Q1 Rpi$Q1 s2 C2 Cbe$Q1 Cbx$Q1 RC RE RL Ro$Q1 Rpi$Q1 s2 V1 R1 R2 RC R1 R2 RE R1 RC RE R2 RC RE R1 R2 Ro$Q1 R1 RE Ro$Q1 R2 RE Ro$Q1 R1 RC Rpi$Q1 R2 RC Rpi$Q1 R1 RE Rpi$Q1 R2 RE Rpi$Q1 R1 Ro$Q1 Rpi$Q1 R2 Ro$Q1 Rpi$Q1 gm$Q1 R1 RE Ro$Q1 Rpi$Q1 gm$Q1 R2 RE Ro$Q1 Rpi$Q1 C1 R1 R2 RC RE s 153 C2 Cbe$Q1 Cbx$Q1 R1 R2 RC RE Ro$Q1 Rpi$Q1 s3 C1 C2 Cbc$Q1 R1 R2 RC RL Ro$Q1 Rpi$Q1 s3 C2 Cbc$Q1 Cbe$Q1 R1 R2 RC RL Ro$Q1 Rpi$Q1 s3 C1 C2 Cbx$Q1 R1 R2 RC RL Ro$Q1 Rpi$Q1 s3 C2 Cbe$Q1 Cbx$Q1 R1 R2 RC RL Ro$Q1 Rpi$Q1 s3 C1 C2 Cbe$Q1 R1 R2 RE RL Ro$Q1 Rpi$Q1 s3 C2 Cbc$Q1 Cbe$Q1 R1 R2 RE RL Ro$Q1 Rpi$Q1 s3 C2 Cbe$Q1 Cbx$Q1 R1 R2 RE RL Ro$Q1 Rpi$Q1 s3 C2 Cbc$Q1 Cbe$Q1 R1 RC RE RL Ro$Q1 Rpi$Q1 s3 C2 Cbe$Q1 Cbx$Q1 R1 RC RE RL Ro$Q1 Rpi$Q1 s3 C2 Cbc$Q1 Cbe$Q1 R2 RC RE RL Ro$Q1 Rpi$Q1 s3 C2 Cbe$Q1 Cbx$Q1 R2 RC RE RL Ro$Q1 Rpi$Q1 s3 C1 C2 Cbc$Q1 gm$Q1 R1 R2 RC RE RL Ro$Q1 Rpi$Q1 s3 C1 C2 Cbx$Q1 gm$Q1 R1 R2 RC RE RL Ro$Q1 Rpi$Q1 s3 C1 C2 Cbc$Q1 Cbe$Q1 R1 R2 RC RE RL Ro$Q1 Rpi$Q1 s4 C1 C2 Cbe$Q1 Cbx$Q1 R1 R2 RC RE RL Ro$Q1 Rpi$Q1 s4 2.8 Linear Symbolic Approximation 129 Even for this very small circuit we obtain a transfer function which contains more than product terms. If you are not impressed yet try calculating the symbolic transfer function of two amplifier stages connected in series, or rather, use ComplexityEstimate (Section 3.11.1) to get an estimate of the expression size. Analog Insydes provides the command ComplexityEstimate for computing an estimate of the number of product terms in a transfer function computed from a symbolic matrix equation A x b (note that the equations have to be given as a system of AC circuit equations). More precisely, the function computes a lower bound for the number of product terms in the determinant of A. For our common-emitter amplifier this yields the following estimate: In[5]:= ComplexityEstimate[ceampsta] Out[5]= 185 A primary goal of symbolic circuit analysis is to give us qualitative insight into circuit behavior. From a symbolic formula we can read off which circuit elements have an influence on particular circuit characteristics, such as voltage gains or poles and zeros, and we can draw conclusions on how to modify element values in order to make a circuit meet some performance specifications. It is quite obvious, though, that this requires the formulas to be rather small – ideally no more than one line on the screen – because an expression as large as the one above hardly yields any insight. Unfortunately, there is little we can do to reduce the size of symbolic analysis results in a purely algebraic way. Algebraic simplifications such as factoring and cancelling common terms seldom have a sufficiently large impact on expression complexity because transfer functions are usually composed of irreducible polynomials. In addition, factored or partially factored expressions are not necessarily easier to understand than their expanded forms. Exact symbolic analysis is therefore infeasible for most circuits of practical size. Approximating Symbolic Expressions There are two ways to cope with the complexity problem. The first one is to keep circuit and device models always as simple as possible. Carefully balancing model accuracy and simplicity holds the key to obtaining meaningful results from symbolic circuit analysis programs, so any knowledge about a particular analysis task should be exploited before running the analyzer. For instance, if our task was to find a symbolic expression describing the voltage gain of the common-emitter amplifier in the passband frequency range for a high-impedance load we should short-circuit the coupling capacitors, neglect the load resistor, and use a transistor model which just meets our accuracy requirements. In other words, to obtain compact results we should model and analyze the circuit exactly like we already did in Chapter 2.3. The major disadvantage of such a-priori simplifications on circuit level is, however, that we cannot always control the final error in our computations which is invariably introduced by neglecting some elements. The second approach to the generation of interpretable formulas is known as symbolic approximation or symbolic simplification, which refers to a whole family of hybrid symbolic/numeric algorithms for expression simplification. Symbolic approximation techniques require more numerical knowledge about the circuit under examination than manual simplifications but yield compact expressions with predictable error in a fully automatic way. The basic idea behind all these algorithms is to compare the magnitudes of symbolic terms in a transfer function or a system of equations on the basis of 2. Tutorial 130 numerical reference values and then to discard all those terms which have negligible influence on the result. In most cases, this leads to a dramatic reduction of expression complexity, thus allowing for approximate symbolic analysis of reasonably large circuits. 1 R1 R3 V0 3 2 R2 R4 Figure 8.2: Double voltage divider To understand how symbolic approximation works let’s look at a simple example – the transfer function of the double voltage divider shown in Figure 8.2: In[6]:= doubleVoltageDivider = Netlist[ {V0, {1, 0}, V0}, {R1, {1, 2}, R1}, {R2, {2, 0}, R2}, {R3, {2, 3}, R3}, {R4, {3, 0}, R4} ] Out[6]= NetlistRaw, 5 In[7]:= dvdmna = CircuitEquations[doubleVoltageDivider]; DisplayForm[dvdmna] Out[8]//DisplayForm= 1 1 R1 R1 1 1 1 1 R1 R1 R2 R3 1 0 R3 0 1 0 1 R3 1 1 R3 R4 0 1 V$1 0 0 V$2 0 . 0 V$3 0 I$V0 V0 0 In[9]:= tfdvd = (V$3 / V0) /. First[Solve[dvdmna, V$3]] R2 R4 Out[9]= R1 R2 R1 R3 R2 R3 R1 R4 R2 R4 Without any additional knowledge about the circuit this transfer function cannot be simplified much further algebraically. Now, let’s assume that in this particular circuit the values of R1 and R2 are approximately equal, as well as those of R3 and R4, but that R1 and R2 have much smaller values 2.8 Linear Symbolic Approximation 131 than R3 and R4: R1 R2 R3 R4. Under these conditions we can discard the product term R1 R2 in the denominator of the transfer function because it is the product of two small quantities and thus contributes little to the total value of the expression as compared to the other terms: In[10]:= simptfdvd = tfdvd /. R1*R2 −> 0 R2 R4 Out[10]= R1 R3 R2 R3 R1 R4 R2 R4 The resulting function can now be factored and simplifies to a more meaningful form. In[11]:= Factor[simptfdvd] R2 R4 Out[11]= R1 R2 R3 R4 This approximate formula holds for all sets of resistor values for which the condition R1 R2 R3 R4 is satisfied, but no longer in the general case. Symbolic approximation thus always implies a trade-off between low expression complexity on the one hand and generality and precision on the other. Numerical Reference Values: Design Points Deciding on which terms to discard from a symbolic expression on the basis of vague information such as "X is much larger than Y" may be feasible for humans but is virtually impossible to do for a computer. This is particularly true when an expression contains a large number of symbols in nontrivial combinations. To enable a computer to reduce a symbolic expression to its dominant content we must provide input which allows for clear yes-or-no decisions on whether a term is important or negligible. This input can be given as a set of accompanying numerical reference values for the symbols, known as a design point, based on which the contributions of compound symbolic terms can be compared numerically. Design-point values need not always be the exact element values for which a circuit works within specifications. However, the reference values should reflect the relative magnitude relations among the symbols in a realistic way. In the case of the double voltage divider we could express the conditions on the relative magnitudes of the resistors by an (arbitrary) numerical assignment of design-point values such as R1 R2 and R3 R4 . We rewrite the netlist of the double voltage divider keeping both a symbolic element value and an associated design-point value together in each netlist entry. In[12]:= doubleVoltageDivider = Netlist[ {V0, {1, 0}, Symbolic {R1, {1, 2}, Symbolic {R2, {2, 0}, Symbolic {R3, {2, 3}, Symbolic {R4, {3, 0}, Symbolic ] −> −> −> −> −> V0, R1, R2, R3, R4, Value Value Value Value Value −> −> −> −> −> 1.}, 10.}, 10.}, 1000.}, 1000.} Out[12]= NetlistRaw, 5 Now, we set up the corresponding equations using the option setting ElementValues −> Symbolic. The design-point values are then automatically stored in the DAEObject and can be extracted via GetDesignPoint (Section 3.6.12). 2. Tutorial 132 In[13]:= dvdmna = CircuitEquations[doubleVoltageDivider, ElementValues −> Symbolic] Out[13]= DAEAC, 4 4 In[14]:= designpoint = GetDesignPoint[dvdmna] Out[14]= V0 1., R1 10., R2 10., R3 1000., R4 1000. With these reference values we can evaluate the symbolic expression numerically. Below, we apply the function HoldForm to the Plus operation which prevents the denominator from being evaluated to a single number. In[15]:= tfdvd /. Plus −> HoldForm[Plus] /. designpoint 10000. Out[15]= Plus100., 10000., 10000., 10000., 10000. By comparing the individual numerical values we, as well as a computer, can now clearly see that the first argument of the Plus expression, corresponding to the term R1 R2, contributes only to the total value of the denominator. The term can thus be safely removed from the transfer function if we allow for an error of, say, or less in the design point. 2.8.2 Solution-Based Symbolic Approximation Groups of Symbolic Approximation Techniques Symbolic approximation techniques can be divided into three different groups of methods which perform Simplifications Before, During, or After the Generation of symbolic formulas (SBG, SDG, and SAG methods). The approach discussed above is thus an SAG, or solution-based, method because we computed the complete transfer function first and then simplified it. While the principle behind this SAG technique was demonstrated on the transfer function of a non-dynamic system it can be applied to general transfer functions containing powers of the frequency variable s as well. In this case, all symbolic coefficients of the different powers of s are simplified separately up to a given maximum error. Approximating Transfer Functions Analog Insydes provides the function ApproximateTransferFunction (Section 3.11.2) for solutionbased symbolic approximation. The argument sequence is ApproximateTransferFunction[tfunc, fvar, dp, maxerr] where tfunc is a rational transfer function in the frequency variable fvar, dp is a design-point specification, and maxerr is the maximum relative error of the simplified coefficients of fvar in the design point. The design point must be specified as a list of rules which associate numerical values with the symbols in tfunc, and maxerr is a real number between and . 2.8 Linear Symbolic Approximation 133 Let’s apply solution-based approximation to the transfer function of the common-emitter amplifier calculated in the preceding section. First, we extract the list of design-point values from the DAEObject using GetDesignPoint . In[16]:= dpceamp = GetDesignPoint[ceampsta] Out[16]= C1 1. 107 , C2 1. 106 , R1 100000., RC 2200., R2 47000., Rpi$Q1 2200., Ro$Q1 36400., Cbc$Q1 4.39 1012 , Cbe$Q1 7.01 1011 , gm$Q1 0.0808, Cbx$Q1 0., RE 1000., V1 1., RL 47000., Simulator PSpice Then we let ApproximateTransferFunction remove all numerical insignificant terms from the coefficients of the frequency variable s, thereby allowing for a maximum design-point error of in each coefficient. Note that a coefficient error does not imply error on the magnitude of the transfer function in the design point. Ideally, the coefficient error should be a common factor and thus cancel from numerator and denominator, yielding zero overall error in the design point. In practice, however, there is no direct correlation between the overall error and the maximum coefficient error. The former is usually lower than the latter but may, in some cases, even be larger. In[17]:= voutsimp = ApproximateTransferFunction[ceampvout, s, dpceamp, 0.1] // Together Out[17]= C1 C2 gm$Q1 R1 R2 RC RL Rpi$Q1 s2 V1 C1 C2 Cbc$Q1 gm$Q1 R1 R2 RC RE RL Rpi$Q1 s3 V1 C1 C2 Cbc$Q1 Cbe$Q1 R1 R2 RC RE RL Rpi$Q1 s4 V1 R1 R2 gm$Q1 R1 RE Rpi$Q1 gm$Q1 R2 RE Rpi$Q1 C2 R1 R2 RL s C1 gm$Q1 R1 R2 RE Rpi$Q1 s C2 gm$Q1 R1 RE RL Rpi$Q1 s C2 gm$Q1 R2 RE RL Rpi$Q1 s C1 C2 gm$Q1 R1 R2 RE RL Rpi$Q1 s2 C1 C2 Cbe$Q1 R1 R2 RE RL Rpi$Q1 s3 C1 C2 Cbc$Q1 gm$Q1 R1 R2 RC RE RL Rpi$Q1 s3 C1 C2 Cbc$Q1 Cbe$Q1 R1 R2 RC RE RL Rpi$Q1 s4 Here, the approximation process reduces the original transfer function to only significant terms. We can check the quality of the approximation by evaluating it with the design-point values and comparing it graphically with the original function. In[18]:= voutexactn[s_] = Together[ceampvout /. dpceamp] Out[18]= 470. s2 6.68943 108 3.00693 s 2.54816 109 s2 1.15576 1015 5.9939 1013 s 1.52545 1011 s2 1543.08 s3 1.19764 106 s4 In[19]:= voutsimpn[s_] = voutsimp /. dpceamp Out[19]= 8.63878 106 s2 0.0379242 s3 3.29021 1011 s4 3.08307 1010 1.53259 109 s 3.92672 106 s2 0.041331 s3 3.29021 1011 s4 For the following BodePlot we choose a linear scaling of the magnitude values to get a better impression of the true magnitude error. It turns out that the simplified expression (dashed line) approximates the original transfer function (solid line) quite well, although it comprises only about one tenth of the terms of the latter. 2. Tutorial 134 In[20]:= BodePlot[{voutexactn[2. Pi I f], voutsimpn[2. Pi I f]}, {f, 1., 1.*10^9}, MagnitudeDisplay −> Linear] 1.0E0 1.0E2 1.0E4 1.0E6 1.0E8 1.0E2 1.0E4 Frequency 1.0E6 1.0E8 Magnitude 2 1.5 1 0.5 Phase (deg) 0 1.0E0 1.0E0 0 -50 -100 -150 -200 -250 -300 -350 1.0E0 1.0E2 1.0E4 1.0E6 1.0E8 1.0E2 1.0E4 Frequency 1.0E6 1.0E8 Out[20]= Graphics 2.8.3 Equation-Based Symbolic Approximation Coping with the Limit of Solution-Based Approximation Techniques Solution-based expression approximation techniques have one obvious drawback: they can only be applied to symbolic transfer functions after these have been computed from systems of circuit equations. This precludes the use of SAG techniques in those cases where calculating an unsimplified symbolic transfer function is technically impossible. In practice, the limit is reached very quickly, because even for small analog building blocks with ten or less active devices the term count of the transfer functions can be expected to grow into the millions, if not into billions. To cope with these cases we must resort to simplification-before-generation techniques which simplify the problem beforehand, i.e. even before a transfer function is computed symbolically. Such simplifications can be done manually on circuit level, for instance by replacing negligible components with zero-admittance or zero-impedance elements. However, as controlling the error introduced by manual simplifications is usually difficult, Analog Insydes provides an automatic and more reliable SBG algorithm which operates on systems of symbolic circuit equations. Hence, it belongs to the class of equation-based approximation techniques. Given a system of symbolic linear circuit equations in matrix form A x b and a design point, the equation-based approximation algorithm implemented in Analog Insydes finds and removes all symbolic matrix entries whose numerical contribution to the design-point value of the transfer function is negligible, thereby keeping track of the accumulated approximation error. As the number of removed matrix entries is usually quite large the solution of the resulting simplified matrix equation will be much less complex than the solution of the unsimplified system. Therefore, we can calculate simplified symbolic transfer functions without ever having to compute the full expressions at all. 2.8 Linear Symbolic Approximation 135 This will be illustrated by an example right after the following explanations on how to specify design points for the matrix approximation function. Design Points for Matrix Approximation Since the matrix approximation algorithm can work with multiple design points with individual error bounds, the design points must be specified in a slightly different form as compared to those for solution-based approximation: designpoint = { {symbol −> value, , MaxError −> maxerr1 }, {symbol −> value, , MaxError −> maxerr2 }, } Note that for symbols which are not specified here the corresponding design-point value is automatically extracted from the design point stored in the DAEObject. Each set of design-point values must be accompanied by a rule with the keyword MaxError on its left-hand side. This rule specifies the maximum relative error by which the magnitude of the solution of the approximated system of equations may deviate from the value of the magnitude of the transfer function in the corresponding design point. The error bound maxerr must be a real number greater than zero. Note that the error definition used here is different from the one used with ApproximateTransferFunction in that it pertains to the total error on the magnitude of the entire transfer function at certain frequencies and not to the error on individual coefficients. It is thus a more reliable error measure than the coefficient error. Let’s define a design point for applying matrix approximation to our double-voltage-divider example (see Figure 8.2 in Section 2.8.1). We can use the same numerical values for the resistors and the voltage source as we did for solution-based approximation. If we allow for up to magnitude error of the simplified result with respect to the unsimplified solution we must write the error bound specification as MaxError −> 0.05. Note that although we have only one single design point here we must wrap the list of rules into an additional level of list braces. In[21]:= dpdvd = {{MaxError −> 0.05}}; Approximating Symbolic Matrix Equations Symbolic matrix equations can be approximated by means of the command ApproximateMatrixEquation (Section 3.11.3), which has the following command syntax: ApproximateMatrixEquation[dae, var, dp, opts] The first argument dae represents a DAEObject containing small-signal circuit equations in matrix form as returned by CircuitEquations , var specifies the variable for which the equations should be solved after approximation, and dp denotes a list of design points as discussed above. The remaining argument opts is a sequence of options which may also be empty. We are now ready to try out equation-based approximation on the MNA equations of the voltage divider. For comparison, here are the original unsimplified equations again. 2. Tutorial 136 In[22]:= DisplayForm[dvdmna] Out[22]//DisplayForm= 1 1 R1 R1 1 1 1 1 R1 R1 R2 R3 1 0 R3 1 0 0 1 R3 1 1 R3 R4 0 1 0 V$1 0 V$2 0 . 0 V$3 0 I$V0 V0 0 Since we are interested in a simplified solution for the voltage at the output node 3, we specify V$3 as the variable for which the equations are to be approximated. In[23]:= approxdvd = ApproximateMatrixEquation[dvdmna, V$3, dpdvd]; DisplayForm[approxdvd] Out[24]//DisplayForm= 0 0 1 1 1 R1 R1 R2 1 1 0 R3 R3 0 1 0 0 1 R4 0 1 0 V$1 0 0 V$2 . 0 V$3 0 V0 I$V0 0 The result is a matrix equation from which all numerical irrelevant symbolic terms have been removed. We can now compute a simplified transfer function directly by solving the approximated equations. In[25]:= Solve[approxdvd, V$3] R2 R4 V0 Out[25]= V$3 R1 R2 R3 R4 In this case, we obtain identical results from both equation-based and solution-based approximation. However, as opposed to the latter, equation-based approximation does not require an exact symbolic solution to be computed first. In such a small example this advantage makes nearly no difference, but it will turn out to be a key factor in larger applications. Approximating the Equations of the Amplifier As an example for a slightly larger application let’s continue with our well-known common-emitter amplifier once more. Again, we start by setting up a design point for ApproximateMatrixEquation , reusing the numerical values we defined for simplifying the exact solution with ApproximateTransferFunction . For matrix approximation, however, we still need some more numerical information. While the SAG algorithm approximates the coefficients of a transfer function independently, the SBG method uses the total value of a transfer function in a design point as reference quantity. Therefore, we must specify one or more particular frequency points at which ApproximateMatrixEquation should monitor the change in the value of the transfer function caused by the removal of terms. Here, we might be interested in computing a simplified expression describing the passband voltage gain of the amplifier. The Bode plot above shows that the passband extends from about Hz to several MHz, so we choose a design-point value for the operating frequency in the middle of the passband, e.g. at f kHz. The corresponding value for the Laplace frequency s is then given by 2.8 Linear Symbolic Approximation 137 s Π I f . Finally, we limit the approximation error in this frequency point to of the original magnitude value. In[26]:= dpceamp2 = {{s −> 2. Pi I 10^4, MaxError −> 0.1}}; In the next step, we approximate the sparse tableau equations of the amplifier for the given designpoint data with respect to the output voltage V$RL. In[27]:= approxceamp = ApproximateMatrixEquation[ceampsta, V$RL, dpceamp2] Out[27]= DAEAC, 32 32 Then we solve the approximated system for V$RL to obtain a simplified voltage transfer function. In[28]:= voutsimp2 = (V$RL / V1) /. First[Solve[approxceamp, V$RL]] RC Out[28]= RE By equation-based approximation we have reduced the symbolic transfer function to the simple quotient of two resistor values. In comparison to the original transfer function, which is composed of more than terms, this may seem to be a rather surprising result. From a technical point of view, however, the extreme reduction of complexity is not surprising at all because the amplifier was designed to have a voltage gain of approximately −RC/RE. Therefore, our approximate symbolic analysis just extracted knowledge which was put into this circuit structure at the time of its design. Again, we evaluate the simplified expression with the design-point values and compare the result with the original transfer function. In[29]:= voutsimp2n[s_] = voutsimp2 /. dpceamp Out[29]= 2.2 In[30]:= BodePlot[{voutexactn[2. Pi I f], voutsimp2n[2. Pi I f]}, {f, 1., 1.*10^9}, MagnitudeDisplay −> Linear, PlotRange −> {{0, 2.5}, Automatic}] 1.0E0 2.5 1.0E2 1.0E4 1.0E6 1.0E8 1.0E2 1.0E4 Frequency 1.0E6 1.0E8 Magnitude 2 1.5 1 0.5 Phase (deg) 1.0E0 1.0E0 0 -50 -100 -150 -200 -250 -300 -350 1.0E0 1.0E2 1.0E4 1.0E6 1.0E8 1.0E2 1.0E4 Frequency 1.0E6 1.0E8 Out[30]= Graphics It becomes immediately apparent from the plots that the result obtained by means of SBG does not constitute a global description of the frequency response of the amplifier. As opposed to the SAG 2. Tutorial 138 solution, the SBG solution is only valid in the passband region and does not reflect the behavior the amplifier exhibits for very low or very high frequencies. But remember that such a local approximation was precisely what we asked for because we specified only one reference point on the frequency axis at kHz. Equation-based approximation thus allows us to compute reduced-order circuit models for limited frequency ranges. Of course, we can also define several frequency points at which ApproximateMatrixEquation monitors the approximation error in order to extend range of validity of a simplified expression. However, best results in terms of expression complexity are usually obtained through local approximations. 2.8.4 Combining SBG and SAG While equation-based approximation can reduce the complexity of a symbolic expression greatly the result may still contain some insignificant terms. So it is generally a good idea to apply solutionbased simplification to such a transfer function as well in order to remove the remaining irrelevant contributions. The following example demonstrates the combination of SBG and SAG. First, we use matrix approximation to compute a reduced-order transfer function of the amplifier from Section 2.8.1 (see Figure 8.1) which is valid for the passband and also for low frequencies. Therefore, we add a second reference point at Hz to the list of design points. We allow for an error of up to in that point because we do not need high precision there. In[31]:= dpceamp3 = {{s −> 2. Pi I 10^4, MaxError −> 0.1}, {s −> 2. Pi I 1, MaxError −> 0.2}}; In the subsequent call to ApproximateMatrixEquation we specify the option CompressEquations −> True. The effect of this option is that all rows and columns of the matrix equation which are not needed to compute the variable of interest will be deleted after approximation. Unlike approximation this is a mathematically exact operation, so no further information will be lost. The benefit gained from compressing a matrix equation is a speed-up in solving the system. In[32]:= approxceamp3 = ApproximateMatrixEquation[ceampsta, V$RL, dpceamp3, CompressEquations −> True] Out[32]= DAEAC, 25 25 With the CompressEquations option the approximated equations are reduced from a to a system without changing the symbolic solution for V$RL. The compression factor usually increases with larger matrix sizes and error bounds. Solving the approximated system yields the following expression. 2.8 Linear Symbolic Approximation 139 In[33]:= voutsimp3 = Together[ V$RL /. First[Solve[approxceamp3, V$RL]]] Out[33]= C1 C2 R1 R2 RL RC RE s2 RC Rpi$Q1 s2 gm$Q1 RC Ro$Q1 Rpi$Q1 s2 V1 R1 RC RE R2 RC RE R1 RE Ro$Q1 R2 RE Ro$Q1 R1 RC Rpi$Q1 R2 RC Rpi$Q1 R1 Ro$Q1 Rpi$Q1 R2 Ro$Q1 Rpi$Q1 gm$Q1 R1 RE Ro$Q1 Rpi$Q1 gm$Q1 R2 RE Ro$Q1 Rpi$Q1 C1 R1 R2 RC RE s C2 R1 RC RE RL s C2 R2 RC RE RL s C1 R1 R2 RE Ro$Q1 s Cbc$Q1 R1 R2 RE Ro$Q1 s C2 R1 RC RE Ro$Q1 s C2 R2 RC RE Ro$Q1 s C2 R1 RE RL Ro$Q1 s 22 C2 Cbc$Q1 R1 R2 RC RE Ro$Q1 s2 C1 C2 R1 R2 RE RL Ro$Q1 s2 C2 Cbc$Q1 R1 R2 RE RL Ro$Q1 s2 C2 Cbe$Q1 R1 R2 RC RE Rpi$Q1 s2 C1 C2 R1 R2 RC RL Rpi$Q1 s2 C2 Cbe$Q1 R1 R2 RC RL Rpi$Q1 s2 C2 Cbe$Q1 R1 R2 RE RL Rpi$Q1 s2 C1 C2 R1 R2 RC Ro$Q1 Rpi$Q1 s2 C2 Cbc$Q1 R1 R2 RC Ro$Q1 Rpi$Q1 s2 C2 Cbe$Q1 R1 R2 RC Ro$Q1 Rpi$Q1 s2 C1 C2 gm$Q1 R1 R2 RC RE Ro$Q1 Rpi$Q1 s2 C2 Cbc$Q1 gm$Q1 R1 R2 RC RE Ro$Q1 Rpi$Q1 s2 C1 C2 R1 R2 RL Ro$Q1 Rpi$Q1 s2 C2 Cbc$Q1 R1 R2 RL Ro$Q1 Rpi$Q1 s2 C2 Cbe$Q1 R1 R2 RL Ro$Q1 Rpi$Q1 s2 C2 Cbc$Q1 gm$Q1 R1 R2 RC RL Ro$Q1 Rpi$Q1 s2 C1 C2 gm$Q1 R1 R2 RE RL Ro$Q1 Rpi$Q1 s2 C2 Cbc$Q1 gm$Q1 R1 R2 RE RL Ro$Q1 Rpi$Q1 s2 As compared to the result of our previous equation-based simplification this transfer function is quite lengthy again. Still, approximating the matrix has reduced the degree of the solution. Therefore, we can apply solution-based approximation to compute a simplified transfer function which is more compact than our SAG-only solution and valid over a larger frequency range than our first SBG result. In[34]:= voutSBGSAG = ApproximateTransferFunction[voutsimp3, s, dpceamp, 0.1] Out[34]= C1 C2 gm$Q1 R1 R2 RC RL Ro$Q1 Rpi$Q1 s2 V1 gm$Q1 R1 RE Ro$Q1 Rpi$Q1 gm$Q1 R2 RE Ro$Q1 Rpi$Q1 C1 gm$Q1 R1 R2 RE Ro$Q1 Rpi$Q1 C2 gm$Q1 R1 RE RL Ro$Q1 Rpi$Q1 C2 gm$Q1 R2 RE RL Ro$Q1 Rpi$Q1 s C1 C2 gm$Q1 R1 R2 RE RL Ro$Q1 Rpi$Q1 s2 The common factor which appears in the coefficients of the numerator and the denominator of this transfer function can be cancelled by algebraic simplification: In[35]:= voutsimp3s = Simplify[voutSBGSAG] C1 C2 R1 R2 RC RL s2 V1 Out[35]= RE R1 R2 C1 R1 R2 s 1 C2 RL s The above result is very useful because it allows for reading off approximate symbolic expressions for the poles. To calculate these explicitly we must solve the denominator of the transfer function for s: In[36]:= poles = Solve[Denominator[voutsimp3s] == 0, s] R1 R2 1 Out[36]= s , s C1 R1 R2 C2 RL From our SAG-only approximation (voutsimp ) alone we cannot determine the poles so easily because the denominator is a polynomial of degree . On the other hand, the SBG-only approximation is 2. Tutorial 140 too large to yield meaningful expressions for the poles. This shows that combining SBG with SAG techniques can also be a powerful approach for computing other circuit characteristics than only transfer functions. In[37]:= voutsimp3n[s_] = voutsimp3s /. dpceamp 48.598 s2 Out[37]= 1 0.047 s 147000. 470. s Finally, we plot this simplified transfer function together with the original function to visualize the effects of our low-and-mid-frequency approximation. The Bode plot shows that the approximation is valid from zero frequency to the upper end of the passband at about MHz. High-frequency effects are not described because we did not specify a design point in the frequency region beyond the passband. In[38]:= BodePlot[{voutexactn[2. Pi I f], voutsimp3n[2. Pi I f]}, {f, 1., 1.*10^9}, MagnitudeDisplay −> Linear, PlotRange −> {{0, 2.5}, Automatic}] 1.0E0 2.5 1.0E2 1.0E4 1.0E6 1.0E8 1.0E2 1.0E4 Frequency 1.0E6 1.0E8 Magnitude 2 1.5 1 0.5 Phase (deg) 1.0E0 1.0E0 0 -50 -100 -150 -200 -250 -300 -350 1.0E0 1.0E2 1.0E4 1.0E6 1.0E8 1.0E2 1.0E4 Frequency 1.0E6 1.0E8 Out[38]= Graphics 2.8.5 Options for ApproximateMatrixEquation ApproximateMatrixEquation can be called with a number of options, most of which are for very advanced usage only and need not be changed unless there appear to be problems with the default settings. Since all options from Options[ApproximateMatrixEquation] are documented in Section 3.11.3, we will restrict ourselves to the discussion of the option SortingMethod . Note that the option CompressEquations has already been introduced in Section 2.8.4. SortingMethod ApproximateMatrixEquation removes negligible contributions from a matrix equation term by term following a ranking scheme which causes the term with the smallest influence on the solution to be removed first. The term ranking is obtained by sorting the list of the individual numerical influences 2.8 Linear Symbolic Approximation 141 of all terms by least influence. If only one design point is present, the sorting order is obvious, but it is not obvious for two or more design points. For example, if removing matrix entry X causes a magnitude error of in design point and an error of in design point while the error values for matrix entry Y are and respectively, which entry should be removed first? Removing X first would introduce a very small error in design point but an excessively large one in design point . On the other hand, Y has a much larger influence in design point than X but the total error in both design points would be smaller if Y is removed first. SortingMethod is an option which selects the sorting strategy that is applied to the influence list to obtain the term rankings. By default, terms are ranked by least influence on the solution in the primary design point, that is design point . In the above example, this strategy would give X precedence over Y. The corresponding option setting in Options[ApproximateMatrixEquation] is SortingMethod −> PrimaryDesignPoint The other available strategy ranks terms by least arithmetic mean influence in all design points, which would give Y precedence over X: SortingMethod −> LeastMeanInfluence Usually, LeastMeanInfluence is the better choice if the calculations involve more than one design point. To examine the effect of selecting a different term ranking method we repeat the previous approximation run with SortingMethod −> LeastMeanInfluence . In[39]:= approxceamp4 = ApproximateMatrixEquation[ceampsta, V$RL, dpceamp3, CompressEquations −> True, SortingMethod −> LeastMeanInfluence] Out[39]= DAEAC, 19 19 Solving these approximated equations now yields a much simpler expression. In[40]:= voutsimp4 = V$RL /. First[Solve[approxceamp4, V$RL]] Out[40]= C1 C2 gm$Q1 R1 R2 RC RL Rpi$Q1 s2 V1 1 C2 RL s R1 R2 gm$Q1 R1 RE Rpi$Q1 gm$Q1 R2 RE Rpi$Q1 C1 gm$Q1 R1 R2 RE Rpi$Q1 s Here, we determined the approximation sequence by using the average of the design-point errors as sorting criterion. In our first approximation run with two design points the term influences on the second design point at Hz were not taken into consideration when the ranking was computed. The error bound at design point was reached quickly because some terms were removed first which had low influence in design point but large influence in design point . 2. Tutorial 142 2.9 Frequency-Domain Analysis of Linear Circuits In the preceding chapters, many aspects of the circuit modeling and analysis functionality provided by Analog Insydes have been introduced in a rather loosely connected fashion. In this chapter we will now discuss how these techniques and functions can be applied to small-signal analysis (or AC analysis) of linear or linearized circuits in the frequency domain. Primarily, this includes classical symbolic analysis tasks such as computing transfer functions, input and output impedances, or calculating two-port parameters. However, we will see that by making use of Mathematica’s vast symbolic computation and expression manipulation capabilities it is easy to extend the standard techniques for calculating nominal small-signal characteristics to the analysis of many other quantities which are of interest to circuit designers. Such quantities are, for example, sensitivities or effects caused by nonidealities of circuit elements due to process tolerances or temperature dependence. 2.9.1 Transistor Models MOS Transistors We will show how Analog Insydes can be used to solve practical AC circuit analysis problems by demonstrating the above-mentioned analysis tasks on a number of basic transistor circuits. Although Analog Insydes has built-in device models (see Chapter 4.3), we start with implementing a set of suitable transistor models in order to better understand the modeling language of Analog Insydes. Since bipolar transistor models have already been dealt with to some extent, we begin with a discussion of MOS field-effect transistor models. D G D B S G B S Figure 9.1: NMOS (left) and PMOS (right) transistor Figure 9.1 shows the schematic representations of an n-channel type (NMOS) and a p-channel type (PMOS) MOSFET on the left-hand side and right-hand side, respectively. The letters D, G, B, and S denote the drain, gate, bulk (substrate), and source connections of the devices. For both NMOS and PMOS transistors, the small-signal operation at DC or low frequencies is characterized by the small-signal equivalent circuit shown in Figure 9.2. The symbol VGS represents the gate-source voltage, which is the main controlling factor for the drain current of the MOSFET, and VBS denotes the bulk-source, or back-gate, voltage. The model parameters of the small-signal equivalent circuits are the transconductance gm, the drain-source conductance GDS and the back-gate transconductance gmb, which is usually, but not always, considerably smaller than gm. 2.9 Frequency-Domain Analysis of Linear Circuits 143 D G B GDS VGS VBS gm*VGS gmb*VBS S S Figure 9.2: Low-frequency small-signal model for MOS transistors To describe the MOSFET AC operation at higher frequencies more accurately a number of parasitic capacitances are added to the low-frequency model, namely the gate-source and gate-drain capacitances CGS and CGD, and the bulk-source and bulk-drain capacitances CBS and CBD. The resulting high-frequency AC model is displayed in Figure 9.3. For simplicity, we have neglected the ohmic resistances in the drain and source regions which are usually accounted for by two additional resistors in between the physical drain and source connections and the corresponding terminals of the internal MOSFET device. D CBD CGD B G GDS VGS CGS gm*VGS S CBS VBS gmb*VBS S Figure 9.3: High-frequency small-signal model for MOS transistors Implementation of Small-Signal MOS Transistor Models For the following calculations we do not need the high-frequency MOSFET equivalent circuit. Therefore, we only implement the low-frequency model at this point. The former will be dealt with later when you have learned more about advanced techniques for associating numerical design-point values with symbolic subcircuit parameters. In[1]:= <<AnalogInsydes‘ 2. Tutorial 144 In[2]:= lfMOSmodel = Circuit[ Model[ Name −> MOSFET, Selector −> LowFrequency, Scope −> Global, Ports −> {D, G, S, B}, Parameters −> {gm, gmb, Gds}, Definition −> Netlist[ {VCG, {G, S, D, S}, gm}, {VCB, {B, S, D, S}, gmb}, {GDS, {D, S}, Gds} ] ] ] Out[2]= Circuit To store the model definition in the global subcircuit database we expand the Circuit object using the function ExpandSubcircuits (Section 3.4.1). The contents of the database can be inspected with the command GlobalSubcircuits (Section 3.3.4). In[3]:= ExpandSubcircuits[lfMOSmodel]; GlobalSubcircuits[] Out[4]= MOSFET, LowFrequency 2.9.2 Transfer Functions A CMOS Differential Amplifier The most basic application of linear symbolic circuit analysis is to compute transfer functions as analytic expressions of the circuit parameters and the Laplace frequency s. For instance, consider the single-ended CMOS differential amplifier stage shown in Figure 9.4 where we might be interested in computing the AC transfer function from the input voltage at node 1 to the output voltage across the load capacitor CL. 2.9 Frequency-Domain Analysis of Linear Circuits 145 VDD 6 M4 M3 5 4 1 M1 2 M2 3 CL V2 V1 IBIAS Figure 9.4: Single-ended CMOS differential stage Following, the netlist description of the circuit is not written by hand, but imported via the Analog Insydes command ReadNetlist (Section 3.10.1) from already existing simulator files. This function supports the standard application of symbolic analysis which is the extension of a simulation performed with a numerical circuit simulator. By this, a time-consuming and error-prone data conversion by hand is ruled out. In our case we start from a PSpice simulation. Thus, we need to specify the PSpice netlist and output file in the ReadNetlist call, as well as the option setting Simulator −> "PSpice" for applying the simulator-specific interface functionality. In[5]:= cmosdiffamp = ReadNetlist[ "AnalogInsydes/DemoFiles/CMOSdiffamp.cir", "AnalogInsydes/DemoFiles/CMOSdiffamp.out", KeepPrefix −> False, Simulator −> "PSpice"] Out[5]= Circuit In[6]:= Statistics[cmosdiffamp] Number of Capacitors : 1 Number of CurrentSources : 1 Number of VoltageSources : 3 Number of models MOSFET/MODN : 2 Number of models MOSFET/MODP : 2 Total number of elements : 9 The automatically generated netlist description of the amplifier contains generic model references of the form 2. Tutorial 146 {refdes, {connections}, Model −> Model[devtype, parset, refdes], Selector −> Selector[devtype, parset, refdes], Parameters −> Parameters[devtype, parset, refdes], } This allows for an easy exchange of device models and parameter sets for each device or group of devices by means of pattern matching and rewriting. The command CircuitEquations (Section 3.5.1) makes use of the above syntax when automatically selecting device models for a specific analysis mode. Computing the Single-Input to Single-Ended Voltage Gain Now, we are ready to analyze the circuit. In order to compute the voltage transfer function from node 1 to node 5 we must first set up a system of circuit equations for the small-signal configuration of the amplifier. This means that all DC sources, namely VDD and IBIAS, are set to zero. Moreover, all signal sources whose contribution is not of interest, i.e. V2, are set to zero as well. The resulting equivalent circuit is shown in Figure 9.5. VDD=0 6 M4 M3 5 4 1 2 M1 M2 3 CL V2=0 V1=1 IBIAS=0 Figure 9.5: Differential stage, configuration for small-signal transfer function analysis In the frequency domain, the relation between a response Ys, an excitation Xs, and the corresponding transfer function Hs of a linear system is given by the equation 2.9 Frequency-Domain Analysis of Linear Circuits 147 Ys Hs Xs Hence, the Laplace transform of the output signal, Ys, is identical to the transfer function if we let Xs : Xs $ Ys Hs Therefore, we can obtain the transfer function of the differential amplifier by applying a unit voltage to the input and computing the output voltage V$5[s] at node 5 because V$5[s] H[s] for V1 . In the following command line we select the low-frequency small-signal MOSFET model by application of the CircuitEquations option setting DefaultSelector −> LowFrequency (see Section 3.5.1). Additionally, we set up symbolic circuit equations in modified nodal formulation (which is the default for CircuitEquations ): In[7]:= mnacmos = CircuitEquations[cmosdiffamp, ElementValues −> Symbolic, DefaultSelector −> LowFrequency] Out[7]= DAEAC, 9 9 Next, we solve the MNA equations for V$5 using the function Solve (Section 3.5.4): In[8]:= solcmos = V$5 /. First[Solve[mnacmos, V$5]] Out[8]= Gds$M1 Gds$M2 gm$M2 Gds$M1 Gds$M2 gm$M1 gm$M2 gm$M4 gm$M1 Gds$M1 Gds$M2 gm$M1 gm$M2 V1 Gds$M1 gm$M1 gm$M1 V1 gm$M2 V2 Gds$M1 Gds$M1 gm$M1 Gds$M1 Gds$M2 gm$M1 gm$M2 Gds$M1 Gds$M3 gm$M3 gm$M2 Gds$M1 Gds$M2 gm$M1 gm$M2 V2 Gds$M2 gm$M2 gm$M1 V1 gm$M2 V2 Gds$M2 Gds$M1 gm$M1 Gds$M1 Gds$M2 gm$M2 Gds$M1 Gds$M2 gm$M1 gm$M2 gm$M4 Gds$M1 Gds$M1 gm$M1 Gds$M1 Gds$M2 gm$M1 gm$M2 Gds$M1 Gds$M3 gm$M3 Gds$M2 Gds$M2 gm$M2 Gds$M1 Gds$M2 gm$M1 gm$M2 Gds$M2 Gds$M4 CL s Finally, we apply a list of replacement rules to replace the values of the DC sources and V2 by zero, set the input voltage V1 to , and rewrite the desired transfer function into canonical sum-of-products form using the Mathematica function Together : 2. Tutorial 148 In[9]:= tfcmos = Together[ solcmos /. {V1 −> 1, V2 −> 0, IBIAS −> 0, VDD −> 0}] Out[9]= Gds$M2 Gds$M3 gm$M1 Gds$M3 gm$M1 gm$M2 Gds$M2 gm$M1 gm$M3 gm$M1 gm$M2 gm$M3 Gds$M2 gm$M1 gm$M4 gm$M1 gm$M2 gm$M4 Gds$M1 Gds$M2 Gds$M3 Gds$M1 Gds$M2 Gds$M4 Gds$M1 Gds$M3 Gds$M4 Gds$M2 Gds$M3 Gds$M4 Gds$M2 Gds$M3 gm$M1 Gds$M3 Gds$M4 gm$M1 Gds$M1 Gds$M4 gm$M2 Gds$M3 Gds$M4 gm$M2 Gds$M1 Gds$M2 gm$M3 Gds$M1 Gds$M4 gm$M3 Gds$M2 Gds$M4 gm$M3 Gds$M2 gm$M1 gm$M3 Gds$M4 gm$M1 gm$M3 Gds$M4 gm$M2 gm$M3 Gds$M1 Gds$M2 gm$M4 Gds$M2 gm$M1 gm$M4 CL Gds$M1 Gds$M2 s CL Gds$M1 Gds$M3 s CL Gds$M2 Gds$M3 s CL Gds$M3 gm$M1 s CL Gds$M1 gm$M2 s CL Gds$M3 gm$M2 s CL Gds$M1 gm$M3 s CL Gds$M2 gm$M3 s CL gm$M1 gm$M3 s CL gm$M2 gm$M3 s Note that alternatively one could use the functions UpdateDesignPoint (Section 3.6.14) and ApplyDesignPoint (Section 3.6.13) to modify or insert design-point values. Computing Differential Gains Similarly, we can compute the differential gain of the amplifier by splitting up the input signal into two equal parts with opposite phase, i.e. V1 and V2 . In[10]:= diffgain = Together[ solcmos /. {V1 −> 1/2, V2 −> −1/2, IBIAS −> 0, VDD −> 0}] Out[10]= Gds$M2 Gds$M3 gm$M1 Gds$M1 Gds$M3 gm$M2 2 Gds$M3 gm$M1 gm$M2 Gds$M2 gm$M1 gm$M3 Gds$M1 gm$M2 gm$M3 2 gm$M1 gm$M2 gm$M3 Gds$M2 gm$M1 gm$M4 Gds$M1 gm$M2 gm$M4 2 gm$M1 gm$M2 gm$M4 2 Gds$M1 Gds$M2 Gds$M3 Gds$M1 Gds$M2 Gds$M4 Gds$M1 Gds$M3 Gds$M4 Gds$M2 Gds$M3 Gds$M4 Gds$M2 Gds$M3 gm$M1 Gds$M3 Gds$M4 gm$M1 Gds$M1 Gds$M4 gm$M2 Gds$M3 Gds$M4 gm$M2 Gds$M1 Gds$M2 gm$M3 Gds$M1 Gds$M4 gm$M3 Gds$M2 Gds$M4 gm$M3 Gds$M2 gm$M1 gm$M3 Gds$M4 gm$M1 gm$M3 Gds$M4 gm$M2 gm$M3 Gds$M1 Gds$M2 gm$M4 Gds$M2 gm$M1 gm$M4 CL Gds$M1 Gds$M2 s CL Gds$M1 Gds$M3 s CL Gds$M2 Gds$M3 s CL Gds$M3 gm$M1 s CL Gds$M1 gm$M2 s CL Gds$M3 gm$M2 s CL Gds$M1 gm$M3 s CL Gds$M2 gm$M3 s CL gm$M1 gm$M3 s CL gm$M2 gm$M3 s From this formula, the DC gain can be obtained by setting the complex Laplace frequency s : In[11]:= diffgainDC = diffgain /. s −> 0 Out[11]= Gds$M2 Gds$M3 gm$M1 Gds$M1 Gds$M3 gm$M2 2 Gds$M3 gm$M1 gm$M2 Gds$M2 gm$M1 gm$M3 Gds$M1 gm$M2 gm$M3 2 gm$M1 gm$M2 gm$M3 Gds$M2 gm$M1 gm$M4 Gds$M1 gm$M2 gm$M4 2 gm$M1 gm$M2 gm$M4 2 Gds$M1 Gds$M2 Gds$M3 Gds$M1 Gds$M2 Gds$M4 Gds$M1 Gds$M3 Gds$M4 Gds$M2 Gds$M3 Gds$M4 Gds$M2 Gds$M3 gm$M1 Gds$M3 Gds$M4 gm$M1 Gds$M1 Gds$M4 gm$M2 Gds$M3 Gds$M4 gm$M2 Gds$M1 Gds$M2 gm$M3 Gds$M1 Gds$M4 gm$M3 Gds$M2 Gds$M4 gm$M3 Gds$M2 gm$M1 gm$M3 Gds$M4 gm$M1 gm$M3 Gds$M4 gm$M2 gm$M3 Gds$M1 Gds$M2 gm$M4 Gds$M2 gm$M1 gm$M4 2.9 Frequency-Domain Analysis of Linear Circuits 149 2.9.3 Device Mismatch Applying Matching Information Many analog circuit designs, including our CMOS differential amplifier, rely upon the theoretical assumption that some semiconductor devices are perfectly matched. For instance, the transistors M1 and M2, as well as M3 and M4, must have equal small-signal characteristics to make the differential stage function ideally, i.e. with zero offset voltage and infinite common-mode rejection ratio (CMRR). For applying matching information Analog Insydes provides the function MatchSymbols (Section 3.6.15). All symbols of a matching group are replaced by a common symbol. In our example, the matching group specification {"$M1", "$M2", "12"} causes all symbols which end with "$M1" or "$M2" to be replaced by a symbol which ends with "12". Thus, gm$M1 and gm$M2 are replaced by gm12, as well as Gds$M1 and Gds$M2 are replaced by Gds12. For the amplifier stage this yields an enormous reduction of the expression size for the differential gain: In[12]:= dgmatch = Simplify @ MatchSymbols[diffgainDC, {{"$M1", "$M2", "12"}, {"$M3", "$M4", "34"}}] gm12 Gds34 2 gm34 Out[12]= 2 Gds12 Gds34 Gds34 gm34 Computing Common-Mode Gains with Mismatch In practice, however, the matching condition cannot always be fulfilled completely because process tolerances or temperature gradients can cause slight differences in transistor parameters that were originally meant to be identical. The result is a deviation from the nominal circuit behavior which may even be unacceptably large. Therefore, it is necessary to take possible performance degradations due to device mismatch into account during circuit design. With a symbolic analyzer we can derive formulas which express circuit characteristics in terms of nominal parameter values plus mismatch contributions. In Analog Insydes, accounting for mismatch is simply achieved by assigning the same symbolic element value to two nominally equal components and adding a "delta term" to one of the element values. Two resistors R1 and R2 with the same nominal value R would thus be assigned the values R and R + dR, respectively, where dR represents the mismatch contribution. To demonstrate this procedure let’s examine the influence of device mismatch on the common-mode gain of the CMOS amplifier from Section 2.9.2 (see Figure 9.4). To consider the corresponding mismatch information, we set up a list of replacement rules. Since M1 and M2 should match, both transconductances gm$M1 and gm$M2 are assigned the value gm12. Mismatch is then accounted by adding the delta term dgm12 to the transconductance of gm$M2. Similarly, all other transistor parameter values are expressed in terms of a nominal value plus a mismatch term. In[13]:= mismatchparams = { gm$M1 −> gm12, Gds$M1 −> Gds12, gm$M2 −> gm12 + dgm12, Gds$M2 −> Gds12 + dGds12, gm$M3 −> gm34, Gds$M3 −> Gds34, gm$M4 −> gm34 + dgm34, Gds$M4 −> Gds34 + dGds34}; 2. Tutorial 150 First, we can compute the common-mode gain taking mismatch into account by applying the same unit signal to both input nodes simultaneously, i.e. V1 V2 and by applying the above defined replacement rules describing the device mismatch: In[14]:= cmgmismatch = Together[solcmos /. mismatchparams /. {V1 −> 1, V2 −> 1, IBIAS −> 0, VDD −> 0}] Out[14]= dgm12 dgm34 Gds12 dgm12 Gds12 Gds34 dGds12 dgm34 gm12 dGds12 Gds34 gm12 2 dgm12 Gds12 gm34 2 dGds12 gm12 gm34 dGds12 dGds34 Gds12 dGds34 dgm12 Gds12 dGds12 dgm34 Gds12 dGds34 Gds122 dgm34 Gds122 dGds12 dGds34 Gds34 dGds34 dgm12 Gds34 2 dGds12 Gds12 Gds34 2 dGds34 Gds12 Gds34 dgm12 Gds12 Gds34 2 Gds122 Gds34 dGds12 Gds342 dgm12 Gds342 2 Gds12 Gds342 dGds12 dgm34 gm12 dGds34 Gds12 gm12 dgm34 Gds12 gm12 dGds12 Gds34 gm12 2 dGds34 Gds34 gm12 2 Gds12 Gds34 gm12 2 Gds342 gm12 dGds12 dGds34 gm34 dGds34 dgm12 gm34 2 dGds12 Gds12 gm34 2 dGds34 Gds12 gm34 2 Gds122 gm34 dGds12 Gds34 gm34 dgm12 Gds34 gm34 2 Gds12 Gds34 gm34 2 dGds12 gm12 gm34 2 dGds34 gm12 gm34 2 Gds12 gm12 gm34 2 Gds34 gm12 gm34 CL dGds12 Gds12 s CL dgm12 Gds12 s CL Gds122 s CL dGds12 Gds34 s CL dgm12 Gds34 s 2 CL Gds12 Gds34 s CL Gds12 gm12 s 2 CL Gds34 gm12 s CL dGds12 gm34 s CL dgm12 gm34 s 2 CL Gds12 gm34 s 2 CL gm12 gm34 s Now, we compute the common-mode gain in the ideal case where all mismatch terms are zero: In[15]:= Simplify[cmgmismatch /. {dgm12 −> 0, dGds12 −> 0, dgm34 −> 0, dGds34 −> 0}] Out[15]= 0 Just as expected, for perfectly matching devices the common-mode gain is zero. In the presence of mismatch terms the common-mode gain is a rather lengthy transfer function whose size makes it hard to read off how the tolerances of individual circuit components contribute to the deviation from the nominal behavior. However, we can find out which mismatch terms have dominant influence by employing symbolic approximation methods (see Chapter 2.8). Below, we choose the design-point values for the MOSFET small-signal parameters gm and Gds taken from the PSpice operating-point simulation. Note that the corresponding data is already included in the above imported Circuit object cmosdiffamp . Assuming a transistor matching precision of the delta terms are given by multiplying the nominal values with . In[16]:= dpcmos = {CL −> 1.*10^−13, gm12 −> 6.*10^−5, dgm12 −> 6.*10^−7, Gds12 −> 3.*10^−7, dGds12 −> 3.*10^−9, gm34 −> 6.*10^−5, dgm34 −> 6.*10^−7, Gds34 −> 8.*10^−7, dGds34 −> 8.*10^−9}; With these design-point values we approximate the expression for the common-mode gain to a coefficient error of . 2.9 Frequency-Domain Analysis of Linear Circuits 151 In[17]:= cmgSAG = ApproximateTransferFunction[ cmgmismatch, s, dpcmos, 0.05] // Simplify dgm12 Gds12 dGds12 gm12 Out[17]= gm12 Gds12 Gds34 CL s The numerator of the result indicates that the nonideal behavior is largely due to mismatch between M1 and M2. On the other hand, tolerances between M3 and M4 have little impact on common-mode operation. Computing CMRR Using the same design point we can also simplify the differential DC gain a bit further, which yields the known approximate gain formula for this amplifier topology: In[18]:= dgSAG = ApproximateTransferFunction[ dgmatch, s, dpcmos, 0.05] // Simplify gm12 Out[18]= Gds12 Gds34 Having derived expressions for both the differential and the common-mode gain we can now calculate the common-mode rejection ratio which is defined as the quotient of both quantities. We let s to focus on the DC component only. In[19]:= CMRR = (dgSAG / cmgSAG) /. s −> 0 gm122 Out[19]= dgm12 Gds12 dGds12 gm12 The conclusion that can be drawn from this result is that increasing CMRR requires making the transconductances gm12 of M1 and M2 larger. 2.9.4 Input and Output Impedances Circuit Configuration for Impedance Calculations Since input and output impedances are transfer functions just like voltage gains we can compute the former using the same circuit analysis procedures as for any other transfer function. An input impedance is the transfer function from the current flowing into a port to the voltage across the same port (see Figure 9.6). 2. Tutorial 152 V$in Iin=1 circuit Figure 9.6: Unit current source excitation for input impedance calculations Likewise, an input admittance is the transfer function from a voltage across the port to the current into the port. The same applies to output impedances and admittances which are, in fact, just the input impedances and admittances at a port which is designated as an output. Consequently, to calculate an output impedance we must connect a unit current source to the port, set up a system of circuit equations, and solve for the port voltage. Computing the Output Impedance of the CMOS Amplifier To determine the output impedance of the differential amplifier (see Figure 9.4 in Section 2.9.2) we replace the load capacitor by a stimulus current source as displayed in Figure 9.7. VDD=0 6 M4 M3 5 4 1 M1 2 M2 IZOUT=1 3 V2=0 V1=0 IBIAS=0 Figure 9.7: Differential amplifier, small-signal configuration for computing the output impedance 2.9 Frequency-Domain Analysis of Linear Circuits 153 Replacing the load capacitor is done by editing our via ReadNetlist imported netlist. Therefore, we first remove the netlist entry for CL using the Analog Insydes command DeleteElements (Section 3.6.2) and in a second step we add an independent current source IZ using the command AddElements (Section 3.6.1). In[20]:= cmosdiffamp2 = DeleteElements[cmosdiffamp, CL]; cmosdiffamp2 = AddElements[cmosdiffamp2, {IZ, {0, 5}, IZout}]; After the modification of the netlist we set up the modified nodal equations and solve for the voltage at the output port, i.e. V$5. In[22]:= mnaZout = CircuitEquations[cmosdiffamp2, ElementValues −> Symbolic, DefaultSelector −> LowFrequency] Out[22]= DAEAC, 9 9 In[23]:= zout = Together[V$5 /. First[Solve[mnaZout, V$5]] /. {IBIAS −> 0, VDD −> 0, V1 −> 0, V2 −> 0, IZout −> 1}] Out[23]= Gds$M1 Gds$M2 Gds$M1 Gds$M3 Gds$M2 Gds$M3 Gds$M3 gm$M1 Gds$M1 gm$M2 Gds$M3 gm$M2 Gds$M1 gm$M3 Gds$M2 gm$M3 gm$M1 gm$M3 gm$M2 gm$M3 Gds$M1 Gds$M2 Gds$M3 Gds$M1 Gds$M2 Gds$M4 Gds$M1 Gds$M3 Gds$M4 Gds$M2 Gds$M3 Gds$M4 Gds$M2 Gds$M3 gm$M1 Gds$M3 Gds$M4 gm$M1 Gds$M1 Gds$M4 gm$M2 Gds$M3 Gds$M4 gm$M2 Gds$M1 Gds$M2 gm$M3 Gds$M1 Gds$M4 gm$M3 Gds$M2 Gds$M4 gm$M3 Gds$M2 gm$M1 gm$M3 Gds$M4 gm$M1 gm$M3 Gds$M4 gm$M2 gm$M3 Gds$M1 Gds$M2 gm$M4 Gds$M2 gm$M1 gm$M4 For matching the MOS transistors forming the differential pair and the current-mirror load we again apply the command MatchSymbols : In[24]:= zoutmatch = Together @ MatchSymbols[zout, {{"$M1", "$M2", "12"}, {"$M3", "$M4", "34"}}] Gds12 2 Gds34 2 gm34 Out[24]= 2 Gds12 Gds34 Gds34 gm34 As usual, this expression contains many numerically small terms which are identified and discarded by ApproximateTransferFunction . The output impedance is then given by the following simple formula in terms of the drain-source conductances Gds12 and Gds34. In[25]:= zoutSAG = ApproximateTransferFunction[ zoutmatch, s, dpcmos, 0.05] // Simplify 1 Out[25]= Gds12 Gds34 2. Tutorial 154 2.9.5 Two-Port Parameters Two-Port Representations It is easy to extend the analysis procedures for computing transfer functions to two-port parameter analysis because two-port or, more generally, n-port matrices can be regarded as transfer functions in several dimensions. Indeed, every single coefficient in a two-port matrix is a transfer function from one port current or voltage to another, so we could obtain the four coefficients of a two-port matrix by means of four separate transfer function analyses. However, we will apply a more efficient strategy which allows for calculating complete n-port matrices in only one step. I1 I2 V1 V2 Figure 9.8: Two-port current and voltage reference directions Figure 9.8 shows the voltages and currents at the terminals of a two port. The relation between the port quantities V , V , I , and I is generally given as a linear mapping of two equations in four variables: p p I q q V p p I q q V Solving these equations for any combination of two-port voltages or currents yields one of six possible two-port representations known as the admittance, impedance, hybrid I and II, and cascade I and II forms. For example, solving for I and I in terms of V and V results in the admittance, or Y-matrix, representation I y y V I y y V whose coefficients y y are known as the Y-parameters of the two port. Similarly, solving for V and V in terms of I and I yields the impedance, or Z-matrix, representation: V z z I V z z I 2.9 Frequency-Domain Analysis of Linear Circuits 155 Stimulus Sources for Two-Port Calculations A particular two-port matrix can be computed by connecting appropriate stimulus sources to the ports and solving for the opposite port quantities. For instance, if we want to compute a Z-matrix we must connect current sources to the ports, set up circuit equations and solve for the corresponding port voltages. Likewise, a Y-matrix is obtained by connecting voltage sources V1 and V2 to the ports and determining the port currents I$V1 and I$V2 in terms of these voltages. I$V2 I$V1 Y V1 V2 Figure 9.9: Voltage source excitation for Y-matrix calculation Note that a straightforward combination of the two-port circuit and the excitation sources as shown in Figure 9.9 will not yield an entirely correct result. The resulting Y-parameters would have a wrong sign because the positive reference directions for the branch currents of the voltage sources are not oriented according to the reference directions for two-port terminal currents. Remember that the positive reference direction for the current and voltage in a circuit branch is always determined by the order of the nodes in the corresponding netlist entry (see Chapter 2.2). The reference direction for the port currents can be aligned with the two-port terminal current directions by reversing the order of the nodes in the netlist entries belonging to the stimulus sources. However, the voltage reference directions, whose initial settings were correct, are changed by this operation as well. Hence, to compensate this unwanted effect, the voltages must be given negative values in the netlist (see Figure 9.10). I$V2 I$V1 -V1 Y -V2 Figure 9.10: Correct voltage source excitation for computing Y-parameters Computing Y-Parameters Let’s demonstrate the procedure for two-port analysis by calculating the Y-matrix of the circuit shown in Figure 9.11. 2. Tutorial 156 CM I1 I2 V1 RO RB V2 gm*V1 Figure 9.11: Two-port circuit As discussed in the preceding subsection we must connect stimulus voltage sources to the circuit as shown in Figure 9.12 and write the corresponding netlist. If you want to calculate two-port parameters of a circuit whose netlist was read by ReadNetlist , you can use DeleteElements (Section 3.6.2) and AddElements (Section 3.6.1) to edit the netlist. CM I$V11 -V1 2 I$V2 RO RB -V2 gm*V1 0 Figure 9.12: Correct voltage source excitation for computing Y-parameters In[26]:= twoport = Netlist[ {V1, {0, 1}, {V2, {0, 2}, {RB, {1, 0}, {CM, {1, 2}, {VC1, {1, 0, {RO, {2, 0}, ] −V1}, −V2}, RB}, CM}, 2, 0}, gm}, RO} Out[26]= NetlistRaw, 6 Next, we set up a system of circuit equations and compute the port currents I$V1 and I$V2 as functions of the stimulus voltages V1 and V2. 2.9 Frequency-Domain Analysis of Linear Circuits 157 In[27]:= twoportmna = CircuitEquations[twoport]; DisplayForm[twoportmna] Out[28]//DisplayForm= 1 CM s 1 0 V$1 0 RB CM s 1 0 V$2 gm CM s CM s 0 1 RO . V1 I$V1 1 0 0 0 V2 I$V2 0 1 0 0 In[29]:= ypar = Solve[twoportmna, {I$V1, I$V2}] V1 CM RB s V1 CM RB s V2 Out[29]= I$V1 , RB 1 I$V2 gm CM s V1 CM s V2 RO The Y-parameters of the two-port circuit are given by the coefficients of V1 and V2 on the right-hand sides of the solutions. In[30]:= yrhs = {I$V1, I$V2} /. First[ypar]; MatrixForm[yrhs] V1CM RB s V1CM RB s V2 RB Out[31]//MatrixForm= 1 CM s V1 CM s V2 gm RO To set up the Y-matrix we must extract the coefficient matrix from these two linear expressions, for example by computing the Jacobian with respect to V1 and V2. In[32]:= JacobianMatrix[eqs_, vars_] := Outer[D, eqs, vars] In[33]:= ymatrix = JacobianMatrix[yrhs, {V1, V2}]; MatrixForm[ymatrix] 1CM RB s RB Out[34]//MatrixForm= gm CM s CM s 1 CM s RO 2.9.6 Advanced Transistor Modeling Implementation of MOS Models with Inline Design-Point Information By using the value-field keywords Value and Symbolic we can provide design-point information in subcircuit or model definitions. However, directly specifying numerical values in the netlist definition of a model object hardly makes sense because, in general, different model instances have different sets of design-point values. Therefore, instead of treating these values as global quantities we must pass individual parameter sets to every model instance. The techniques for passing parameters to subcircuit instances have already been dealt with in Chapter 2.3, and the same approaches can be used to handle instance-specific design-point information. Here, we just have to observe the additional requirement that every element in a model netlist now needs two symbolic parameters: one that represents the symbolic value of the element and one that is replaced by the associated numerical value during subcircuit expansion. 2. Tutorial 158 For standard applications, you do not need to take care of these things as on the one hand Analog Insydes provides a library with built-in device models and on the other hand there is no need to write netlists by hand as this is automatically done by ReadNetlist. Following, we explain the internal model mechanism which is implemented in the Analog Insydes model library. Consider the following circuit description which contains a model definition for the high-frequency MOSFET model introduced in Section 2.9.1 (see Figure 9.3). The symbolic element values are given as arguments to the Symbolic options while the design-point values, denoted by the names with a trailing $ac, are given as arguments to the Value options. Both sets of symbols must appear in the parameter lists of the model definitions to allow for passing design-point values from a model reference to a model instance and to ensure that symbolic parameters are correctly instantiated. In[35]:= hfMOSmodel = Circuit[ Model[ Name −> MOSFET, Selector −> HighFrequency, Scope −> Global, Ports −> {D, G, S, B}, Parameters −> {gm, gmb, Gds, Cgs, Cgd, Cbs, Cbd, GM$ac, GMB$ac, GDS$ac, CGS$ac, CGD$ac, CBS$ac, CBD$ac}, Definition −> Netlist[ {CGS, {G, S}, Value −> CGS$ac, Symbolic −> Cgs}, {CGD, {G, D}, Value −> CGD$ac, Symbolic −> Cgd}, {VCG, {G, S, D, S}, Value −> GM$ac, Symbolic −> gm}, {GDS, {D, S}, Value −> GDS$ac, Symbolic −> Gds}, {VCB, {B, S, D, S}, Value −> GMB$ac, Symbolic −> gmb}, {CBD, {B, D}, Value −> CBD$ac, Symbolic −> Cbd}, {CBS, {B, S}, Value −> CBS$ac, Symbolic −> Cbs} ] ] ] Out[35]= Circuit In[36]:= ExpandSubcircuits[hfMOSmodel]; GlobalSubcircuits[] Out[37]= MOSFET, HighFrequency, MOSFET, LowFrequency Generating Design Points Please consider the circuit description of the differential amplifier circuit from Section 2.9.2 (see Figure 9.4). From the netlist entries for M1 to M4 it becomes apparent how the design-point information is specified for each transistor model instance. Values are assigned only to parameters which represent numerical information. No assignments are made to the corresponding symbolic model parameters to let them be instantiated automatically. Note again, that this is all taken care of automatically by the command ReadNetlist . 2.9 Frequency-Domain Analysis of Linear Circuits 159 Let’s examine the effects of the preceding parameter definitions and assignments by recalculating the single-input-to-single-ended voltage transfer function of the differential amplifier, this time using the high-frequency MOS model we just defined. First, we set up symbolic circuit equations using the option setting DefaultSelector −> HighFrequency . In[38]:= eqscmoshf = CircuitEquations[cmosdiffamp, ElementValues −> Symbolic, DefaultSelector −> HighFrequency] Out[38]= DAEAC, 9 9 As a result of default parameter instantiation (see Chapter 2.3) unique symbolic values have been generated for all instances of the transistor model elements. In addition, the arguments of the Value keywords have been replaced by the numerical values specified in the model references. Therefore, we can now use GetDesignPoint to extract the design-point list from the DAEObject. In[39]:= GetDesignPoint[eqscmoshf] Out[39]= V2 0.0001, V1 1., CL 1. 1013 , Cgs$M3 2.38 1013 , Cgd$M3 0., gm$M3 0.0000654, Gds$M3 7.89 107 , gmb$M3 0.00002169999999999999, Cbd$M3 0., Cbs$M3 0., Cgs$M4 2.38 1013 , Cgd$M4 0., gm$M4 0.0000654, Gds$M4 7.89 107 , gmb$M4 0.00002169999999999999, Cbd$M4 0., Cbs$M4 0., Cgs$M1 2.33 1013 , Cgd$M1 0., gm$M1 0.00005959999999999999, Gds$M1 3.01 107 , gmb$M1 0.0000441, Cbd$M1 0., Cbs$M1 0., Cgs$M2 2.33 1013 , Cgd$M2 0., gm$M2 0.00005959999999999999, Gds$M2 3.01 107 , gmb$M2 0.0000441, Cbd$M2 0., Cbs$M2 0., Simulator PSpice 2.9.7 AC Analysis of the CMOS Amplifier To conclude this chapter let’s carry out an AC analysis of the CMOS amplifier. Our task shall be to determine a symbolic formula which approximates the frequency response of the voltage gain to first order. We begin with importing the numerical data from the PSpice small-signal simulation applying the Analog Insydes command ReadSimulationData (Section 3.10.3). Note that we have to specify the simulator-specific option setting Simulator −> "PSpice". In[40]:= data = ReadSimulationData[ "AnalogInsydes/DemoFiles/CMOSdiffamp.csd", Simulator −> "PSpice"] Out[40]= V5 InterpolatingFunction1., 1. 109 , In[41]:= tfcmosPSpice := "V(5)" /. First[data] The Bode diagram of the simulation result shows that the transfer function has a dominant pole which is responsible for the corner in the magnitude response at MHz. 2. Tutorial 160 Magnitude (dB) In[42]:= BodePlot[tfcmosPSpice[f], {f, 1., 1.*10^9}] 1.0E0 1.0E2 1.0E4 1.0E6 1.0E8 30 20 10 0 -10 -20 -30 1.0E0 1.0E2 1.0E4 Frequency 1.0E6 1.0E8 Phase (deg) 1.0E0 0 1.0E2 1.0E4 1.0E6 1.0E8 1.0E2 1.0E4 Frequency 1.0E6 1.0E8 -20 -40 -60 -80 -100 1.0E0 Out[42]= Graphics Next, we set up a system of circuit equations in symbolic form. Remember that this requires specifying the option ElementValues −> Symbolic in the call to CircuitEquations . Furthermore, we use a complexityreduced device model for the transistors by the option setting ModelLibrary −> "BasicModels‘" (see Section 3.14.4) as we shall not be interested in high-frequency parasitic effects. In[43]:= stacmoshf = CircuitEquations[cmosdiffamp, ElementValues −> Symbolic, Formulation −> SparseTableau, ModelLibrary −> "BasicModels‘"] Out[43]= DAEAC, 50 50 We can now perform a numerical reference simulation within Analog Insydes to ensure that the imported data is correct and that the employed transistor models are sufficient for computing the small-signal voltage gain and the subsequent symbolic approximations. The corresponding Analog Insydes command for carrying out a numerical small-signal analysis is ACAnalysis (Section 3.7.3). In[44]:= reference = ACAnalysis[stacmoshf, {V$CL}, {f, 1., 1.*^9}] Out[44]= V$CL InterpolatingFunction1., 1. 109 , Within the Bode diagram we compare the results of the PSpice simulation and the Analog Insydes simulation. One can see that the curves match perfectly in the computed frequency range. 2.9 Frequency-Domain Analysis of Linear Circuits 161 Magnitude (dB) In[45]:= BodePlot[reference, {tfcmosPSpice[f], V$CL[f]}, {f, 1., 1.*10^9}, ShowLegend −> False] 1.0E0 1.0E2 1.0E4 1.0E6 1.0E8 30 20 10 0 -10 -20 -30 1.0E0 1.0E2 1.0E4 Frequency 1.0E6 1.0E8 Phase (deg) 1.0E0 0 1.0E2 1.0E4 1.0E6 1.0E8 1.0E2 1.0E4 Frequency 1.0E6 1.0E8 -20 -40 -60 -80 -100 1.0E0 Out[45]= Graphics Following, we can proceed with carrying out the symbolic approximation. Note that statistical information concerning DAEObjects can be displayed via the Analog Insydes command Statistics (Section 3.6.17): In[46]:= Statistics[stacmoshf] Number of equations : 50 Number of variables : 50 Number of entries : 2500 Number of non−zero entries : 139 Complexity estimate : 184 You may ask yourself why we set up the sparse tableau above instead of modified nodal equations which would be considerably smaller. The reason for this is that, in most cases, equation-based symbolic approximation tends to produce better results when applied to tableau equations. To capture the corner in the magnitude response we select two representative design points on the frequency axis, one to the left of the corner at kHz and the other to the right of the corner at MHz (see Chapter 2.8). In[47]:= dpSBG = {{s −> 2. Pi 10^4 I, MaxError −> 0.1}, {s −> 2. Pi 10^6 I, MaxError −> 0.1}}; Then, we approximate the tableau matrix with respect to the voltage across the load capacitor CL: In[48]:= stacmoshfSBG = ApproximateMatrixEquation[ stacmoshf, V$CL, dpSBG] Out[48]= DAEAC, 50 50 Please note the reduced complexity of the returned DAEObject inspected via Statistics : 2. Tutorial 162 In[49]:= Statistics[stacmoshfSBG] Number of equations : 50 Number of variables : 50 Number of entries : 2500 Number of non−zero entries : 87 Complexity estimate : 48 Next, we solve for the capacitor voltage V$CL to obtain a simplified transfer function: In[50]:= tfcmoshf = Together[V$CL /. First[Solve[stacmoshfSBG, V$CL]]] Out[50]= Gds$M2 Gds$M3 gm$M1 V1 Gds$M3 gm$M1 gm$M2 V1 Gds$M2 gm$M1 gm$M3 V1 gm$M1 gm$M2 gm$M3 V1 Gds$M2 gm$M1 gm$M4 V1 gm$M1 gm$M2 gm$M4 V1 Gds$M1 Gds$M3 gm$M2 V2 Gds$M3 gm$M1 gm$M2 V2 Gds$M1 gm$M2 gm$M3 V2 gm$M1 gm$M2 gm$M3 V2 Gds$M1 gm$M2 gm$M4 V2 gm$M1 gm$M2 gm$M4 V2 Gds$M1 Gds$M2 Gds$M3 Gds$M1 Gds$M2 Gds$M4 Gds$M1 Gds$M3 Gds$M4 Gds$M2 Gds$M3 Gds$M4 Gds$M2 Gds$M3 gm$M1 Gds$M3 Gds$M4 gm$M1 Gds$M1 Gds$M4 gm$M2 Gds$M3 Gds$M4 gm$M2 Gds$M1 Gds$M2 gm$M3 Gds$M1 Gds$M4 gm$M3 Gds$M2 Gds$M4 gm$M3 Gds$M2 gm$M1 gm$M3 Gds$M4 gm$M1 gm$M3 Gds$M4 gm$M2 gm$M3 Gds$M1 Gds$M2 gm$M4 Gds$M2 gm$M1 gm$M4 Cgd$M2 Gds$M1 Gds$M2 s CL Gds$M1 Gds$M2 s Cgd$M2 Gds$M1 Gds$M3 s Cgd$M4 Gds$M1 Gds$M3 s CL Gds$M1 Gds$M3 s Cgd$M2 Gds$M2 Gds$M3 s Cgd$M4 Gds$M2 Gds$M3 s CL Gds$M2 Gds$M3 s Cgd$M2 Gds$M3 gm$M1 s Cgd$M4 Gds$M3 gm$M1 s CL Gds$M3 gm$M1 s Cgd$M2 Gds$M1 gm$M2 s CL Gds$M1 gm$M2 s Cgd$M2 Gds$M3 gm$M2 s Cgd$M4 Gds$M3 gm$M2 s CL Gds$M3 gm$M2 s Cgd$M2 Gds$M1 gm$M3 s Cgd$M4 Gds$M1 gm$M3 s CL Gds$M1 gm$M3 s Cgd$M2 Gds$M2 gm$M3 s Cgd$M4 Gds$M2 gm$M3 s CL Gds$M2 gm$M3 s Cgd$M2 gm$M1 gm$M3 s Cgd$M4 gm$M1 gm$M3 s CL gm$M1 gm$M3 s Cgd$M2 gm$M2 gm$M3 s Cgd$M4 gm$M2 gm$M3 s CL gm$M2 gm$M3 s Cgd$M4 Gds$M1 gm$M4 s Cgd$M4 Gds$M2 gm$M4 s Cgd$M4 gm$M1 gm$M4 s Cgd$M4 gm$M2 gm$M4 s Approximating the tableau equations has reduced the transfer function, which was initially of order four, to the first-order formula we were looking for. In a last postprocessing step, we can remove all remaining numerically irrelevant terms by solution-based approximation. In[51]:= dpcmos2 = GetDesignPoint[stacmoshf]; In[52]:= tfcmoshfSAG = Simplify @ ApproximateTransferFunction[tfcmoshf, s, dpcmos2, 0.1] Out[52]= gm$M1 gm$M2 gm$M3 gm$M4 V1 Gds$M2 gm$M1 gm$M3 gm$M4 gm$M1 gm$M2 Gds$M4 gm$M3 Cgd$M2 gm$M3 Cgd$M4 gm$M3 CL gm$M3 Cgd$M4 gm$M4 s From the above result we can now easily compute a formula for the pole of the transfer function by solving the denominator of the expression for s: 2.9 Frequency-Domain Analysis of Linear Circuits 163 In[53]:= Solve[Denominator[tfcmoshfSAG] == 0, s] // Simplify Out[53]= s Gds$M4 gm$M1 gm$M2 gm$M3 Gds$M2 gm$M1 gm$M3 gm$M4 gm$M1 gm$M2 Cgd$M2 gm$M3 CL gm$M3 Cgd$M4 gm$M3 gm$M4 Finally, we verify the result by evaluating the approximated formula with the design-point values and comparing its frequency response to that of the original PSpice simulation. The simplified formula turns out to be a good approximation from DC up to a frequency of about MHz. In[54]:= tfcmoshf2 = Together[tfcmoshfSAG /. dpcmos2 /. s −> 2 Pi I f] 4.64623 1013 Out[54]= 8.49729 1015 1.0776 1020 I f Magnitude (dB) In[55]:= BodePlot[reference, {tfcmosPSpice[f], tfcmoshf2}, {f, 1., 1.*10^9}, ShowLegend −> False] 1.0E0 1.0E2 1.0E4 1.0E6 1.0E8 30 20 10 0 -10 -20 -30 1.0E0 1.0E2 1.0E4 Frequency 1.0E6 1.0E8 Phase (deg) 1.0E0 0 1.0E2 1.0E4 1.0E6 1.0E8 1.0E2 1.0E4 Frequency 1.0E6 1.0E8 -20 -40 -60 -80 -100 1.0E0 Out[55]= Graphics 2. Tutorial 164 2.10 Nonlinear Symbolic Approximation The linear simplification techniques implemented in Analog Insydes proved to be very effective and powerful. As of version 2, simplification routines for nonlinear circuits have been added to Analog Insydes. They are able to reduce the complexity of symbolic nonlinear differential-algebraic equations systems (DAE) with automated error control and can be used, for example, for behavioral model generation. Section 2.10.1 describes the main principles of the nonlinear simplification techniques in Analog Insydes. Section 2.10.2 shows their application on an example. 2.10.1 Introduction to Nonlinear Approximation As opposed to the linear case, for nonlinear approximation techniques there is no distinction between simplification-before-generation and simplification-after-generation methods. All nonlinear simplification commands expect a symbolic DAEObject as input and return an approximated symbolic DAEObject. This simplified system can then be approximated further until the desired complexity reduction is reached. During simplification, the error is measured by numerical simulations and the simplification is stopped as soon as the error exceeds a user-given error bound. Different user-defined numerical analyses can be performed for error calculation. Before the nonlinear simplification techniques can be applied, the equation system has to be prepared using the command NonlinearSetup (Section 3.12.1). The command syntax is as follows: NonlinearSetup[dae, inputs, outputs, mode1 −> {settings1 }, ] The first argument of NonlinearSetup is the DAEObject to be simplified. It has to be set up in symbolic formulation for DC or transient analysis mode. See the command CircuitEquations (Section 3.5.1), especially the options ElementValues and AnalysisMode , for setting up an appropriate equation system. Then you have to specify the input and output symbols of the equation system. During simplification, the input symbols are swept in a user-given range, whereas the value of the output symbols is used to calculate the numerical error. All parameters of the DAEObject can be used as input symbols. To get a list of all valid input symbols, use the command GetParameters (Section 3.6.9). On the other hand, all variables of the DAEObject can be used as output symbols. To get a list of all valid output symbols, use the command GetVariables (Section 3.6.7). Both arguments inputs and outputs can either be a single symbol or a list of symbols. Since several input and output symbols can be specified, the nonlinear simplification techniques are able to approximate multi-input/multi-output (MIMO) systems. Finally, the analysis modes used for error calculation have to be given as rules of the form modei −> {settingsi }, where modei is either DT (for DC-transfer analysis) or AC (for AC analysis). The argument settingsi is a sequence of rules for specifying the sweep range (using the symbol Range), the simulation function (using the symbol SimulationFunction ), and the error function (using the symbol ErrorFunction ). The sweep range is a required argument and determines for 2.10 Nonlinear Symbolic Approximation 165 each input symbol (as specified by inputs) the numerical range in which to sweep the symbol during numerical simulation. The sweep range is given by a standard Analog Insydes parameter sweep specification as described in Section 3.7.2. Both the simulation function and error function arguments are optional and for advanced usage only. For usual applications you do not need to specify them. For example, the argument DT −> {Range −> {VIN, {0., 5., 1.}}} specifies that a DC-transfer analysis has to be performed for error calculation. For this, the input symbol VIN has to be swept from 0. to 5. in steps of 1. and the default simulation and error functions have to be used. NonlinearSetup returns a new DAEObject which is prepared for nonlinear approximation. All data given as arguments to NonlinearSetup are stored in the returned DAEObject and automatically extracted by subsequent commands, such that there is no need to specify them again. Additionally, NonlinearSetup performs numerical simulations and stores the result as reference values used for error calculations. You can use the command NonlinearSettings (Section 3.12.5) to inspect which data has been added to the DAEObject for nonlinear simplifications. Once the DAEObject is prepared, there are two major commands for nonlinear simplifications: CompressNonlinearEquations and CancelTerms . CompressNonlinearEquations CompressNonlinearEquations (Section 3.12.2) removes equations and eliminates variables from the DAEObject which are irrelevant for solving for the output variables. The general syntax is as follows: CompressNonlinearEquations[dae, vars] If the given DAEObject is prepared via NonlinearSetup , the output variables specified in the call to NonlinearSetup are added to the given list vars of variables to hold in the equation system. Note that compressing equations is a mathematically exact operation, there is no need to perform numerical error calculations. Since CompressNonlinearEquations reduces the number of equations in a DAEObject, it is recommended as the first step in a nonlinear simplification procedure. CancelTerms CancelTerms (Section 3.12.3) simplifies a DAEObject by successive removal of terms in the equation system. The general syntax is as follows: CancelTerms[dae, maxerrors] After each each term removal, CancelTerms performs a numeric simulation (as set by NonlinearSetup ), calculates the error, and compares it to the user-given error bound maxerrors. If the error caused by a simplification exceeds this error bound, the simplification is undone. 2. Tutorial 166 CancelTerms returns the simplified DAEObject. All nonlinear options which are stored in dae are copied to the new system. Thus, the returned system can be used as input for subsequent simplifications. By default, CancelTerms removes terms in top-level sums of the equation system. Using the option Level, removal of terms can be performed in deeper levels, too. The value of this option is either a non-negative integer, a list of non-negative integers, or the symbol All. For the latter, removal of terms is performed in all levels, starting on top level. 2.10.2 Analyzing a Square Root Function Block In this section the application of the nonlinear simplification functions is demonstrated on an example. Figure 10.1 shows the schematic of a nonlinear square root function block consisting of four bipolar transistors. VLOAD VCC I0 Q3 Q2 Q1 5 Q4 II Figure 10.1: Square root function block The input is given by the current source II and the voltage source VLOAD, the output is given by the current through the voltage source VLOAD. Using the nonlinear approximation routines we want to generate a symbolic expression for the static input output behavior of the circuit. Importing Numerical Data In PSpice the numerical simulation is performed as a DC sweep on ii and vload. The corresponding part of the .cir-file looks as follows: .op .dc ii 0.0 0.001 0.00001 vload 0 3.5 0.875 .probe/csdf .options numdgt=8 2.10 Nonlinear Symbolic Approximation 167 As a first step we import the numerical simulation data calculated with PSpice into Mathematica using ReadSimulationData (Section 3.10.3). In[1]:= <<AnalogInsydes‘ In[2]:= data = ReadSimulationData[ "AnalogInsydes/DemoFiles/Sqrt.txt", Simulator −> "PSpice"] Out[2]= V3 InterpolatingFunction0., 0.001, , V5 InterpolatingFunction0., 0.001, , V1 InterpolatingFunction0., 0.001, , Vout InterpolatingFunction0., 0.001, , V4 InterpolatingFunction0., 0.001, , III InterpolatingFunction0., 0.001, , IIB InterpolatingFunction0., 0.001, , IVLOAD InterpolatingFunction0., 0.001, , Ivdc InterpolatingFunction0., 0.001, , ICQ1 InterpolatingFunction0., 0.001, , IBQ1 InterpolatingFunction0., 0.001, , IEQ1 InterpolatingFunction0., 0.001, , ISQ1 InterpolatingFunction0., 0.001, , ICQ2 InterpolatingFunction0., 0.001, , IBQ2 InterpolatingFunction0., 0.001, , IEQ2 InterpolatingFunction0., 0.001, , ISQ2 InterpolatingFunction0., 0.001, , ICQ3 InterpolatingFunction0., 0.001, , IBQ3 InterpolatingFunction0., 0.001, , IEQ3 InterpolatingFunction0., 0.001, , ISQ3 InterpolatingFunction0., 0.001, , ICQ4 InterpolatingFunction0., 0.001, , IBQ4 InterpolatingFunction0., 0.001, , IEQ4 InterpolatingFunction0., 0.001, , ISQ4 InterpolatingFunction0., 0.001, , SweepParameters VLOAD 0., 1, 1, 1, V3 InterpolatingFunction0., 0.001, , V5 InterpolatingFunction0., 0.001, , V1 InterpolatingFunction0., 0.001, , Vout InterpolatingFunction0., 0.001, , V4 InterpolatingFunction0., 0.001, , III InterpolatingFunction0., 0.001, , IIB InterpolatingFunction0., 0.001, , IVLOAD InterpolatingFunction0., 0.001, , 10, IBQ3 InterpolatingFunction0., 0.001, , IEQ3 InterpolatingFunction0., 0.001, , ISQ3 InterpolatingFunction0., 0.001, , ICQ4 InterpolatingFunction0., 0.001, , IBQ4 InterpolatingFunction0., 0.001, , IEQ4 InterpolatingFunction0., 0.001, , ISQ4 InterpolatingFunction0., 0.001, , SweepParameters VLOAD 3.5 ReadSimulationData returns the two-dimensional sweep data as a list of lists of one-dimensional interpolating functions as described in Section 3.7.1. To transform the data into a list of twodimensional interpolating functions we can use the command ConvertDataTo2D (Section 3.13.1). In the following step we extract the interpolating function corresponding to the output value I(VLOAD) and assign it to the function ivloadPSpice . 2. Tutorial 168 In[3]:= data2d = ConvertDataTo2D[data] Out[3]= V3 InterpolatingFunction0., 3.5, 0., 0.001, , V5 InterpolatingFunction0., 3.5, 0., 0.001, , V1 InterpolatingFunction0., 3.5, 0., 0.001, , Vout InterpolatingFunction0., 3.5, 0., 0.001, , V4 InterpolatingFunction0., 3.5, 0., 0.001, , III InterpolatingFunction0., 3.5, 0., 0.001, , IIB InterpolatingFunction0., 3.5, 0., 0.001, , IVLOAD InterpolatingFunction0., 3.5, 0., 0.001, , Ivdc InterpolatingFunction0., 3.5, 0., 0.001, , ICQ1 InterpolatingFunction0., 3.5, 0., 0.001, , IBQ1 InterpolatingFunction0., 3.5, 0., 0.001, , IEQ1 InterpolatingFunction0., 3.5, 0., 0.001, , ISQ1 InterpolatingFunction0., 3.5, 0., 0.001, , ICQ2 InterpolatingFunction0., 3.5, 0., 0.001, , IBQ2 InterpolatingFunction0., 3.5, 0., 0.001, , IEQ2 InterpolatingFunction0., 3.5, 0., 0.001, , ISQ2 InterpolatingFunction0., 3.5, 0., 0.001, , ICQ3 InterpolatingFunction0., 3.5, 0., 0.001, , IBQ3 InterpolatingFunction0., 3.5, 0., 0.001, , IEQ3 InterpolatingFunction0., 3.5, 0., 0.001, , ISQ3 InterpolatingFunction0., 3.5, 0., 0.001, , ICQ4 InterpolatingFunction0., 3.5, 0., 0.001, , IBQ4 InterpolatingFunction0., 3.5, 0., 0.001, , IEQ4 InterpolatingFunction0., 3.5, 0., 0.001, , ISQ4 InterpolatingFunction0., 3.5, 0., 0.001, In[4]:= ivloadPSpice[VLOAD_, II_] = "I(VLOAD)"[VLOAD, II] /. data2d Out[4]= InterpolatingFunction0., 3.5, 0., 0.001, VLOAD, II The interpolating function ivloadPSpice can now be plotted in a three-dimensional plot: In[5]:= Plot3D[ivloadPSpice[VLOAD, II], {VLOAD, 0., 3.5}, {II, 0., 0.001}, AxesLabel −> {"VLOAD", "II", ""}, PlotLabel −> "IVLOAD (PSpice)"] IVLOAD (PSpice) 0.0003 0.0002 0.0001 0 0 0.001 0.0008 0.0006 II 0.0004 1 VLOAD 0.0002 2 3 Out[5]= SurfaceGraphics 0 2.10 Nonlinear Symbolic Approximation 169 Equation Setup In the next step the equation system has to be set up. For this we import the PSpice .cir-file and convert it into an Analog Insydes Circuit object using the command ReadNetlist (Section 3.10.1). In[6]:= netlist = ReadNetlist[ "AnalogInsydes/DemoFiles/Sqrt.cir", Simulator −> "PSpice"]; DisplayForm[netlist] Out[7]//DisplayForm= Circuit: Netlist Raw, 8 Entries: Q1, 3 C, 5 B, 0 E, Model ModelBJT, BJTNPN, Q1, Selecto Q2, 1 C, 3 B, 5 E, Model ModelBJT, BJTNPN, Q2, Selecto Q3, OUT C, 3 B, 4 E, Model ModelBJT, BJTNPN, Q3, Selec Q4, 4 C, 4 B, 0 E, Model ModelBJT, BJTNPN, Q4, Selecto VLOAD, 1, OUT, Type VoltageSource, Value AC 0, DC Tran II, 5, 0, Type CurrentSource, Value AC 0, DC Transient IB, 1, 3, Type CurrentSource, Value AC 0, DC Transient VDC, 1, 0, Type VoltageSource, Value AC 0, DC Transien ModelParametersName BJTNPN, Type NPN GlobalParametersSimulator PSpice Afterwards, we set up a symbolic DC equation system using the modified nodal formulation. Since we are not interested in temperature effects, we instruct CircuitEquations (Section 3.5.1) to replace TEMP, TNOM, the elementary charge $q, and Boltzmann’s constant $k by their numerical values. In[8]:= mnaFull = CircuitEquations[netlist, AnalysisMode −> DC, ElementValues −> Symbolic, Value −> {"*" −> {TEMP, TNOM, $q, $k}}] Out[8]= DAEDC, 27 27 In[9]:= GetVariables[mnaFull] Out[9]= V$1, V$3, V$4, V$5, V$OUT, I$BS$Q1, I$CS$Q1, I$ES$Q1, ib$Q1, ic$Q1, I$BS$Q2, I$CS$Q2, I$ES$Q2, ib$Q2, ic$Q2, I$BS$Q3, I$CS$Q3, I$ES$Q3, ib$Q3, ic$Q3, I$BS$Q4, I$CS$Q4, I$ES$Q4, ib$Q4, ic$Q4, I$VLOAD, I$VDC In[10]:= GetParameters[mnaFull] Out[10]= AREA$Q1, AREA$Q2, AREA$Q3, AREA$Q4, BF$Q1, BF$Q2, BF$Q3, BF$Q4, BR$Q1, BR$Q2, BR$Q3, BR$Q4, GMIN, IB, II, IS$Q1, IS$Q2, IS$Q3, IS$Q4, VDC, VLOAD Numerical Reference Calculation Using NDAESolve (Section 3.7.5) we now perform the same numerical simulation as in PSpice, transform the result again into a two-dimensional interpolating function, and plot it in a three-dimensional plot. In[11]:= data = NDAESolve[mnaFull, {II, 0.0, 0.001}, {VLOAD, 0., 3.5, 0.5}]; 2. Tutorial 170 In[12]:= data2d = ConvertDataTo2D[data]; In[13]:= ivload[VLOAD_, II_] = I$VLOAD[VLOAD, II] /. data2d Out[13]= InterpolatingFunction0., 3.5, 0, 0.001, VLOAD, II In[14]:= Plot3D[ivload[VLOAD, II], {VLOAD, 0., 3.5}, {II, 0., 0.001}, AxesLabel −> {"VLOAD", "II", ""}, PlotLabel −> "IVLOAD (Analog Insydes)"] IVLOAD (Analog Insydes) 0.0003 0.0002 0.0001 0 0 0.001 0.0008 0.0006 II 0.0004 1 VLOAD 0.0002 2 3 0 Out[14]= SurfaceGraphics Model Validation One key step is now to check if the numerical simulation in Analog Insydes is identical to the result of the PSpice simulation, i.e. to check if we have chosen appropriate transistor models. This can for example be done by comparing the graphical output. We choose some arbitrary value for VLOAD and plot both output values in one graph sweeping II. The plot shows that both curves are identical (for this value of VLOAD). Alternatively, we can calculate the maximum difference of both output values evaluated on a uniform grid. The result shows that the deviation is of order ΜA. 2.10 Nonlinear Symbolic Approximation 171 In[15]:= TransientPlot[{ivloadPSpice[2., II], ivload[2., II]}, {II, 0., 0.001}] 0.0003 0.00025 ivloadPSp 0.0002 0.00015 ivload[2. 0.0001 0.00005 II 0.00020.00040.00060.0008 0.001 Out[15]= Graphics In[16]:= Max @ Map[Abs[Apply[ivload,#] − Apply[ivloadPSpice,#]] &, Flatten[Table[{VLOAD, II}, {VLOAD, 0., 3.5, 0.1}, {II,0., 0.001, 0.000025}], 1]] Out[16]= 2.62136 107 Starting Nonlinear Simplifications Now that we have ensured to use the same equation system as PSpice does, we can proceed with the nonlinear simplification routines. The task is to generate a simplified static equation system which has the same input-output behavior as the original system mnaFull . To get an impression of the complexity of the original system, we use the command Statistics (Section 3.6.17). In[17]:= Statistics[mnaFull] Number of equations : 27 Number of variables : 27 Length of equations : {4, 4, 3, 3, 2, 3, 2, 3, 8, 8, 3, 2, 3, 9, 9, 3, 2, 3, 9, 9, 3, 2, 3, 4, 4, 3, 2} Terms with derivatives : 0 Sums in levels : {113, 20} Compressing Equations In a first step we eliminate irrelevant variables using the function CompressNonlinearEquations (Section 3.12.2). The argument {I$VLOAD} to CompressNonlinearEquations assures that our variable of interest is not eliminated from the equation system. Eliminating variables is a mathematically exact operation, thus no error calculation is needed. As in our example, this usually reduces the number of equations drastically (but not necessarily the number of terms) and is therefore recommended as the first step in the simplification procedure. 2. Tutorial 172 In[18]:= step1 = CompressNonlinearEquations[mnaFull, {I$VLOAD}] Out[18]= DAEDC, 6 6 In[19]:= Statistics[step1] Number of equations : 6 Number of variables : 6 Length of equations : {16, 24, 9, 23, 3, 2} Terms with derivatives : 0 Sums in levels : {77, 42} Preparing Approximation Routines To further reduce the complexity of the DAE system we now cancel terms in the equations. Since this operation alters the output of the system, numerical control simulations have to be applied to check the current error. We use NonlinearSetup (Section 3.12.1) to prepare the DAEObject for the following simplification steps. Since we are dealing with a static equation system, we choose the DT analysis mode for error checking, specifying sweep ranges for both input values VLOAD and II. NonlinearSetup performs a numerical reference simulation and stores the result in the returned DAEObject. These numerical values are used automatically to calculate the error in subsequent simplification steps. In[20]:= step2 = NonlinearSetup[step1, {II, VLOAD}, {I$VLOAD}, DT −> {Range −> {{VLOAD, 0., 3.5, 0.5}, {II, 0., 0.001, 0.0002}} }] Out[20]= DAEDC, 6 6 Cancelling Terms Once we have set up the DAE system we call CancelTerms (Section 3.12.3) where we specify an error bound for the output variable. CancelTerms then deletes terms in the equation system using this error bound. Afterwards we again use Statistics to inspect the complexity reduction achieved by CancelTerms . In[21]:= step3 = CancelTerms[step2, {DT −> {I$VLOAD −> 25.*^−6}}] Out[21]= DAEDC, 6 6 In[22]:= Statistics[step3] Number of equations : 6 Number of variables : 6 Length of equations : {2, 2, 2, 4, 2, 1} Terms with derivatives : 0 Sums in levels : {12, 4} Note that CancelTerms reduces the number of terms drastically. 2.10 Nonlinear Symbolic Approximation 173 Compressing Equations again Deletion of terms changes the equations in such a way that it is often possible to further solve equations for some variables. Thus, we can again try to eliminate variables using CompressNonlinearEquations . Here, two more equations can be removed from the system. Note that CompressNonlinearEquations automatically retrieves the settings made by NonlinearSetup , so there is no need to specify the variable of interest I$VLOAD as a second argument. Afterwards we drop those parameters from the design point which no longer appear in the equation system using UpdateDesignPoint (Section 3.6.14). In[23]:= step4 = CompressNonlinearEquations[step3] Out[23]= DAEDC, 4 4 In[24]:= Statistics[step4] Number of equations : 4 Number of variables : 4 Length of equations : {2, 2, 2, 4} Terms with derivatives : 0 Sums in levels : {10, 4} In[25]:= step5 = UpdateDesignPoint[step4] Out[25]= DAEDC, 4 4 In[26]:= step5 // DisplayForm Out[26]//DisplayForm= II 1. AREA$Q2 E38.6635 V$3V$5 IS$Q2 0, 1. IB 1. AREA$Q1 E38.6635 V$5 IS$Q1 0, 1. AREA$Q3 E38.6635 V$3V$4 IS$Q3 1. I$VLOAD 0, 1. IB 1. AREA$Q1 E38.6635 V$5 IS$Q1 1. AREA$Q4 E38.6635 V$4 IS$Q4 1. I$VLOAD 0, V$3, V$4, V$5, I$VLOAD, DesignPoint II 0.0001, IB 0.0001, AREA$Q1 1., IS$Q1 1. 1016 , AREA$Q2 1., IS$Q2 1. 1016 , AREA$Q3 1., IS$Q3 1. 1016 , AREA$Q4 1., IS$Q4 1. 1016 Looking at the simplified DAE system one can see that the parameter VLOAD disappeared from the equations. The three-dimensional plot of the output from the beginning shows that the output does not depend on VLOAD, thus the simplification procedure automatically removes this parameter from the equation system. Validating the Result Now we can compare the output of the simplified system step5 with the output of the original system. Since VLOAD no longer appears in the DAE system, we no longer need to perform a multi-dimensional parametric sweep of NDAESolve . A single sweep on II suffices, resulting in a one-dimensional interpolating function. In[27]:= data = NDAESolve[step5, {II, 0., 0.001}]; 2. Tutorial 174 In[28]:= ivloadSimp[II_] = I$VLOAD[II] /. First @ data Out[28]= InterpolatingFunction0, 0.001, II In[29]:= Plot3D[ivloadSimp[II], {VLOAD, 0., 3.5}, {II, 0., 0.001}, AxesLabel −> {"VLOAD", "II", ""}, PlotLabel −> "IVLOAD (simplified system)"] IVLOAD (simplified system) 0.0003 0.0002 0.0001 0 0 0.001 0.0008 0.0006 II 0.0004 1 VLOAD 0.0002 2 3 0 Out[29]= SurfaceGraphics To show that the requested error bound is met, we plot the deviation of the output comparing the original and the simplified system (note the plot range). In[30]:= Plot3D[Abs[ivloadSimp[II]−ivload[VLOAD, II]], {VLOAD, 0., 3.5}, {II, 0., 0.001}, PlotRange −> {0, 25.*^−6}, AxesLabel −> {"VLOAD", "II", ""}, PlotLabel −> "absolute error"] absolute error 0.00002 0.001 0.0008 0.0006 II 0.0004 0.00001 0 0 1 VLOAD 0.0002 2 3 Out[30]= SurfaceGraphics 0 2.10 Nonlinear Symbolic Approximation 175 Further Postprocessing In the final step we further reduce the complexity of the equation system by applying some standard Mathematica functions to manipulate the equations symbolically. In this example it is possible to solve the equations for the output variable I$VLOAD symbolically yielding an explicit formula describing the input-output behavior. In[31]:= eqs = GetEquations[step5]; In[32]:= eqs2 = Eliminate[eqs, {V$3, V$4, V$5}] Eliminate::ifun: Inverse functions are being used by Eliminate, so some solutions may not be found. Out[32]= I$VLOAD Log AREA$Q3 IS$Q3 IB II I$VLOAD Log Log 1. Log AREA$Q1 IS$Q1 AREA$Q2 IS$Q2 AREA$Q4 IS$Q4 In[33]:= Solve[Map[Exp, eqs2], I$VLOAD] Out[33]= 1. AREA$Q3 AREA$Q4 IB II IS$Q3 IS$Q4 I$VLOAD , AREA$Q1 AREA$Q2 IS$Q1 IS$Q2 1. AREA$Q3 AREA$Q4 IB II IS$Q3 IS$Q4 I$VLOAD AREA$Q1 AREA$Q2 IS$Q1 IS$Q2 From the result it can be seen that the output current I$VLOAD depends on the square root of the input current II and that it is independent of the input voltage VLOAD. Reference Manual 3.1 Netlist Format . . . . . . . . . . . . . . . . . . . . . . . 178 3.2 Subcircuit and Device Model Definition . . . . . . . . . . 190 3.3 Model Library Management . . . . . . . . . . . . . . . . 211 3.4 Expanding Subcircuits and Device Models . . . . . . . . 221 3.5 Setting Up and Solving Circuit Equations . . . . . . . . . 227 3.6 Circuit and DAEObject Manipulation . . . . . . . . . . . 255 3.7 Numerical Analyses . . . . . . . . . . . . . . . . . . . . 280 3.8 Pole/Zero Analysis . . . . . . . . . . . . . . . . . . . . . 304 3.9 Graphics Functions . . . . . . . . . . . . . . . . . . . . . 330 3.10 Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . 365 3.11 Linear Simplification Techniques . . . . . . . . . . . . . . 385 3.12 Nonlinear Simplification Techniques . . . . . . . . . . . . 401 3.13 Miscellaneous Functions . . . . . . . . . . . . . . . . . . 418 3.14 Global Options . . . . . . . . . . . . . . . . . . . . . . . 425 3.15 The Analog Insydes Environment . . . . . . . . . . . . . 432 3. Reference Manual 178 3.1 Netlist Format The following chapter explains the circuit-description language used by Analog Insydes. In Analog Insydes, circuits are described in terms of Netlist and Circuit objects. Section 3.1.2 shows the general syntax for Circuit objects, Section 3.1.1 for Netlist objects. Sections 3.1.3–3.1.8 describe the syntax of the Netlist object entries, Sections 3.1.9–3.1.11 describe the syntax of the Circuit object entries. 3.1.1 Netlist Netlist[args] defines a circuit in terms of basic components and model references where args may be any sequence of netlist entries Command structure of Netlist. A flat netlist is described in Analog Insydes by means of a Netlist object. A Netlist consists of a sequence of netlist entries which can be either basic components or model references. Each netlist entry is a list. The general syntax for a Netlist object is as follows: netlistname = Netlist[ netlist entry 1, netlist entry 2, ] The format of a netlist entry is described in Section 3.1.3. Usually, a Netlist object is contained in a Circuit object together with model and parameter definitions. See also: Circuit (Section 3.1.2), CircuitEquations (Section 3.5.1), Sections 3.1.3–3.1.7. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ A simple voltage divider netlist. In[2]:= voldiv = Netlist[ {V0, {1, 0}, V0}, {R1, {1, 2}, R1}, {R2, {2, 0}, R2} ] Out[2]= NetlistRaw, 3 3.1 Netlist Format 179 3.1.2 Circuit Circuit[args] defines a circuit in terms of top-level netlists and models where args may be any sequence of Netlist, Subcircuit , Model, ModelParameters , or GlobalParameters objects Command structure of Circuit. With Analog Insydes you can describe electrical circuits and control systems hierarchically in terms of netlists, subcircuit or device model definitions, and model parameter sets. Circuits are defined with the commands Circuit or Netlist. The general syntax for a Circuit object is as follows: Circuit[ Netlist[top-level netlist with subcircuit references], Model[subcircuit/model definition], ModelParameters[model parameters specification], GlobalParameters[global parameters specification], ] Multiple Netlist sections in a Circuit object will be concatenated in order of appearance upon subcircuit expansion. See also: Netlist (Section 3.1.1), ModelParameters (Section 3.1.10), GlobalParameters (Section 3.1.11), Model (Section 3.2.1), CircuitEquations (Section 3.5.1), ReadNetlist (Section 3.10.1). Examples The following is an example for a complete Analog Insydes circuit description including device model and parameter definitions. Load Analog Insydes. In[1]:= <<AnalogInsydes‘ 3. Reference Manual 180 A complex circuit description. In[2]:= amplifier = Circuit[ Netlist[ {V0, {VCC, 0}, Symbolic −> {AC−>0, _ −> VCC}, Value −> {DC | Transient −> 12}}, {V1, {1, 0}, Symbolic −> V1, Value −> {AC −> 1, DC | Transient −> SinWave[Time, 0.8, 0.01, 1000]}}, {Q1, {2 −> C, 1 −> B, 0 −> E}, Model −> Model[BJT, DEFNPN, Q1], Selector −> Selector[BJT, DEFNPN, Q1], Parameters −> Parameters[BJT, DEFNPN, Q1], GM$ac −> 0.02, RPI$ac −> 5.0*^3, RO$ac −> 1.0*^4}, {RC, {VCC, 2}, Value −> 500, Symbolic −> RC} ], Model[Name −> BJT, Selector −> ACsimple, Scope −> Global, Ports −> {C, B, E}, Parameters −> {gm, Rpi, Ro, GM$ac, RPI$ac, RO$ac}, Definition −> Netlist[ {RPI, {B, E}, Value −> RPI$ac, Symbolic −> Rpi}, {VC, {B, E, C, E}, Value −> GM$ac, Symbolic −> gm}, {RO, {C, E}, Value −> RO$ac, Symbolic −> Ro} ] ], ModelParameters[Name −> DEFNPN, Type −> "NPN", IS −> 1.0*^−16, BF −> 100, BR −> 1, VAF −> 150], GlobalParameters[TEMP −> 300.15, GMIN −> 1.0*^−12] ] Out[2]= Circuit 3.1.3 Netlist Entries Netlist entries must be written in one of the following ways: {refdes, {nodes}, value} simple netlist entry format {refdes, {nodes}, Value−>value, opts} extended value field format for netlist entries {refdes, {node −>port , † † † }, Model−>name, Selector−>sel, par −>val , † † † } netlist entry format for model references Netlist entry formats. The reference designator (refdes) is a unique name (a symbol or a string) by which a circuit component can be identified, such as R1 and CL for a resistor R and a load capacitor CL . For linear netlist elements, the first one, two, or three letters of the reference designator (the type tag) determine the type of the element (see Chapter 4.2 for a list of available linear element types). In the following, the simple and extended netlist entry format is described. Section 3.1.8 describes the netlist format for model references in more detail. 3.1 Netlist Format 181 Reference designators must be symbols or strings that can be converted to symbols. Reference designators are case sensitive. Therefore, R1 and r1 denote different elements. All reference designators are converted internally to strings. Therefore, R1 and "R1" refer to the same element. The second argument of a netlist entry (nodes) specifies the nodes to which the element is connected. The number of nodes that have to be specified depends on the element type. You may use nonnegative integers, symbols, and strings as node identifiers. The number 0, or equivalently the string "0", designates the ground node. Numeric node identifiers are not required to be consecutive. Node identifiers are case sensitive. Therefore, N1 and n1 denote different nodes. All node identifiers are converted internally to strings. Therefore, N1 and "N1" refer to the same node. The value of a circuit element may be a symbol, a number, or any Mathematica expression involving both numeric and symbolic quantities. Whenever the extended value field format is used for a netlist entry, the value of the corresponding element must be specified with the keyword Value; this keyword may not be omitted. See also: Section 3.1.4. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ This defines an RLC lowpass filter circuit. In[2]:= rlcf = {V1, {R1, {L1, {C1, ] Netlist[ {1, 0}, V}, {1, 2}, R}, {2, 3}, L}, {3, 0}, C} Out[2]= NetlistRaw, 4 3. Reference Manual 182 This netlist is semantically identical to the previous one. In[3]:= rlcf2 = Netlist[ {"V1", {1, 0}, Value {"R1", {1, 2}, Value {"L1", {2, 3}, Value {"C1", {3, 0}, Value ] −> −> −> −> V}, R}, L}, C} Out[3]= NetlistRaw, 4 Set up a system of circuit equations. In[4]:= CircuitEquations[rlcf] // DisplayForm Out[4]//DisplayForm= 1 1 0 R R 1 1 1 1 R R L s L s 1 1 0 L s L s C s 0 0 1 1 V$1 0 0 V$2 0 . 0 V$3 0 I$V1 V 0 The example below shows a valid mixture of data types and formats for reference designators, node identifiers, and value specifications. This defines a voltage divider circuit. In[5]:= divider = Netlist[ {V1, {"in", 0}, Value −> 5}, {"R1", {in, out}, R}, {R2, {"out", 0}, 2*R} ] Out[5]= NetlistRaw, 3 3.1.4 Netlist Entry Options The extended value field format allows you to specify additional information related to a circuit element expressed in terms of rules with the following keywords: option name default value InitialCondition Automatic the initial condition for a dynamic element (L or C) Pattern Automatic the MNA pattern for a two-terminal impedance or admittance element (R, G, C, L, Z, Y) Symbolic (no default) the symbolic value of a circuit element Type Automatic explicit specification of the element type Netlist entry options. A netlist entry in extended value field format looks like 3.1 Netlist Format 183 {refdes, {nodes}, Value −> value, Symbolic −> symbolicvalue, Pattern −> pattern, Type −> type, InitialCondition −> initialcondition} where parameters in slanted typewriter font are optional. InitialCondition With InitialCondition −> ic, you can specify initial currents and voltages for inductors and capacitors, respectively. If no initial condition is given explicitly, it will be assumed to be zero (AC analysis) or will be calculated automatically from operating-point data (transient analysis). Pattern The option Pattern allows you to select the matrix fill-in patterns for two-terminal admittances and impedances (immittances) to be used in modified nodal analysis (MNA). By default, all impedances Z are converted to equivalent admittances Y Z to keep the dimensions of the circuit equations small. The following values are allowed: Automatic convert impedances to admittances for MNA Admittance use admittance pattern for immittances Impedance use impedance pattern for immittances Values for the Pattern option. An explicit Pattern specification overrides the setting of the option ConvertImmittances locally. Symbolic With Symbolic −> symbol, you can specify an alternative symbolic element value in addition to a numerical value given by Value −> value. This feature is used to associate design-point data with symbolic element values. Note that symbol is not strictly required to be a symbol; you may also specify any Mathematica expression. However, design-point management will work as intended only if the value of the Symbolic option is a symbol. 3. Reference Manual 184 You may not use the Symbolic option without the Value option. If the extended value field format is used, the Value option must always be present (except in model references). Type The Type option allows you to override the automatic element type detection mechanism. With the default setting Type −> Automatic , the type of an element is determined from the leading characters of its reference designator. With Type −> typename, the element is assumed to be of type typename regardless of what the reference designator implies. The argument typename must be a full type name. To get a list of all available type names, inspect the contents of the global variable ElementTypes . See also: ElementTypes (Section 3.1.5), Section 3.1.3, Section 3.5.1. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ The following netlist illustrates the use of the netlist entry options described above. The option Pattern −> Impedance , prevents the resistance R1 from being converted to an equivalent admittance 1/R1 when setting up modified nodal equations. The Type option in the value field of the component Load tells Analog Insydes to treat the element as a resistor although the type tag is L (inductor). Finally, the InitialCondition option in the netlist entry for C1 sets an initial capacitor voltage of V. This illustrates the use of the netlist entry options. In[2]:= filter = Netlist[ {V1, {1, 0}, Value −> 5, Symbolic −> V1}, {R1, {1, 2}, Value −> 1000., Symbolic −> R1, Pattern −> Impedance}, {Load, {2, 3}, Value −> 10., Symbolic −> RL, Type −> Resistor}, {C1, {3, 0}, Value −> 1.*^−6, Symbolic −> C, InitialCondition −> 2.5} ] Out[2]= NetlistRaw, 4 Set up a system of symbolic circuit equations. In[3]:= CircuitEquations[filter, ElementValues −> Symbolic, InitialConditions −> Automatic] // DisplayForm Out[3]//DisplayForm= 0 0 0 1 1 0 RL RL 1 1 0 RL RL C s 1 0 0 1 0 1 1 1 0 V$1 0 1 0 V$2 2.5 C . V$3 0 0 V1 I$V1 0 0 0 I$R1 0 R1 3.1 Netlist Format 185 3.1.5 ElementTypes ElementTypes contains the names of all primitive circuit element types Global variable ElementTypes. The global variable ElementTypes contains a list of the internal names of all primitive circuit element types supported by Analog Insydes. Any name from this list can be used as value of the option Type in the value fields of netlist entries. See also: Section 3.1.4, Chapter 4.2. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Get the list of element type names. In[2]:= ElementTypes Out[2]= Resistor, Conductance, Admittance, Impedance, Capacitor, Inductor, CurrentSource, VoltageSource, CCCSource, CCVSource, VCCSource, VCVSource, Nullator, Norator, Fixator, OpAmp, OTAmp, ABModel, OpenCircuit, ShortCircuit, SignalSource, Amplifier, Integrator, Differentiator, TransmissionLine, TransferFunction 3.1.6 Value Specifications for Independent Sources Independent sources may require multiple value specifications for different analysis modes. For example, a supply voltage source may have a value of V for DC and transient analysis and an AC value of V (e.g. for PSRR calculation). Multiple source values for both numerical and symbolic values can be specified in a netlist entry using a special form of the extended value field syntax (see Section 3.1.3). Value | Symbolic−>{modespec−>value, † † † } mode-specific source value specification AC mode key for AC analysis DC mode key for DC analysis Transient mode key for transient analysis Mode specific source value specifications. A mode specification (modespec) is a Mathematica pattern which is compared against the value of the option AnalysisMode given to CircuitEquations (Section 3.5.1) during equation setup. Mode specifications are evaluated from left to right. The first matching pattern yields the element value that will be used. 3. Reference Manual 186 If no value is specified for a particular analysis mode, the value is assumed to be zero. Multiple element values may be given in both Value and Symbolic specifications. The value specification in the following netlist entry will yield the source value for the option settings AnalysisMode −> DC and AnalysisMode −> Transient . For AC analysis the value will be used. {VSUP, {VCC, 0}, Value −> {DC | Transient −> 12, AC −> 1}} The value specification in the following netlist entry sets both the numeric and symbolic AC values of V1 to zero whereas the values Vin and 12 are used for all other analysis modes (DC and Transient). {V1, {1, 0}, Symbolic −> {AC −> 0, _ −> Vin}, Value −> {AC −> 0, _ −> 12}} Note that the above approach allows you to keep symbols that represent pure DC values out of AC equations (see example in Section 3.1.2): Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define filter circuit. In[2]:= filter = Netlist[ {V0, {1, 0}, Value −> {DC|Transient −> 5, AC −> 0}, Symbolic −> {AC −> 0, _ −> V0}}, {V1, {1, 2}, Value −> {AC −> 1, DC −> 0, Transient −> SinWave[Time, 0.8, 0.01, 1000]}, Symbolic −> V1}, {R1, {2, 3}, Value −> 1000., Symbolic −> R1}, {C1, {3, 0}, Value −> 1.*^−6, Symbolic −> C} ] Out[2]= NetlistRaw, 4 Set up AC equation system. Note that symbol V0 does not appear in the AC equations. In[3]:= CircuitEquations[ filter, AnalysisMode −> AC, ElementValues −> Symbolic] // DisplayForm Out[3]//DisplayForm= 0 0 0 1 1 0 R1 R1 1 1 0 R1 R1 C s 1 0 0 0 1 1 1 1 0 V$1 0 1 0 V$2 0 . V$3 0 0 0 I$V0 0 0 V1 I$V1 0 0 3.1.7 Time and Frequency The keywords Time and Frequency can be used in the value fields of netlist entries to refer to time and the complex Laplace frequency, respectively. For example, the netlist entry 3.1 Netlist Format 187 {L1, {2, 3}, L[Time]} defines a time-variant inductance, and {VC2, {1, 2, 3, 4}, Frequency*C} defines a transcapacitance, i.e. a voltage-controlled current source with a transconductance that depends linearly on frequency. Upon setting up circuit equations, the keywords Time and Frequency are replaced by the symbols that designate time and frequency as set in Options[CircuitEquations] (see also Section 3.5.1). The following analysis mode specific settings are performed: For DC analysis, Time is replaced by the value of InitialTime and Frequency is set to zero. For AC analysis, Time is replaced by the value of InitialTime . For transient analysis, Frequency is set to zero. Mode-specific replacement of Time and Frequency. 3.1.8 Model References Subcircuits and device models are referenced via special netlist entries of the following form. A model reference is recognized by the presence of the keyword Model in the value field. {refdes, {node −>port , † † † }, Model−>name, Selector−>sel, par −>val , † † † } netlist entry format for model references Referencing models. The following netlist entry references a transistor model NPN/DC and specifies numerical values for the transistor parameters IS, BF, and BR: {Q1, {1 −> C, 2 −> B, 3 −> E}, Model −> NPN, Selector −> DC, IS −> 1.*^−16, BF −> 100, BR −> 1} To reference a parameter set, use the value-field option Parameters −> name, where name denotes the name of the parameter set defined with ModelParameters (see Section 3.1.10). The following netlist entry includes a reference to the model parameter set DEFNPN. {Q1, {1 −> C, 2 −> B, 3 −> E}, Model −> NPN, Selector −> DC, Parameters −> DEFNPN} 3. Reference Manual 188 A model reference may contain multiple parameter set references. References to parameter sets are replaced by the corresponding model parameters in the given order. When you read in circuit descriptions using the command ReadNetlist (Section 3.10.1), the Model, Selector , and Parameters keys in the value fields of model references are returned in the generic form key −> key[devtype, parset, refdes], for example {Q1, {1 −> C, 2 −> B, 3 −> E}, Model −> Model[BJT, DEFNPN, Q1], Selector −> Selector[BJT, DEFNPN, Q1], Parameters −> Parameters[BJT, DEFNPN, Q1]} This approach permits an easy exchange of device models and parameter sets for each device or group of devices by means of pattern matching and rewriting (see also Section 3.4.1). In the default case, i.e. when no replacement rules are applied to these keys, the model name, the selector, and the parameter set key are rewritten as follows upon circuit equation setup: Model −> devtype, Selector −> mode, Parameters −> parset For the following model reference Q1, the generic right-hand sides of these rules are transformed as shown below if AnalysisMode −> AC. {Q1,{2 −> C, 1 −> B, 0 −> E} Model −> BJT, Selector −> AC, Parameters −> DEFNPN, GM$ac −> 0.02, RPI$ac −> 5.0*^3, RO$ac −> 1.0*^4} See also: Model (Section 3.2.1), ModelParameters (Section 3.1.10), Section 3.1.3. 3.1.9 Model and Subcircuit In Analog Insydes, Subcircuit is a synonym for Model. You may use either function name as you like. For a detailed description of the Model command, see Section 3.2.1. 3.1 Netlist Format 189 3.1.10 ModelParameters ModelParameters[Name−>name, par −>val , † † † ] defines a local model parameter set ModelParameters[Name−>name, Scope−>Global, par −>val , † † † ] stores a model parameter set in the global subcircuit database Command structure of ModelParameters . In addition to subcircuit and device models, you can also define parameter sets (model cards) that can be used in conjunction with model references in a circuit description. The following statement defines a model parameter set for the device type DEFNPN. ModelParameters[Name −> DEFNPN, IS −> 1.0*^−16, BF −> 100, BR −> 1, VAF −> 150] These model parameter sets can be used in model references by means of the Parameters keyword. See also: Section 3.1.8. 3.1.11 GlobalParameters GlobalParameters[par −>val , † † † ] defines global parameter settings Command structure of GlobalParameters . With GlobalParameters you can specify settings for global parameters used in a Circuit object, as for instance TEMP or GMIN. Global parameter definitions may be self-referencing, i.e. a global parameter may be specified as a function of one or several others (make sure that there are no circular references). The list of global parameters is implicitly appended to the value fields of all model references in a circuit. Therefore, you can use global parameter settings in a model without having to pass these settings explicitly in each model reference. The following examples are valid declarations for global parameters: GlobalParameters[TEMP −> 300.15, GMIN −> 1.0*^−12] GlobalParameters[TEMP −> TNOM, TNOM −> 300.15, GMIN −> 1.0*^−12] 3. Reference Manual 190 3.2 Subcircuit and Device Model Definition This chapter describes the usage of the command Model (Section 3.2.1), which enables you to describe your circuits hierarchically in terms of subcircuits and device models. In the following sections, Analog Insydes’ subcircuit and device modeling functionality is presented mainly from the perspective of language syntax. Therefore, it is recommended that you also read Chapter 2.3 and Chapter 2.6 of the Analog Insydes Tutorial to understand the philosophy behind the modeling language and learn more about methodologies for modeling linear and nonlinear circuits and devices. Analog Insydes provides a unified modeling scheme that lets you implement and instantiate both subcircuits and device models in exactly the same way. Therefore, the terms model and subcircuit shall be treated as synonyms throughout this chapter. Whenever the word model is used in the following text, it may refer to a component of a hierarchically structured circuit as well as to an equivalent circuit or set of equations that describes a physical device. Consequently, the Analog Insydes command Subcircuit is just an alias for Model, and you may use both names interchangeably. 3.2.1 Model Model[keyword −>value , keyword −>value , † † † ] defines a subcircuit or device model in terms of a netlist or a system of behavioral equations Command structure of Model. Subcircuits and device models can be implemented either as netlists, i.e. as equivalent circuits composed of electrical primitives and model references (see Section 3.1.3), or as behavioral descriptions in terms of linear and nonlinear algebraic and differential equations. Both equivalent circuits and analog behavioral models (ABMs) can be defined with the Model command. Model takes a sequence of named arguments, four of which are required while the remaining arguments are optional. Name Selector Ports Definition Required arguments of the Model command. the model class name the selector for a particular member from a model class the list of model port nodes the model definition (a netlist or a system of equations) 3.2 Subcircuit and Device Model Definition Scope Parameters Defaults Translation Symbolic Variables InitialGuess InitialConditions 191 the scope of the model definition (local or global) the list of model parameter names default values for model parameters translation rules for parameter conversion the list of ABM parameters to be kept in symbolic form the variables in a system of ABM equations initial guess for the numerical values of ABM variables initial conditions for dynamic ABM variables Optional arguments of the Model command. A valid Model definition has the following general form: Model[ Name −> name, Selector −> selector Ports −> {port nodes}, optarg −> value , Definition −> Netlist[ ] | Circuit[ ] | Equations[ ] ] Arguments Description The arguments of the Model command are explained in detail below. Name Name−>"string" Name−>symbol Name−>{"string ", "string ", † † † } the name of the model class to which the model definition is assigned equivalent to Name−>ToString[symbol] assign the model definition to several model classes Format of the Name argument. The value of the argument Name identifies a class of model definitions for a non-primitive circuit object or a device type, such as current mirror, operational amplifier, bipolar junction transistor, or MOSFET. The class name must be a symbol or a string. For example, the class names of BJT and MOSFET models are defined in the Analog Insydes model library as: 3. Reference Manual 192 Name −> "BJT" Name −> "MOSFET" You may assign one or more alias names to a model class by specifying a list of strings: Name −> {"BJT", "Q"} Internally, all model names are converted to strings. Therefore, Name−>symbol and Name−>ToString[symbol] are equivalent name specifications. Likewise, you can specify the model class name in a model reference (see Section 3.1.8) either as a symbol or a string regardless of the data type used in the model definition. Selector Selector−>"string" Selector−>symbol the key by which the model can be identified among the members of the model class equivalent to Selector−>ToString[symbol] Selector−>{"string ", "string ", † † † } assign several alias names to the model definition Format of the Selector argument. The value of the argument Selector selects a particular member from the class of models identified with Name. For instance, the AC, DC, and dynamic large-signal models of the device type MOSFET can be defined and distinguished with the following Name/Selector pairs: Model[Name −> "MOSFET", Selector −> "AC", ], Model[Name −> "MOSFET", Selector −> "DC", ], Model[Name −> "MOSFET", Selector −> "Transient", ] By assigning several selector keys to a model definition, you can set up a list of alias names for the model. This feature allows you to configure models for use with several closely related analysis modes, such as AC and noise analysis (see DefaultSelector in Section 3.5.1). To prepare a model for use with both AC and noise analysis, your selector specification should be written as follows: Model[Name −> "MOSFET", Selector −> {"AC", "Noise"}, ] 3.2 Subcircuit and Device Model Definition 193 Internally, all model selectors are converted to strings. Therefore, Selector−>symbol and Selector−>ToString[symbol] are equivalent selector specifications. Likewise, you can specify the selector in a model reference (see Section 3.1.8) either as a symbol or a string regardless of the data type used in the model definition. Scope Scope−>Local Scope−>Global restrict the visibility of the model definition to the surrounding Circuit object store the model definition in the global subcircuit database Format of the Scope argument. The optional argument Scope determines the scope of the model definition. With the default setting Scope −> Local, the model can only be referenced from Netlist objects inside the Circuit object that contains the corresponding Model statement. With Scope −> Global, the model is stored in the global subcircuit database and can be accessed by other Circuit objects. You can use the Scope mechanism to implement a library of frequently used device models separately from any top-level circuit description and load the models into Analog Insydes’ global subcircuit database. This can be accomplished by implementing a set of models in a Mathematica *.m file as illustrated below. (* Begin MyModels.m *) Circuit[ Model[Name −> "BJT", Selector −> "AC", Scope −> Global, Definition −> ], Model[Name −> "MOSFET", Selector −> "AC", Scope −> Global, Definition −> ], ] // ExpandSubcircuits; (* End MyModels.m *) The library file "MyModels.m" can then be loaded using the command Get["MyModels.m"] . See also: GlobalSubcircuits (Section 3.3.4), RemoveSubcircuit (Section 3.3.8). 3. Reference Manual 194 Ports Ports−>{portspec , portspec , † † † } specify the nodes in the model definition which serve as external connection points Format of the Ports argument. With the Ports keyword, you can define the port nodes of a model. The value of the argument must be a list of the identifiers of the model nodes which serve as external connection points. Nodes in a model definition which are not listed in the Ports statement (internal nodes) are not accessible from the outside. "string" or symbol declare a required port node Optional[port] declare port as optional port node; if port remains unconnected in a model reference, treat it as if it were an internal node of the model Optional[port, default] declare port as optional port node; if port remains unconnected in a model reference, connect it to the node default instead Values for the port specification portspec. For a three-pin BJT model with collector (C), base (B), and emitter (E) terminals, the list of port nodes can be specified as a list of strings Ports −> {"C", "B", "E"} or, equivalently, as a list of symbols Ports −> {C, B, E} Although there is no semantic difference between these two Ports declarations, it is recommended that you always use strings as port node identifiers. This avoids potential errors caused by accidentally assigning a value to a Mathematica symbol which is used as a port node identifier in some model definitions. For example, the assignment C = 1 + x will corrupt the latter of the above Ports declarations whereas the version that uses strings is not affected. The global ground node 0 (or "0") may not be used as a port identifier. In a model reference, all required ports listed in the Ports argument of the corresponding model definition must be connected to an external node exactly once; otherwise, subcircuit expansion fails. 3.2 Subcircuit and Device Model Definition 195 By declaring a port as Optional , you can tell Analog Insydes to ignore any missing connections to this port and perform some default action instead, such as connecting the port to the ground node. This is useful for modeling integrated semiconductor devices with substrate pins. If the substrate pin of a BJT or MOSFET model is an optional port, you can use the same model definition for both three-pin and four-pin devices. If you write the Ports specifications for these device types as shown below, then the substrate pin is connected implicitly to the ground node and source terminal, respectively, whenever a BJT or MOSFET model is instantiated as a three-pin device. The following Ports declaration causes the substrate pin S of a BJT device to be connected to the ground node if S is left unconnected: Ports −> {"C", "B", "E", Optional["S", 0]} This causes the bulk node B of a MOSFET device to be connected to the source terminal if the port node B is left unconnected: Ports −> {"D", "G", "S", Optional["B", "S"]} You can also tell Analog Insydes to leave an unconnected node floating by using Optional without a second argument. The following Ports declaration treats S as if it were an internal node of the model definition if S is left unconnected. Ports −> {"C", "B", "E", Optional["S"]} The second node given in an Optional declaration must be a required port, an internal node of the model definition, or the global ground node. Parameters Parameters−>{parspec , parspec , † † † } specify the symbols which represent parameters of a model definition Format of the Parameters argument. With the Parameters keyword, you can specify the set of symbols which represent the parameters of a model definition. Possible values are: symbol Global[symbol] Values for the parameter specification parspec. declare symbol as an instance-specific model parameter declare symbol as a global quantity but allow instance-specific value assignments 3. Reference Manual 196 Any symbol which appears in the value field of a model netlist entry or in a set of behavioral equations can be designated as a parameter. The difference between parameters and other symbols is that you can assign instance-specific values only to parameters. Other symbols are regarded as global quantities which cannot be bound to instance-specific values in a model reference. In addition, if a model parameter p is left unbound in a model reference, it will be replaced by a uniquely instantiated symbol p$instance upon subcircuit expansion whereas symbols representing global quantities are not changed. The following line shows a valid example for the Parameters declaration of a BJT model: Parameters −> {IS, N, BF, BR} In some cases it is necessary to override the value of a global circuit parameter locally for a particular model instance. For example, you may have set the environmental temperature TEMP in a Circuit object with the GlobalParameters statement Circuit[ Netlist[ ], GlobalParameters[TEMP −> 300.15] ] but you want to specify a different operating temperature for an individual device, such as a temperature sensor or the output transistor of a power amplifier. In order to override the global value of TEMP for this device, the local temperature value must be specified explicitly in the corresponding model reference: {QOUT, {VCC −> C, 5 −> B, out −> E}, Model −> BJT, Selector −> DC, IS −> 1.*^−16, N −> 1., BF −> 100., BR −> 1., TEMP −> 340.} However, TEMP is a global quantity and not an instance parameter of the model BJT/DC. Therefore, the local setting TEMP −> 340. in the model reference QOUT has no effect unless the Parameters specification in the model definition is modified as follows: Parameters −> {IS, N, BF, BR, Global[TEMP]} Now the setting Global[TEMP] allows you to change the value of TEMP individually for any instance of BJT/DC while the setting from the GlobalParameters list will be used for all instances for which no local temperature value is given. Defaults Defaults−>{param −>value , param −>value , † † † } specify default values for model parameters Format of the Defaults argument. With the Defaults keyword, you can specify default values for model parameters which have been left unbound in a model reference. For example, with the settings 3.2 Subcircuit and Device Model Definition 197 Parameters −> {IS, N, BF, BR, Global[TEMP]}, Defaults −> {IS −> 1.*^−16, N −> 1., BF −> 100., BR −> 1., TEMP −> 300.15}, you can instantiate a default BJT device without having to specify values for the parameters in the model reference: {QDEF, {nout −> C, 2 −> B, 3 −> E}, Model −> BJT, Selector −> DC} During subcircuit expansion the numerical default values specified by the Defaults argument are used as model parameter values. The above model reference is thus processed as if its value field had been specified as shown below. {QDEF, {nout −> C, 2 −> B, 3 −> E}, Model −> BJT, Selector −> DC, IS −> 1.*^−16, N −> 1., BF −> 100., BR −> 1., TEMP −> 300.15} Translation Translation−>{param −>expr , param −>expr , † † † } specify model parameter translation rules Format of the Translation argument. The optional argument Translation allows you to specify conversion rules for calculating values of internal model parameters from external parameters declared with the Parameters argument. For example, the following code defines a simple BJT small-signal model with the external parameters RB (base resistance) and beta (current gain). Internally, the model is implemented using a VCCS whose transconductance gm is calculated automatically from RB and beta by means of the Translation rule gm −> RB*beta. Model[ Name −> "BJT", Selector −> "SimpleACgm", Ports −> {"C", "B", "E"}, Parameters −> {RB, beta}, Translation −> {gm −> RB*beta}, Definition −> Netlist[ {"RB", {"B", "E"}, RB}, {"VC", {"B", "E", "C", "E"}, gm} ] ] Translation rules may also be specified using the RuleDelayed operator (:>). This enables you to defer the evaluation of function calls on the right-hand sides of translation rules until model expansion. In the following list of rules, the thermal voltage Vt of a semiconductor device is calculated by 3. Reference Manual 198 a delayed rule to prevent the function ThermalVoltage to be evaluated before the value of TEMP is known for an individual device. Translation −> {Is −> Js*Area, Vt :> ThermalVoltage[TEMP]} If Vt were calculated using a simple Rule (−>), ThermalVoltage would already be called at the time of model definition, i.e. execution of the Model command. Symbolic Symbolic−>{symbol , symbol , † † † } Symbolic−>{symbol −>alias , † † † } declare behavioral model parameters as symbolic quantities declare behavioral model parameters as symbolic quantities and specify alias names to be used in symbolic circuit equations Format of the Symbolic argument. The optional argument Symbolic is used only in conjunction with analog behavioral model definitions. It lets you specify the subset of the model parameters declared in the Parameters section that will be treated as symbolic quantities in a set of behavioral model equations. Model parameters which are not listed in the Symbolic section are always replaced by their numerical values when you set up circuit equations. This feature allows you to restrict the parameters that will appear in a system of symbolic circuit equations to the ones you really wish to see. The following code defines a DC model for a temperature-dependent linear resistor. The model parameters are the nominal resistance RES, the first-order temperature coefficient TC1, the ambient temperature TEMP, and the reference temperature TNOM. The Symbolic argument declares RES as a model parameter which will appear in symbolic circuit equations. The other parameters will always be evaluated numerically and will not appear explicitly in circuit equations. Model[ Name −> "RES", Selector −> "DC", Ports −> {"P", "N"}, Parameters −> {RES, TC1, Global[TEMP, TNOM]}, Symbolic −> {RES}, Variables −> {Voltage["P", "N"], Current["P", "N"]}, Definition −> Equations[ Voltage["P", "N"] == RES*(1 + TC1*(TEMP − TNOM))*Current["P", "N"] ] ] Names of device model or instance parameters in netlists imported from external circuit simulators with ReadNetlist sometimes have lengthy or ugly names. The alternative format of the Symbolic 3.2 Subcircuit and Device Model Definition 199 argument allows you to assign alias names to model parameters which will appear in symbolic circuit equations in place of the original names. For example, the following declaration causes the symbol R to be used instead of the original model parameter name RES whenever you set up symbolic circuit equations with the above model definition. Symbolic −> {RES −> R} Variables Variables−>{varspec , varspec , † † † } specify the identifiers which represent unknowns in a set of model equations Format of the Variables argument. The Variables argument is used only in conjunction with analog behavioral model definitions. It serves to declare the identifiers in a set of model equations which represent the unknowns. The identifiers have to be of the following form: symbol declare symbol as an internal model variable Voltage[port , port ] or Current[port , port ] declare a model variable as a branch voltage or branch current Values for the variable specification varspec. For each port branch you must declare both the branch voltage and the branch current as model variables, even in cases where one of the two does not appear explicitly in the equations. 3. Reference Manual 200 Definition Definition−>Netlist[† † †]|Circuit[† † †] define a model in terms of an equivalent Netlist or Circuit object Definition−>Equations[† † †] define a behavioral model in terms of a system of equations Format of the Definition argument. With the Definition argument, you specify the implementation of a model. A model can be implemented either as an equivalent circuit or as a set of linear or nonlinear differential-algebraic equations. You may use a Netlist or a Circuit object to implement an equivalent circuit. The netlist that represents the equivalent circuit may contain primitive devices as well as further model references. There is no fixed limit of the subcircuit nesting level. The following example shows a model implementation for a simple RC tank. Definition −> Netlist[ {R, {in, out}, R}, {C, {out, ref}, C} ] A Circuit object may contain local ModelParameters sections as well as local Model definitions. Local model definitions and parameter sets should have Scope −> Local to prevent interference with the global subcircuit and parameter databases. Using a Circuit instead of a simple Netlist feature allows you to define models with instance-specific model parameter sets, i.e. device model parameters whose values are calculated from model instance parameters. For example, the following code implements a device-level description of a bipolar differential pair with emitter degeneration resistors. The model definition contains a local ModelParameters statement in which the ohmic collector and emitter resistances RC and RE are calculated as functions of the BJT area factor Area for each instance of the subcircuit DifferentialPair/DeviceLevel . 3.2 Subcircuit and Device Model Definition 201 Subcircuit[ Name −> "DifferentialPair", Selector −> "DeviceLevel", Ports −> {"H1", "H2", "IN1", "IN2", "L"}, Parameters −> {Area, RED}, Definition −> Circuit[ Netlist[ {"Q1", {"H1" −> "C", "IN1" −> "B", "ED1" −> "E"}, Model −> "BJT", Selector −> Selector["BJT", "Q1"], Parameters −> "LocalNPN"}, {"RED1", {"ED1", "L"}, RED}, {"Q2", {"H2" −> "C", "IN2" −> "B", "ED2" −> "E"}, Model −> "BJT", Selector −> Selector["BJT", "Q2"], Parameters −> "LocalNPN"}, {"RED2", {"ED2", "L"}, RED} ], ModelParameters[Name −> "LocalNPN", Type −> "NPN", IS −> 2.*^−15, BF −> 200., RC −> 50./Area, RE −> 2./Area] ] ] Analog Insydes allows you to implement arbitrary multi-dimensional voltage-current relations as analog behavioral models. ABMs are implemented using sets of Equations instead of Netlist or Circuit objects. Each model equation must be written in the form lhs == rhs, where lhs and rhs denote arbitrary Mathematica expressions. If you implement a behavioral model using the Equations keyword, you must declare the unknowns of the model equations in the Variables section. The following code implements a nonlinear DC model for a bipolar junction diode with series resistance Rs. The first equation serves to compute the effective diode voltage vdeff. It is written in implicit notation to demonstrate that Analog Insydes does not require model equations to be written in explicit form var == expr, where var denotes a single symbol or branch quantity identifier. Model[ Name −> "Diode", Selector −> "DC", Ports −> {"A", "C"}, Parameters −> {Rs, Is, Global[Vt]}, Variables −> {Voltage["A", "C"], Current["A", "C"], vdeff}, Definition −> Equations[ Voltage["A", "C"] − Rs*Current["A", "C"] − vdeff == 0, Current["A", "C"] == Is*(Exp[vdeff/Vt] − 1) ] ] In addition, the Model command lets you implement behavioral models involving ordinary differential equations (ODEs). In general, the independent variable of such equations is the time variable, 3. Reference Manual 202 denoted by the symbol Time, but other quantities than time may be used as independent variable as well (see Section 3.5.1). You can attach a trailing tick mark (’) to a variable in a set of model equations to denote a time derivative. The following model definition implements the voltage-current relation of a linear, timeinvariant capacitor in the time domain. The time derivative of the capacitor voltage is denoted by Voltage["P", "N"]’. Variables −> {Current["P", "N"], Voltage["P", "N"]}, Definition −> Equations[ Current["P", "N"] == C*Voltage["P", "N"]’ ], To denote a derivative of a variable var with respect to some other quantity q, you must use Mathematica’s full derivative notation Derivative[n][var][q] where n is the order of the differentiation. Of course, you can also use this notation for time derivatives. For example, the first derivative of the variable vdeff with respect to time can be written as: Derivative[1][vdeff][Time] Since Time is the default quantity with respect to which derivatives are computed, the above line can be abbreviated as follows. Derivative[1][vdeff] Any derivative term lacking an explicit specification of the independent variables is assumed to be a derivative with respect to Time. Your equations may involve second and higher-order derivatives. Your equations may not involve partial derivatives. See also: IndependentVariable (Section 3.5.1), Section 3.1.7. InitialGuess InitialGuess−>{var −>value , var −>value , † † † } specify initial guesses for the values of behavioral model variables Format of the InitialGuess argument. 3.2 Subcircuit and Device Model Definition 203 With the InitialGuess argument, you can specify a set of numerical values that will be used by NDAESolve (Section 3.7.5) as initial guess for the solution of behavioral model variables. Initial guesses may be specified for some or all of the variables listed in the corresponding Variables declaration. The default value for initial guesses is 0. When you analyze strongly nonlinear circuits, an educated initial guess helps to speed up DC calculations with NDAESolve considerably. The effect of initial guess specifications on the convergence behavior of NDAESolve depends on the type of circuit equations. In the example shown below, initial guesses of V and V are specified for the model variables vdeff and Voltage["A", "C"], respectively. No initial guess is given for Current["A", "C"], therefore, NDAESolve uses 0 as initial guess for this current. Model[ Name −> "Diode", Selector −> "DC", Ports −> {"A", "C"}, Parameters −> {Rs, Is, Global[Vt]}, Variables −> {Voltage["A", "C"], Current["A", "C"], vdeff}, Definition −> Equations[ Voltage["A", "C"] − Rs*Current["A", "C"] − vdeff == 0, Current["A", "C"] == Is*(Exp[vdeff/Vt] − 1) ], InitialGuess −> {vdeff −> 0.7, Voltage["A", "C"] −> 0.8} ] InitialConditions InitialConditions−>{var −>value , var −>value , † † † } specify initial conditions for dynamic model variables Format of the InitialConditions argument. With the InitialConditions argument, you can specify initial conditions for dynamic variables in behavioral model equations. Initial conditions can be assigned to any quantity x whose derivative x’ appears in the equations. This applies to internal model variables as well as to branch voltages and currents. The following example shows how to specify an initial condition for the branch quantity Voltage["P", "N"]. Note that it is not important whether this quantity appears directly in the equations or not. However, its derivative Voltage["P", "N"]’ must be present as a prerequisite for the assignment of an initial condition. 3. Reference Manual 204 Model[ Name −> "Capacitor", Selector −> "Behavioral", Ports −> {"P", "N"}, Parameters −> {C}, Variables −> {Current["P", "N"], Voltage["P", "N"]}, Definition −> Equations[ Current["P", "N"] == C*Voltage["P", "N"]’ ], InitialConditions −> {Voltage["P", "N"] −> 1.52} ] Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ The following model commands implement a CCCS-based model for bipolar transistors and an equivalent VCCS-based model. The transconductance of the VCCS in BJT/SimpleACgm is calculated automatically from the parameters RB and beta by means of a translation rule. CCCS and VCCS-based BJT small-signal models. In[2]:= Circuit[ Model[ Name −> "BJT", Selector −> "SimpleACbeta", Scope −> Global, Ports −> {"C", "B", "E"}, Parameters −> {RB, beta}, Definition −> Netlist[ {"RB", {"B", "X"}, RB}, {"CC", {"X", "E", "C", "E"}, beta} ] ], Model[ Name −> "BJT", Selector −> "SimpleACgm", Scope −> Global, Ports −> {"C", "B", "E"}, Parameters −> {RB, beta}, Translation −> {gm −> RB*beta}, Definition −> Netlist[ {"RB", {"B", "E"}, RB}, {"VC", {"B", "E", "C", "E"}, gm} ] ] ] // ExpandSubcircuits; List the contents of the global subcircuit database. In[3]:= GlobalSubcircuits[] Out[3]= BJT, SimpleACbeta, BJT, SimpleACgm The Circuit object shown below describes a common-source amplifier with a MOSFET device. In the model definition for MOSFET, the bulk terminal B is defined as an optional port. Since this node is not connected in the top-level netlist, the bulk terminal is connected implicitly to the source node. 3.2 Subcircuit and Device Model Definition This netlist describes a common-source amplifier. 205 In[4]:= csamp = Circuit[ Netlist[ {V1, {1, 0}, Value −> {DC −> 1.5, AC −> 1}}, {M1, {"out" −> "D", 1 −> "G", 3 −> "S"}, Model −> "MOSFET", Selector −> "DCSmallSignal", GM −> 2.*^−4, GMB −> 3.*^−5, GDS −> 1.*^−6}, {RD, {"VDD", "out"}, Symbolic −> Rd, Value −> 1.*^6}, {RS, {3, 0}, Symbolic −> Rs, Value −> 5000.}, {VDD, {"VDD", 0}, Value −> {DC −> 3.3, _ −> 0}} ], Model[ Name −> "MOSFET", Selector −> "DCSmallSignal", Ports −> {"D", "G", "S", Optional["B", "S"]}, Parameters −> {gm, gmb, Gds, GM, GMB, GDS}, Definition −> Netlist[ {VCG, {"G", "S", "D", "S"}, Symbolic −> gm, Value −> GM}, {VCB, {"B", "S", "D", "S"}, Symbolic −> gmb, Value −> GMB}, {GDS, {"D", "S"}, Symbolic −> Gds, Value −> GDS} ] ] ] Out[4]= Circuit Expand the MOSFET model. In[5]:= ExpandSubcircuits[csamp] // DisplayForm Out[5]//DisplayForm= Netlist Flat, 7 Entries: V1, 1, 0, Value DC 1.5, AC 1 VCG$M1, 1, 3, out, 3, Symbolic gm$M1, Value 0.0002 VCB$M1, 3, 3, out, 3, Symbolic gmb$M1, Value 0.00003 GDS$M1, out, 3, Symbolic Gds$M1, Value 1. 106 RD, VDD, out, Symbolic Rd, Value 1. 106 RS, 3, 0, Symbolic Rs, Value 5000. VDD, VDD, 0, Value DC 3.3, _ 0 This example shows the effect of the argument Symbolic in a Model statement. The model equations describe the DC behavior of a linear resistor including first-order temperature dependence. Note that although there are four model parameters, only the resistance appears explicitly in symbolic circuit equations. Note also that the alias name R is used instead of RES to denote the resistance. 3. Reference Manual 206 A circuit with a resistor model. In[6]:= resckt = Circuit[ Netlist[ {V0, {1, 0}, Symbolic −> V0, Value −> 1}, {R1, {1 −> "P", 0 −> "N"}, Model −> "RES", Selector −> "DC", RES −> 1000., TC1 −> 10^−3} ], Model[ Name −> "RES", Selector −> "DC", Ports −> {"P", "N"}, Parameters −> {RES, TC1, Global[TEMP, TNOM]}, Defaults −> {TC1 −> 0, TNOM −> 300.15, TEMP −> 300.15}, Symbolic −> {RES −> R}, Variables −> {Voltage["P", "N"], Current["P", "N"]}, Definition −> Equations[ Voltage["P", "N"] == RES*(1 + TC1*(TEMP − TNOM))*Current["P", "N"] ] ], GlobalParameters[TEMP −> 310.] ] Out[6]= Circuit Note that only R$R1 is kept in symbolic form. In[7]:= CircuitEquations[resckt, AnalysisMode −> DC, ElementValues −> Symbolic] // DisplayForm Out[7]//DisplayForm= I$PN$R1 I$V0 0, V$1 V0, V$1 1.00985 I$PN$R1 R$R1, V$1, I$V0, I$PN$R1, DesignPoint V0 1, R$R1 1000., TEMP 310. The following example demonstrates the use of local model parameter sets in a subcircuit definition. The netlist shown below represents a bipolar differential pair with emitter degeneration resistors. The Circuit object contains a local ModelParameters statement in which the values of the BJT’s ohmic collector and emitter resistances are calculated as a function of the area factor. 3.2 Subcircuit and Device Model Definition A differential pair with emitter degeneration resistors. 207 In[8]:= dpwedr = Subcircuit[ Name −> "DifferentialPair", Selector −> "DeviceLevel", Ports −> {"H1", "H2", "IN1", "IN2", "L"}, Parameters −> {Area, RED}, Definition −> Circuit[ Netlist[ {"Q1", {"H1" −> "C", "IN1" −> "B", "ED1" −> "E"}, Model −> "BJT", Selector −> Selector["BJT", "Q1"], Parameters −> "LocalNPN"}, {"RED1", {"ED1", "L"}, RED}, {"Q2", {"H2" −> "C", "IN2" −> "B", "ED2" −> "E"}, Model −> "BJT", Selector −> Selector["BJT", "Q2"], Parameters −> "LocalNPN"}, {"RED2", {"ED2", "L"}, RED} ], ModelParameters[Name −> "LocalNPN", Type −> "NPN", IS −> 2.*^−15, BF −> 200., RC −> 50./Area, RE −> 2./Area] ] ] Out[8]= SubcircuitDifferentialPair, DeviceLevel, 5 This netlist describes a differential amplifier on the basis of the subcircuit implemented above. In[9]:= diffamp = Circuit[ Netlist[ {V0, {"VCC", 0}, Value −> {DC −> 9., _ −> 0}}, {V1, {2, 0}, Value −> {DC −> 4.5, AC −> 1}}, {V2, {3, 0}, Value −> {DC −> 4.5, AC −> 0}}, {R1, {"VCC", 4}, 5000.}, {R2, {"VCC", 5}, 5000.}, {DP1, {4 −> "H1", 5 −> "H2", 2 −> "IN1", 3 −> "IN2", 6 −> "L"}, Model −> "DifferentialPair", Selector −> "DeviceLevel", RED −> 100., Area −> 2.}, {IBIAS, {6, 0}, Value −> {DC −> 0.001, _ −> 0}} ], dpwedr ] Out[9]= Circuit Set up circuit equations. In[10]:= diffampeqs = CircuitEquations[diffamp, AnalysisMode −> DC, ElementValues −> Symbolic] Out[10]= DAEDC, 25 25 The nominal collector and emitter resistances have been divided by the area factor. In[11]:= {RC$Q1$DP1, RE$Q1$DP1} /. GetDesignPoint[diffampeqs] Out[11]= 25., 1. The following code is a slightly more complex example for a behavioral model definition. The Model statement implements a nonlinear DC model for a bipolar junction diode, taking into account junction voltage reduction due to series resistance (Rs) and DC convergence issues (GMIN). 3. Reference Manual 208 This code defines a diode model and stores it in the global subcircuit database. In[12]:= Circuit[ Model[ Name −> "Diode", Selector −> "DC", Scope −> Global, Ports −> {"A", "C"}, Parameters −> {Is, Rs, Global[TEMP, GMIN]}, Defaults −> {Is −> 1.*^−15, Rs −> 0, TEMP −> 300., GMIN −> 1.*^−12, $q −> 1.6021918*^−19, $k −> 1.3806226*^−23}, Translation −> {Vt −> $k*TEMP/$q}, Symbolic −> {Is, Vt, Rs, GMIN}, Variables −> {Voltage["A", "C"], Current["A", "C"], vdeff}, Definition −> Equations[ Current["A", "C"] == Is*(Exp[vdeff/Vt] − 1) + vdeff*GMIN, vdeff == Voltage["A", "C"] − Rs*Current["A", "C"] ], InitialGuess −> {vdeff −> 0.7} ] ] // ExpandSubcircuits; This defines a circuit with a diode in series connection with a resistor. In[13]:= diodeckt = Circuit[ Netlist[ {V1, {1, 0}, Vin}, {R1, {1, 2}, Symbolic −> R1, Value −> 1000.}, {D1, {2 −> "A", 0 −> "C"}, Model −> "Diode", Selector −> "DC", Rs −> 10.} ], GlobalParameters[TEMP −> 330.] ] Out[13]= Circuit Set up modified nodal equations. In[14]:= diodeeqs = CircuitEquations[diodeckt, AnalysisMode −> DC, ElementValues −> Symbolic] Out[14]= DAEDC, 5 5 Display the equations. In[15]:= diodeeqs // DisplayForm Out[15]//DisplayForm= V$1 V$2 V$1 V$2 I$V1 0, I$AC$D1 0, R1 R1 V$1 Vin, I$AC$D1 1 Evdeff$D1Vt$D1 Is$D1 GMIN vdeff$D1, vdeff$D1 I$AC$D1 Rs$D1 V$2, V$1, V$2, I$V1, I$AC$D1, vdeff$D1, DesignPoint Vin Vin, R1 1000., Is$D1 1. 1015 , Vt$D1 0.0284364, Rs$D1 10., GMIN 1. 1012 , TEMP 330. Calculate the DC response while sweeping Rs$D1 from to . In[16]:= diodedc = NDAESolve[diodeeqs, {Vin, −1., 5.}, {Rs$D1, 0., 200., 50.}]; 3.2 Subcircuit and Device Model Definition Plot the diode voltage. 209 In[17]:= TransientPlot[diodedc, V$2[Vin], {Vin, −1., 5.}] 1.5 1 0.5 -1 V$2[Vin] 1 2 3 4 5 Vin -0.5 -1 Out[17]= Graphics This example demonstrates how to specify initial conditions. The netlist describes an RLC series resonator. The behavior of the LC subcircuit is modeled by a system of differential equations. An RLC circuit with a behavioral description for the LC resonator. In[18]:= rlcfilter = Circuit[ Netlist[ {R, {1, 0}, 100.}, {LC, {1 −> "P", 0 −> "N"}, Model −> "LCSeriesResonator", Selector −> "Behavioral", L −> 0.02, C −> 5.*^−7} ], Model[ Name −> "LCSeriesResonator", Selector −> "Behavioral", Ports −> {"P", "N"}, Parameters −> {L, C}, Variables −> {Current["P", "N"], Voltage["P", "N"], vind, vcap}, Definition −> Equations[ vind == L*Current["P", "N"]’, Voltage["P", "N"] − vcap − vind == 0, Current["P", "N"] == C*vcap’ ], InitialConditions −> {vcap −> 5., Current["P", "N"] −> −0.02} ] ] Out[18]= Circuit Set up time-domain circuit equations. In[19]:= rlcfeqs = CircuitEquations[rlcfilter, AnalysisMode −> Transient, InitialConditions −> Automatic] Out[19]= DAETransient, 6 4 Display the circuit equations. In[20]:= rlcfeqs // DisplayForm Out[20]//DisplayForm= I$PN$LCt 0.01 V$1t 0, vind$LCt 0.02 I$PN$LC t, vcap$LCt vind$LCt V$1t 0, I$PN$LCt 5. 107 vcap$LC t, vcap$LC0 5., I$PN$LC0 0.02, V$1t, I$PN$LCt, vind$LCt, vcap$LCt, DesignPoint 3. Reference Manual 210 Simulate the circuit. In[21]:= rlcftran = NDAESolve[rlcfeqs, {t, 0., 0.002}] Out[21]= I$PN$LC InterpolatingFunction0, 0.002, , vcap$LC InterpolatingFunction0, 0.002, , V$1 InterpolatingFunction0, 0.002, , vind$LC InterpolatingFunction0, 0.002, Display the capacitor voltage and the inductor current. In[22]:= TransientPlot[rlcftran, {vcap$LC[t], I$PN$LC[t]}, {t, 0., 0.002}, SingleDiagram −> False, PlotRange −> All] 4 2 vcap 0.0005 0.001 0.0015 t 0.002 -2 0.01 0.005 t 0.0005 0.001 0.0015 0.002 -0.005 -0.01 -0.015 -0.02 -0.025 I$PN$ Out[22]= GraphicsArray 3.2.2 Subcircuit The command Subcircuit is an alias for Model (Section 3.2.1). You may use either of the two function names to define a subcircuit or device model. 3.3 Model Library Management 211 3.3 Model Library Management Analog Insydes provides a number of functions for inspecting and managing the contents of its global subcircuit database and external model libraries. These functions are described in detail below. ListLibrary (Section 3.3.1) FindModel (Section 3.3.2) listing contents of a library locating models FindModelParameters (Section 3.3.3) locating model parameters GlobalSubcircuits (Section 3.3.4) inspecting global subcircuit database GlobalModelParameters (Section 3.3.5) inspecting global model-parameters database LoadModel (Section 3.3.6) loading models LoadModelParameters (Section 3.3.7) loading model parameters RemoveSubcircuits (Section 3.3.8) removing subcircuits from global database RemoveModelParameters (Section 3.3.9) removing model parameters from global database 3.3.1 ListLibrary ListLibrary[] lists the contents of the default model library ListLibrary["libfile"] lists the contents of the model library "libfile" Command structure of ListLibrary. With ListLibrary you can list the contents of one or several model library files. ListLibrary returns the model definitions and model parameter sets stored in the specified files. ListLibrary has the following options: 3. Reference Manual 212 option name default value LibraryPath Inherited[AnalogInsydes] the search path for device model libraries (see Section 3.14.3) ModelLibrary Inherited[AnalogInsydes] the name of the library to be searched for device models (see Section 3.14.4) Options for ListLibrary. See also: FindModel (Section 3.3.2), FindModelParameters (Section 3.3.3), LoadModel (Section 3.3.6), LoadModelParameters (Section 3.3.7). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ List the contents of the default model library. In[2]:= ListLibrary[] List the contents of the specified libraries. In[3]:= ListLibrary[ModelLibrary −> {"BasicResistorModels‘", "FullDiodeModels‘"}] Out[2]= FullModels‘ ModelBJT, DC, SpiceDC, GummelPoonDC, Transient, Spice, GummelPoon , ModelBJT, AC, SpiceAC, Noise, SpiceNoise , ModelMOSFET, DC, SpiceDC, Transient, Spice , ModelMOSFET, AC, SpiceAC, Noise, SpiceNoise , ModelDiode, DC, SpiceDC, Transient, Spice , ModelDiode, AC, SpiceAC, Noise, SpiceNoise , ModelJFET, DC, SpiceDC, Transient, Spice , ModelJFET, AC, SpiceAC, Noise, SpiceNoise , ModelRES, DC, Transient , ModelRES, AC , ModelRES, Noise , ModelCAP, DC, Transient , ModelCAP, AC, Noise , ModelIND, DC, Transient , ModelIND, AC, Noise Out[3]= BasicResistorModels‘ ModelRES, AC, BasicSpiceAC, DC, BasicSpiceDC, Transient, BasicSpice , ModelRES, Noise, SpiceNoise , FullDiodeModels‘ ModelDiode, DC, SpiceDC, Transient, Spice , ModelDiode, AC, SpiceAC, Noise, SpiceNoise 3.3 Model Library Management 213 3.3.2 FindModel FindModel[name, selector] searches the default library for the model definition name/selector Command structure of FindModel. FindModel searches a list of model library files for a specified model definition and returns the name of the first library in which the model was found. FindModel returns the symbol $Failed if it cannot find the model definition in any of the library files. FindModel has the following options: option name default value LibraryPath Inherited[AnalogInsydes] the search path for device model libraries (see Section 3.14.3) ModelLibrary Inherited[AnalogInsydes] the name of the library to be searched for device models (see Section 3.14.4) Options for FindModel. See also: FindModelParameters (Section 3.3.3), ListLibrary (Section 3.3.1), LoadModel (Section 3.3.6). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Determine the name of the library file which contains the model "BJT/GummelPoon" . In[2]:= FindModel["BJT", "GummelPoon"] // InputForm Return the name of the first library from the given list which contains the model "BJT/AC" . In[3]:= FindModel["BJT", "AC", ModelLibrary −> {"FullDiodeModels‘", "BasicBJTModels‘", "SimplifiedModels‘"} ] // InputForm Out[2]//InputForm= "FullModels‘" Out[3]//InputForm= "BasicBJTModels‘" 3. Reference Manual 214 3.3.3 FindModelParameters FindModelParameters[name] searches the default library for the parameter set name Command structure of FindModelParameters . FindModelParameters searches a list of model library files for a specified model parameter set and returns the name of the first library in which the parameter set was found. FindModelParameters returns the symbol $Failed if it cannot find the parameter set in any of the library files. FindModelParameters has the following options: option name default value LibraryPath Inherited[AnalogInsydes] the search path for device model libraries (see Section 3.14.3) ModelLibrary Inherited[AnalogInsydes] the name of the library to be searched for device models (see Section 3.14.4) Options for FindModelParameters . See also: FindModel (Section 3.3.2), ListLibrary (Section 3.3.1), LoadModelParameters (Section 3.3.7). 3.3.4 GlobalSubcircuits GlobalSubcircuits[] lists the names and selectors of the subcircuit definitions stored in the global subcircuit database Command structure of GlobalSubcircuits . With GlobalSubcircuits you can inspect the contents of the global subcircuit database. GlobalSubcircuits returns a list of the names and selectors of the subcircuits stored in the database. GlobalSubcircuits not only returns the name under which a model was loaded but also all alias names assigned to the model definition. For example, "Diode", "DC" | "Transient" denotes a model definition which can be accessed through Name −> "Diode", Selector −> "DC" as well through Name −> "Diode" , Selector −> "Transient" . See also: FindModel (Section 3.3.2), GlobalModelParameters (Section 3.3.5). 3.3 Model Library Management 215 Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Load two model definitions from the model library and store them in the global subcircuit database. In[2]:= Circuit[ LoadModel["Diode", "Transient", Scope −> Global], LoadModel["JFET", "AC", Scope −> Global] ] // ExpandSubcircuits; List the contents of the global subcircuit database. In[3]:= GlobalSubcircuits[] Out[3]= Diode, DC SpiceDC Transient Spice, JFET, AC SpiceAC Noise SpiceNoise 3.3.5 GlobalModelParameters GlobalModelParameters[] lists the names of the model parameter sets stored in the global model parameter database Command structure of GlobalModelParameters . With GlobalModelParameters you can inspect the contents of the global model parameter database. GlobalModelParameters returns a list of the names of the parameter sets stored in the database. See also: FindModelParameters (Section 3.3.3), GlobalSubcircuits (Section 3.3.4). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define two diode model parameter sets. In[2]:= Circuit[ ModelParameters[Name −> "Diode1", Scope −> Global, IS −> 1.2*^−12, N −> 1.1], ModelParameters[Name −> "Diode2", Scope −> Global, IS −> 1.0*^−14, N −> 1.5] ] // ExpandSubcircuits; List the contents of the global model parameter database. In[3]:= GlobalModelParameters[] // InputForm Out[3]//InputForm= {{"Diode1"}, {"Diode2"}} 3. Reference Manual 216 3.3.6 LoadModel LoadModel[name, selector] loads the model definition name/selector from the default model library LoadModel["libfile", name, selector] loads the model definition name/selector from the model library "libfile" LoadModel[{{name , selector }, † † † }] loads the models name /selector , † † † Command structure of LoadModel. With LoadModel you can load a model definition from a library file. LoadModel searches a list of model library files and returns the first model definition that matches the specified name and selector. You can use LoadModel within a Circuit object to load a model definition at run time and assign global scope to the model. LoadModel has the following options: option name default value Scope Local LibraryPath Inherited[AnalogInsydes] the search path for device model libraries (see Section 3.14.3) ModelLibrary Inherited[AnalogInsydes] the name of the library to be searched for device models (see Section 3.14.4) the designated scope of the loaded model definition Options for LoadModel. LoadModel only loads Model records from library files; it does not store the models in the database. To store a loaded model in the database, you must use Circuit and ExpandSubcircuits . See also: Circuit (Section 3.1.2), ExpandSubcircuits (Section 3.4.1), LoadModelParameters (Section 3.3.7). 3.3 Model Library Management 217 Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Load two model definitions from the model library and store them in the global subcircuit database. In[2]:= Circuit[ LoadModel["Diode", "Transient", Scope −> Global], LoadModel["JFET", "AC", Scope −> Global] ] // ExpandSubcircuits; List the contents of the global subcircuit database. In[3]:= GlobalSubcircuits[] Out[3]= Diode, DC SpiceDC Transient Spice, JFET, AC SpiceAC Noise SpiceNoise 3.3.7 LoadModelParameters LoadModelParameters[name] loads the model parameter set definition name from the default model library LoadModelParameters["libfile", name] loads the model parameter set definition name from "libfile" LoadModelParameters[{name , † † †}] loads the model parameter set definitions name , † † † Command structure of LoadModelParameters . With LoadModelParameters you can load a model parameter set definition from a library file. LoadModelParameters searches a list of model library files and returns the first model parameter set definition that matches the specified name. You can use LoadModelParameters within a Circuit object to load a model parameter set definition at run time and assign global scope to it. LoadModelParameters has the following options: 3. Reference Manual 218 option name default value Scope Local LibraryPath Inherited[AnalogInsydes] the search path for device model libraries (see Section 3.14.3) ModelLibrary Inherited[AnalogInsydes] the name of the library to be searched for model parameter set definitions (see Section 3.14.4) the designated scope of the loaded model parameter set definition Options for LoadModelParameters . LoadModelParameters only loads ModelParameters records from library files; it does not store the model parameter sets in the database. To store a loaded model parameter set in the database, you must use Circuit and ExpandSubcircuits . See also: Circuit (Section 3.1.2), ExpandSubcircuits (Section 3.4.1), LoadModel (Section 3.3.6). 3.3.8 RemoveSubcircuit RemoveSubcircuit[name, selector] removes the subcircuit definition name/selector from the global database RemoveSubcircuit[All] clears the global subcircuit database Command structure of RemoveSubcircuit . RemoveSubcircuit allows you to remove individual subcircuit definitions from the global subcircuit database or to clear the database completely. RemoveSubcircuit returns the list of the names and selectors of the remaining subcircuit definitions. See also: GlobalSubcircuits (Section 3.3.4), RemoveModelParameters (Section 3.3.9). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ 3.3 Model Library Management 219 Load two model definitions from the model library and store them in the global subcircuit database. In[2]:= Circuit[ LoadModel["Diode", "Transient", Scope −> Global], LoadModel["JFET", "AC", Scope −> Global] ] // ExpandSubcircuits; List the contents of the global subcircuit database. In[3]:= GlobalSubcircuits[] Out[3]= Diode, DC SpiceDC Transient Spice, JFET, AC SpiceAC Noise SpiceNoise Removing the model definition automatically clears all alias names for the model. Thus, if you remove the model "JFET/AC" , the aliases "JFET/SpiceAC" , "JFET/Noise" etc. will be deleted as well. Remove the subcircuit definition "JFET/AC" . In[4]:= RemoveSubcircuit["JFET", "AC"] Delete all remaining subcircuit definitions. In[5]:= RemoveSubcircuit[All] Out[4]= Diode, DC SpiceDC Transient Spice Out[5]= 3.3.9 RemoveModelParameters RemoveModelParameters[name] RemoveModelParameters[All] removes the model parameter set name from the global database clears the global model parameter database Command structure of RemoveModelParameters . RemoveModelParameters allows you to remove individual model parameter sets from the global parameter database or to clear the database completely. RemoveModelParameters returns the list of the names of the remaining model parameter sets. See also: GlobalModelParameters (Section 3.3.5), RemoveSubcircuit (Section 3.3.8). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define two diode model parameter sets. In[2]:= Circuit[ ModelParameters[Name −> "Diode1", Scope −> Global, IS −> 1.2*^−12, N −> 1.1], ModelParameters[Name −> "Diode2", Scope −> Global, IS −> 1.0*^−14, N −> 1.5] ] // ExpandSubcircuits; List the contents of the global parameter database. In[3]:= GlobalModelParameters[] Out[3]= Diode1, Diode2 3. Reference Manual 220 Remove the parameter set "Diode1" . In[4]:= RemoveModelParameters["Diode1"] Delete all remaining global parameter sets. In[5]:= RemoveModelParameters[All] Out[4]= Diode2 Out[5]= 3.4 Expanding Subcircuits and Device Models 221 3.4 Expanding Subcircuits and Device Models Before Analog Insydes can set up a system of circuit equations from a netlist, all subcircuits and model references in the netlist must be expanded and instantiated with ExpandSubcircuits . Subcircuit expansion is taken care of automatically by CircuitEquations , so that, except for debugging purposes, there is usually no need to call ExpandSubcircuits explicitly. 3.4.1 ExpandSubcircuits ExpandSubcircuits[netlist, opts] expands and instantiates all subcircuit and model references in netlist Command structure of ExpandSubcircuits . Given a Netlist or Circuit object, ExpandSubcircuits expands all model references and stores model definitions to the global model data base. It returns a Netlist object. Expanding subcircuits is taken care of automatically by CircuitEquations , so that there is usually no need to call ExpandSubcircuits explicitly nor to take care of its options. ExpandSubcircuits has the following options: option name default value AutoloadModels True whether to load device models automatically from the model library DefaultSelector None the default value to be used to replace generic subcircuit selectors HoldModels None a list of patterns matching the names and selectors of model references that shall remain unexpanded InstanceNameSeparator Inherited[AnalogInsydes] the separator string for name components of model variables and reference designators (see Section 3.14.2) KeepLocalModels False Options for ExpandSubcircuits , Part I. whether to keep local model definitions in a netlist after subcircuit expansion 3. Reference Manual 222 option name default value LibraryPath Inherited[AnalogInsydes] the search path for device model libraries (see Section 3.14.3) ModelLibrary Inherited[AnalogInsydes] the name of the library to be searched for device models (see Section 3.14.4) Protocol Inherited[AnalogInsydes] standard Analog Insydes protocol specification (see Section 3.14.5) Symbolic All the parameters of behavioral models to be kept symbolic when setting up symbolic circuit equations (see Section 3.5.1) Value None the parameters of behavioral models to be kept numeric when setting up symbolic circuit equations (see Section 3.5.1) Options for ExpandSubcircuits , Part II. Options Description A detailed description of all ExpandSubcircuits options is given below in alphabetical order: AutoloadModels With the option AutoloadModels , you can specify how ExpandSubcircuits handles references to device models which have not been loaded into the global subcircuit database or defined locally in the netlist. The following values are possible: True False Values for the AutoloadModels option. search model libraries for device models and parameter sets (model cards). do not load models from the model library automatically; abort subcircuit expansion when a reference to an unavailable model is found 3.4 Expanding Subcircuits and Device Models 223 DefaultSelector With the option DefaultSelector , you can specify the key used by ExpandSubcircuits to replace the right-hand sides of generic device model selector specifications in netlists generated with ReadNetlist (Section 3.10.1). The setting DefaultSelector −> selector causes all generic selectors to be replaced by the key selector. Possible values are: None "string" symbol do not use a default value for generic model selectors use "string" as default model selector use SymbolName[symbol] as default model selector Values for the DefaultSelector option. With the setting DefaultSelector −> None, ExpandSubcircuits will print an error message and abort upon encountering a generic Selector specification. Usually ExpandSubcircuits is automatically called by CircuitEquations which sets the DefaultSelector option to an appropriate value based on the chosen analysis mode. HoldModels With HoldModels −> patterns, you can specify a list of Mathematica patterns matching the names and selectors of model references ExpandSubcircuits should not expand. Note that the application of the HoldModels option is only necessary for advanced tasks. Usually there is no need to use this option. A practical application of the HoldModels option is to stop expansion of a hierarchical circuit description at the device level. The function ReadNetlist (Section 3.10.1) makes use of this feature to assign small-signal data read from a simulator output file to individual devices in a circuit which contain subcircuit definitions. The following values are allowed: pattern do not expand model references whose name specification matches pattern {pattern , pattern } do not expand model references whose name specification matches pattern and whose selector specification matches pattern {{pattern , pattern }, † † † } Values for the HoldModels option. do not expand model references that match at least one of the pattern pairs 3. Reference Manual 224 When HoldModels has a value other than None, ExpandSubcircuits returns a checked Netlist or a Circuit instead of a flat Netlist regardless of whether any model references were kept unresolved. If the netlist contains references to local model definitions or model parameter sets, you should use the setting KeepLocalModels −> True with the HoldModels option to prevent local model data from being discarded prematurely. In the above cases, ExpandSubcircuits must be called at least one more time to produce a flat netlist. KeepLocalModels When you expand the model references in a Circuit only partially using the HoldModels option, then the held model references may still contain unresolved links to local model definitions and model parameter sets. By default, local model data is discarded after subcircuit expansion, so that essential information for expanding the netlist completely may be lost. The setting KeepLocalModels −> True tells ExpandSubcircuits to keep local model data for future reference. Note that for usual applications there is no need to change the default value of this option. Possible values are: False True discard local model definitions and parameter sets from the netlist after subcircuit expansion return local model definitions and parameter sets together with the expanded netlist in a Circuit object Values for the KeepLocalModels option. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Import PSpice netlist. In[2]:= buffer = ReadNetlist[ "AnalogInsydes/DemoFiles/Buffer.cir", Simulator −> "PSpice"] Out[2]= Circuit The following call to ExpandSubcircuits results in an error because the model "BJT/AC" needs to be loaded from the model library. Turn off model autoloading. In[3]:= ExpandSubcircuits[buffer, DefaultSelector −> AC, AutoloadModels −> False] ExpandSubcircuits::undefsc: Subcircuit "BJT/AC" is undefined. Out[3]= $Failed 3.4 Expanding Subcircuits and Device Models 225 With AutoloadModels −> True, ExpandSubcircuits searches the model library for undefined device models. Load undefined models from the library. In[4]:= ExpandSubcircuits[buffer, DefaultSelector −> AC, AutoloadModels −> True, Protocol −> Notebook] Searching model libraries for model "BJT/AC". Loading model "BJT/AC" from library FullModels‘. Instantiating model "BJT/AC" for reference Q$T1. Instantiating model "BJT/AC" for reference Q$T3. Instantiating model "BJT/AC" for reference Q$T4. Instantiating model "BJT/AC" for reference Q$T5. Instantiating model "BJT/AC" for reference Q$T2. Out[4]= NetlistFlat, 55 The following command tells Analog Insydes to load a model from the library into memory and store it in the global subcircuit database for future reference. Further requests for the model "BJT/AC" will not invoke a library search. Load the model "BJT/AC" and store it in the global subcircuit database. In[5]:= Circuit[ LoadModel["BJT", "AC", Scope −> Global] ] // ExpandSubcircuits; List the contents of the global subcircuit database. In[6]:= GlobalSubcircuits[] Out[6]= BJT, AC SpiceAC Noise SpiceNoise Now that the model "BJT/AC" has been loaded into memory, turning off the autoloading mechanism no longer results in an error when expanding the netlist buffer. Use only model definitions from the subcircuit database; do not search the library. In[7]:= ExpandSubcircuits[buffer, DefaultSelector −> AC, AutoloadModels −> False, Protocol −> Notebook] Instantiating model "BJT/AC" for reference Q$T1. Instantiating model "BJT/AC" for reference Q$T3. Instantiating model "BJT/AC" for reference Q$T4. Instantiating model "BJT/AC" for reference Q$T5. Instantiating model "BJT/AC" for reference Q$T2. Out[7]= NetlistFlat, 55 Clear the subcircuit database. In[8]:= RemoveSubcircuit[All] Out[8]= To illustrate how to write patterns for HoldModels , we make a list off all Model and Selector specifications in the netlist buffer. 3. Reference Manual 226 List the Model and Selector specifications. In[9]:= Cases[buffer, _Model | _Selector, Infinity] // InputForm Out[9]//InputForm= {Model["BJT", "Q2N2222", "Q$T1"], Selector["BJT", "Q2N2222", "Q$T1"], Model["BJT", "Q2N2907A", "Q$T3"], Selector["BJT", "Q2N2907A", "Q$T3"], Model["BJT", "Q2N2907A", "Q$T4"], Selector["BJT", "Q2N2907A", "Q$T4"], Model["BJT", "Q2N2907A", "Q$T5"], Selector["BJT", "Q2N2907A", "Q$T5"], Model["BJT", "Q2N2222", "Q$T2"], Selector["BJT", "Q2N2222", "Q$T2"]} You can use HoldModels to prevent expansion of a particular device type or model instance. Do not expand references to "Q2N2222" devices. In[10]:= ExpandSubcircuits[buffer, DefaultSelector −> AC, Protocol −> Notebook, HoldModels −> Model[_, "Q2N2222", _]] Searching model libraries for model "BJT/AC". Loading model "BJT/AC" from library FullModels‘. Instantiating model "BJT/AC" for reference Q$T3. Instantiating model "BJT/AC" for reference Q$T4. Instantiating model "BJT/AC" for reference Q$T5. Out[10]= NetlistChecked, 37 If you want to flatten a netlist completely after partial expansion, you must specify KeepLocalModels −> True to prevent local model definitions and parameter sets from being discarded by ExpandSubcircuits . Keep the transistor instance "Q$T3" and references to "Q2N2222" devices; do not discard local model card data for these devices. In[11]:= xbuffer = ExpandSubcircuits[buffer, DefaultSelector −> AC, Protocol −> Notebook, HoldModels −> {{Model[_, "Q2N2222", _], _}, {Model[__, "Q$T3"], _}}, KeepLocalModels −> True] Searching model libraries for model "BJT/AC". Loading model "BJT/AC" from library FullModels‘. Instantiating model "BJT/AC" for reference Q$T4. Instantiating model "BJT/AC" for reference Q$T5. Out[11]= Circuit Expand the held model references. In[12]:= ExpandSubcircuits[xbuffer, DefaultSelector −> AC, Protocol −> Notebook] Instantiating model "BJT/AC" for reference Q$T1. Instantiating model "BJT/AC" for reference Q$T3. Instantiating model "BJT/AC" for reference Q$T2. Out[12]= NetlistFlat, 55 3.5 Setting Up and Solving Circuit Equations 227 3.5 Setting Up and Solving Circuit Equations Setting up a system of equations from a netlist description of a circuit is the central step of most circuit analysis problems you will solve with Analog Insydes. All types of equations can be set up using the command CircuitEquations (Section 3.5.1). Additionally, there are the commands ACEquations (Section 3.5.2) and DCEquations (Section 3.5.3) which transform a nonlinear dynamic equation system into a linear and static equation system, respectively. In order to solve systems of equations symbolically, Mathematica’s built-in function Solve has been extended to handle DAEObjects as well (see Section 3.5.4). 3.5.1 CircuitEquations CircuitEquations[netlist, opts] sets up a system of circuit equations from a netlist description CircuitEquations[circuit, opts] sets up a system of circuit equations from a circuit description Command structure of CircuitEquations . The first argument of CircuitEquations must be a Circuit or Netlist object. If it is not a flat netlist, then ExpandSubcircuits will be called first automatically to expand any subcircuit or device model references. CircuitEquations sets up modified nodal, sparse tableau, or extended sparse tableau equations for AC, DC, or transient analysis. CircuitEquations returns a DAEObject. The type and appearance of equations generated with CircuitEquations can be changed with the following options: 3. Reference Manual 228 option name default value BranchCurrentPrefix "I$" the prefix used for branch current identifiers BranchVoltagePrefix "V$" the prefix used for branch voltage identifiers ControllingCurrentPrefix "IC$" the prefix used for controlling current identifiers ControllingVoltagePrefix "VC$" the prefix used for controlling voltage identifiers InstanceNameSeparator Inherited[AnalogInsydes] the separator string for name components of model variables and reference designators (see Section 3.14.2) NodeVoltagePrefix "V$" the prefix used for node voltage identifiers Naming convention options for CircuitEquations . option name default value AnalysisMode AC the circuit analysis mode FrequencyVariable s the symbol which denotes the complex Laplace frequency IndependentVariable Automatic the independent variable for transient analysis InitialGuess Automatic the initial guess for the DC solver InitialTime 0 the initial time for transient analysis TimeVariable t the symbol which denotes time in transient analysis Analysis mode specific options for CircuitEquations . 3.5 Setting Up and Solving Circuit Equations 229 option name default value ConvertImmittances True whether to convert impedances to admittances for nodal analysis ElementValues Value whether to set up numeric or symbolic equations Formulation ModifiedNodal the circuit analysis formulation InitialConditions None whether to use and how to handle initial conditions for dynamic quantities MatrixEquation True whether to represent a system of AC equations as matrix equation Symbolic All the parameters of behavioral models to be kept symbolic when setting up symbolic circuit equations Value None the parameters of behavioral models to be kept numeric when setting up symbolic circuit equations Equation-formulation options for CircuitEquations . option name default value DefaultSelector Automatic LibraryPath Inherited[AnalogInsydes] the search path for device model libraries (see Section 3.14.3) ModelLibrary Inherited[AnalogInsydes] the name of the library to be searched for device models (see Section 3.14.4) Model library options for CircuitEquations . the default value to be used by ExpandSubcircuits to replace generic model selectors 3. Reference Manual 230 option name default value DesignPoint Automatic the design point for a symbolic DAEObject IgnoreMissingGround False whether to ignore a missing analog ground node Protocol Inherited[AnalogInsydes] standard Analog Insydes protocol specification (see Section 3.14.5) Miscellaneous options for CircuitEquations . See also: Netlist (Section 3.1.1), Circuit (Section 3.1.2), ExpandSubcircuits (Section 3.4.1), Chapter 4.3. Options Description A detailed description of all CircuitEquations options is given below in alphabetical order: AnalysisMode The option AnalysisMode −> mode specifies the circuit analysis mode for which CircuitEquations sets up a system of equations. Possible values are: AC small-signal frequency-domain (AC) analysis DC operating-point (DC) or DC-transfer (DT) analysis Transient large-signal time-domain (transient) analysis Values for the AnalysisMode option. With the setting AnalysisMode −> AC, CircuitEquations sets up a system of small-signal Laplacedomain equations. CircuitEquations does not linearize nonlinear circuits. Therefore, the first argument of CircuitEquations must represent a linear circuit. If it contains references to device models, the AC equivalent circuits of the referenced device are used to set up the equations. By default, AC equations are set up in matrix formulation, but this can be changed using the MatrixEquation option (see below). With the setting AnalysisMode −> DC, CircuitEquations yields a system of (usually nonlinear) DC equations. Any time derivatives resulting from the constitutive equations of dynamic elements as well as derivatives with respect to other independent quantities are set to zero. 3.5 Setting Up and Solving Circuit Equations 231 With AnalysisMode −> Transient , you can set up a system of differential-algebraic equations (DAE) for nonlinear dynamic circuits. The independent variable of transient analysis is given by the value of the option IndependentVariable , which is not necessarily time. BranchCurrentPrefix With BranchCurrentPrefix −> "string", you can specify the prefix string CircuitEquations prepends to an element’s reference designator to generate a unique branch current identifier. For example, with BranchCurrentPrefix −> "I$", the current through a resistor R1 will be named I$R1. Symbol["string" <> "refdes"] must yield a valid symbol. Therefore, "string" must not contain characters which have a special meaning in Mathematica. BranchVoltagePrefix With BranchVoltagePrefix −> "string", you can specify the prefix string CircuitEquations prepends to an element’s reference designator to generate a unique branch voltage identifier. For example, with BranchVoltagePrefix −> "V$", the voltage across a resistor R1 will be named V$R1. Symbol["string" <> "refdes"] must yield a valid symbol. Therefore, "string" must not contain characters which have a special meaning in Mathematica. ControllingCurrentPrefix With ControllingCurrentPrefix −> "string", you can specify the prefix string CircuitEquations prepends to the reference designator of a current-controlled source to generate a unique identifier for the controlling current. For example, with ControllingCurrentPrefix −> "IC$", the controlling current of a currentcontrolled voltage source CV1 will be named IC$CV1. Symbol["string" <> "refdes"] must yield a valid symbol. Therefore, "string" must not contain characters which have a special meaning in Mathematica. 3. Reference Manual 232 ControllingVoltagePrefix With ControllingVoltagePrefix −> "string", you can specify the prefix string CircuitEquations prepends to the reference designator of a voltage-controlled source to generate a unique identifier for the controlling voltage. For example, with ControllingVoltagePrefix −> "VC$", the controlling voltage of a voltagecontrolled voltage source VV1 will be named VC$VV1. Symbol["string" <> "refdes"] must yield a valid symbol. Therefore, "string" must not contain characters which have a special meaning in Mathematica. ConvertImmittances With the option ConvertImmittances , you can control the way in which CircuitEquations handles impedances when setting up modified nodal equations. The following values are allowed: True convert impedances Z to equivalent admittances Z False do not convert impedances to equivalent admittances Values for the ConvertImmittances option. For example, with ConvertImmittances −> True, a resistance R1 will appear as an admittance 1/R1 in a system of modified nodal equations. With ConvertImmittances −> False, the resistance will not be converted to an admittance, and the MNA equations will be augmented by the branch current I$R1. The setting of ConvertImmittances has no influence on sparse tableau equations. An explicit Pattern specification in a netlist entry for an impedance or admittance overrides the setting of ConvertImmittances for this element. DefaultSelector With the option DefaultSelector , you can specify the key used by ExpandSubcircuits to replace the right-hand sides of generic device model selector specifications in netlists generated with ReadNetlist (Section 3.10.1). The setting DefaultSelector −> selector causes all generic selectors to be replaced by the key selector. Generic selector specifications have the form Selector −> Selector["device", "type", "instance"] for example, 3.5 Setting Up and Solving Circuit Equations 233 Selector −> Selector["BJT", "Q2N2222", "Q1"] Possible values are: Automatic "string" symbol use value of option AnalysisMode as default model selector for ExpandSubcircuits use "string" as default model selector for ExpandSubcircuits use SymbolName[symbol] as default model selector for ExpandSubcircuits Values for the DefaultSelector option. The standard setting DefaultSelector −> Automatic causes the default selector to be determined from the value of the option AnalysisMode . This enables ExpandSubcircuits to load semiconductor device models from the model library which are compatible with the current analysis mode. DesignPoint The DesignPoint option allows you to specify a set of numerical reference values for the circuit parameters in a symbolic system of circuit equations. It allows the following values: Automatic extract design-point information from Value and Symbolic specifications in the netlist {symbol −>value , symbol −>value , † † † } specify numerical values for symbolic circuit parameters explicitly None do not extract design-point information from the netlist Values for the DesignPoint option. The design point is stored in the DAEObject returned by CircuitEquations . If available, designpoint information is applied automatically whenever numerical calculations are performed with a system of equations which has been set up with ElementValues −> Symbolic . The design point can be extracted from the DAEObject with the function GetDesignPoint (Section 3.6.12). ElementValues With ElementValues −> value, you can decide whether CircuitEquations sets up a system of circuit equations symbolically or numerically. Possible choices are: 3. Reference Manual 234 Value Symbolic use Value specifications from the value fields of netlist entries as element values use Symbolic specifications from the value fields of netlist entries as element values Values for the ElementValues option. With the settings ElementValues −> Symbolic and DesignPoint −> Automatic , CircuitEquations will extract design-point information from a netlist automatically. The design point is stored in the DAEObject returned by CircuitEquations . It can be retrieved with GetDesignPoint (Section 3.6.12). Formulation The option Formulation −> type selects the type of circuit equations set up by CircuitEquations and allows the following values: ModifiedNodal modified nodal analysis (MNA) SparseTableau sparse tableau analysis (STA) ExtendedTableau extended sparse tableau analysis (ESTA) Values for the Formulation option. Modified nodal analysis expresses systems of circuit equations in terms of node voltages and currents through impedance branches. Sparse tableau analysis yields systems of circuit equations in terms of all branch currents and branch voltages. In addition to the branch currents and voltages, extended sparse tableau analysis also includes all node voltages of a circuit. To set up equations for circuits including control network elements, you must use Formulation −> ModifiedNodal . FrequencyVariable With FrequencyVariable −> symbol, you can change the symbol CircuitEquations uses to denote the complex frequency in AC equations. The default setting is FrequencyVariable −> s. 3.5 Setting Up and Solving Circuit Equations 235 IgnoreMissingGround IgnoreMissingGround is an option needed for analyzing pure control circuits (also known as block diagrams). Equation setup for control circuits is based on the modified nodal analysis functionality for electrical circuits, which are expected to contain a ground node. CircuitEquations displays an error message when you try to set up equations from a netlist in which no reference to the ground node is present. As pure control networks do not have ground nodes, these error messages must be suppressed by means of the IgnoreMissingGround option, which allows the following values: False display a warning when no ground node is present True ignore missing ground node when analyzing control circuits Values for the IgnoreMissingGround option. You do not need to set IgnoreMissingGround −> True when a ground node is present in a circuit containing both electrical and control components. IndependentVariable With IndependentVariable −> var, you can specify a variable other than time as independent variable for transient analysis. Note that in Analog Insydes, transient analysis does not necessarily mean analysis in the time domain. You can perform transient analysis, i.e. solving differential-algebraic equations, with respect to any other independent variable, for instance, temperature. This feature is useful for tasks such as parametric analyses or sizing problems with differential-algebraic constraints. Possible values for the IndependentVariable option are: Automatic symbol use value of option TimeVariable as independent variable for transient analysis use symbol as independent variable for transient analysis Values for the IndependentVariable option. If AnalysisMode −> Transient , then time-dependent variables or derivatives of circuit variables with respect to time or other quantities are handled as follows. 3. Reference Manual 236 If the IndependentVariable is not identical to the TimeVariable , then all time derivatives in a system of circuit equations are set to zero and all explicit references to Time are replaced by the value of InitialTime . If the IndependentVariable is identical to the TimeVariable , then any derivatives with respect to other variables, such as temperature, are set to zero. InitialConditions The option InitialConditions allows you to specify how CircuitEquations handles initial conditions for dynamic quantities, such as capacitor voltages and inductor currents. The following values are allowed: Automatic use initial conditions where given in the value field of netlist entries All use initial conditions where given explicitly, set initial conditions of all other dynamic quantities to zero None do not use any given initial conditions Values for the InitialConditions option. InitialTime With InitialTime −> t , you can specify the point of time for which initial conditions are given. By default, t , but you may choose any other value. NodeVoltagePrefix With NodeVoltagePrefix −> "string" you can specify the prefix string CircuitEquations prepends to a node name to generate a node voltage identifier. For example, with NodeVoltagePrefix −> "V$", the node voltage at node 1 will be named V$1. Symbol["string" <> "node"] must yield a valid symbol. Therefore, "string" must not contain characters which have a special meaning in Mathematica. 3.5 Setting Up and Solving Circuit Equations 237 Protocol This option describes the standard Analog Insydes protocol specification (see Section 3.14.5). The top-level function for the Protocol option is CircuitEquations . The second-level function is ExpandSubcircuits . Protocol output generated by models is printed as third level. Symbolic The Symbolic option gives you control over the set of symbolic parameters of behavioral models which are kept as symbolic quantities in a system of circuit equations. The Symbolic option is the complement of the Value option and expects the following values: All None {instances −> params, † † † } keep all symbolic parameters of behavioral models in symbolic form replace all symbolic model parameters by numerical values keep only the specified parameters from the given instances in symbolic form Values for the Symbolic option. If the value form {instances −> params, † † † } is chosen, both instances and params can be a string pattern or a list of string patterns. The instances specification may have the following format: "pattern" {"pattern ", "pattern ", † † † } matches any reference designator "refdes" for which StringMatchQ["refdes", "pattern"] yields True matches any reference designator that matches at least one of the patterns; patterns are evaluated in the given order Format specifications for instances. The params specification may have the following format: symbol "pattern" {"pattern" | symbol, † † † } Format specifications for params. matches symbol literally matches any symbol arg for which StringMatchQ[ToString[arg], "pattern"] yields True matches any symbol that matches at least one of the patterns; patterns are evaluated in the given order 3. Reference Manual 238 Value takes precedence over Symbolic . Thus, a model parameter listed in the arguments of both options will be converted to a numerical value. Symbolic−>None is equivalent to Value−>All . TimeVariable With the option TimeVariable −> var, you can change the symbol which CircuitEquations uses to denote time. By default, this symbol is used to denote the independent variable in transient analysis. In addition, all explicit references to the identifier Time are replaced by the time variable. Value The Value option gives you control over the set of symbolic parameters of behavioral models which are kept as numeric quantities in a system of circuit equations. The Value option is the complement of the Symbolic option. All None {instances −> params, † † † } replace all symbolic parameters of behavioral models by numerical values keep all symbolic parameters of behavioral models in symbolic form replace only the specified parameters from the given instances by numerical values Values for the Value option. If the value form {instances −> params, † † † } is chosen, both instances and params can be a string pattern or a list of string patterns. The instances specification may have the following format: "pattern" {"pattern ", "pattern ", † † † } matches any reference designator "refdes" for which StringMatchQ["refdes", "pattern"] yields True matches any reference designator that matches at least one of the patterns; patterns are evaluated in the given order Format specifications for instances. The params specification may have the following format: 3.5 Setting Up and Solving Circuit Equations symbol "pattern" {"pattern" | symbol, † † † } 239 matches symbol literally matches any symbol arg for which StringMatchQ[ToString[arg], "pattern"] yields True matches any symbol that matches at least one of the patterns; patterns are evaluated in the given order Format specifications for params. Value takes precedence over Symbolic . Thus, a model parameter listed in the arguments of both options will be converted to a numerical value. Value−>All is equivalent to Symbolic−>None . Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ This defines an RLC lowpass filter circuit. In[2]:= rlcf = {V1, {R1, {L1, {C1, ] Netlist[ {1, 0}, V}, {1, 2}, R}, {2, 3}, L}, {3, 0}, C} Out[2]= NetlistRaw, 4 Set up a system of AC equations. Set up a system of DC equations. In[3]:= CircuitEquations[rlcf, AnalysisMode −> AC] // DisplayForm Out[3]//DisplayForm= 1 1 0 R R 1 1 1 1 R R Ls L s 1 1 0 L s L s C s 1 0 0 1 0 V$1 0 V$2 0 . 0 V$3 0 I$V1 V 0 In[4]:= CircuitEquations[rlcf, AnalysisMode −> DC] // DisplayForm Out[4]//DisplayForm= V$1 V$2 V$1 V$2 I$V1 0, I$L1 0, I$L1 0, R R V$1 V, V$2 V$3 0, V$1, V$2, V$3, I$V1, I$L1, DesignPoint 3. Reference Manual 240 Set up a system of time-domain equations. In[5]:= CircuitEquations[rlcf, AnalysisMode −> Transient] // DisplayForm Out[5]//DisplayForm= V$1t V$2t I$V1t 0, R V$1t V$2t I$L1t 0, I$L1t C V$3 t 0, R V$1t V, V$2t V$3t L I$L1 t 0, V$1t, V$2t, V$3t, I$V1t, I$L1t, DesignPoint Change the branch current prefix to "ib$". In[6]:= CircuitEquations[rlcf, BranchCurrentPrefix −> "ib$"] // DisplayForm Out[6]//DisplayForm= 1 1 0 R R 1 1 1 1 R R L s L s 1 1 0 L s L s C s 0 0 1 Change the branch voltage prefix to "ub$". In[7]:= CircuitEquations[rlcf, Formulation −> SparseTableau, BranchVoltagePrefix −> "ub$"] // DisplayForm Out[7]//DisplayForm= 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 Cs 0 Do not convert R and L to equivalent admittances. 1 0 V$1 0 V$2 0 . 0 V$3 0 ib$V1 V 0 0 0 0 0 0 ub$V1 0 1 1 0 0 ub$R1 0 0 1 1 0 ub$L1 0 0 0 1 1 ub$C1 . V 0 0 0 0 I$V1 0 0 R 0 0 I$R1 0 0 0 Ls 0 I$L1 0 0 0 1 I$C1 0 In[8]:= CircuitEquations[rlcf, ConvertImmittances −> False] // DisplayForm Out[8]//DisplayForm= 0 0 0 1 0 0 0 0 0 0 C s 0 1 0 0 0 0 0 1 1 0 1 1 0 1 0 V$1 0 1 1 0 V$2 0 1 0 V$3 . 0 0 V I$V1 R 0 0 I$R1 0 L s I$L1 0 The DefaultSelector option allows you to choose a different set of device models than would be normally used for the selected analysis mode. You can use this feature to set up circuit equations for noise analysis. Noise equations are essentially AC equations with some extensions, that can be included by selecting noise models instead of plain AC models using DefaultSelector −> Noise. Read in a PSpice netlist and small-signal data. In[9]:= buffer = ReadNetlist[ "AnalogInsydes/DemoFiles/Buffer.cir", "AnalogInsydes/DemoFiles/Buffer.out", Simulator −> "PSpice"] Out[9]= Circuit 3.5 Setting Up and Solving Circuit Equations Set up a system of AC equations. 241 In[10]:= CircuitEquations[buffer, AnalysisMode −> AC, Protocol −> {None, Notebook}] > ExpandSubcircuits... > Searching model libraries for model "BJT/AC". > Loading model "BJT/AC" from library FullModels‘. > Instantiating model "BJT/AC" for reference Q$T1. > Instantiating model "BJT/AC" for reference Q$T3. > Instantiating model "BJT/AC" for reference Q$T4. > Instantiating model "BJT/AC" for reference Q$T5. > Instantiating model "BJT/AC" for reference Q$T2. Out[10]= DAEAC, 18 18 Set up a system of AC equations with noise extensions. In[11]:= CircuitEquations[buffer, AnalysisMode −> AC, DefaultSelector −> Noise, Protocol −> {None, Notebook}] > ExpandSubcircuits... > Searching model libraries for model "BJT/Noise". > Loading model "BJT/Noise" from library FullModels‘. > Instantiating model "BJT/Noise" for reference Q$T1. > Instantiating model "BJT/Noise" for reference Q$T3. > Instantiating model "BJT/Noise" for reference Q$T4. > Instantiating model "BJT/Noise" for reference Q$T5. > Instantiating model "BJT/Noise" for reference Q$T2. Out[11]= DAEAC, 18 18 Specify numerical reference values for the circuit parameters. In[12]:= eqs = CircuitEquations[rlcf, DesignPoint −> {V −> 1., R −> 1000., L −> 0.001, C −> 2.2*10^−6}] Retrieve design point from DAEObject. In[13]:= GetDesignPoint[eqs] Define an RLC lowpass filter circuit with design-point information. In[14]:= rlcf2 = Netlist[ {V1, {1, 0}, Symbolic {R1, {1, 2}, Symbolic {L1, {2, 3}, Symbolic {C1, {3, 0}, Symbolic ] Out[12]= DAEAC, 4 4 Out[13]= V 1., R 1000., L 0.001, C 2.2 106 −> −> −> −> V, R, L, C, Value Value Value Value −> −> −> −> 1.}, 1000.}, 0.001}, 2.2*10^−6} Out[14]= NetlistRaw, 4 Set up a system of AC equations with numerical coefficients. In[15]:= CircuitEquations[rlcf2, ElementValues −> Value] // DisplayForm Out[15]//DisplayForm= 0.001 0.001 1000. 0.001 0.001 s 1000. 0 s 1 0 0 1000. s 1000. 2.2 106 s 0 1 0 V$1 0 0 V$2 . 0 V$3 s 0 I$V1 1. 0 3. Reference Manual 242 Set up a symbolic system of AC equations. In[16]:= eqssym = CircuitEquations[rlcf2, ElementValues −> Symbolic] Out[16]= DAEAC, 4 4 Show the equations. In[17]:= eqssym // DisplayForm Out[17]//DisplayForm= 1 1 0 R R 1 1 1 1 R R Ls L s 1 1 0 L s L s C s 1 0 0 1 0 V$1 0 V$2 0 . 0 V$3 0 I$V1 V 0 Get the design point from the DAEObject. In[18]:= GetDesignPoint[eqssym] Set up a system of sparse tableau equations. In[19]:= CircuitEquations[rlcf, Formulation −> SparseTableau] // DisplayForm Out[18]= V 1., R 1000., L 0.001, C 2.2 106 Out[19]//DisplayForm= 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 Cs 0 Set up a system of extended sparse tableau equations. 0 0 0 0 0 V$V1 0 1 1 0 0 V$R1 0 0 1 1 0 V$L1 0 0 0 1 1 V$C1 . V 0 0 0 0 I$V1 0 0 R 0 0 I$R1 0 0 0 Ls 0 I$L1 0 0 0 0 1 I$C1 In[20]:= CircuitEquations[rlcf, Formulation −> ExtendedTableau] // DisplayForm Out[20]//DisplayForm= 0 0 0 0 0 0 1 0 0 V$V1 0 1 0 0 0 1 0 0 0 0 0 0 1 1 0 V$R1 0 0 0 1 0 0 0 0 0 0 1 1 V$L1 0 0 0 0 1 0 0 0 0 0 0 1 V$C1 0 0 0 0 0 1 1 0 0 0 0 0 I$V1 0 . 0 0 0 0 0 1 1 0 0 0 0 I$R1 0 0 0 0 0 0 0 1 1 0 0 0 I$L1 V 1 0 0 0 0 0 0 0 0 0 0 I$C1 0 0 1 0 0 0 R 0 0 0 0 0 V$1 0 0 0 1 0 0 0 L s 0 0 0 0 V$2 0 0 0 0 C s 0 0 0 1 0 0 0 V$3 The default setting for the complex frequency is FrequencyVariable −> s, which is the most widely used symbol. However, some people prefer to use the setting FrequencyVariable −> p. 3.5 Setting Up and Solving Circuit Equations Use the symbol p to denote the complex frequency. This defines a simple control circuit with a signal source, a forward signal path, and a feedback path. 243 In[21]:= CircuitEquations[rlcf, FrequencyVariable −> p] // DisplayForm Out[21]//DisplayForm= 1 1 0 R R 1 1 1 1 R L p R L p 1 1 0 L p L p C p 0 0 1 1 0 V$1 0 0 V$2 . 0 V$3 0 I$V1 V 0 In[22]:= fbloop = Netlist[ {HS1, {in}, X[Frequency]}, {HG1, {in, out}, Hf[Frequency]}, {HG2, {out, in}, Hfb[Frequency]} ] Out[22]= NetlistRaw, 3 By default, CircuitEquations prints a warning because the netlist does not contain a reference to the electrical ground node 0. To turn off the warning, you must set IgnoreMissingGround −> True. Set up modified nodal equations for the control circuit. In[23]:= CircuitEquations[fbloop, NodeVoltagePrefix −> "x$"] Netlist::gndnode: Found no connections to the ground node. Netlist::lttc: Less than two connections at node(s) {0}. Out[23]= DAEAC, 2 2 This tells Analog Insydes to ignore the missing reference to ground. In[24]:= fbleqs = CircuitEquations[fbloop, IgnoreMissingGround −> True, NodeVoltagePrefix −> "x$"]; fbleqs // DisplayForm Out[25]//DisplayForm= 1 Xs Hfbs x$in . 1 0 Hfs x$out This defines a circuit with two time-varying and temperature-dependent resistors. In[26]:= tempckt = Netlist[ {V1, {1, 0}, V1}, {R1, {1, 2}, R1[Time]*(1 + TC11*TEMP)}, {R2, {2, 0}, R2[Time]*(1 + TC12*TEMP)}, {C1, {2, 0}, C1} ] Out[26]= NetlistRaw, 4 By default, TEMP is simply regarded as a global parameter. Equations for transient analysis are formulated with time as independent variable. Set up circuit equations for time-domain analysis. In[27]:= CircuitEquations[tempckt, AnalysisMode −> Transient] // DisplayForm Out[27]//DisplayForm= V$1t V$2t I$V1t 0, 1 TC11 TEMP R1t V$2t V$1t V$2t C1 V$2 t 0, 1 TC12 TEMP R2t 1 TC11 TEMP R1t V$1t V1, V$1t, V$2t, I$V1t, DesignPoint 3. Reference Manual 244 Now we use TEMP as independent variable. This causes the time derivative due to C1 to be set to zero and Time to be replaced by the value of InitialTime . Designate temperature as independent variable. In[28]:= CircuitEquations[tempckt, AnalysisMode −> Transient, IndependentVariable −> TEMP] // DisplayForm Out[28]//DisplayForm= V$1TEMP V$2TEMP I$V1TEMP 0, 1 TC11 TEMP R10 V$2TEMP V$1TEMP V$2TEMP 0, 1 TC12 TEMP R20 1 TC11 TEMP R10 V$1TEMP V1, V$1TEMP, V$2TEMP, I$V1TEMP, DesignPoint This assigns an initial condition to the inductor L1. In[29]:= rlcfic = Netlist[ {V1, {1, 0}, V}, {R1, {1, 2}, R}, {L1, {2, 3}, Value −> L, InitialCondition −> iL0}, {C1, {3, 0}, C} ] Out[29]= NetlistRaw, 4 By default, initial conditions are ignored by CircuitEquations . To use the given initial conditions, you must specify InitialConditions −> Automatic or InitialConditions −> All. Set up circuit equations for transient analysis. In[30]:= CircuitEquations[rlcfic, AnalysisMode −> Transient] // DisplayForm Out[30]//DisplayForm= V$1t V$2t I$V1t 0, R V$1t V$2t I$L1t 0, I$L1t C V$3 t 0, R V$1t V, V$2t V$3t L I$L1 t 0, V$1t, V$2t, V$3t, I$V1t, I$L1t, DesignPoint Use initial conditions only where specified explicitly. In[31]:= CircuitEquations[rlcfic, AnalysisMode −> Transient, InitialConditions −> Automatic] // DisplayForm Out[31]//DisplayForm= V$1t V$2t I$V1t 0, R V$1t V$2t I$L1t 0, I$L1t C V$3 t 0, R V$1t V, V$2t V$3t L I$L1 t 0, I$L10 iL0, V$1t, V$2t, V$3t, I$V1t, I$L1t, DesignPoint 3.5 Setting Up and Solving Circuit Equations Use given initial conditions, set all other initial conditions to zero. 245 In[32]:= CircuitEquations[rlcfic, AnalysisMode −> Transient, InitialConditions −> All] // DisplayForm Out[32]//DisplayForm= V$1t V$2t V$1t V$2t I$V1t 0, I$L1t 0, R R I$L1t C V$3 t 0, V$1t V, V$2t V$3t L I$L1 t 0, I$L10 iL0, V$30 0, V$1t, V$2t, V$3t, I$V1t, I$L1t, DesignPoint Use the symbol t0 to denote the initial time. In[33]:= CircuitEquations[rlcfic, AnalysisMode −> Transient, InitialConditions −> All, InitialTime −> t0 ] // DisplayForm Out[33]//DisplayForm= V$1t V$2t V$1t V$2t I$V1t 0, I$L1t 0, R R I$L1t C V$3 t 0, V$1t V, V$2t V$3t L I$L1 t 0, I$L1t0 iL0, V$3t0 0, V$1t, V$2t, V$3t, I$V1t, I$L1t, DesignPoint Change the node voltage prefix to "vn$". In[34]:= CircuitEquations[rlcf, NodeVoltagePrefix −> "vn$"] // DisplayForm Out[34]//DisplayForm= 1 1 0 R R 1 1 1 1 R R L s L s 1 1 0 L s L s C s 0 0 1 1 vn$1 0 0 vn$2 0 . 0 vn$3 0 I$V1 V 0 With the default settings Symbolic −> All and Value −> None, all device parameters of the diode appear in symbolic form when you set up a system of circuit equations with ElementValues −> Symbolic. This defines a simple half-wave diode rectifier circuit. In[35]:= rectifier = Netlist[ {V1, {1, 0}, Symbolic −> Vin, Value −> 5*Sin[2*Pi*50*Time]}, {D1, {1 −> A, 2 −> C}, Model −> "Diode", Selector −> Selector["Diode", "Spice", "D1"]}, {RL, {2, 0}, Symbolic −> RL, Value −> 1000.0}, {CL, {2, 0}, Symbolic −> CL, Value −> 2.2*^−5} ] Out[35]= NetlistRaw, 4 3. Reference Manual 246 Set up symbolic circuit equations for transient analysis. In[36]:= CircuitEquations[rectifier, AnalysisMode −> Transient, ElementValues −> Symbolic] // DisplayForm Out[36]//DisplayForm= V$2t I$AC$D1t I$V1t 0, I$AC$D1t CL V$2 t 0, RL TEMP 1.11 1. TNOM $q TEMP $k V$1t Vin, I$AC$D1t AREA$D1 E 3. 1. $q V$1tV$2t TEMP TEMP $k 1 E IS$D1 GMIN V$1t V$2t, TNOM V$1t, V$2t, I$V1t, I$AC$D1t, DesignPoint Vin 5 Sin100 Π t, RL 1000., CL 0.000022, AREA$D1 1., BV$D1 , CJO$D1 0, GMIN 1. 1012 , IBV$D1 0.001, IS$D1 1. 1014 , RS$D1 0, TEMP 300.15, TNOM 300.15, $k 1.38062 1023 , $q 1.60219 1019 You can also tell CircuitEquations to treat all device parameters as numeric quantities. Replace all parameters in device model equations by numerical values. In[37]:= CircuitEquations[rectifier, AnalysisMode −> Transient, ElementValues −> Symbolic, Symbolic −> None ] // DisplayForm Out[37]//DisplayForm= V$2t I$AC$D1t I$V1t 0, I$AC$D1t CL V$2 t 0, RL V$1t Vin, I$AC$D1t 1. 1014 1 E38.6635 V$1tV$2t 1. 1012 V$1t V$2t, V$1t, V$2t, I$V1t, I$AC$D1t, DesignPoint Vin 5 Sin100 Π t, RL 1000., CL 0.000022 Finally, the Symbolic option allows you to specify for each device or group of devices the parameters which CircuitEquations should keep in symbolic form. Keep only the parameters AREA and TEMP of all diode instances "D*" in symbolic form, replace all other model parameters by numerical values. In[38]:= CircuitEquations[rectifier, AnalysisMode −> Transient, ElementValues −> Symbolic, Symbolic −> {"D*" −> {AREA, TEMP}}] // DisplayForm Out[38]//DisplayForm= I$AC$D1t I$V1t 0, V$2t I$AC$D1t CL V$2 t 0, V$1t Vin, RL 12881.4 1.0.00333167 TEMP TEMP I$AC$D1t 3.69815 1022 AREA$D1 E 11604.8 V$1tV$2t TEMP 1 E TEMP3. 1. 1012 V$1t V$2t, V$1t, V$2t, I$V1t, I$AC$D1t, DesignPoint Vin 5 Sin100 Π t, RL 1000., CL 0.000022, AREA$D1 1., TEMP 300.15 3.5 Setting Up and Solving Circuit Equations Use the symbol Τ to denote time. 247 In[39]:= CircuitEquations[tempckt, AnalysisMode −> Transient, TimeVariable −> \[Tau]] // DisplayForm Out[39]//DisplayForm= V$1Τ V$2Τ I$V1Τ 0, 1 TC11 TEMP R1Τ V$2Τ V$1Τ V$2Τ C1 V$2 Τ 0, 1 TC12 TEMP R2Τ 1 TC11 TEMP R1Τ V$1Τ V1, V$1Τ, V$2Τ, I$V1Τ, DesignPoint With the default settings Symbolic −> All and Value −> None, all device parameters of the diode appear in symbolic form when you set up a system of circuit equations with ElementValues −> Symbolic. Set up a system of symbolic circuit equations for transient analysis. In[40]:= CircuitEquations[rectifier, AnalysisMode −> Transient, ElementValues −> Symbolic] // DisplayForm Out[40]//DisplayForm= V$2t I$AC$D1t I$V1t 0, I$AC$D1t CL V$2 t 0, RL TEMP 1.11 1. TNOM $q TEMP $k V$1t Vin, I$AC$D1t AREA$D1 E 3. 1. $q V$1tV$2t TEMP TEMP $k 1 E IS$D1 GMIN V$1t V$2t, TNOM V$1t, V$2t, I$V1t, I$AC$D1t, DesignPoint Vin 5 Sin100 Π t, RL 1000., CL 0.000022, AREA$D1 1., BV$D1 , CJO$D1 0, GMIN 1. 1012 , IBV$D1 0.001, IS$D1 1. 1014 , RS$D1 0, TEMP 300.15, TNOM 300.15, $k 1.38062 1023 , $q 1.60219 1019 You can also tell CircuitEquations to treat all device parameters as numeric quantities. Replace all parameters in device model equations by numerical values. In[41]:= CircuitEquations[rectifier, AnalysisMode −> Transient, ElementValues −> Symbolic, Value −> All] // DisplayForm Out[41]//DisplayForm= V$2t I$AC$D1t I$V1t 0, I$AC$D1t CL V$2 t 0, RL V$1t Vin, I$AC$D1t 1. 1014 1 E38.6635 V$1tV$2t 1. 1012 V$1t V$2t, V$1t, V$2t, I$V1t, I$AC$D1t, DesignPoint Vin 5 Sin100 Π t, RL 1000., CL 0.000022 Finally, the Value option allows you to specify for each device or group of devices the parameters which CircuitEquations should treat as numeric quantities. 3. Reference Manual 248 Replace the parameters TEMP, TNOM, $k, and $q of the model instance D1 by their numerical values. In[42]:= CircuitEquations[rectifier, AnalysisMode −> Transient, ElementValues −> Symbolic, Value −> {"D1" −> {TEMP, TNOM, $k, $q}}] // DisplayForm Out[42]//DisplayForm= V$2t I$AC$D1t I$V1t 0, I$AC$D1t CL V$2 t 0, RL V$1t Vin, I$AC$D1t 1. AREA$D1 1 E38.6635 V$1tV$2t IS$D1 GMIN V$1t V$2t, V$1t, V$2t, I$V1t, I$AC$D1t, DesignPoint Vin 5 Sin100 Π t, RL 1000., CL 0.000022, AREA$D1 1., BV$D1 , CJO$D1 0, GMIN 1. 1012 , IBV$D1 0.001, IS$D1 1. 1014 , RS$D1 0 3.5.2 ACEquations ACEquations[dae, oppoint, sources] linearizes equations about oppoint, replaces sources by values (specified via sources), and returns an AC DAEObject ACEquations[dae, oppoint] linearizes equations using the AC source specifiations given by the ModeValues option stored in dae Command structure of ACEquations. Given a Transient or DC DAEObject, ACEquations linearizes the equation system about the given operating point oppoint and returns an AC DAEObject. The operating point is given by a list of rules of the form var −> value for each variable of the equation system. It is possible to assign values to time derivatives of variables, too. The list of value mappings is added to the DesignPoint option of the returned DAEObject. During linearization, the values of AC sources are replaced by their AC value as given by sources, where sources is a list of rules of the form acsource −> val for each parameter representing an AC source. If this third argument is omitted, the AC values are automatically extracted from the ModeValues option stored in the DAEObject. Note that, given a Netlist or Circuit object, you can set up AC equations directly using CircuitEquations (Section 3.5.1). ACEquations provides the following options: 3.5 Setting Up and Solving Circuit Equations 249 option name default value FrequencyVariable Automatic specifies the symbol denoting the complex Laplace frequency OperatingPointPostfix "$op" string to append to variable names denoting symbolic operating points DerivativePostfix "d" string to append to variable names denoting derivatives Options for ACEquations. See also: DCEquations (Section 3.5.3), CircuitEquations (Section 3.5.1). Options Description A detailed description of all ACEquations options is given below in alphabetical order: DerivativePostfix If symbol names denoting derivates of varibles have to be created during linearization, the value of the DerivativePostfix option is appended to the variable name. Thus, the value of the DerivativePostfix option has to be a string which can be converted to a valid Mathematica symbol. The default setting is DerivativePostfix −> "d". FrequencyVariable The option FrequencyVariable specifies the symbol denoting the complex Laplace frequency. If set to Automatic , the value of the option FrequencyVariable as stored in the DAEObject dae is used. The default setting is FrequencyVariable −> Automatic . OperatingPointPostfix If the given operating point list oppoint contains a rule of the form var −> value, the rule opvar −> value is added to the DesignPoint option of the returned DAEObject, where opvar is given by appending the value of the OperatingPointPostfix option to the variable name var. Thus, the value of the OperatingPointPostfix option has to be a string which can be converted to a valid Mathematica symbol. The default setting is OperatingPointPostfix −> "$op". Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ 3. Reference Manual 250 Define netlist description of a simple diode rectifier circuit. In[2]:= rectifier = Circuit[ Netlist[ {V0, {1, 0}, Symbolic −> V0, Value −>2. Sin[10^6 Time]}, {R1, {2, 0}, Symbolic −> R1, Value −> 100.}, {C1, {2, 0}, Symbolic −> C1, Value −> 1.*^−7}, {D1, {1 −> A, 2 −> C}, Model −> "Diode", Selector −> "Spice", GMIN −> 0, AREA −> 1} ] ] Out[2]= Circuit Set up transient equation system. In[3]:= tran = CircuitEquations[rectifier, ElementValues −> Symbolic, AnalysisMode −> Transient, Value −> {"*" −> {TEMP, TNOM, $q, $k, AREA, GMIN}}] Out[3]= DAETransient, 4 4 Show equation system. In[4]:= tran // DisplayForm Out[4]//DisplayForm= V$2t I$AC$D1t I$V0t 0, I$AC$D1t C1 V$2 t 0, R1 V$1t V0, I$AC$D1t 1. 1 E38.6635 V$1tV$2t IS$D1, V$1t, V$2t, I$V0t, I$AC$D1t, DesignPoint V0 2. Sin1000000 t, R1 100., C1 1. 107 , BV$D1 , CJO$D1 0, IBV$D1 0.001, IS$D1 1. 1014 , RS$D1 0 Calculate operating point. In[5]:= op = First[NDAESolve[tran, {t, 0.}]] Out[5]= V$2 0., V$1 0., I$V0 0., I$AC$D1 0. Linearize equations about the operating point. In[6]:= ac = ACEquations[tran, op, {V0 −> 1}] Extract equation system. In[7]:= GetEquations[ac] Out[6]= DAEAC, 4 4 Out[7]= 1 I$AC$D1 I$V0 0, I$AC$D1 C1 s V$2 0, R1 V$1 V0, I$AC$D1 38.6635 E38.6635 V$1$opV$2$op IS$D1 V$1 38.6635 E38.6635 V$1$opV$2$op IS$D1 V$2 0 Display design point stored in the DAEObject. Note that new parameters have been generated. In[8]:= GetDesignPoint[ac] Out[8]= R1 100., C1 1. 107 , BV$D1 , CJO$D1 0, IBV$D1 0.001, IS$D1 1. 1014 , RS$D1 0, V0 1, V$1$op 0., V$2$op 0., I$V0$op 0., I$AC$D1$op 0., V0$op 2. Sin1000000 t$op 3.5 Setting Up and Solving Circuit Equations 251 3.5.3 DCEquations DCEquations[dae] transforms a dynamic Transient DAEObject into a static DC DAEObject Command structure of DCEquations. Given a Transient DAEObject, DCEquations transforms the dynamic equations into a static system and returns a DC DAEObject. All derivatives with respect to the IndependentVariable (as stored in the DAEObject) are replaced by zero. The initial time is inserted into both the equations and the design point. Depending on the value of the ModeValues option, the values of independent sources stored in the DesginPoint option of the DAEObject are replaced by the corresponding DC values stored in the ModeValues option of the DAEObject. Note that, given a Netlist or Circuit object, you can set up DC equations directly using CircuitEquations (Section 3.5.1). DCEquations provides the following options: option name default value InitialTime Automatic initial time to insert into the equation and the design point ModeValues Automatic whether to extract independent source values from the ModeValues option of the DAEObject Options for DCEquations. See also: ACEquations (Section 3.5.2), CircuitEquations (Section 3.5.1). Options Description InitialTime The option InitialTime specifies the value (which can be any Mathematica expression) to be substituted for the independent variable in the equation system and the design point. If the value of the InitialTime option is set to Automatic , the initial time is extracted from the InitialTime option stored in the DAEObject. The default setting is InitialTime −> Automatic . ModeValues The option ModeValues specifies whether values of independent sources should be updated in the DesignPoint option of the returned DAEObject. If the value of the ModeValues option is set to 3. Reference Manual 252 Automatic , DC values of independent sources are extracted from the ModeValues option stored in the DAEObject. If the value of the ModeValues option is set to None, the values of independent sources are used as-is. Note that in both cases the initial time is inserted into the design-point values. The default setting is ModeValues −> Automatic . Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define netlist description of a simple diode rectifier circuit. In[2]:= rectifier = Circuit[ Netlist[ {V0, {1, 0}, Symbolic −> V0, Value −>2. Sin[10^6 Time]}, {R1, {2, 0}, Symbolic −> R1, Value −> 100.}, {C1, {2, 0}, Symbolic −> C1, Value −> 1.*^−7}, {D1, {1 −> A, 2 −> C}, Model −> "Diode", Selector −> "Spice", GMIN −> 0, AREA −> 1} ] ] Out[2]= Circuit Set up transient equation system. In[3]:= tran = CircuitEquations[rectifier, ElementValues −> Symbolic, AnalysisMode −> Transient, Value −> {"*" −> {TEMP, TNOM, $q, $k, AREA, GMIN}}] Out[3]= DAETransient, 4 4 Show equation system. In[4]:= tran // DisplayForm Out[4]//DisplayForm= V$2t I$AC$D1t I$V0t 0, I$AC$D1t C1 V$2 t 0, R1 V$1t V0, I$AC$D1t 1. 1 E38.6635 V$1tV$2t IS$D1, V$1t, V$2t, I$V0t, I$AC$D1t, DesignPoint V0 2. Sin1000000 t, R1 100., C1 1. 107 , BV$D1 , CJO$D1 0, IBV$D1 0.001, IS$D1 1. 1014 , RS$D1 0 Transform dynamic equations into a static system. Show equation system. In[5]:= dc = DCEquations[tran] Out[5]= DAEDC, 4 4 In[6]:= dc // DisplayForm Out[6]//DisplayForm= V$2 I$AC$D1 I$V0 0, I$AC$D1 0, V$1 V0, I$AC$D1 R1 1. 1 E38.6635 V$1V$2 IS$D1, V$1, V$2, I$V0, I$AC$D1, DesignPoint V0 0, R1 100., C1 1. 107 , BV$D1 , CJO$D1 0, IBV$D1 0.001, IS$D1 1. 1014 , RS$D1 0 3.5 Setting Up and Solving Circuit Equations 253 3.5.4 Solve Solve[dae] Solve[dae, var] Solve[dae, {var , var , † † † }] solves a system of equations given by dae for all variables solves for one variable solves for several variables Command structure of Solve. In order to symbolically solve systems of equations formulated by the function CircuitEquations , Mathematica’s built-in function Solve has been extended to handle DAEObjects as well. Solve returns its result as lists of rules of the form {{var −> expr }, † † † }, where the variables var are assigned symbolic expressions expr. See also: CircuitEquations (Section 3.5.1), ACAnalysis (Section 3.7.3), NDAESolve (Section 3.7.5). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define netlist description. In[2]:= vdiv = {V0, {R1, {R2, ] Netlist[ {1, 0}, V0}, {1, 2}, R1}, {2, 0}, R2} Out[2]= NetlistRaw, 3 Set up a system of small-signal equations. In[3]:= vdiveqs = CircuitEquations[vdiv] Display equations. In[4]:= DisplayForm[vdiveqs] Out[3]= DAEAC, 3 3 Out[4]//DisplayForm= 1 1 1 V$1 R1 R1 0 1 1 1 0 . V$2 0 R1 R2 R1 V0 I$V0 0 0 1 Solve only for the variable V$2. In[5]:= Solve[vdiveqs, V$2] Solve for the variables V$1 and V$2. In[6]:= Solve[vdiveqs, {V$1, V$2}] Solve for all variables. In[7]:= solution = Solve[vdiveqs] R2 V0 Out[5]= V$2 R1 R2 R2 V0 Out[6]= V$2 , V$1 V0 R1 R2 V0 R2 V0 Out[7]= I$V0 , V$2 , V$1 V0 R1 R2 R1 R2 3. Reference Manual 254 Extract value of V$2 from the list of solutions. In[8]:= V$2 /. First[solution] R2 V0 Out[8]= R1 R2 3.6 Circuit and DAEObject Manipulation 255 3.6 Circuit and DAEObject Manipulation This chapter describes a number of functions which simplify the usage of the key objects existing in Analog Insydes, the Netlist object, the Circuit object, and the DAEObject. These functions allow you to manipulate the objects without knowledge of the internal data format. The following functions are available: AddElements (Section 3.6.1) DeleteElements (Section 3.6.2) inserting netlist elements deleting netlist elements GetElements (Section 3.6.3) extracting netlist elements RenameNodes (Section 3.6.4) renaming node identifiers Statistics (Section 3.6.17) showing contents of a Circuit object Functions dealing with Netlist and Circuit objects. GetEquations (Section 3.6.5) GetMatrix (Section 3.6.6) GetVariables (Section 3.6.7) GetRHS (Section 3.6.8) GetParameters (Section 3.6.9) extracting equations extracting matrix extracting variables extracting right-hand side vector extracting parameters GetDAEOptions (Section 3.6.10) extracting options SetDAEOptions (Section 3.6.11) setting and modifying options GetDesignPoint (Section 3.6.12) extracting design point ApplyDesignPoint (Section 3.6.13) inserting design point UpdateDesignPoint (Section 3.6.14) modifying design point MatchSymbols (Section 3.6.15) ShortenSymbols (Section 3.6.16) Statistics (Section 3.6.17) Functions dealing with DAEObjects. matching symbol names shortening symbol names showing contents of a DAEObject 3. Reference Manual 256 3.6.1 AddElements AddElements[netlist, element] adds netlist entry element to netlist AddElements[circuit, element] adds netlist entry element to the top-level netlist of circuit AddElements[circuit, element, subcirspec] adds netlist entry to subcircuits specified by subcirspec Command structure of AddElements. Given a Netlist or Circuit object, AddElements adds a new netlist element to the top-level netlist or to subcircuits defined in the circuit and returns the new Netlist or Circuit object, respectively. The subcircuits are given by means of the subcircuit specification subcirspec which is a sequence of rules of the following form: sequence description Name−>stringpattern , Selector−>stringpattern adds netlist entry to subcircuits whose Name matches stringpattern and whose Selector matches stringpattern Name−>stringpattern equivalent to Name−>stringpattern, Selector−>"*" Selector−>stringpattern equivalent to Name−>"*", Selector−>stringpattern Possible subcircuit specifications. The new netlist element is added to all subcircuits, whose Name and Selector fields match the string pattern given by the subcircuit specification. Note that there is no check whether the returned circuit defines a valid netlist. See also: DeleteElements (Section 3.6.2), GetElements (Section 3.6.3). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define a simple voltage divider circuit. In[2]:= net = Netlist[ {V0, {1, 0}, V0}, {R1, {1, 2}, R1}, {R2, {2, 0}, R2} ] Out[2]= NetlistRaw, 3 Add a load resistance to the voltage divider. In[3]:= netload = AddElements[net, {Rload, {2, 0}, Rload}] Out[3]= NetlistRaw, 4 3.6 Circuit and DAEObject Manipulation Display new netlist. 257 In[4]:= DisplayForm[netload] Out[4]//DisplayForm= Netlist Raw, 4 Entries: V0, 1, 0, V0 R1, 1, 2, R1 R2, 2, 0, R2 Rload, 2, 0, Rload 3.6.2 DeleteElements DeleteElements[netlist, stringpattern] removes those netlist entries from netlist whose reference designator matches stringpattern DeleteElements[circuit, stringpattern] removes those netlist entries from the top-level netlist of circuit whose reference designator matches stringpattern DeleteElements[circuit, stringpattern, subcirspec] removes netlist entries in subcircuits specified by subcirspec Command structure of DeleteElements . Given a Netlist or Circuit object, DeleteElements removes netlist elements from the top-level netlist or from subcircuits defined in the circuit and returns the new Netlist or Circuit object, respectively. The argument stringpattern is either a single string pattern or a list of string patterns. Netlist elements whose reference designator matches any of the string patterns are removed. To delete elements in subcircuits, referencing to certain subcircuits is performed by means of the subcircuit specification subcirspec which is a sequence of rules of the following form: sequence description Name−>stringpattern , Selector−>stringpattern deletes netlist entries in subcircuits whose Name matches stringpattern and whose Selector matches stringpattern Name−>stringpattern equivalent to Name−>stringpattern, Selector−>"*" Selector−>stringpattern equivalent to Name−>"*", Selector−>stringpattern Possible subcircuit specifications. Note that there is no check whether the returned Circuit object defines a valid circuit. See also: AddElements (Section 3.6.1), GetElements (Section 3.6.3). 3. Reference Manual 258 Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define a simple voltage divider with load resistance. In[2]:= netload = Netlist[ {V0, {1, 0}, V0}, {R1, {1, 2}, R1}, {R2, {2, 0}, R2}, {Rload, {2, 0}, Rload} ] Out[2]= NetlistRaw, 4 Remove all elements whose reference designator match the string pattern "*load" . Display new netlist. In[3]:= net = DeleteElements[netload, "*load"] Out[3]= NetlistRaw, 3 In[4]:= DisplayForm[net] Out[4]//DisplayForm= Netlist Raw, 3 Entries: V0, 1, 0, V0 R1, 1, 2, R1 R2, 2, 0, R2 3.6.3 GetElements GetElements[netlist, stringpattern] extracts those netlist entries from netlist whose reference designator matches stringpattern GetElements[circuit, stringpattern] extracts those netlist entries from the top-level netlist of circuit whose reference designator matches stringpattern Command structure of GetElements. Given a Netlist or Circuit object, GetElements extracts netlist elements from the top-level netlist and returns a list of these elements. The argument stringpattern is either a single string pattern or a list of string patterns. Netlist elements whose reference designator matches any of the string patterns are extracted. See also: AddElements (Section 3.6.1), DeleteElements (Section 3.6.2). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ 3.6 Circuit and DAEObject Manipulation Define a simple voltage divider. 259 In[2]:= netload = Netlist[ {V0, {1, 0}, V0}, {R1, {1, 2}, R1}, {R2, {2, 0}, R2}, {Rload, {2, 0}, Rload} ] Out[2]= NetlistRaw, 4 Extract all elements whose reference designator match the string pattern "R*". In[3]:= GetElements[netload, "R*"] Out[3]= R1, 1, 2, R1, R2, 2, 0, R2, Rload, 2, 0, Rload 3.6.4 RenameNodes RenameNodes[netlist, repl] renames nodes in netlist RenameNodes[circuit, repl] renames nodes in the top-level netlist of circuit Command structure of RenameNodes. Given a Netlist or Circuit object, RenameNodes changes node names in the top-level netlist and returns the new Netlist or Circuit object, respectively. The replacements repl are given as a single rule, a sequence of rules, or as a list of replacement rules of the form oldnodename −> newnodename. The node names can be given as symbols or as strings. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define a simple voltage divider. In[2]:= net = Netlist[ {V0, {1, 0}, V0}, {R1, {1, 2}, R1}, {R2, {2, 0}, R2} ] Out[2]= NetlistRaw, 3 Show variable names. In[3]:= GetVariables[CircuitEquations[net]] Out[3]= V$1, V$2, I$V0 The variable of interest – the voltage at node 2 – is called V$2. To mark this variable as the output variable we rename node 2 to OUT. Then the output variable is called V$OUT. Rename node 2 to OUT. In[4]:= net2 = RenameNodes[net, {2 −> OUT}] Out[4]= NetlistRaw, 3 3. Reference Manual 260 Display netlist. In[5]:= DisplayForm[net2] Out[5]//DisplayForm= Netlist Raw, 3 Entries: V0, 1, 0, V0 R1, 1, OUT, R1 R2, OUT, 0, R2 Show variable names. Now the variable of interest is called V$OUT. In[6]:= GetVariables[CircuitEquations[net2]] Out[6]= V$1, V$OUT, I$V0 3.6.5 GetEquations GetEquations[dae] returns the list of equations stored in dae Command structure of GetEquations. Given a DAEObject dae, GetEquations returns the equation system stored in the object as a list of equations. In case of an AC DAEObject the internal matrix representation is converted to a list of linear equations. See also: GetMatrix (Section 3.6.6), GetVariables (Section 3.6.7), GetRHS (Section 3.6.8), GetParameters (Section 3.6.9), GetDAEOptions (Section 3.6.10), GetDesignPoint (Section 3.6.12). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define netlist description of a simple diode rectifier circuit. In[2]:= cir = Circuit[ Netlist[ {V0, {1, 0}, Symbolic −> V0, Value −> 2. Sin[10^6 Time]}, {R1, {2, 0}, Symbolic −> R1, Value −> 100.}, {C1, {2, 0}, Symbolic −> C1, Value −> 1.*^−7}, {D1, {1 −> A, 2 −> C}, Model −> "Diode"} ] ] Out[2]= Circuit Set up Transient DAE system. In[3]:= dae = CircuitEquations[cir, AnalysisMode −> Transient, DefaultSelector −> "Spice", ElementValues −> Symbolic] Out[3]= DAETransient, 4 4 3.6 Circuit and DAEObject Manipulation Return list of equations. 261 In[4]:= GetEquations[dae] Out[4]= I$AC$D1t I$V0t 0, V$2t I$AC$D1t C1 V$2 t 0, V$1t V0, I$AC$D1t R1 TEMP 1.11 1. 1. $q V$1tV$2t TEMP 3. TNOM $q TEMP $k TEMP $k 1 E IS$D1 AREA$D1 E TNOM GMIN V$1t V$2t Set up AC DAE system. In[5]:= daeac = CircuitEquations[cir, AnalysisMode −> AC, DefaultSelector −> "SpiceAC", ElementValues −> Symbolic] Out[5]= DAEAC, 3 3 The system is set up as a matrix equation. Return value is again a list of equations. In[6]:= DisplayForm[daeac] Out[6]//DisplayForm= 1 Rd$D1 Cd$D1 s 1 Cd$D1 s Rd$D1 1 1 Rd$D1 Cd$D1 s 1 0 V$1 1 1 0 . V$2 C1 s Cd$D1 s 0 R1 Rd$D1 V0 I$V0 0 0 In[7]:= GetEquations[daeac] Out[7]= 1 1 I$V0 Cd$D1 s V$1 Cd$D1 s V$2 0, Rd$D1 Rd$D1 1 1 1 Cd$D1 s V$1 C1 s Cd$D1 s V$2 0, Rd$D1 R1 Rd$D1 V$1 V0 3.6.6 GetMatrix GetMatrix[dae] returns the matrix equations stored in dae Command structure of GetMatrix. Given a DAEObject dae, GetMatrix returns the matrix A of the linear equation system A x b stored in the object. Please note that GetMatrix is only valid for AC DAEObjects. See also: GetEquations (Section 3.6.5), GetVariables (Section 3.6.7), GetRHS (Section 3.6.8), GetParameters (Section 3.6.9), GetDAEOptions (Section 3.6.10), GetDesignPoint (Section 3.6.12). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ 3. Reference Manual 262 Define a simple voltage divider netlist. In[2]:= net = Netlist[ {V0, {1, 0}, V0}, {R1, {1, 2}, R1}, {R2, {2, 0}, R2} ] Out[2]= NetlistRaw, 3 Set up AC DAE system. In[3]:= dae = CircuitEquations[net] Out[3]= DAEAC, 3 3 Return matrix A. In[4]:= GetMatrix[dae] // MatrixForm 1 R1 1 Out[4]//MatrixForm= R1 1 1 R1 1 R1 0 1 R2 1 0 0 3.6.7 GetVariables GetVariables[dae] returns the list of variables stored in dae Command structure of GetVariables. Given a DAEObject dae, GetVariables returns the list of variables stored in the object. For AC and DC DAEObjects this is a list of symbols, for Transient DAEObjects this is a list of the form symbt where symb is a symbol and t is the independent variable. See also: GetEquations (Section 3.6.5), GetMatrix (Section 3.6.6), GetRHS (Section 3.6.8), GetParameters (Section 3.6.9), GetDAEOptions (Section 3.6.10), GetDesignPoint (Section 3.6.12). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define netlist description of a simple diode rectifier circuit. In[2]:= cir = Circuit[ Netlist[ {V0, {1, 0}, Symbolic −> V0, Value −> 2. Sin[10^6 Time]}, {R1, {2, 0}, Symbolic −> R1, Value −> 100.}, {C1, {2, 0}, Symbolic −> C1, Value −> 1.*^−7}, {D1, {1 −> A, 2 −> C}, Model −> "Diode"} ] ] Out[2]= Circuit Set up AC DAE system. In[3]:= dae = CircuitEquations[cir, AnalysisMode −> AC, DefaultSelector −> "SpiceAC"] Out[3]= DAEAC, 3 3 3.6 Circuit and DAEObject Manipulation Return list of variables stored in dae. In[4]:= GetVariables[dae] Set up Transient DAE system. In[5]:= daetran = CircuitEquations[cir, AnalysisMode −> Transient, DefaultSelector −> "Spice"] 263 Out[4]= V$1, V$2, I$V0 Out[5]= DAETransient, 4 4 Return list of variables stored in daetran. In[6]:= GetVariables[daetran] Out[6]= V$1t, V$2t, I$V0t, I$AC$D1t 3.6.8 GetRHS GetRHS[dae] returns the right-hand side source vector stored in dae Command structure of GetRHS. Given a DAEObject dae, GetRHS returns the right-hand side source vector b of the linear equation system A x b stored in the object. Please note that GetRHS is only valid for AC DAEObjects. See also: GetEquations (Section 3.6.5), GetMatrix (Section 3.6.6), GetVariables (Section 3.6.7), GetParameters (Section 3.6.9), GetDAEOptions (Section 3.6.10), GetDesignPoint (Section 3.6.12). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define a simple voltage divider netlist. In[2]:= net = Netlist[ {V0, {1, 0}, V0}, {R1, {1, 2}, R1}, {R2, {2, 0}, R2} ] Out[2]= NetlistRaw, 3 Set up AC DAE system. In[3]:= dae = CircuitEquations[net] Out[3]= DAEAC, 3 3 Return vector b. In[4]:= GetRHS[dae] // MatrixForm 0 Out[4]//MatrixForm= 0 V0 3. Reference Manual 264 3.6.9 GetParameters GetParameters[dae] returns the list of parameters stored in dae Command structure of GetParameters. Given a DAEObject dae, GetParameters returns the list of parameters occuring in the equation system of the object. Note that GetParameters differs from GetDesignPoint in that it returns only those parameters which appear in the equations of dae. Moreover, it returns a list of symbols, not a list of replacement rules. See also: GetEquations (Section 3.6.5), GetMatrix (Section 3.6.6), GetVariables (Section 3.6.7), GetRHS (Section 3.6.8), GetDAEOptions (Section 3.6.10), GetDesignPoint (Section 3.6.12). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define netlist description of a simple diode rectifier circuit. In[2]:= cir = Circuit[ Netlist[ {V0, {1, 0}, Symbolic −> V0, Value −> 2. Sin[10^6 Time]}, {R1, {2, 0}, Symbolic −> R1, Value −> 100.}, {C1, {2, 0}, Symbolic −> C1, Value −> 1.*^−7}, {D1, {1 −> A, 2 −> C}, Model −> "Diode", Selector −> "Spice"} ] ] Out[2]= Circuit Set up DAE system. In[3]:= dae = CircuitEquations[cir, AnalysisMode −> Transient, ElementValues −> Symbolic] Out[3]= DAETransient, 4 4 Return list of parameters occuring in the equations of dae. In[4]:= GetParameters[dae] Out[4]= AREA$D1, C1, GMIN, IS$D1, R1, TEMP, TNOM, V0, $k, $q 3.6 Circuit and DAEObject Manipulation 265 3.6.10 GetDAEOptions GetDAEOptions[dae] GetDAEOptions[dae, symb] returns the list of options stored in the DAEObject dae returns the value of the option symb stored in dae GetDAEOptions[dae, {symb , symb , † † † }] returns a list of values of the options symbi stored in dae Command structure of GetDAEOptions . Besides the equation system and the list of variables, a DAEObject contains a list of arbitrary options. Use GetDAEOptions to extract these options: GetDAEOptions[dae] returns a list of all options stored in the DAEObject dae. If a second argument is specified and is an option symbol, the value of this option stored in the DAEObject is returned. If it is a list of option symbols, a list of the option values is returned. The function CircuitEquations (Section 3.5.1) automatically adds a number of options to the DAEObject which have been used during equation setup. To extract the DesignPoint option of a DAEObject it is recommended to use the function GetDesignPoint . See also: SetDAEOptions (Section 3.6.11), GetEquations (Section 3.6.5), GetMatrix (Section 3.6.6), GetVariables (Section 3.6.7), GetRHS (Section 3.6.8), GetDesignPoint (Section 3.6.12). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define netlist description of a simple diode rectifier circuit. In[2]:= cir = Circuit[ Netlist[ {V0, {1, 0}, Symbolic −> V0, Value −> 2. Sin[10^6 Time]}, {R1, {2, 0}, Symbolic −> R1, Value −> 100.}, {C1, {2, 0}, Symbolic −> C1, Value −> 1.*^−7}, {D1, {1 −> A, 2 −> C}, Model −> "Diode", Selector −> "Spice"} ] ] Out[2]= Circuit Set up DAE system. In[3]:= dae = CircuitEquations[cir, AnalysisMode −> Transient, ElementValues −> Symbolic] Out[3]= DAETransient, 4 4 3. Reference Manual 266 Return the list of all options stored in dae. In[4]:= GetDAEOptions[dae] Return special options stored in dae. In[5]:= GetDAEOptions[dae, {IndependentVariable, InitialTime}] Out[4]= AnalysisMode Transient, BranchCurrentPrefix I$, BranchVoltagePrefix V$, ControllingCurrentPrefix IC$, ControllingVoltagePrefix VC$, ConvertImmittances True, DesignPoint V0 2. Sin1000000 t, R1 100., C1 1. 107 , AREA$D1 1., BV$D1 , CJO$D1 0, GMIN 1. 1012 , IBV$D1 0.001, IS$D1 1. 1014 , RS$D1 0, TEMP 300.15, TNOM 300.15, $k 1.38062 1023 , $q 1.60219 1019 , ElementValues Symbolic, Formulation ModifiedNodal, FrequencyVariable s, IgnoreMissingGround False, IndependentVariable t, InitialConditions None, InitialGuess I$AC$D1 0, V$1 V$2 0, InitialTime 0, InstanceNameSeparator $, MatrixEquation True, ModeValues , NodeVoltagePrefix V$, Symbolic All, TimeVariable t, Value None Out[5]= t, 0 3.6.11 SetDAEOptions SetDAEOptions[dae, name−>val] stores the value val of the option name in dae, removing any previously stored value for this option SetDAEOptions[dae, {name −>val , name −>val , † † † }] stores the values vali for the options namei in dae Command structure of SetDAEOptions. Besides the equation system and the list of variables, a DAEObject contains a list of arbitrary options. Use SetDAEOptions to store or to update options in a DAEObject: SetDAEOptions[dae, name −> val] stores the value val of the option name in dae and returns the new list of options. If the second argument is a list of option rules, the value for each option rule is stored. Previously stored values for the given options are replaced by the new values and new options are appended to the list of options. Note that SetDAEOptions alters the given DAEObject rather than returning a new object. Instead it returns the updated option list. In contrast to the Mathematica function SetOptions , the function SetDAEOptions does not check whether a given option is a valid DAEObject option. Any option is a valid DAEObject option and can be stored in the object (there is no Options[DAEObject] ). To alter the DesignPoint option of a DAEObject it is recommended to use the function UpdateDesignPoint . See also: GetDAEOptions (Section 3.6.10), GetEquations (Section 3.6.5), GetMatrix (Section 3.6.6), GetVariables (Section 3.6.7), GetRHS (Section 3.6.8), GetDesignPoint (Section 3.6.12), UpdateDesignPoint (Section 3.6.14). 3.6 Circuit and DAEObject Manipulation 267 Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define netlist description of a simple diode rectifier circuit. In[2]:= cir = Circuit[ Netlist[ {V0, {1, 0}, Symbolic −> V0, Value −> 2. Sin[10^6 Time]}, {R1, {2, 0}, Symbolic −> R1, Value −> 100.}, {C1, {2, 0}, Symbolic −> C1, Value −> 1.*^−7}, {D1, {1 −> A, 2 −> C}, Model −> "Diode", Selector −> "Spice"} ] ] Out[2]= Circuit Set up DAE system. In[3]:= dae = CircuitEquations[cir, AnalysisMode −> Transient, ElementValues −> Symbolic] Out[3]= DAETransient, 4 4 Inspect the value of the InitialTime option in dae. In[4]:= GetDAEOptions[dae, InitialTime] Alter the value of the InitialTime option. In[5]:= SetDAEOptions[dae, InitialTime −> 0.5] Note that dae was altered by SetDAEOptions . In[6]:= GetDAEOptions[dae, InitialTime] Out[4]= 0 Out[5]= AnalysisMode Transient, BranchCurrentPrefix I$, BranchVoltagePrefix V$, ControllingCurrentPrefix IC$, ControllingVoltagePrefix VC$, ConvertImmittances True, DesignPoint V0 2. Sin1000000 t, R1 100., C1 1. 107 , AREA$D1 1., BV$D1 , CJO$D1 0, GMIN 1. 1012 , IBV$D1 0.001, IS$D1 1. 1014 , RS$D1 0, TEMP 300.15, TNOM 300.15, $k 1.38062 1023 , $q 1.60219 1019 , ElementValues Symbolic, Formulation ModifiedNodal, FrequencyVariable s, IgnoreMissingGround False, IndependentVariable t, InitialConditions None, InitialGuess I$AC$D1 0, V$1 V$2 0, InstanceNameSeparator $, MatrixEquation True, ModeValues , NodeVoltagePrefix V$, Symbolic All, TimeVariable t, Value None, InitialTime 0.5 Out[6]= 0.5 3. Reference Manual 268 You can set arbitrary options with arbitrary values. In[7]:= SetDAEOptions[dae, Comment −> "This object describes a rectifier circuit"] Out[7]= AnalysisMode Transient, BranchCurrentPrefix I$, BranchVoltagePrefix V$, ControllingCurrentPrefix IC$, ControllingVoltagePrefix VC$, ConvertImmittances True, DesignPoint V0 2. Sin1000000 t, R1 100., C1 1. 107 , AREA$D1 1., BV$D1 , CJO$D1 0, GMIN 1. 1012 , IBV$D1 0.001, IS$D1 1. 1014 , RS$D1 0, TEMP 300.15, TNOM 300.15, $k 1.38062 1023 , $q 1.60219 1019 , ElementValues Symbolic, Formulation ModifiedNodal, FrequencyVariable s, IgnoreMissingGround False, IndependentVariable t, InitialConditions None, InitialGuess I$AC$D1 0, V$1 V$2 0, InstanceNameSeparator $, MatrixEquation True, ModeValues , NodeVoltagePrefix V$, Symbolic All, TimeVariable t, Value None, InitialTime 0.5, Comment This object describes a rectifier circuit 3.6.12 GetDesignPoint GetDesignPoint[dae] GetDesignPoint[dae, param] returns the design point stored in dae returns the value of the parameter param from the design point stored in dae GetDesignPoint[dae, {param , param , † † † }] returns the value of each parameter parami Command structure of GetDesignPoint . Given a DAEObject dae, GetDesignPoint returns the design point list stored in the object. If a symbol is given as a second argument, the value of the corresponding parameter stored in the design point is returned. If the second argument is a list of symbols, a list of the corresponding parameter values is returned. Note that GetDesignPoint differs from GetParameters in that it returns the complete design point stored in dae and not only those parameters which appear in the equations of dae. See also: GetEquations (Section 3.6.5), GetMatrix (Section 3.6.6), GetVariables (Section 3.6.7), GetRHS (Section 3.6.8), GetParameters (Section 3.6.9), GetDAEOptions (Section 3.6.10). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ 3.6 Circuit and DAEObject Manipulation Define netlist description of a simple diode rectifier circuit. 269 In[2]:= cir = Circuit[ Netlist[ {V0, {1, 0}, Symbolic −> V0, Value −> 2. Sin[10^6 Time]}, {R1, {2, 0}, Symbolic −> R1, Value −> 100.}, {C1, {2, 0}, Symbolic −> C1, Value −> 1.*^−7}, {D1, {1 −> A, 2 −> C}, Model −> "Diode", Selector −> "Spice"} ] ] Out[2]= Circuit Set up DAE system. In[3]:= dae = CircuitEquations[cir, AnalysisMode −> Transient, ElementValues −> Symbolic] Out[3]= DAETransient, 4 4 Return design point stored in dae. In[4]:= GetDesignPoint[dae] Return the values of the parameters R1 and C1. In[5]:= GetDesignPoint[dae, {R1, C1}] Out[4]= V0 2. Sin1000000 t, R1 100., C1 1. 107 , AREA$D1 1., BV$D1 , CJO$D1 0, GMIN 1. 1012 , IBV$D1 0.001, IS$D1 1. 1014 , RS$D1 0, TEMP 300.15, TNOM 300.15, $k 1.38062 1023 , $q 1.60219 1019 Out[5]= 100., 1. 107 3.6.13 ApplyDesignPoint ApplyDesignPoint[dae, stringpattern] replaces all parameters of dae matching stringpattern with their numerical values ApplyDesignPoint[dae, {stringpattern , stringpattern , † † † }] replaces all parameters matching a list of string patterns with their numerical values ApplyDesignPoint[dae] replaces all parameters of the design point with their numerical values Command structure of ApplyDesignPoint . Given a DAEObject, ApplyDesignPoint returns a new DAEObject where all parameters in the equation system which match a string pattern stringpattern are replaced with their numerical values stored in the DesignPoint option of dae. If a list of string patterns is given, all parameters which match at least one of the patterns are replaced. By default, all replaced parameters are removed from the DesignPoint option in the returned DAEObject. You can use the option Cleanup to change this behavior (see below). Note that matching is performed using string patterns. 3. Reference Manual 270 It is possible to specify a symbol symb instead of a string pattern as parameter to ApplyDesignPoint , which is equivalent to specifying the string pattern "symb". This is also valid for the option KeepSymbolic (see below). ApplyDesignPoint has the following options: option name default value Cleanup True removes unused parameters from the design point KeepSymbolic {} specifies parameters to be kept symbolic Protocol Inherited[AnalogInsydes] standard Analog Insydes protocol specification (see Section 3.14.5) Options for ApplyDesignPoint. See also: UpdateDesignPoint (Section 3.6.14). Options Description Cleanup This option allows for removing parameters from the design point of a DAEObject that do not occur in the corresponding equations. The default setting is Cleanup −> True, which means that at least all those parameters which have been inserted numerically are removed from the design point. KeepSymbolic By default, all parameters which match one of the string patterns stringpatterni are replaced by their numerical value. The option KeepSymbolic allows for filtering this list of replaced parameters. The option value must be a list of string patterns. All parameters which match at least one of these string patterns are kept symbolic even if they match the string patterns given as arguments to ApplyDesignPoint . This option is especially useful to insert the numerical value for a model parameter keeping the parameter of a specific instance symbolic. For example, ApplyDesignPoint[dae, "AREA*", KeepSymbolic −> {"AREA$Q1"}] inserts the numerical value of the model parameter AREA for each instance except for the instance Q1 for which the parameter is kept symbolic. 3.6 Circuit and DAEObject Manipulation 271 The default setting is KeepSymbolic −> {}, which means not to filter the parameters to be inserted numerically. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define netlist. In[2]:= cir = Circuit[ Netlist[ {V0, {1, 0}, Symbolic −> V0, Value −> 2. Sin[10^6 Time]}, {R1, {2, 0}, Symbolic −> R1, Value −> 100.}, {C1, {2, 0}, Symbolic −> C1, Value −> 1.*^−7}, {D1, {1 −> A, 2 −> C}, Model −> "Diode", Selector −> "Spice"} ] ] Out[2]= Circuit Set up DAE system. In[3]:= dae = CircuitEquations[cir, AnalysisMode −> Transient, ElementValues −> Symbolic] Out[3]= DAETransient, 4 4 Show DAE system. In[4]:= DisplayForm[dae] Out[4]//DisplayForm= V$2t I$AC$D1t I$V0t 0, I$AC$D1t C1 V$2 t 0, R1 TEMP 1.11 1. TNOM $q TEMP $k V$1t V0, I$AC$D1t AREA$D1 E 3. 1. $q V$1tV$2t TEMP TEMP $k 1 E IS$D1 GMIN V$1t V$2t, TNOM V$1t, V$2t, I$V0t, I$AC$D1t, DesignPoint V0 2. Sin1000000 t, R1 100., C1 1. 107 , AREA$D1 1., BV$D1 , CJO$D1 0, GMIN 1. 1012 , IBV$D1 0.001, IS$D1 1. 1014 , RS$D1 0, TEMP 300.15, TNOM 300.15, $k 1.38062 1023 , $q 1.60219 1019 Insert numerical values for all parameters except AREA$D1 . In[5]:= daenew = ApplyDesignPoint[dae, "*", KeepSymbolic −> {AREA$D1}] Show new DAE system. Note that parameters are removed from the DesignPoint option of daenew . In[6]:= DisplayForm[daenew] Out[5]= DAETransient, 4 4 Out[6]//DisplayForm= I$AC$D1t I$V0t 0, I$AC$D1t 0.01 V$2t 1. 107 V$2 t 0, V$1t 2. Sin1000000 t, I$AC$D1t 1. 1014 AREA$D1 1 E38.6635 V$1tV$2t 1. 1012 V$1t V$2t, V$1t, V$2t, I$V0t, I$AC$D1t, DesignPoint AREA$D1 1. 3. Reference Manual 272 3.6.14 UpdateDesignPoint UpdateDesignPoint[dae, repl] allows for modifying the DesignPoint by replacement rules Command structure of UpdateDesignPoint . Given a DAEObject dae, UpdateDesignPoint replaces all parameters in the DesignPoint option stored in dae according to the replacement rules repl and returns the new DAEObject. The replacements repl are given as a list of rules of the form symbol −> newvalue which means to replace the value of the parameter symbol by the new numerical value newvalue in the design point of the DAEObject. If a replacement rule is of the form stringpattern −> newvalue then the value of each parameter which matches the string pattern is replaced by newvalue. This can for example be used to set a model parameter to a common value for each instance of this model. If UpdateDesignPoint is called without a second argument, the values of the design point are not changed. However, if the option Cleanup is set to True (which is the default), unused parameters are removed from the design point. Thus, this pattern is useful for stripping the design point to the relevant data. UpdateDesignPoint has the following options: option name default value Cleanup True Protocol Inherited[AnalogInsydes] standard Analog Insydes protocol specification (see Section 3.14.5) removes unused parameters from the design point Options for UpdateDesignPoint . See also: ApplyDesignPoint (Section 3.6.13). Options Description Cleanup This option allows for removing parameters from the design point of a DAEObject that do not occur in the corresponding equations. The default setting is Cleanup −> True, which means to remove all those parameters from the design point which do not occur in the equation system. 3.6 Circuit and DAEObject Manipulation 273 Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define netlist. In[2]:= cir = Circuit[ Netlist[ {V0, {1, 0}, Symbolic −> V0, Value −> 2. Sin[10^6 Time]}, {R1, {2, 0}, Symbolic −> R1, Value −> 100.}, {C1, {2, 0}, Symbolic −> C1, Value −> 1.*^−7}, {D1, {1 −> A, 2 −> C}, Model −> "Diode", Selector −> "Spice"} ] ] Out[2]= Circuit Set up DAE system. In[3]:= dae = CircuitEquations[cir, AnalysisMode −> Transient, ElementValues −> Symbolic] Out[3]= DAETransient, 4 4 Show DAE system. In[4]:= DisplayForm[dae] Out[4]//DisplayForm= V$2t I$AC$D1t I$V0t 0, I$AC$D1t C1 V$2 t 0, R1 TEMP 1.11 1. TNOM $q TEMP $k V$1t V0, I$AC$D1t AREA$D1 E 3. 1. $q V$1tV$2t TEMP TEMP $k 1 E IS$D1 GMIN V$1t V$2t, TNOM V$1t, V$2t, I$V0t, I$AC$D1t, DesignPoint V0 2. Sin1000000 t, R1 100., C1 1. 107 , AREA$D1 1., BV$D1 , CJO$D1 0, GMIN 1. 1012 , IBV$D1 0.001, IS$D1 1. 1014 , RS$D1 0, TEMP 300.15, TNOM 300.15, $k 1.38062 1023 , $q 1.60219 1019 Store new values for the parameters R1, C1, and V0 in the design point. In[5]:= daenew = UpdateDesignPoint[dae, {R1 −> 10., C1 −> 1.*^−6, V0 −> 1.}] Show updated design point of daenew. Note that unused parameters are removed from the design point. In[6]:= GetDesignPoint[daenew] Out[5]= DAETransient, 4 4 Out[6]= V0 1., R1 10., C1 1. 106 , AREA$D1 1., GMIN 1. 1012 , IS$D1 1. 1014 , TEMP 300.15, TNOM 300.15, $k 1.38062 1023 , $q 1.60219 1019 3. Reference Manual 274 3.6.15 MatchSymbols MatchSymbols[expr, matchgroups] matches symbols in an expression expr MatchSymbols[dae, matchgroups] matches symbols in a system of equations dae Command structure of MatchSymbols. Given an expression expr or a DAEObject dae, MatchSymbols replaces all symbols which belong to a given matching group matchgroups by a common symbol and returns a new expression or DAEObject, respectively. The matching groups must be specified as lists of the form: {suffix , suffix , † † † , matchsuffix}. Please note that the function pattern for equations uses the design-point information stored in the DAEObject to validate the matching specifications. MatchSymbols has the following options: option name default value DesignPoint Automatic list of numerical reference values for symbolic element values in a set of circuit equations Tolerance 0.1 tolerance specification for matching the symbols in a matching group Options for MatchSymbols. See also: ShortenSymbols (Section 3.6.16). Options Description DesignPoint With DesignPoint −> {symbol −> value , † † † } you can overwrite the design point given in the DAEObject (see also CircuitEquations in Section 3.5.1). The default setting is DesignPoint −> Automatic , which means to use the design point given in the DAEObject. 3.6 Circuit and DAEObject Manipulation 275 Tolerance Tolerance −> tol specifies the maximum relative deviation of the values of the symbols in a matching group from the group’s mean value. Please note that the option Tolerance is neglected if the DAEObject contains no design-point information. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define netlist. In[2]:= net = Netlist[ {V0, {1, 0}, 1}, {R1, {1, 2}, Symbolic −> R1, Value −> 10.}, {R2, {2, 3}, Symbolic −> R2, Value −> 10.}, {R3, {3, out}, Symbolic −> R3, Value −> 10.}, {RL, {out, 0}, Load} ] Out[2]= NetlistRaw, 5 Set up equations. In[3]:= dae = CircuitEquations[net, ElementValues −> Symbolic]; DisplayForm[dae] Out[4]//DisplayForm= 1 1 0 R1 R1 1 1 1 1 R1 R1 R2 R2 1 1 1 0 R2 R2 R3 1 0 0 R3 0 0 1 0 0 1 R3 1 Load 1 R3 0 1 0 V$1 0 0 V$2 0 . V$3 0 0 V$out 0 I$V0 1 0 Compute voltage transfer function. In[5]:= vout = V$out /. First[Solve[dae]] Match symbols of resistors R1, R2, and R3. In[6]:= MatchSymbols[vout, {"R*", R}] Match symbols of resistors in the DAEObject. In[7]:= daematch = MatchSymbols[dae, {"R*", R}]; DisplayForm[daematch] Load Out[5]= Load R1 R2 R3 Load Out[6]= Load 3 R Out[8]//DisplayForm= 1 1 0 0 R R 1 2 1 0 R R R 2 1 1 0 R R R 1 1 1 0 0 R Load R 0 0 0 1 1 0 V$1 0 0 V$2 0 . V$3 0 0 V$out 0 I$V0 1 0 3. Reference Manual 276 Compute matched voltage transfer function. In[9]:= V$out /. First[Solve[daematch]] Modify values of resistors R2 and R3. In[10]:= daenew = UpdateDesignPoint[dae, {R2 −> 15., R3 −> 20.}] Match symbols of resistors of the modified DAEObject. In[11]:= MatchSymbols[daenew, {"R*", R}] // DisplayForm Load Out[9]= Load 3 R Out[10]= DAEAC, 5 5 MatchSymbols::mtol: Design−point values of matching group {R1, R2, R3} do not meet the tolerance specification. Out[11]//DisplayForm= 1 1 0 R1 R1 1 1 1 1 R1 R1 R2 R2 1 1 1 0 R2 R2 R3 1 0 0 R3 0 0 1 0 0 1 R3 1 Load 1 R3 0 1 0 V$1 0 0 V$2 0 . V$3 0 0 V$out 0 I$V0 1 0 3.6.16 ShortenSymbols ShortenSymbols[dae] replaces symbols in dae by a set of symbols with shorter symbol names Command structure of ShortenSymbols . Given a DAEObject dae, ShortenSymbols replaces all symbols (variables and parameters) by a set of new symbols with shorter symbol names and returns a new DAEObject. Please note that the new symbols are generated at the expense of instance information as name components enclosed by the InstanceNameSeparator are dropped. ShortenSymbols has the following options: option name default value InstanceNameSeparator Inherited[AnalogInsydes] specifies the character(s) used to separate name components of variables and parameters, see InstanceNameSeparator (Section 3.14.2) Protocol Inherited[AnalogInsydes] standard Analog Insydes protocol specification (see Section 3.14.5) Options for ShortenSymbols. 3.6 Circuit and DAEObject Manipulation 277 See also: MatchSymbols (Section 3.6.15). 3.6.17 Statistics Statistics[netlist] prints type and number of netlist elements in a Netlist object netlist Statistics[circuit] prints type and number of netlist elements in a Circuit object circuit Statistics[dae] prints complexity information of a DAEObject dae Command structure of Statistics. The command Statistics can be used to display both type and number of the netlist elements in a circuit or a netlist. Additionally, you can obtain detailed information concerning the complexity of a DAEObject. Statistics[circuit] and Statistics[netlist] provide the following information: type and number of occurrence of each netlist element type and number of occurrence of each model/selector call total number of entries Statistics[dae] for DC and Transient DAEObjects provides the following information: number of equations number of variables number of top-level terms for each equation number of terms which involve derivatives number of terms for each level Statistics[dae] for AC DAEObjects provides the following information: 3. Reference Manual 278 number of equations number of variables total number of entries number of non-zero entries complexity estimate (only if the DAEObject option ElementValues is set to Symbolic , and if the option value for the time constraint is chosen large enough) Statistics has the following options: option name default value Protocol Inherited[AnalogInsydes] standard Analog Insydes protocol specification (see Section 3.14.5) TimeConstraint 10 specifies the maximum number of seconds for the complexity estimate computation for AC DAEObjects Options for Statistics. TimeConstraint TimeConstraint specifies the number of seconds after which the computation of the complexity estimate for an AC DAEObject is aborted. The option value may be any positive numeric value or Infinity . The default setting is TimeConstraint −> 10. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define netlist. In[2]:= cir = Circuit[ Netlist[ {V0, {1, 0}, Symbolic −> V0, Value −> 2. Sin[10^6 Time]}, {R1, {2, 0}, Symbolic −> R1, Value −> 100.}, {C1, {2, 0}, Symbolic −> C1, Value −> 1.*^−7}, {D1, {1 −> A, 2 −> C}, Model −> "Diode", Selector −> "Spice"} ] ] Out[2]= Circuit 3.6 Circuit and DAEObject Manipulation Display netlist information using Statistics . 279 In[3]:= Statistics[cir] Number of Resistors : 1 Number of Capacitors : 1 Number of VoltageSources : 1 Number of models Diode/Spice : 1 Total number of elements Set up DAE system. : 4 In[4]:= dae = CircuitEquations[cir, AnalysisMode −> Transient]; dae // DisplayForm Out[5]//DisplayForm= I$AC$D1t I$V0t 0, I$AC$D1t 0.01 V$2t 1. 107 V$2 t 0, V$1t 2. Sin1000000 t, I$AC$D1t 1. 1014 1 E38.6635 V$1tV$2t 1. 1012 V$1t V$2t, V$1t, V$2t, I$V0t, I$AC$D1t, DesignPoint Display complexity information using Statistics . In[6]:= Statistics[dae] Number of equations : 4 Number of variables : 4 Length of equations : {2, 3, 2, 5} Terms with derivatives : 1 Sums in levels : {12, 2} 3. Reference Manual 280 3.7 Numerical Analyses This chapter describes the standard numerical analyses types you can perform with most numerical circuit simulators. The following table shows the supported analyses and their corresponding Analog Insydes functions: ACAnalysis (Section 3.7.3) NoiseAnalysis (Section 3.7.4) small-signal (AC) analysis noise analysis NDAESolve (Section 3.7.5) operating-point (DC) analysis NDAESolve (Section 3.7.5) DC-transfer (DT) analysis NDAESolve (Section 3.7.5) large-signal (transient) analysis Section 3.7.1 starts with an introduction of the Analog Insydes numerical data format, which all of the above mentioned functions rely on. Section 3.7.2 describes the format which is used in Analog Insydes to perform parameter sweeps. 3.7.1 Analog Insydes Numerical Data Format This section introduces the simulation data format used in Analog Insydes. Some functions like ACAnalysis (Section 3.7.3), NoiseAnalysis (Section 3.7.4), NDAESolve (Section 3.7.5), or ReadSimulationData (Section 3.10.3) need to return numerical data which represents zero, one, or multi-dimensional numerical data. This data will be returned in the following form: {{l1 −> v1 , l2 −> v2 , , SweepParameters −> {p1 −> s1 , p2 −> s2 , }}, } The variable labels l and the parameter labels p can be of type String or Symbol. For operating-point data the value vi is a single numerical value, for sweep data it is an InterpolatingFunction . The parameter value si is always a single numerical value. SweepParameters denotes the parameters which have been swept. It can be omitted if only one data set is present. 3.7.2 Parameter Sweeps A few Analog Insydes functions make use of parameter sweeping: Besides the integration variable, NDAESolve (Section 3.7.5) allows for varying several parameters performing a multi-dimensional parameter sweep. For preparation of the nonlinear simplification methods the range of the input variables has to be specified as a parameter sweep using the command NonlinearSetup (Section 3.12.1). 3.7 Numerical Analyses 281 Analog Insydes supports the following parameter sweep formats: format {symbol, {f , † † † , fm }} {symbol, start, stop, incr} description symbol has values f , † † † , fm equivalent to {symbol, Range[start, stop, incr]} {{symb −>f , † † † , symbn −>fn }, † † † , {symb −>fm , † † † , symbn −>fmn }} First, symb has value f , , and symbn has value fn , and so forth. In the last step, symb has value fm , , and symbn has value fmn {sweep , † † † , sweepm } combinations of the above sweep formats Valid parameter sweep formats. The following example shows valid parameter sweeps: {{R1, {100, 1000, 10000}}, {V1, 1, 5, 1}, {{P1 −> 10, P2 −> 20}, {P1 −> 20, P2 −> 10}}} If several sweep formats are combined in a list (as shown in the example above) the outer product of all sweep specifications is computed. You can use ParamSweepQ to check whether a given sweep specification is valid in the above sense. Examples To demonstrate the parameter sweep format, in this example section the internal command ResolveParamSweep is used. This function returns a list where the first element is the canonical representation of the sweep specification (i.e. a flat list of rules). The second element of the result is for internal purposes only. Load Analog Insydes. In[1]:= <<AnalogInsydes‘ A one-dimensional sweep with values given explicitly. In[2]:= First @ ResolveParamSweep[{R1, {100, 1000, 10000}}] A one-dimensional sweep with values given by an interval. In[3]:= First @ ResolveParamSweep[{V1, 1, 5, 1}] Out[2]= R1 100., R1 1000., R1 10000. Out[3]= V1 1., V1 2., V1 3., V1 4., V1 5. 3. Reference Manual 282 The combination of both sweeps yields a two-dimensional sweep. In[4]:= First @ ResolveParamSweep[ {{R1, {100, 1000, 10000}}, {V1, 1, 4, 1}}] You can mix any sweep format to build valid multi-dimensional sweeps. In[5]:= ParamSweepQ[{{R1, {100, 1000}}, {V1, 1, 5, 1}, {{P1 −> 10, P2 −> 20}, {P1 −> 20, P2 −> 10}}}] Out[4]= R1 100., V1 1., R1 100., V1 2., R1 100., V1 3., R1 100., V1 4., R1 1000., V1 1., R1 1000., V1 2., R1 1000., V1 3., R1 1000., V1 4., R1 10000., V1 1., R1 10000., V1 2., R1 10000., V1 3., R1 10000., V1 4. Out[5]= True 3.7.3 ACAnalysis ACAnalysis[dae, {fvar, fstart, fend}] computes the small-signal solution of a linear DAEObject dae within a specified frequency range fstart fend as function of the frequency variable fvar for all variables ACAnalysis[dae, var, {fvar, fstart, fend}] solves for the variable var ACAnalysis[dae, {var , var , † † † }, {fvar, fstart, fend}] solves for several variables Command structure of ACAnalysis. This functions allows for carrying out a numerical small-signal analysis. Given an AC DAEObject, ACAnalysis computes the small-signal solution in the specified frequency range and returns the result according to the Analog Insydes numerical data format described in Section 3.7.1. It consists of lists of rules, where the variables are assigned InterpolatingFunction objects. The result of the small-signal analysis can be displayed with Analog Insydes graphics functions such as BodePlot (Section 3.9.1). ACAnalysis has the following options: 3.7 Numerical Analyses 283 option name default value FrequencyVariable Automatic specifies the symbol that denotes the complex Laplace frequency InterpolateResult True specifies the return format of the result InterpolationOrder 1 specifies the interpolation order of the resulting interpolating functions PointsPerDecade 10 specifies the number of sampling points per frequency decade Protocol Inherited[AnalogInsydes] standard Analog Insydes protocol specification (see Section 3.14.5) SweepPath (2. Pi I #1 &) specifies a mapping from a frequency to a point in the complex plane Options for ACAnalysis. See also: BodePlot (Section 3.9.1), NoiseAnalysis (Section 3.7.4), Section 3.7.1. Options Description A detailed description of all ACAnalysis options is given below in alphabetical order: FrequencyVariable This option specifies the symbol that denotes the complex Laplace frequency. See CircuitEquations in Section 3.5.1. The default setting is FrequencyVariable −> Automatic , which means to use the symbol given in the DAEObject. InterpolateResult If InterpolateResult is set to True, the result is returned as an interpolating function for each variable. If the option is set to False, the result is returned as a list of {frequency, value} pairs. InterpolationOrder With InterpolationOrder −> integer you can change the interpolation order of the resulting interpolating functions (see the Mathematica object InterpolatingFunction ). The default setting is InterpolationOrder −> 1, which means linear interpolation. 3. Reference Manual 284 PointsPerDecade PointsPerDecade specifies the number of sampling points per frequency decade. The default setting is PointsPerDecade −> 10. SweepPath SweepPath specifies a mapping from a frequency to a point in the complex plane. The option value has to be a pure function with one argument which returns a complex number. The default setting is SweepPath −> (2. Pi I #1 &), which specifies a sweep along the IΩ axis. Examples Below we compute the frequency response of a RC lowpass filter circuit. Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define netlist description. In[2]:= lowpass = Circuit[ Netlist[ {V1, {1, {R1, {1, {C1, {2, {R2, {2, {C2, {3, {RL, {3, ] ] 0}, 2}, 0}, 3}, 0}, 0}, 1}, 100.}, 1.*^−6}, 100.}, 1.*^−6}, 1000.} Out[2]= Circuit Set up system of small-signal equations. In[3]:= lowpasseqs = CircuitEquations[lowpass] Display equations. In[4]:= DisplayForm[lowpasseqs] Out[3]= DAEAC, 4 4 Out[4]//DisplayForm= 0.01 0.01 0 1 0 V$1 6 0 0.01 0.02 1. 10 s 0.01 0 V$2 . 6 0 V$3 0 0.01 0.011 1. 10 s 0 I$V1 1 0 0 0 1 Perform numerical small-signal analysis with ACAnalysis . In[5]:= acsweep = ACAnalysis[lowpasseqs, {f, 1., 1.*^6}] Out[5]= V$1 InterpolatingFunction1., 1. 106 , , V$2 InterpolatingFunction1., 1. 106 , , V$3 InterpolatingFunction1., 1. 106 , , I$V1 InterpolatingFunction1., 1. 106 , 3.7 Numerical Analyses 285 To solve only for one variable, specify the variable as second argument. In[6]:= ACAnalysis[lowpasseqs, V$3, {f, 1., 1.*^6}] Display the simulation result with BodePlot . In[7]:= BodePlot[acsweep, {V$2[f]}, {f, 1., 1.*^6}] Phase (deg) Magnitude (dB) Out[6]= V$3 InterpolatingFunction1., 1. 106 , 1.0E0 0 -10 -20 -30 -40 -50 1.0E1 1.0E2 1.0E3 1.0E4 1.0E5 1.0E6 1.0E0 1.0E1 1.0E2 1.0E3 1.0E4 Frequency 1.0E5 1.0E6 1.0E0 0 1.0E1 1.0E2 1.0E4 1.0E5 1.0E6 1.0E1 1.0E2 1.0E3 1.0E4 Frequency 1.0E5 1.0E6 1.0E3 -20 -40 -60 -80 1.0E0 V$2[f] Out[7]= Graphics 3.7.4 NoiseAnalysis NoiseAnalysis[dae, invar, outvar, {f, fstart, fstop}] computes the output noise and the equivalent input noise for a linear DAEObject dae where the input signal is specified by invar and the output by outvar Command structure of NoiseAnalysis . This functions allows for carrying out a numerical noise analysis. The output noise and the equivalent input noise are computed from a linear DAEObject dae, where the parameter invar denotes the input and the variable outvar denotes the output, respectively. Use GetParameters to get a valid list of input symbols and GetVariables for a list of valid output symbols. NoiseAnalysis returns the result according to the Analog Insydes numerical data format (see Section 3.7.1) for the output noise (denoted by the symbol OutputNoise ), the equivalent input noise (denoted by the symbol InputNoise ), the output variable outvar, and each noise source. The computed values for the noise sources are given in A Hz and V Hz, input and output noise in A Hz and V Hz, respectively. The result of the numerical noise analysis can be displayed with Analog Insydes graphics functions such as BodePlot (Section 3.9.1). The DAEObject dae must be set up symbolically (use ElementValues −> Symbolic during equation setup). Note that at least all sources (noise sources and the one small-signal input source invar) 3. Reference Manual 286 have to be accessible symbolically. When setting up equations for noise analysis, specify the option settings AnalysisMode −> AC and DefaultSelector −> "Noise" for CircuitEquations in order to use the noise models. See CircuitEquations (Section 3.5.1) for a description of the options DefaultSelector and ElementValues . Note that the noise sources are expressed in the following units: source type unit example: thermal noise CurrentSource A Hz Sqrt[4 k T / R] VoltageSource V Hz Sqrt[4 k T R] Units of noise sources. While specifying the value of a noise source it is also assumed that the bandwidth is Hz. NoiseAnalysis has the following options: option name default value DesignPoint Automatic specifies a list of numerical reference values for symbolic element values in a set of circuit equations FrequencyVariable Automatic specifies the symbol that denotes the complex Laplace frequency InterpolationOrder 1 specifies the interpolation order of the resulting interpolating functions PointsPerDecade 10 specifies the number of sampling points per frequency decade Protocol Inherited[AnalogInsydes] standard Analog Insydes protocol specification (see Section 3.14.5) SweepPath (2. Pi I #1 &) specifies a mapping from a frequency to a point in the complex plane Options for NoiseAnalysis See also: BodePlot (Section 3.9.1), ACAnalysis (Section 3.7.3), GetVariables (Section 3.6.7), GetParameters (Section 3.6.9), Section 3.7.1. 3.7 Numerical Analyses 287 Options Description A detailed description of all NoiseAnalysis options is given below in alphabetical order: DesignPoint With DesignPoint −> {symbol −> value, † † † }, you can specify the design point. See also CircuitEquations (Section 3.5.1). The default setting is DesignPoint −> Automatic , which means to use the design point given in the DAEObject. FrequencyVariable This option specifies the symbol that denotes the complex Laplace frequency. See CircuitEquations in Section 3.5.1. The default setting is FrequencyVariable −> Automatic , which means to use the symbol given in the DAEObject. InterpolationOrder With InterpolationOrder −> integer, you can change the interpolation order of the resulting interpolating functions. See the Mathematica object InterpolatingFunction . The default setting is InterpolationOrder −> 1, which is linear interpolation. PointsPerDecade PointsPerDecade specifies the number of sampling points per frequency decade. The default setting is PointsPerDecade −> 10. SweepPath SweepPath specifies a mapping from a frequency to a point in the complex plane. The option value has to be a pure function with one argument which returns a complex number. The default setting is SweepPath −> (2. Pi I #1 &), which specifies a sweep along the IΩ axis. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ 3. Reference Manual 288 Read the netlist and the operating-point information. In[2]:= bufcir = ReadNetlist[ "AnalogInsydes/DemoFiles/Buffer.cir", "AnalogInsydes/DemoFiles/Buffer.out", Simulator −> "PSpice"] Out[2]= Circuit Choose noise models and set up system of equations symbolically. In[3]:= bufeq = CircuitEquations[bufcir, AnalysisMode −> AC, DefaultSelector −> "Noise", ElementValues −> Symbolic] View circuit variables. The variable V$99 is chosen as output symbol. In[4]:= GetVariables[bufeq] View circuit parameters. The parameter V$VIN is chosen as input symbol. In[5]:= GetParameters[bufeq] Out[3]= DAEAC, 18 18 Out[4]= V$1, V$2, V$3, V$4, V$5, V$99, V$BS$Q$T1, V$BS$Q$T2, V$BS$Q$T3, V$BS$Q$T4, V$BS$Q$T5, V$CS$Q$T1, V$CS$Q$T2, V$CS$Q$T3, V$CS$Q$T4, V$CS$Q$T5, I$V$VDD, I$V$VIN Out[5]= Cbc$Q$T1, Cbc$Q$T2, Cbc$Q$T3, Cbc$Q$T4, Cbc$Q$T5, Cbe$Q$T1, Cbe$Q$T2, Cbe$Q$T3, Cbe$Q$T4, Cbe$Q$T5, Cbx$Q$T1, Cbx$Q$T2, Cbx$Q$T3, Cbx$Q$T4, Cbx$Q$T5, Gmu$Q$T1, Gmu$Q$T2, Gmu$Q$T3, Gmu$Q$T4, Gmu$Q$T5, gm$Q$T1, gm$Q$T2, gm$Q$T3, gm$Q$T4, gm$Q$T5, Ib$Q$T1, Ib$Q$T2, Ib$Q$T3, Ib$Q$T4, Ib$Q$T5, Ic$Q$T1, Ic$Q$T2, Ic$Q$T3, Ic$Q$T4, Ic$Q$T5, Irc$Q$T1, Irc$Q$T2, Irc$Q$T3, Irc$Q$T4, Irc$Q$T5, Irx$Q$T1, Irx$Q$T2, Irx$Q$T3, Irx$Q$T4, Irx$Q$T5, Rc$Q$T1, Rc$Q$T2, Rc$Q$T3, Rc$Q$T4, Rc$Q$T5, Ro$Q$T1, Ro$Q$T2, Ro$Q$T3, Ro$Q$T4, Ro$Q$T5, Rpi$Q$T1, Rpi$Q$T2, Rpi$Q$T3, Rpi$Q$T4, Rpi$Q$T5, Rx$Q$T1, Rx$Q$T2, Rx$Q$T3, Rx$Q$T4, Rx$Q$T5, V$VIN 3.7 Numerical Analyses 289 Perform numerical noise analysis with NoiseAnalysis . Note the additional symbols OutputNoise and InputNoise in the result. In[6]:= bufnoi = NoiseAnalysis[bufeq, V$VIN, V$99, {f, 10., 1.*^8}] Display the simulation result. In[7]:= BodePlot[bufnoi, {OutputNoise[f], InputNoise[f]}, {f, 10., 1.*^8}, PhaseDisplay −> None, TraceNames −> {"noise(out)", "noise(in)"}] Out[6]= OutputNoise InterpolatingFunction10., 1. 108 , , InputNoise InterpolatingFunction10., 1. 108 , , V$99 InterpolatingFunction10., 1. 108 , , Ib$Q$T1 InterpolatingFunction10., 1. 108 , , Ib$Q$T2 InterpolatingFunction10., 1. 108 , , Ib$Q$T3 InterpolatingFunction10., 1. 108 , , Ib$Q$T4 InterpolatingFunction10., 1. 108 , , Ib$Q$T5 InterpolatingFunction10., 1. 108 , , Ic$Q$T1 InterpolatingFunction10., 1. 108 , , Ic$Q$T2 InterpolatingFunction10., 1. 108 , , Ic$Q$T3 InterpolatingFunction10., 1. 108 , , Ic$Q$T4 InterpolatingFunction10., 1. 108 , , Ic$Q$T5 InterpolatingFunction10., 1. 108 , , Irc$Q$T1 InterpolatingFunction10., 1. 108 , , Irc$Q$T2 InterpolatingFunction10., 1. 108 , , Irc$Q$T3 InterpolatingFunction10., 1. 108 , , Irc$Q$T4 InterpolatingFunction10., 1. 108 , , Irc$Q$T5 InterpolatingFunction10., 1. 108 , , Irx$Q$T1 InterpolatingFunction10., 1. 108 , , Irx$Q$T2 InterpolatingFunction10., 1. 108 , , Irx$Q$T3 InterpolatingFunction10., 1. 108 , , Irx$Q$T4 InterpolatingFunction10., 1. 108 , , Irx$Q$T5 InterpolatingFunction10., 1. 108 , 1.0E0 1.0E2 1.0E4 1.0E6 1.0E8 1.0E2 1.0E4 Frequency 1.0E6 1.0E8 -140 Magnitude (dB) -150 -160 -170 -180 1.0E0 noise(out) noise(in) Out[7]= Graphics 3. Reference Manual 290 3.7.5 NDAESolve NDAESolve[dae, {tvar, t }] computes the DC solution of a nonlinear DAEObject dae at the time point tvar t NDAESolve[dae, {tvar, t }, params] carries out a parametric DC analysis NDAESolve[dae, {tvar, tstart, tend}] computes the transient or the DC-transfer solution of a nonlinear DAEObject dae within a specified integration interval tstart tend as function of the independent variable tvar NDAESolve[dae, {tvar, tstart, tend}, params] carries out a parametric transient or a parametric DC-transfer analysis Command structure of NDAESolve. The function NDAESolve allows for carrying out several numerical analyses, such as an operatingpoint (DC) analysis, a DC-transfer (DT) analysis, or a large-signal (transient) analysis. NDAESolve returns the result according to the Analog Insydes numerical data format described in Section 3.7.1. It consists of lists of rules, where the variables are assigned InterpolatingFunction objects in case of a transient analysis or numerical values in case of a DC analysis. Both analysis modes can also be carried out as parametric analyses. For this, specify a parameter sweep params according to the Analog Insydes parameter sweep format described in Section 3.7.2. The result of the numerical transient analysis can be displayed with Analog Insydes graphics functions such as TransientPlot (Section 3.9.6). Note that NDAESolve still supports the command structure from Release 1 where the first argument is given as {eqns, vars} instead of a DAEObject: NDAESolve[{eqns, vars}, {tvar, t }] carries out a DC analysis NDAESolve[{eqns, vars}, {tvar, t }, params] carries out a parametric DC analysis NDAESolve[{eqns, vars}, {tvar, tstart, tend}] carries out a transient or a DC-transfer analysis NDAESolve[{eqns, vars}, {tvar, tstart, tend}, params] carries out a parametric transient or a parametric DC-transfer analysis Additional patterns of NDAESolve. 3.7 Numerical Analyses 291 NDAESolve has the following options: option name default value AccuracyGoal 6 number of digits of accuracy to seek in the result (see also FindRoot) Compiled True whether to compile the equations (see also FindRoot ) MaxIterations {100, 20} maximum number of iterations of the nonlinear solver WorkingPrecision 16 number of digits of precision to keep in internal computations (see also FindRoot ) NonlinearMethod FindRoot allows for switching the nonlinear equation solver Nonlinear solver options of NDAESolve. option name default value MaxDelta 1. limit for the deviation of variable values during the automatic step size control MaxSteps Automatic maximum number of integration steps MaxStepSize Automatic upper limit of the integration step size MinStepSize Automatic lower limit of the integration step size StartingStepSize Automatic initial integration step size StepSizeFactor 1.5 modification factor of the integration step size Step size control options of NDAESolve. 3. Reference Manual 292 option name default value InitialConditions Automatic whether to consider initial conditions InitialGuess Automatic initial guess for the operating-point computation InitialSolution Automatic initial solution for the operating-point computation RandomFunction (Random[Real, {0., 0.1}]&) random function for perturbing the initial guess Operating-point computation options of NDAESolve. option name default value InterpolationOrder 1 interpolation order of the resulting interpolating functions OutputVariables All variables to appear in the solution vector ReturnDerivatives False whether to include solutions for the derivatives in the solution vector Return format options of NDAESolve. 3.7 Numerical Analyses 293 option name default value AnalysisMode Transient circuit analysis mode BreakOnError False whether to interrupt a parametric DC or transient analysis in case of an error CompressEquations False whether to carry out a symbolic pre-processing of the equation system DesignPoint Automatic list of numerical reference values for symbolic element values in a set of circuit equations Protocol Inherited[AnalogInsydes] standard Analog Insydes protocol specification (see Section 3.14.5) Simulator Inherited[AnalogInsydes] standard Analog Insydes simulator specification (see Section 3.14.6) SimulatorExecutable Automatic name of the external simulator executable Miscellaneous options of NDAESolve. See also: TransientPlot (Section 3.9.6), Section 3.7.1, Section 3.7.2. Options Description A detailed description of all NDAESolve options is given below in alphabetical order: AnalysisMode The option AnalysisMode specifies the circuit analysis mode, where the default setting is AnalysisMode −> Transient . Valid option values are as follows: DC Transient carries out a DC-transfer analysis carries out a large-signal time-domain analysis Values for the AnalysisMode option. Note that this option is only valid for the NDAESolve pattern where you have to specify a start value tstart and an end value tend. In this case NDAESolve is able to carry out a DC-transfer analysis by setting the option to AnalysisMode −> DC, although the input is a Transient DAEObject. 3. Reference Manual 294 Note that the DC-transfer analysis method replaces all derivatives in the circuit equations by zero. Thus, inductors are replaced by short circuits because all inductor voltages are set to zero: Inductor: VL t L #IL t #t DC $ VL t % Short Circuit and capacitors are replaced by open circuits because all capacitor currents are set to zero: Capacitor: IC t C #UC t #t DC $ IC t % Open Circuit BreakOnError The option BreakOnError allows for interrupting a parametric DC or transient analysis in case of an error. If set to True and the computation for one parameter sweep fails, the simulation is interrupted and $Failed is returned. The default setting is BreakOnError −> False. CompressEquations The option CompressEquations allows for carrying out a symbolic pre-processing of the equation system before it is solved numerically. This means that equations and variables which are not relevant for computing the variables of interest (given by the option OutputVariables ) are removed. Note that this option is only effective if the option OutputVariables is not set to All. The option is realized by an internal call of the function CompressNonlinearEquations (Section 3.12.2). The default setting is CompressEquations −> False. DesignPoint With DesignPoint −> {symbol −> value , † † † } you can overwrite the design point given in the DAEObject (see also CircuitEquations in Section 3.5.1). The default setting is DesignPoint −> Automatic , which means to use the design point given in the DAEObject. InitialConditions The option InitialConditions allows for considering initial conditions (see also CircuitEquations in Section 3.5.1). The default setting is InitialConditions −> Automatic . Valid option values are as follows: 3.7 Numerical Analyses 295 None Automatic All neglects initial conditions considers initial conditions same as Automatic Values for the InitialConditions option. InitialGuess The option InitialGuess allows for explicitly specifying an initial guess for the Newton iteration when computing the operating point. Note that missing variables are set to zero. The default setting is InitialGuess −> Automatic, which means that all variables have the initial value zero. Possible option values are as follows: Automatic {var −> value , † † † } uses zero values as initial guess uses specified values as initial guess and sets values not specified to zero Values for the InitialGuess option. InitialSolution The option InitialSolution allows for specifying an initial solution for certain variables of the operating point. Note that missing variables are computed consistently. The default setting is InitialSolution −> Automatic , which automatically computes the operating point. Possible option values are as follows: Automatic {var −> value , † † † } computes operating point automatically uses specified values as initial solution Values for the InitialSolution option. InterpolationOrder With InterpolationOrder −> integer you can change the interpolation order of the resulting interpolating functions (see the Mathematica object InterpolatingFunction ). The default setting is InterpolationOrder −> 1, which means linear interpolation. 296 3. Reference Manual MaxDelta One of the conditions included in the automatic step size control is a check for rapidly changing variable values from a certain point in time to its succeeding time instant. The maximum allowed deviation is controlled via the option MaxDelta. The default setting is MaxDelta −> 1. MaxIterations MaxIterations specifies the maximum number of iterations the nonlinear equation solver should use attempting to find a solution. The option setting can either be an integer int or a list of two integers {int , int }. If it is specified as a single integer int then it is equivalent to the list {int, int}. The first integer value defines the iteration limit for finding a DC operating-point and the second integer value the iteration limit for transient computations, respectively. If the number of iterations for the operating-point computation exceeds the limit, an error message is generated and the computation is interrupted. If the iteration limit for transient computations is exceeded, the step size is reduced by the factor given by the option StepSizeFactor . The default setting is MaxIterations −> {100, 20}. MaxSteps The option MaxSteps limits the number of integration steps. The computation will be stopped immediately if the limiting value is exceeded. The default setting is MaxSteps −> Automatic , which means MaxSteps tend tstart StartingStepSize . MaxStepSize The option MaxStepSize specifies the upper limit of the integration step size. The default setting is MaxStepSize −> Automatic , which means MaxStepSize tend tstart . MinStepSize The option MinStepSize specifies the lower limit of the integration step size. The computation will be stopped immediately if the integration step size falls below this limit. The default setting is MinStepSize −> Automatic , which means MinStepSize tend tstart . NonlinearMethod The option NonlinearMethod allows for choosing between different algorithms for numerically solving nonlinear equation systems. The default setting is NonlinearMethod −> FindRoot. Valid option values are as follows: 3.7 Numerical Analyses 297 FindRoot NewtonIteration uses Mathematica’s numerical equation solver FindRoot uses multi-dimensional Newton-Raphson implementation Values for the NonlinearMethod option. OutputVariables The option OutputVariables specifies those variables which should be included in the solution vector. The default setting is OutputVariables −> All. Valid option values are as follows: All {var , † † † } returns solutions for all variables returns solutions for the specified variables only Values for the OutputVariables option. RandomFunction The option RandomFunction specifies a function used for generating random numbers for perturbing the initial guess during the operating-point computation. Note that the generated random numbers are added to the initial guess. The return value of the function should be a real number. The default setting is RandomFunction −> (Random[Real, {0., 0.1}]&). ReturnDerivatives The option ReturnDerivatives allows for including solutions of the derivatives in the solution vector. The default setting is ReturnDerivatives −> False. Simulator The option Simulator specifies the simulator which should be applied for numerically solving the system of equations. The default setting is Simulator −> Inherited[AnalogInsydes] . Valid option values are as follows: "AnalogInsydes" applies internal Analog Insydes solver "PSpice" applies PSpice kernel "Saber" applies Saber kernel Values for the Simulator option. 3. Reference Manual 298 In case of an external simulator kernel a behavioral model in the simulator-specific language is generated with the function WriteModel (Section 3.10.5). Then the respective simulator kernel given by the option SimulatorExecutable is applied, and finally the generated simulation data is imported via the function ReadSimulationData (Section 3.10.3). Please note that this option is in an experimental state. Additionally, it is extremely dependent on the applied simulator, its underlying operating system, and even the available simulator version. SimulatorExecutable The option SimulatorExecutable specifies the name of the external simulator executable. Note that this option is only effective if an external simulator is applied via the option Simulator . The default setting is SimulatorExecutable −> Automatic , which means "pspice" in case of PSpice and "saber" in case of Saber, respectively. If set to a string make sure that the simulator call corresponds to the setting of the Simulator option. Otherwise the internal calls to the functions WriteModel and ReadSimulationData fail. Valid option values are as follows: Automatic "string" generates simulator call according to the Simulator option allows user specific simulator call Values for the SimulatorExecutable option. StartingStepSize The option StartingStepSize specifies the initial integration step size. The default setting is StartingStepSize −> Automatic , which means StartingStepSize tend tstart . StepSizeFactor To speed up the computation time NDAESolve includes an automatic step size control. If the deviations of the variable values from one time point to its succeeding time instant fulfill certain conditions the actual step size will be multiplied or divided by the value given by the option StepSizeFactor . The default setting is StepSizeFactor −> 1.5. Examples Consider the following diode rectifier circuit with a sinusoidal input voltage. 3.7 Numerical Analyses 299 D1 1 2 V0 C1 R1 Vout Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define netlist description of a simple diode rectifier circuit. In[2]:= rectifier = Circuit[ Netlist[ {V0, {1, 0}, Symbolic −> V0, Value −> 2. Sin[10^6 Time]}, {R1, {2, 0}, Symbolic −> R1, Value −> 100.}, {C1, {2, 0}, Symbolic −> C1, Value −> 1.*^−7}, {D1, {1 −> A, 2 −> C}, Model −> "Diode", Selector −> "Spice"} ] ] Out[2]= Circuit Set up system of symbolic time-domain equations. In[3]:= rectifiereqs = CircuitEquations[rectifier, AnalysisMode −> Transient, ElementValues −> Symbolic] Out[3]= DAETransient, 4 4 Display equations. In[4]:= DisplayForm[rectifiereqs] Out[4]//DisplayForm= V$2t I$AC$D1t I$V0t 0, I$AC$D1t C1 V$2 t 0, R1 TEMP 1.11 1. TNOM $q TEMP $k V$1t V0, I$AC$D1t AREA$D1 E 3. 1. $q V$1tV$2t TEMP TEMP $k 1 E IS$D1 GMIN V$1t V$2t, TNOM V$1t, V$2t, I$V0t, I$AC$D1t, DesignPoint V0 2. Sin1000000 t, R1 100., C1 1. 107 , AREA$D1 1., BV$D1 , CJO$D1 0, GMIN 1. 1012 , IBV$D1 0.001, IS$D1 1. 1014 , RS$D1 0, TEMP 300.15, TNOM 300.15, $k 1.38062 1023 , $q 1.60219 1019 Perform numerical DC analysis with NDAESolve . In[5]:= NDAESolve[rectifiereqs, {t, 0.}] Out[5]= V$2 0., V$1 0., I$V0 0., I$AC$D1 0. 3. Reference Manual 300 Perform numerical transient analysis with NDAESolve . In[6]:= tran = NDAESolve[rectifiereqs, {t, 0., 2.*^−5}] Display the simulation result. In[7]:= TransientPlot[tran, {V$1[t], V$2[t]}, {t, 0., 2.*^−5}] Out[6]= V$2 InterpolatingFunction0, 0.00002, , V$1 InterpolatingFunction0, 0.00002, , I$V0 InterpolatingFunction0, 0.00002, , I$AC$D1 InterpolatingFunction0, 0.00002, 2 1 V$1[t] -6 t 0.00001 0.000015 0.00002 5. 10 V$2[t] -1 -2 Out[7]= Graphics Perform numerical DC-transfer analysis with NDAESolve . In[8]:= dctran = NDAESolve[rectifiereqs, {t, 0., 1.*^−5}, AnalysisMode −> DC] Display the simulation result. In[9]:= TransientPlot[dctran, {V$1[t], V$2[t]}, {t, 0., 1.*^−5}] Out[8]= V$1 InterpolatingFunction0, 0.00001, , V$2 InterpolatingFunction0, 0.00001, , I$V0 InterpolatingFunction0, 0.00001, , I$AC$D1 InterpolatingFunction0, 0.00001, 2 1 V$1[t] -6 2. 10 -6 4. 10 -1 -2 Out[9]= Graphics t -60.00001 -6 6. 10 8. 10 V$2[t] 3.7 Numerical Analyses Perform parametric transient analysis with NDAESolve . 301 In[10]:= paramtran = NDAESolve[rectifiereqs, {t, 0., 2.*^−5}, {R1, Table[10^i, {i, 0, 3}]}] Out[10]= V$2 InterpolatingFunction0, 0.00002, , V$1 InterpolatingFunction0, 0.00002, , I$V0 InterpolatingFunction0, 0.00002, , I$AC$D1 InterpolatingFunction0, 0.00002, , SweepParameters R1 1., V$2 InterpolatingFunction0, 0.00002, , V$1 InterpolatingFunction0, 0.00002, , I$V0 InterpolatingFunction0, 0.00002, , I$AC$D1 InterpolatingFunction0, 0.00002, , SweepParameters R1 10., V$2 InterpolatingFunction0, 0.00002, , V$1 InterpolatingFunction0, 0.00002, , I$V0 InterpolatingFunction0, 0.00002, , I$AC$D1 InterpolatingFunction0, 0.00002, , SweepParameters R1 100., V$2 InterpolatingFunction0, 0.00002, , V$1 InterpolatingFunction0, 0.00002, , I$V0 InterpolatingFunction0, 0.00002, , I$AC$D1 InterpolatingFunction0, 0.00002, , SweepParameters R1 1000. By default, TransientPlot displays the solutions for all parameter sweep values within a single plot. Display the simulation result. In[11]:= TransientPlot[paramtran, {V$2[t]}, {t, 0., 2.*^−5}] 1.2 1 0.8 0.6 V$2[t] 0.4 0.2 t -6 0.00001 0.000015 0.00002 5. 10 Out[11]= Graphics Consider the following oscillator circuit with initial conditions at the time t . 3. Reference Manual 302 Vic 2 1 L1 C1 R1 Iout Define netlist description of a simple oscillator circuit. In[12]:= oscillator = Netlist[ {L1, {0, 1}, Symbolic {C1, {1, 2}, Symbolic InitialCondition −> {R1, {2, 0}, Symbolic ] −> L1, Value −> 1.*^−5}, −> C1, Value −> 3.*^−7, 2.*^−3}, −> R1, Value −> 1.} Out[12]= NetlistRaw, 3 Set up system of symbolic time-domain equations with initial conditions where given in the netlist. In[13]:= oscillatoreqs1 = CircuitEquations[oscillator, AnalysisMode −> Transient, ElementValues −> Symbolic, InitialConditions −> Automatic]; DisplayForm[oscillatoreqs1] Out[14]//DisplayForm= I$L1t C1 V$1 t V$2 t 0, V$2t C1 V$1 t V$2 t 0, V$1t L1 I$L1 t 0, R1 V$10 V$20 0.002, V$1t, V$2t, I$L1t, DesignPoint L1 0.00001, C1 3. 107 , R1 1. Set up system of symbolic time-domain equations with initial conditions for all dynamic netlist elements. In[15]:= oscillatoreqs2 = CircuitEquations[oscillator, AnalysisMode −> Transient, ElementValues −> Symbolic, InitialConditions −> All]; DisplayForm[oscillatoreqs2] Out[16]//DisplayForm= I$L1t C1 V$1 t V$2 t 0, V$2t C1 V$1 t V$2 t 0, R1 V$1t L1 I$L1 t 0, I$L10 0, V$10 V$20 0.002, V$1t, V$2t, I$L1t, DesignPoint L1 0.00001, C1 3. 107 , R1 1. Perform numerical transient analysis for both equation systems. In[17]:= tran1 = NDAESolve[oscillatoreqs1, {t, 0., 1.*^−4}]; tran2 = NDAESolve[oscillatoreqs2, {t, 0., 1.*^−4}]; 3.7 Numerical Analyses 303 With InitialConditions −> Automatic , initial conditions are applied only where specified in the netlist, all others are computed consistently. With InitialConditions −> All, initial conditions are set to zero for all elements for which there is no condition specified in the netlist. You can see the difference between both possibilities in the following two plots. Display the first simulation result. In[19]:= TransientPlot[tran1, {I$L1[t]}, {t, 0., 1.*^−4}, PlotRange −> All] 0.0015 0.001 0.0005 0.00002 0.00004 0.00006 0.00008 t 0.0001 I$L1[t] -0.0005 -0.001 -0.0015 -0.002 Out[19]= Graphics Display the second simulation result. In[20]:= TransientPlot[tran2, {I$L1[t]}, {t, 0., 1.*^−4}] 0.0002 0.0001 0.00002 0.00004 -0.0001 -0.0002 -0.0003 Out[20]= Graphics 0.00006 0.00008 t 0.0001 I$L1[t] 3. Reference Manual 304 3.8 Pole/Zero Analysis This chapter describes the Analog Insydes functions for numerical and symbolic pole/zero analysis by solving generalized eigenvalue problems (GEPs). The GEPs considered here have the form A ΛBu v A ΛB H where A and B are real-valued square matrices that arise from decomposing the coefficient matrix of a system of circuit equations Ts x b into the contributions from the static and the dynamic elements. Ts A sB In the above GEP, Λ is an eigenvalue, and u and v denote the right and left eigenvectors corresponding to Λ (vH denotes the Hermitian conjugate of v). In the following, the pairs Λ u and Λ v are referred to as (left and right) eigenpairs of the matrix pencil A B. Analog Insydes includes two different GEP solvers: an enhanced version of the QZ algorithm and a variant of the Jacobi orthogonal correction method (JOCM). The following table shows the available Analog Insydes functions for solving GEPs: GeneralizedEigensystem (Section 3.8.1) computing eigenvalues and eigenvectors by QZ GeneralizedEigenvalues (Section 3.8.2) computing eigenvalues by QZ PolesAndZerosByQZ (Section 3.8.3) computing poles and zeros by QZ PolesByQZ (Section 3.8.4) computing poles by QZ ZerosByQZ (Section 3.8.5) computing zeros by QZ RootLocusByQZ (Section 3.8.6) LREigenpair (Section 3.8.7) computing root locus by QZ computing eigenvalues and eigenvectors by JOCM 3.8 Pole/Zero Analysis 305 3.8.1 GeneralizedEigensystem GeneralizedEigensystem[A, B] computes the eigenvalues and the corresponding left and right eigenvectors of the matrix pencil A B Command structure of GeneralizedEigensystem . GeneralizedEigensytem computes the eigenvalues and the corresponding left and right eigenvectors of a matrix pencil A B by the QZ algorithm. The function returns a list of lists of the form {{lambda, v, u, iter}, † † † }, where lambda denotes a finite eigenvalue of A B, v and u the corresponding left and right eigenvectors, and iter the number of iterations the QZ algorithm needed to compute lambda. Note that this function is accessible only if the global Analog Insydes option UseExternals is set to True and if a native version of the external MathLink module QZ.exe is available for your machine (see Section 3.13.4). GeneralizedEigensystem has the following option: option name default value Normalize True whether to normalize the eigenvectors Option for GeneralizedEigensystem . Unless you specify Normalize −> False, the eigenvectors are scaled such that vi ui . See also: GeneralizedEigenvalues (Section 3.8.2), UseExternals (Section 3.14.7). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define two square real-valued matrices. In[2]:= A = {{1, 2}, {−3, 1}}; B = {{1, −1}, {0, 0}}; Compute the eigenvalues and eigenvectors of A B. In[4]:= eigsys = GeneralizedEigensystem[A, B] Get the eigenvalue and corresponding eigenvectors. In[5]:= {lambda, v, u, iter} = First[eigsys]; Out[4]= 3.5, 0.5547, 0.83205, 0.316228, 0.948683, 0 To show that lambda, v, and u are indeed solutions of the GEP within machine precision, we compute the L norms of the residual vectors rv and ru : 3. Reference Manual 306 rv vH A ΛB ru A ΛBu Compute the residual norms. In[6]:= {L2Norm[Conjugate[v].(A − lambda*B)], L2Norm[(A − lambda*B).u]} Out[6]= 4.57757 1016 , 3.29562 1016 3.8.2 GeneralizedEigenvalues GeneralizedEigenvalues[A, B] computes the eigenvalues of the matrix pencil A B where A and B must be real-valued square matrices Command structure of GeneralizedEigenvalues . GeneralizedEigenvalues computes the eigenvalues of a matrix pencil A B by the QZ algorithm. The function returns a list of the finite Λi that satisfy the GEP defined by A B. Note that this function is accessible only if the global Analog Insydes option UseExternals is set to True and if a native version of the external MathLink module QZ.exe is available for your machine (see Section 3.13.4). See also: GeneralizedEigensystem (Section 3.8.1), UseExternals (Section 3.14.7). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define two square real-valued matrices. In[2]:= A = {{1, 2}, {−3, 1}}; B = {{1, 4}, { 2, 1}}; Compute the eigenvalues of A B. In[4]:= GeneralizedEigenvalues[A, B] Out[4]= 0.514618, 1.94319 GeneralizedEigenvalues also works if some or all of the eigenvalues are complex and in the case where A or B are singular. Define two further B matrices. In[5]:= B2 = {{1, −5}, {2, 1}}; B3 = {{1, −1}, {0, 0}}; Compute the eigenvalues of A B . In[7]:= GeneralizedEigenvalues[A, B2] Compute the eigenvalues of A B . In[8]:= GeneralizedEigenvalues[A, B3] Out[7]= 0.772727 0.198132 I, 0.772727 0.198132 I Out[8]= 3.5 3.8 Pole/Zero Analysis 307 3.8.3 PolesAndZerosByQZ PolesAndZerosByQZ[dae, var] calculates the poles of the system described by the AC DAEObject dae and the zeros with respect to var Command structure of PolesAndZerosByQZ . To calculate the poles and zeros of a linear circuit, the coefficient matrix of the corresponding system of circuit equations must be decomposed into a matrix pencil A B. PolesAndZerosByQZ performs this decomposition and calls GeneralizedEigenvalues to compute the poles and zeros numerically. The argument dae must be an AC DAEObject written in matrix form (see CircuitEquations in Section 3.5.1). PolesAndZerosByQZ returns a list of rules of the form: {Poles −> {poles}, Zeros −> {zeros}} The return value can directly be used as input for RootLocusPlot for visualizing the pole/zero distribution. Calculating zeros requires the circuit to be a single-input system, i.e. the circuit must be excited by a single AC input source. Note that this function is accessible only if the global Analog Insydes option UseExternals is set to True and if a native version of the external MathLink module QZ.exe is available for your machine (see Section 3.13.4). See also: PolesByQZ (Section 3.8.4), ZerosByQZ (Section 3.8.5), RootLocusPlot (Section 3.9.5), UseExternals (Section 3.14.7). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Read in a PSpice netlist and small-signal data. In[2]:= buffer = ReadNetlist[ "AnalogInsydes/DemoFiles/Buffer.cir", "AnalogInsydes/DemoFiles/Buffer.out", Simulator −> "PSpice"] Out[2]= Circuit Set up a system of AC equations. In[3]:= mnabuffer = CircuitEquations[buffer, AnalysisMode −> AC] Out[3]= DAEAC, 18 18 3. Reference Manual 308 Calculate both poles and zeros with respect to the output voltage V$99 of the circuit. In[4]:= pz = PolesAndZerosByQZ[mnabuffer, V$99] Show the pole/zero distribution. In[5]:= RootLocusPlot[pz, LinearRegionLimit −> Infinity, PlotRange −> 5.0*^6] Out[4]= Poles 1.93945 1011 , 3.51956 1010 , 279586. 2.89305 106 I, 279586. 2.89305 106 I, 3.20148 106 , 3.22422 106 , 2.26133 109 , 1.31955 1010 , 6.86928 109 , 8.83669 109 , Zeros 1.31966 1010 , 7.47584 109 , 2.26016 109 , 1.52864 106 4.19572 106 I, 1.52864 106 4.19572 106 I, 2.98706 106 , 2.40024 106 , 1.59415 1011 , 2.1154 1011 4.95934 109 I, 2.1154 1011 4.95934 109 I Im s 6 4. 10 6 2. 10 6 -4. 10 6 6 -2. 10 2. 10 6 Re s 4. 10 6 -2. 10 6 -4. 10 Out[5]= Graphics 3.8.4 PolesByQZ PolesByQZ[dae] calculates the poles of the dynamic system described by the AC DAEObject dae Command structure of PolesByQZ. To calculate the poles of a linear circuit, the coefficient matrix of the corresponding system of circuit equations must be decomposed into a matrix pencil A B. PolesByQZ performs this decomposition and calls GeneralizedEigenvalues to compute the poles numerically. The argument dae must be an AC DAEObject written in matrix form (see CircuitEquations in Section 3.5.1). Note that this function is accessible only if the global Analog Insydes option UseExternals is set to True and if a native version of the external MathLink module QZ.exe is available for your machine (see Section 3.13.4). See also: PolesAndZerosByQZ (Section 3.8.3), ZerosByQZ (Section 3.8.5), UseExternals (Section 3.14.7). 3.8 Pole/Zero Analysis 309 Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Read in a PSpice netlist and small-signal data. In[2]:= buffer = ReadNetlist[ "AnalogInsydes/DemoFiles/Buffer.cir", "AnalogInsydes/DemoFiles/Buffer.out", Simulator −> "PSpice"] Out[2]= Circuit Set up a system of AC equations. In[3]:= mnabuffer = CircuitEquations[buffer, AnalysisMode −> AC] Calculate the poles of the circuit. In[4]:= PolesByQZ[mnabuffer] Out[3]= DAEAC, 18 18 Out[4]= 1.93945 1011 , 3.51956 1010 , 279586. 2.89305 106 I, 279586. 2.89305 106 I, 3.20148 106 , 3.22422 106 , 2.26133 109 , 1.31955 1010 , 6.86928 109 , 8.83669 109 3.8.5 ZerosByQZ ZerosByQZ[dae, var] calculates the zeros of the transfer function from the AC DAEObject dae to the output variable var Command structure of ZerosByQZ. To calculate the zeros of a linear circuit, the coefficient matrix of the corresponding system of circuit equations must be decomposed into a matrix pencil A B. ZerosByQZ performs this decomposition and calls GeneralizedEigenvalues to compute the zeros numerically. The argument dae must be an AC DAEObject written in matrix form (see CircuitEquations in Section 3.5.1). Calculating zeros requires the circuit to be a single-input system, i.e. the circuit must be excited by a single AC input source. Note that this function is accessible only if the global Analog Insydes option UseExternals is set to True and if a native version of the external MathLink module QZ.exe is available for your machine (see Section 3.13.4). See also: PolesAndZerosByQZ (Section 3.8.3), PolesByQZ (Section 3.8.4), UseExternals (Section 3.14.7). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ 3. Reference Manual 310 Read in a PSpice netlist and small-signal data. In[2]:= buffer = ReadNetlist[ "AnalogInsydes/DemoFiles/Buffer.cir", "AnalogInsydes/DemoFiles/Buffer.out", Simulator −> "PSpice"] Out[2]= Circuit Set up a system of AC equations. In[3]:= mnabuffer = CircuitEquations[buffer, AnalysisMode −> AC] Calculate the zeros of the circuit with respect to the output voltage V$99. In[4]:= ZerosByQZ[mnabuffer, V$99] Out[3]= DAEAC, 18 18 Out[4]= 1.31966 1010 , 7.47584 109 , 2.26016 109 , 1.52864 106 4.19572 106 I, 1.52864 106 4.19572 106 I, 2.98706 106 , 2.40024 106 , 1.59415 1011 , 2.1154 1011 4.95934 109 I, 2.1154 1011 4.95934 109 I 3.8.6 RootLocusByQZ RootLocusByQZ[dae, var, {k, k , k , incr}] calculates the root locus of the AC DAEObject dae as the parameter k is swept from k to k in steps of incr; zeros are calculated with respect to the output variable var Command structure of RootLocusByQZ. With RootLocusByQZ you can sweep a parameter of a linear system over an interval and calculate the root locus of the system directly from the corresponding circuit equations using the QZ algorithm. The argument dae has to be an AC DAEObject written in matrix form (see CircuitEquations in Section 3.5.1). RootLocusByQZ returns data in the following form: {{Poles −> {poles}, Zeros −> {zeros}, SweepParameters −> {k −> k0 }}, } The return value can directly be used as input for RootLocusPlot for visualizing the root locus. Note that this function is accessible only if the global Analog Insydes option UseExternals is set to True and if a native version of the external MathLink module QZ.exe is available for your machine (see Section 3.13.4). RootLocusByQZ has the following option: 3.8 Pole/Zero Analysis 311 option name default value Protocol Inherited[AnalogInsydes] standard Analog Insydes protocol specification (see Section 3.14.5) Option for RootLocusByQZ . See also: PolesAndZerosByQZ (Section 3.8.3), RootLocusPlot (Section 3.9.5), UseExternals (Section 3.14.7). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Read in a PSpice netlist and small-signal data. In[2]:= buffer = ReadNetlist[ "AnalogInsydes/DemoFiles/Buffer.cir", "AnalogInsydes/DemoFiles/Buffer.out", Simulator −> "PSpice"] Out[2]= Circuit Set up system of symbolic AC equations. In[3]:= mnabuffersym = CircuitEquations[buffer, AnalysisMode −> AC, ElementValues −> Symbolic] Out[3]= DAEAC, 18 18 Get the design-point value of Cbc$Q$T5 . In[4]:= Cbc$Q$T5 /. GetDesignPoint[mnabuffersym] Calculate root locus of the circuit as Cbc$Q$T5 is varied from pF to pF in steps of pF. In[5]:= rloc = RootLocusByQZ[mnabuffersym, V$99, {Cbc$Q$T5, 5.0*^−12, 50.0*^−12, 5.0*^−12}]; Out[4]= 8.39 1012 3. Reference Manual 312 Show the root locus. In[6]:= RootLocusPlot[rloc, LinearRegionLimit −> Infinity, PlotRange −> 5.0*^6] Cbc$Q$T5 = 5.000e-12 .. 5.000e-11 (0% .. 100%) Im s Poles 0% 6 4. 10 6 2. 10 100 6 6 -4. 10 -2. 10 6 2. 10 6 4. 10 Re s Zeros 0% 6 -2. 10 6 -4. 10 100 Out[6]= Graphics 3.8.7 LREigenpair LREigenpair[A, B, theta0] LREigenpair[dae, theta0] solves the GEP described by the matrix pencil A B for an eigenvalue Λ near the initial guess theta0 where A and B must be real-valued square matrices of equal dimensions solves the GEP defined by the coefficient matrix of the AC DAEObject dae for an eigenvalue Λ near theta0 Command structure of LREigenpair. As an alternative to the QZ algorithm, Analog Insydes provides the function LREigenpair for solving GEPs iteratively using a variant of the Jacobi orthogonal correction method. This approach is more efficient and reliable than the QZ algorithm for large GEPs when only one single eigenvalue is sought. In addition to the eigenvalue, LREigenpair also yields the corresponding left and right eigenvectors. The argument dae has to be an AC DAEObject written in matrix form (see CircuitEquations in Section 3.5.1). If the target eigenvalue is complex, the initial guess theta0 must also be a complex number. LREigenpair returns a list of the form {{lambda, v, u, rv , ru , iter}}, where lambda, v, and u denote the calculated eigenvalue and eigenvectors, rv and ru the corresponding L norms of the residual vectors 3.8 Pole/Zero Analysis 313 rv vH A ΛB ru A ΛBu The last return value, iter, denotes the number of iterations needed to compute lambda with the desired accuracy. LREigenpair has the following options: option name default value AccuracyGoal Round[0.5*$MachinePrecision] the accuracy goal for the sought eigenvalue DesignPoint Automatic the design-point values for the coefficients of dae FrequencyVariable Automatic the name of the variable that represents the complex frequency in dae InitialGuess Automatic initial guesses for the left and right eigenvectors MaxIterations 60 the maximum number of iterations for the Jacobi orthogonal correction method Options for LREigenpair, Part I. 3. Reference Manual 314 option name default value MaxResidual Automatic the maximum L norm of the residual vectors rv and ru Prescaling True whether to prescale the rows of the matrix pencil ProjectionVectors {LeftEigenvector, RightEigenvector} the projection vectors used by the Jacobi orthogonal correction method Protocol Inherited[AnalogInsydes] standard Analog Insydes protocol specification (see Section 3.14.5) Tolerance Infinity the maximum logarithmic distance between the initial guess theta0 and the calculated eigenvalue Λ Options for LREigenpair, Part II. See also: GeneralizedEigensystem (Section 3.8.1). Options Description A detailed description of all LREigenpair options is given below in alphabetical order: AccuracyGoal AccuracyGoal −> n specifies the desired accuracy of the sought eigenvalue in terms of the number of accurate significant digits. The value of AccuracyGoal is used to determine an appropriate setting for the MaxResidual option if MaxResidual −> Automatic . DesignPoint With DesignPoint −> dp, you can specify a list of design-point values for the coefficients of a symbolic system of circuit equations. The default setting DesignPoint −> Automatic causes LREigenpair to use the design-point information stored in dae. You can use the DesignPoint option to override design-point data stored in dae. FrequencyVariable LREigenpair needs to know the symbol which represents the complex frequency in order to be able to decompose the system of circuit equations dae into the matrices A and B. With 3.8 Pole/Zero Analysis 315 FrequencyVariable −> Automatic, the symbol is determined automatically from the status information stored in dae. You can specify the frequency variable manually with FrequencyVariable −> var. InitialGuess With InitialGuess −> {v0, u0}, you can specify initial guesses for the sought eigenvectors v and u. Both v0 and u0 must be real or complex-valued numeric vectors whose dimensions are compatible with dae. MaxIterations MaxIterations −> n specifies the maximum number of orthogonal correction iterations LREigenpair should use in order to find an eigenvalue and the corresponding eigenvectors. If LREigenpair fails to find solutions which satisfy the MaxResidual specification within n iterations, a warning is generated and the most recent iterates are returned. MaxResidual With MaxResidual −> maxres, you can set the convergence criterion for LREigenpair . The value maxres denotes the maximum L norm the residual vectors rv and ru may have such that the current set of iterates can be regarded as valid approximations of the sought eigenpairs. LREigenpair stops iterating as soon as both rv and ru fall below maxres. With the default setting MaxResidual −> Automatic , the maximum residual norm is computed as maxres AccuracyGoal /* / B A Note that the value of maxres depends on the setting of the Prescaling option because the norms of A and B are computed after prescaling. Prescaling With Prescaling −> True, LREigenpair scales the rows of the matrix pencil A B such that the absolute value of the largest coefficient in each row is 1. In general, prescaling improves the numerical properties of ill-conditioned GEPs and helps to reduce the number of iterations. Prescaling does not change the eigenvalues and eigenvectors of the matrix pencil. You can turn off prescaling by setting Prescaling −> False. ProjectionVectors Starting with a given initial guess * v u for the sought eigenvalue and eigenvectors, LREigenpair repeatedly solves the correction equation 3. Reference Manual 316 A *i B w̃ z r ỹH for updates z of u and v. The symbols w̃ and ỹ denote two arbitrary projection vectors, which must be chosen appropriately in each step to ensure convergence of the iterates. Suitable choices for w̃ and ỹ include combinations of the initial guesses and the most recent approximations of the eigenvectors v and u. With the option ProjectionVectors −> {wt, yt}, you can choose the vectors LREigenpair uses as projection vectors. Possible values are: LeftEigenvector RightEigenvector InitialLeftEigenvector InitialRightEigenvector the most recent approximation of the left eigenvector v the most recent approximation of the right eigenvector u the initial guess v for the left eigenvector the initial guess u for the right eigenvector Values for the ProjectionVectors option. In most cases, the default setting ProjectionVectors −> {LeftEigenvector, RightEigenvector} constitutes an appropriate choice. You will need to change the setting of this option only if you encounter convergence problems. Tolerance Tolerance −> tol specifies the radius of the tolerance region around the initial guess theta0 in which the sought eigenvalue Λ should lie. LREigenpair generates a warning if it converges to an eigenvalue that lies outside the tolerance region. The Tolerance option allows you to check whether LREigenpair has found the eigenvalue you wished to compute or whether the iterations have converged to a completely different solution. Tolerance uses a logarithmic measure for distances. For example, Tolerance −> 1.0 allows the value of the solution Λ to lie within and times the value of the initial guess theta0. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define three square real-valued matrices. In[2]:= A = {{1, 2}, {−3, 1}}; B = {{1, 4}, { 2, 1}}; B2 = {{1, −1}, {0, 0}}; Solve the GEP A B iteratively using the initial guess theta . In[5]:= LREigenpair[A, B2, −3.0] Out[5]= 3.5, 0.5547, 0.83205, 0.316228, 0.948683, 9.48575 1016 , 1.17657 1015 , 5 3.8 Pole/Zero Analysis 317 Solve the GEP A B. Specify initial guesses for the eigenvectors. In[6]:= LREigenpair[A, B, −1., InitialGuess −> {{0, 1}, {1, 0}}] Use the default projection vectors. In[7]:= LREigenpair[A, B, 1., MaxResidual −> 1.*^−15] Out[6]= 1.94319, 0.288369, 0.957519, 0.957519, 0.288369, 5.05207 1010 , 8.70217 1010 , 4 Out[7]= 0.514618, 0.992822, 0.1196, 0.1196, 0.992822, 2.23773 1016 , 2.48253 1016 , 4 Note that the following setting for ProjectionVectors increases the number of iterations. Use right eigenvectors as projection vectors. In[8]:= LREigenpair[A, B, 1., MaxResidual −> 1.*^−15, ProjectionVectors −> {RightEigenvector, RightEigenvector}] Out[8]= 0.514618, 0.992822, 0.1196, 0.1196, 0.992822, 0., 4.04127 1016 , 5 The setting Tolerance −> 1.0 allows the value of the solution Λ to lie within and times the value of the initial guess theta0. Search for an eigenvalue in the interval In[9]:= LREigenpair[A, B, −100., Tolerance −> 1.] LREigenpair::tolx: Eigenvalue lies outside the specified tolerance region. Out[9]= 1.94319, 0.288369, 0.957519, 0.957519, 0.288369, 2.70895 1011 , 4.66522 1011 , 6 With the default setting Tolerance −> Infinity , any solution of the GEP is accepted without a warning. Do not specify a tolerance region. In[10]:= LREigenpair[A, B, −100., Tolerance −> Infinity] Read in a PSpice netlist and small-signal data. In[11]:= buffer = ReadNetlist[ "AnalogInsydes/DemoFiles/Buffer.cir", "AnalogInsydes/DemoFiles/Buffer.out", Simulator −> "PSpice"] Out[10]= 1.94319, 0.288369, 0.957519, 0.957519, 0.288369, 2.70895 1011 , 4.66522 1011 , 6 Out[11]= Circuit Set up a system of symbolic AC equations. In[12]:= mnabuffersym = CircuitEquations[buffer, AnalysisMode −> AC, ElementValues −> Symbolic] Out[12]= DAEAC, 18 18 3. Reference Manual 318 Find the pole of the buffer circuit near theta i and the corresponding left and right eigenvectors. In[13]:= lreigenpairs = LREigenpair[mnabuffersym, 3.0*^6 I] Show the eigenvalue. In[14]:= lreigenpairs[[1, 1]] Out[13]= 279586. 2.89305 106 I, 1.70056 1018 2.18582 1018 I, 0.101704 0.218124 I, 0.0281952 0.414952 I, 0.175266 0.0104981 I, 1.70111 1018 2.18582 1018 I, 0.177763 0.0195432 I, 0.000145936 0.000121065 I, 0.177854 0.0196025 I, 0.175419 0.0103065 I, 0.175107 0.0106381 I, 0.0284306 0.414988 I, 0.0281891 0.414953 I, 0.175267 0.0105033 I, 0.0281827 0.414949 I, 0.175266 0.0104982 I, 0.177756 0.019539 I, 0.0000145936 0.0000121065 I, 0.0000145936 0.0000121065 I, 9.51237 1019 4.50366 1019 I, 0.055128 0.256781 I, 0.108991 0.0369544 I, 0.0952012 0.0116717 I, 9.51493 1019 4.50349 1019 I, 0.109187 0.515199 I, 0.000239817 0.0000548798 I, 0.108876 0.515278 I, 0.0952466 0.0115085 I, 0.0952183 0.0115916 I, 0.10892 0.0367968 I, 0.108987 0.0369774 I, 0.0952038 0.0116972 I, 0.109 0.0369492 I, 0.0951948 0.011671 I, 0.109209 0.515193 I, 0.0000239817 5.48798 106 I, 0.0000239817 5.48798 106 I, 3.61927 1013 , 6.03057 1012 , 4 Out[14]= 279586. 2.89305 106 I Compare the eigenvalue with the result of the QZ algorithm. In[15]:= Cases[PolesByQZ[mnabuffersym], _Complex] Out[15]= 279586. 2.89305 106 I, 279586. 2.89305 106 I 3.8.8 ApproximateDeterminant ApproximateDeterminant[dae, lambda, error] approximates the equations dae with respect to the pole closest to the initial guess lambda where dae has to be an AC DAEObject and error has to be a positive real value ApproximateDeterminant[dae, zvar, lambda, error] approximates the equations dae with respect to the zero of the transfer function from the input signal to the output zvar Command structure of ApproximateDeterminant . With ApproximateDeterminant you can approximate a linear symbolic matrix equation Ts x b directly with respect to a particular eigenvalue Λ (a pole or a zero). By discarding all terms which have little or no influence on Λ, ApproximateDeterminant reduces both the complexity and the degree of the characteristic polynomial Ps det Ts. Provided that the eigenvalue of interest is located sufficiently far apart from other eigenvalues, the polynomial degree can be reduced to if Λ 3.8 Pole/Zero Analysis 319 is real or if Λ is complex. The argument dae must be an AC DAEObject written in matrix form (see CircuitEquations in Section 3.5.1). The following options can be used with ApproximateDeterminant : option name default value AccuracyGoal Round[0.5*$MachinePrecision] the desired numerical accuracy of numerical computations DesignPoint Automatic the design-point values for the coefficients of dae ErrorFunction Automatic the function to be used for calculating the approximation error FrequencyVariable Automatic the symbol which denotes the complex Laplace frequency GEPSolver LREigenpair the GEP solver to be used for calculating the initial reference solution GEPSolverOptions Automatic options which are passed to the GEP solver Options for ApproximateDeterminant , Part I. 3. Reference Manual 320 option name default value InitialSolution Automatic the initial reference solution MaxDivergentSteps 1 the maximum number of divergent iterations allowed in the error tracking process MaxIterations 3 the maximum number of eigenvalue correction iterations allowed in each error tracking step MaxResidual Automatic the convergence criterion for the error tracking iterations MaxShift 1.0 the maximum relative eigenvalue sensitivity a matrix entry may have to be considered as a candidate for removal MinMAC 0.95 the minimum MAC value between the original eigenvector and the corresponding eigenvector of the approximated system Options for ApproximateDeterminant , Part II. 3.8 Pole/Zero Analysis 321 option name default value Prescaling True ProjectionVectors {LeftEigenvector, RightEigenvector} the projection vectors used by the Jacobi orthogonal correction method Protocol Inherited[AnalogInsydes] standard Analog Insydes protocol specification (see Section 3.14.5) SingularityTest SingularityTestByLU whether to prescale the rows of the matrix pencil the function used to determine whether an approximated matrix is singular TestFrequency 1. the frequency or point in the complex plane at which singularity tests are performed Tolerance 0.05 the maximum logarithmic distance between the initial guess and the calculated eigenvalue Λ Options for ApproximateDeterminant , Part III. See also: GeneralizedEigensystem (Section 3.8.1), LREigenpair (Section 3.8.7). Options Description A detailed description of all ApproximateDeterminant options is given below in alphabetical order: AccuracyGoal AccuracyGoal −> n specifies the desired accuracy of the sought eigenvalue in terms of the number of accurate significant digits. The value of AccuracyGoal is used to determine an appropriate setting for the MaxResidual option if MaxResidual −> Automatic . See also LREigenpair (Section 3.8.7). DesignPoint With DesignPoint −> dp, you can specify a list of design-point values for the coefficients of a symbolic system of circuit equations. The default setting DesignPoint −> Automatic causes ApproximateDeterminant to use the design-point information stored in dae. You can use the DesignPoint option to override design-point data stored in dae. 3. Reference Manual 322 ErrorFunction ErrorFunction −> func specifies the function to be used for calculating the error of an approximated eigenvalue with respect to the reference solution. The following values are allowed: Automatic select the error function according to the properties of the eigenvalue of interest: use LogError for real eigenvalues and DirectedLogError for complex ones LogError yields the logarithmic difference of the magnitudes of two eigenvalues; most suitable for real eigenvalues DirectedLogError similar to LogError , but takes into account the phases of complex numbers; most suitable for complex eigenvalues Values for the ErrorFunction option. FrequencyVariable ApproximateDeterminant needs to know the symbol which represents the complex frequency in order to be able to decompose the system of circuit equations dae into the matrices A and B. With FrequencyVariable −> Automatic , the symbol is determined automatically from the status information stored in dae. You can specify the frequency variable manually with FrequencyVariable −> var. GEPSolver With GEPSolver −> func, you can select the GEP solver ApproximateDeterminant uses to calculate the initial reference solution. Possible option values are: GeneralizedEigensystem use the QZ algorithm for computing the reference solution LREigenpair use the Jacobi orthogonal correction method for computing the reference solution Values for the GEPSolver option. GEPSolverOptions With GEPSolverOptions −> opts, you can specify a list of option settings that will be passed to the selected GEP solver, for example: GEPSolverOptions −> {MaxResidual −> 1.*^−7, MaxIterations −> 100} 3.8 Pole/Zero Analysis 323 Note that you may also change the option settings of the selected GEP solver directly with SetOptions[gepsolver, opts]. However, with GEPSolverOptions , you can specify private option settings which will only be used in conjunction with ApproximateDeterminant . InitialSolution With InitialSolution −> initsol, you can specify the initial reference solution for the GEP to be approximated. The value of InitialSolution must be given in the same format as the return value of LREigenpair (Section 3.8.7). Possible values are: Automatic {lambda , v , u , † † † } compute the initial reference solution using the GEP solver specified with GEPSolver use the given initial reference solution Values for the InitialSolution option. MaxDivergentSteps MaxDivergentSteps −> n specifies the maximum number of divergent iterations allowed in the error tracking step following the elimination of a matrix entry. Iterates are considered divergent if the residual of the numerical solution of the GEP becomes larger between two consecutive steps. If the number of divergent steps exceeds the specified maximum in the error tracking process, ApproximateDeterminant aborts the iterations, reinserts the current term into the matrix, and continues with the next term. MaxIterations MaxIterations −> n specifies the maximum number of error tracking iterations performed after removing a matrix entry. An approximation is considered valid if the iterations converge within n steps, and if both the MaxResidual and MinMAC specifications are satisfied. See also LREigenpair (Section 3.8.7). If you set GEPSolver −> LREigenpair , note that the MaxIterations setting given for ApproximateDeterminant is not passed to LREigenpair . To specify the maximum number of iterations for the GEP solver, change the value of GEPSolverOptions . MaxResidual MaxResidual −> posreal specifies the convergence criterion for the error tracking iterations. MaxResidual is one of the key options you should play with in order to obtain good results from ApproximateDeterminant . You should choose the value as large as possible to allow for a reason- 3. Reference Manual 324 able error but small enough to prevent the iterations from “converging” to an arbitrary value. This may require some experimentation. See also LREigenpair (Section 3.8.7). The value of MaxResidual depends on the setting of the Prescaling option. If you set GEPSolver −> LREigenpair , note that the MaxIterations setting given for ApproximateDeterminant is not passed to LREigenpair . To specify the maximum residual for the GEP solver, change the value of GEPSolverOptions . MaxShift MaxShift −> posreal restricts the list of matrix entries which are candidates for removal to those entries with a eigenvalue sensitivity figure less than posreal. With MaxShift −> 1.0, a term will be considered for removal if the eigenvalue shift caused by removing the term has been predicted to be less than . To restrict the list of matrix entries to terms with small eigenvalue sensitivities, use a setting such as MaxShift −> 0.1. MinMAC MinMAC −> posreal specifies the minimum allowed value of the modal assurance criterion between the right eigenvector of the original GEP, u, and the right eigenvector of the approximated GEP, u+ . The MAC between u and u+ constitutes a measure for the correlation of the two eigenvectors. It is defined as + MAC u u uH u+ H +H u u u u+ The value of the MAC ranges from to . A value of means that one eigenvector is a multiple of the other. A value of means that the two vectors are completely uncorrelated. The use of the MAC helps to prevent ApproximateDeterminant from accidentally converging to some other eigenvalue than the one of interest. For corresponding eigenpairs of the original and approximated GEP, the value of the MAC should be close to , say MAC , whereas the MAC between the eigenvector of the original GEP and some other eigenvector of the approximated system should be small. ApproximateDeterminant considers an approximation step as invalid if the MAC between the two eigenvectors falls below the value of MinMAC. Prescaling With Prescaling −> True, ApproximateDeterminant scales the rows of the matrix pencil A B such that the absolute value of the largest coefficient in each row is 1. In general, prescaling improves the numerical properties of ill-conditioned GEPs and helps to reduce the number of iterations. 3.8 Pole/Zero Analysis 325 Prescaling does not change the eigenvalues and eigenvectors of the matrix pencil. You can turn off prescaling by setting Prescaling −> False. The value of Prescaling has an influence on the required setting of the MaxResidual option. If you set GEPSolver −> LREigenpair , note that the Prescaling setting given for ApproximateDeterminant is not passed to LREigenpair . To turn on prescaling for the GEP solver, change the value of GEPSolverOptions . ProjectionVectors With the option ProjectionVectors −> {wt, yt}, you can choose the vectors ApproximateDeterminant uses as projection vectors for the Jacobi orthogonal correction method (JOCM) during error tracking operations: Starting with a given initial guess * v u for the sought eigenvalue and eigenvectors, the JOCM repeatedly solves the correction equation A *i B w̃ z r ỹH for updates z of u and v. The symbols w̃ and ỹ denote two arbitrary projection vectors, which must be chosen appropriately in each step to ensure convergence of the iterates. Suitable choices for w̃ and ỹ include combinations of the initial guesses and the most recent approximations of the eigenvectors v and u. Possible settings for the ProjectionVectors option are: LeftEigenvector RightEigenvector InitialLeftEigenvector InitialRightEigenvector the most recent approximation of the left eigenvector v the most recent approximation of the right eigenvector u the initial guess v for the left eigenvector the initial guess u for the right eigenvector Values for the ProjectionVectors option. In most cases, the default setting ProjectionVectors −> {LeftEigenvector, RightEigenvector} constitutes an appropriate choice. You will need to change the setting of this option only if you encounter convergence problems. See also Section 3.8.7. 3. Reference Manual 326 If you set GEPSolver −> LREigenpair , note that the ProjectionVectors setting given for ApproximateDeterminant is not passed to LREigenpair . To choose the projection vectors for the GEP solver, change the value of GEPSolverOptions . SingularityTest After each approximation step, ApproximateDeterminant applies a singularity test to the matrix A s B to ensure that removing a matrix entry has not rendered the GEP singular. The singularity test is performed by numerical computation of the rank of A s B for some s " C which is not an eigenvalue of the GEP. However, there is no guarantee that numerical rank computation always yields a mathematically correct result. This may cause singularity to remain undetected in some situations, particularly when the GEP is ill-conditioned. With the option SingularityTest , you can select the function ApproximateDeterminant uses to determine whether the GEP is singular. If you encounter singularity problems, i.e. if detA s B after approximating a system of circuit equations, then you should change the value of SingularityTest and rerun the approximation. The possible values for SingularityTest are: SingularityTestByLU perform singularity tests by rank computation using LUDecomposition SingularityTestByQR perform singularity tests by rank computation using QRDecomposition Function[{M}, expr] specify a user-defined function which returns True if the complex-valued floating-point matrix M is singular Values for the SingularityTest option. TestFrequency With the option TestFrequency , you can specify the value of the complex frequency variable s which is used for testing whether the numerical matrix A s B is singular. For best numerical accuracy and computing performance, it is recommended that you choose a real value of the same order of magnitude as the modulus of the target eigenvalue. For example, if you wish to approximate a GEP with respect to an eigenvalue s j , then the option setting TestFrequency −> 1.0*^8 constitutes an appropriate choice. The point in the complex plane represented by the value of TestFrequency should not lie in the neighborhood of any eigenvalue of the GEP to be approximated. An inappropriate choice of the test frequency may result in ill-conditioned rank computation problems. 3.8 Pole/Zero Analysis 327 Tolerance Tolerance −> tol specifies the radius of the tolerance region around the initial guess theta0 in which the sought eigenvalue Λ should lie. ApproximateDeterminant generates a warning if it converges to an eigenvalue that lies outside the tolerance region. The Tolerance option allows you to check whether ApproximateDeterminant has found the eigenvalue you wished to compute or whether the iterations have converged to a completely different solution. Tolerance uses a logarithmic measure for distances. For example, Tolerance −> 1.0 allows the value of the solution Λ to lie within and times the value of the initial guess theta0. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define an AC model for BJTs. In[2]:= Circuit[ Model[ Name −> BJT, Selector −> AC, Scope −> Global, Ports −> {B, C, E}, Parameters −> {Rbe, Cbc, Cbe, beta, Ro, RBE, CBC, CBE, BETA, RO}, Definition −> Netlist[ {CBE, {B, E}, Symbolic −> Cbe, Value −> CBE}, {RBE, {X, E}, Symbolic −> Rbe, Value −> RBE}, {CBC, {B, C}, Symbolic −> Cbc, Value −> CBC}, {CC, {B, X, C, E}, Symbolic −> beta, Value −> BETA}, {RO, {C, E}, Symbolic −> Ro, Value −> RO} ] ] ] // ExpandSubcircuits; This netlist describes a common-emitter amplifier. In[3]:= ceamplifier = Circuit[ Netlist[ {V1, {1, 0}, 1}, {V0, {6, 0}, 0}, {C1, {1, 2}, Symbolic −> C1, Value {R1, {2, 6}, Symbolic −> R1, Value {R2, {2, 0}, Symbolic −> R2, Value {RC, {6, 3}, Symbolic −> RC, Value {RE, {4, 0}, Symbolic −> RE, Value {C2, {3, 5}, Symbolic −> C2, Value {RL, {5, 0}, Symbolic −> RL, Value {Q1, {2 −> B, 3 −> C, 4 −> E}, Model −> BJT, Selector −> AC, CBE −> 30.*^−12, CBC −> 5.*^−12, RO −> 10000., BETA −> 200.} ] ] Out[3]= Circuit −> −> −> −> −> −> −> 1.0*^−7}, 1.0*^5}, 47000.}, 2200.}, 1000.}, 1.0*^−6}, 47000.}, RBE −> 1000., 3. Reference Manual 328 Set up system of symbolic AC equations. In[4]:= eqs = CircuitEquations[ceamplifier, ElementValues −> Symbolic] Out[4]= DAEAC, 10 10 Calculate poles and zeros of the voltage transfer function. In[5]:= pz = PolesAndZerosByQZ[eqs, V$5] Show the pole/zero distribution. In[6]:= RootLocusPlot[pz, LinearRegionLimit −> 100, PlotRange −> 5.0*^10] Out[5]= Poles 20.4778, 375.176, 9.50936 107 , 6.75675 109 , Zeros 0., 1.35569 1027 , 1.91793 108 , 6.94846 109 Im s 1.0E8 1.0E5 100. -1.0E8-1.0E5 -100. 100. 1.0E5 1.0E8 Re s -100. -1.0E5 -1.0E8 Out[6]= Graphics The numerical pole/zero analysis shows that the characteristic polynomial of the equations has a degree of four because the amplifier has four poles. Although polynomial equations with a degree up to four can be solved analytically, the resulting expressions are usually very complex if the degree is greater than two. Therefore, we use ApproximateDeterminant to compute simplified formulas for the poles. We begin by computing an approximate expression for the pole near s . The logarithmic error bound specification corresponds to a tolerance region from to of the design-point value p . Approximate the equations with respect to p using the QZ algorithm for computing the reference solution. In[7]:= sbgp2 = ApproximateDeterminant[eqs, −400, 0.05, MaxIterations −> 4, GEPSolver −> GeneralizedEigensystem] Out[7]= DAEAC, 10 10 To check if the algorithm has successfully isolated the pole of interest, we compute the poles of the approximated system. Compute the remaining poles numerically. In[8]:= PolesByQZ[sbgp2] Estimate the number of remaining terms. In[9]:= ComplexityEstimate[sbgp2] Out[8]= 0., 362.766 Out[9]= 4 3.8 Pole/Zero Analysis Show complexity of original system. 329 In[10]:= ComplexityEstimate[eqs] Out[10]= 132 The result shows that the algorithm has eliminated the two high-frequency poles and has approximated the low-frequency pole p near s by zero. On the contrary, the pole p has been preserved, and its numerical value lies in the specified tolerance region. In addition, the complexity of the characteristic polynomial has been greatly reduced. Therefore, we can expect to obtain an interpretable formula for p . Compute the approximated characteristic polynomial. In[11]:= detp2 = Det[GetMatrix[sbgp2]] // Together Solve for the poles. In[12]:= sbgpoles = Solve[detp2 == 0, s] Out[11]= C2 R1 R2 s beta$Q1 C2 R1 RE s beta$Q1 C2 R2 RE s beta$Q1 C1 C2 R1 R2 RE s2 R1 R2 Rbe$Q1 RC RE Out[12]= R1 R2 beta$Q1 R1 RE beta$Q1 R2 RE s 0, s beta$Q1 C1 R1 R2 RE Extract the pole of interest. In[13]:= p2 = s /. Last[sbgpoles] // Simplify 1 1 1 R1 R2 beta$Q1 RE Out[13]= C1 Next, we try to extract the right-half plane zero z near s . Approximate the equations with respect to z . In[14]:= sbgz3 = ApproximateDeterminant[eqs, V$5, 2.0*^8, 0.05, GEPSolver −> GeneralizedEigensystem] Out[14]= DAEAC, 10 10 Compute the remaining zeros numerically. In[15]:= ZerosByQZ[sbgz3, V$5] Compute the approximated polynomial. In[16]:= detz3 = Det[GetMatrix[sbgz3]] // Simplify Solve for the zeros. In[17]:= sbgzeros = Solve[detz3 == 0, s] Out[15]= 0., 0., 2. 108 beta$Q1 C1 C2 s2 1 Cbc$Q1 RE s Out[16]= Rbe$Q1 RE 1 Out[17]= s 0, s 0, s Cbc$Q1 RE Extract the zero of interest. In[18]:= z3 = s /. Last[sbgzeros] 1 Out[18]= Cbc$Q1 RE 3. Reference Manual 330 3.9 Graphics Functions Analog Insydes extends Mathematica’s graphics functionality by several custom functions for producing frequently used graphs in circuit design. The package provides special functionality for displaying the following types of plots: BodePlot (Section 3.9.1) FourierPlot (Section 3.9.2) NicholPlot (Section 3.9.3) NyquistPlot (Section 3.9.4) Bode plot (frequency response: magnitude and phase vs. frequency) Fourier spectrum plot (frequency spectrum: spectral magnitude vs. frequency) Nichol plot (frequency response: gain vs. phase) Nyquist plot (frequency response: imaginary vs. real part) RootLocusPlot (Section 3.9.5) pole/zero and root locus plot (parameter response: imaginary vs. real part) TransientPlot (Section 3.9.6) transient waveform plot (signal value vs. time) 3.9.1 BodePlot BodePlot[func, {var, f , f }] displays a Bode plot of the transfer function func[var] as the independent variable var is swept from f to f BodePlot[{func , func , † † † }, {var, f , f }] displays the transfer functions func , func , † † † simultaneously in a Bode plot Command structure of BodePlot. BodePlot displays one or several transfer functions in a Bode plot. A Bode plot consists of two separate charts in which the magnitude and phase of a transfer function are plotted vs. frequency. Magnitude and phase are displayed, respectively, on logarithmic and linear scales. The frequency axis is scaled logarithmically for both charts. Note that BodePlot has attribute HoldFirst . BodePlot supports additional patterns for displaying numerical data generated with the functions ACAnalysis (Section 3.7.3), NoiseAnalysis (Section 3.7.4), or ReadSimulationData (Section 3.10.3): 3.9 Graphics Functions 331 BodePlot[traces, {var, f , f }] displays a list of AC traces computed with e.g. ACAnalysis in a Bode plot BodePlot[traces, expr, {var, f , f }] displays the value of an expression in terms of AC traces BodePlot[traces, {expr , expr , † † † }, {var, f , f }] displays the values of several expressions Displaying numerical data with BodePlot. You can customize the appearance of Bode plots with the options listed below. In addition, BodePlot inherits many options from LogLinearListPlot and Legend. Both the options which are specific to BodePlot as well as the inherited options can be set with SetOptions[BodePlot, opts]. option name default value AspectRatio 0.75 the aspect ratio of the whole plot AspectFactor 0.8 a correction factor by which the aspect ratios of the magnitude and phase plots are multiplied so as to fill the individual plot areas optimally FrequencyScaling Exponential whether to distribute sampling points exponentially or linearly along the frequency axis GraphicsSpacing 0.05 the distance between the magnitude and the phase plot in percent of the total plot height MagnitudeDisplay Decibels how to scale and display magnitude values Options for BodePlot, Part I. 3. Reference Manual 332 option name default value PhaseDisplay Degrees whether to display phase traces and which unit to use for phase values PlotPoints 25 the number of frequency sampling points PlotRange Automatic the plot ranges for the magnitude and the phase plot ShowLegend True whether to display a plot legend TraceNames Automatic the trace names displayed in the plot legend UnwrapPhase True whether to unwrap phase traces UnwrapTolerance 0.2 the maximum relative difference between two successive phase values that triggers phase unwrapping Options for BodePlot, Part II. See also: ACAnalysis (Section 3.7.3), NoiseAnalysis (Section 3.7.4), ReadSimulationData (Section 3.10.3), NicholPlot (Section 3.9.3), NyquistPlot (Section 3.9.4). Options Description A detailed description of all options that are specific to BodePlot or are used in a non-standard way is given below in alphabetical order: FrequencyScaling The option FrequencyScaling determines how sampling points are distributed over the frequency axis. Possible values are: Exponential Linear use exponentially spaced sampling points use linearly spaced sampling points Values for the FrequencyScaling option. MagnitudeDisplay With the option MagnitudeDisplay , you can specify how magnitude values are displayed in a Bode plot. The following values are allowed: 3.9 Graphics Functions 333 Decibels AbsoluteValues Linear convert magnitude values to decibels show absolute magnitude values on a logarithmic scale show magnitude values on a linear scale Values for the MagnitudeDisplay option. PhaseDisplay The option PhaseDisplay specifies whether and how to display phase values. Possible choices are: Degrees display phase values in degrees Radians display phase values in radians None suppress the phase plot Values for the PhaseDisplay option. PlotRange With the PlotRange option, you can set the plot ranges for the y-axes of the magnitude and phase plots. Possible values are: Automatic {magrng, phsrng} determine the plot ranges automatically specify plot ranges for magnitude and phase plot; the values of magrng and phsrng can be Automatic , All, or {ymin, ymax} Values for the PlotRange option. TraceNames The option TraceNames allows you to specify the labels that are shown in the plot legend for the displayed traces if ShowLegend −> True. The following values are possible: 3. Reference Manual 334 Automatic string or expr {string, † † † } or {expr, † † † } use trace names from AC sweeps computed with e.g. ACAnalysis the name for a single trace names for all traces; the number of names must equal the number of traces Values for the TraceNames option. UnwrapPhase With the option UnwrapPhase , you can specify whether BodePlot should restrict phase values to the interval or try to unwrap the phase values of a frequency response trace that wraps around the origin of the complex plane more than once. UnwrapTolerance With UnwrapTolerance −> tol, you can specify the maximum percentage of a full revolution by which two successive phase values may differ such that phase unwrapping is triggered. Examples In[1]:= <<AnalogInsydes‘ Define two transfer functions. In[2]:= H1[s_] := 1/(s + 1); H2[s_] := 10/(s^2 + s + 10) This produces a Bode plot of H jΩ. In[4]:= BodePlot[H1[I w], {w, 0.01, 100}] Phase (deg) Magnitude (dB) Load Analog Insydes. 1.0E-2 0 1.0E-1 1.0E0 1.0E1 1.0E2 -40 1.0E-2 1.0E-1 1.0E0 Frequency 1.0E1 1.0E2 1.0E-2 0 1.0E-1 1.0E0 1.0E1 1.0E2 1.0E-1 1.0E0 Frequency 1.0E1 1.0E2 -10 -20 -30 -20 -40 -60 -80 1.0E-2 Out[4]= Graphics 3.9 Graphics Functions In[5]:= BodePlot[{H1[I w], H2[I w]}, {w, 0.01, 100}] Phase (deg) Magnitude (dB) This produces a Bode plot of H jΩ and H jΩ. 335 1.0E-2 10 0 -10 -20 -30 -40 -50 -60 1.0E-2 1.0E-2 0 -25 -50 -75 -100 -125 -150 -175 1.0E-2 1.0E-1 1.0E0 1.0E1 1.0E2 1.0E-1 1.0E0 Frequency 1.0E1 1.0E2 1.0E-1 1.0E0 1.0E1 1.0E2 1.0E-1 1.0E0 Frequency 1.0E1 1.0E2 Out[5]= Graphics This defines an RLC filter circuit. In[6]:= rlcf = {V1, {R1, {L1, {C1, {R2, ]; Set up modified nodal equations. In[7]:= eqsrlcf = CircuitEquations[rlcf] Do an AC analysis from Hz to MHz. In[8]:= acsweep = ACAnalysis[eqsrlcf, {f, 10, 10^6}] Increase the number of plot points. In[9]:= SetOptions[BodePlot, PlotPoints −> 200]; Netlist[ {1, 0}, Symbolic {1, 2}, Symbolic {2, 3}, Symbolic {3, 0}, Symbolic {3, 0}, Symbolic −> −> −> −> −> V, R1, L, C, R2, Value Value Value Value Value −> −> −> −> −> 1}, 1000.}, 0.001}, 2.2*10^−6}, 1000.} Out[7]= DAEAC, 4 4 Out[8]= V$1 InterpolatingFunction10., 1. 106 , , V$2 InterpolatingFunction10., 1. 106 , , V$3 InterpolatingFunction10., 1. 106 , , I$V1 InterpolatingFunction10., 1. 106 , 3. Reference Manual 336 Magnitude (dB) In[10]:= BodePlot[acsweep, {f, 10, 10^6}] 1.0E1 0 -20 -40 -60 -80 -100 1.0E1 1.0E2 1.0E3 1.0E4 1.0E5 1.0E6 1.0E2 1.0E3 1.0E4 Frequency 1.0E5 1.0E6 1.0E1 0 -50 -100 -150 -200 -250 -300 -350 1.0E1 1.0E2 1.0E3 1.0E4 1.0E5 1.0E6 Phase (deg) Display all traces in a Bode plot. 1.0E2 1.0E3 1.0E4 Frequency 1.0E5 1.0E6 V$1 V$2 V$3 I$V1 Out[10]= Graphics Magnitude (dB) In[11]:= BodePlot[acsweep, {V$2[f], V$3[f]}, {f, 10, 10^6}] 1.0E1 0 -20 -40 -60 -80 -100 1.0E1 1.0E2 1.0E3 1.0E4 1.0E5 1.0E6 1.0E2 1.0E3 1.0E4 Frequency 1.0E5 1.0E6 1.0E1 0 -50 -100 -150 -200 -250 -300 -350 1.0E1 1.0E2 1.0E3 1.0E4 1.0E5 1.0E6 Phase (deg) Display only the traces V$2[f] and V$3[f]. 1.0E2 1.0E3 1.0E4 Frequency 1.0E5 1.0E6 V$2[f] Out[11]= Graphics V$3[f] 3.9 Graphics Functions In[12]:= BodePlot[acsweep, {V$2[f], V$2[f]−V$3[f]}, {f, 10, 10^6}] Phase (deg) Magnitude (dB) Display the traces V$2[f] and V$2[f]−V$3[f] . 337 1.0E1 0 1.0E2 1.0E3 1.0E4 1.0E5 1.0E6 1.0E2 1.0E3 1.0E4 Frequency 1.0E5 1.0E6 -20 -40 -60 -80 1.0E1 1.0E1 0 -50 -100 -150 -200 -250 -300 -350 1.0E1 1.0E2 1.0E3 1.0E4 1.0E5 1.0E6 1.0E2 1.0E3 1.0E4 Frequency 1.0E5 1.0E6 V$2[f] V$2[f] - V$3[f Out[12]= Graphics In[13]:= BodePlot[H1[I w], {w, 0.01, 100}, MagnitudeDisplay −> AbsoluteValues] Magnitude 1.0E-2 1.0E0 5.0E-1 1.0E-1 1.0E0 1.0E1 1.0E2 1.0E-1 1.0E0 Frequency 1.0E1 1.0E2 2.0E-1 1.0E-1 5.0E-2 2.0E-2 1.0E-2 1.0E-2 1.0E-2 0 Phase (deg) Show absolute magnitude values instead of decibels. 1.0E-1 1.0E0 1.0E1 1.0E2 1.0E-1 1.0E0 Frequency 1.0E1 1.0E2 -20 -40 -60 -80 1.0E-2 Out[13]= Graphics 3. Reference Manual 338 Show magnitude values on a linear scale. In[14]:= BodePlot[H1[I w], {w, 0.01, 100}, MagnitudeDisplay −> Linear] Phase (deg) Magnitude 1.0E-2 1 1.0E-1 1.0E0 1.0E1 1.0E2 0 1.0E-2 1.0E-1 1.0E0 Frequency 1.0E1 1.0E2 1.0E-2 0 1.0E-1 1.0E0 1.0E1 1.0E2 1.0E-1 1.0E0 Frequency 1.0E1 1.0E2 0.8 0.6 0.4 0.2 -20 -40 -60 -80 1.0E-2 Out[14]= Graphics In[15]:= BodePlot[acsweep, {V$2[f], V$2[f]−V$3[f]}, {f, 100, 10^5}, PhaseDisplay −> None] 1.0E2 0 5.0E21.0E3 5.0E31.0E4 5.0E41.0E5 5.0E21.0E3 5.0E31.0E4 Frequency 5.0E41.0E5 -10 Magnitude (dB) Do not show the phase plot. -20 -30 -40 -50 -60 1.0E2 V$2[f] V$2[f] - V$3[f Out[15]= Graphics 3.9 Graphics Functions In[16]:= BodePlot[H1[I w]^5, {w, 0.01, 100}, UnwrapPhase −> False] Magnitude (dB) Restrict the phase to the interval . 339 1.0E-2 0 1.0E0 1.0E1 1.0E2 1.0E-1 1.0E0 Frequency 1.0E1 1.0E2 1.0E-1 1.0E0 1.0E1 1.0E2 1.0E-1 1.0E0 Frequency 1.0E1 1.0E2 -50 -100 -150 -200 1.0E-2 Phase (deg) 1.0E-1 1.0E-2 0 -50 -100 -150 -200 -250 -300 -350 1.0E-2 Out[16]= Graphics In[17]:= BodePlot[H1[I w]^5, {w, 0.01, 100}, UnwrapPhase −> True] Phase (deg) Magnitude (dB) Unwrap the phase trace. 1.0E-2 0 1.0E-1 1.0E0 1.0E1 1.0E2 -200 1.0E-2 1.0E-1 1.0E0 Frequency 1.0E1 1.0E2 1.0E-2 0 1.0E-1 1.0E0 1.0E1 1.0E2 1.0E-1 1.0E0 Frequency 1.0E1 1.0E2 -50 -100 -150 -100 -200 -300 -400 1.0E-2 Out[17]= Graphics In the following example, the number of plot points is reduced so that the differences between successive phase values become too large for phase unwrapping. 3. Reference Manual 340 In[18]:= BodePlot[H1[I w]^5, {w, 0.01, 100}, PlotPoints −> 10, PlotRange −> {Automatic, {−360, 0}}] Magnitude (dB) Reduce the number of plot points. 1.0E-2 0 1.0E0 1.0E1 1.0E2 1.0E-1 1.0E0 Frequency 1.0E1 1.0E2 1.0E-1 1.0E0 1.0E1 1.0E2 1.0E-1 1.0E0 Frequency 1.0E1 1.0E2 -50 -100 -150 -200 1.0E-2 Phase (deg) 1.0E-1 1.0E-2 0 -50 -100 -150 -200 -250 -300 -350 1.0E-2 Out[18]= Graphics To unwrap the phase trace, you can specify a larger number of plot points or increase the value of UnwrapTolerance . Magnitude (dB) In[19]:= BodePlot[H1[I w]^5, {w, 0.01, 100}, PlotPoints −> 10, UnwrapTolerance −> 0.3] Phase (deg) Increase the unwrap tolerance to 30% of . 1.0E-2 0 1.0E-1 1.0E0 1.0E1 1.0E2 -200 1.0E-2 1.0E-1 1.0E0 Frequency 1.0E1 1.0E2 1.0E-2 0 1.0E-1 1.0E0 1.0E1 1.0E2 1.0E-1 1.0E0 Frequency 1.0E1 1.0E2 -50 -100 -150 -100 -200 -300 -400 1.0E-2 Out[19]= Graphics 3.9 Graphics Functions 341 3.9.2 FourierPlot FourierPlot[func, {t, t , t }] plots the frequency spectrum of the function func where the independent variable t is swept from t to t FourierPlot[{func , func , † † † }, {t, t , t }] superimposes the Fourier plots of several functions Command structure of FourierPlot. FourierPlot performs a discrete fourier analysis by applying Fourier on the given functions. FourierPlot inherits all options from ListPlot . Additionally the following option is available: option name default value PlotPoints 250 specifies the number of sample points Options for FourierPlot. PlotPoints The option PlotPoints −> integer specifies the number of sample points. The maximum displayed frequency is given by integert t . See also: Fourier. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Plot a spectrum of two signals with Hz and Hz. In[2]:= FourierPlot[{0.5 Sin[2. Pi 20. t], 2. Cos[2. Pi 80. t]}, {t, 0, 1.}, PlotStyle −> {{Hue[0]}, {Hue[0.4]}}] Amplitude 1.5 1.25 1 0.75 0.5 0.25 0 0 Out[2]= Graphics 20 40 60 80 Frequency 100 120 3. Reference Manual 342 3.9.3 NicholPlot NicholPlot[func, {var, f , f }] displays a Nichol plot of the transfer function func[var] as the independent variable var is swept from f to f NicholPlot[{func , func , † † † }, {var, f , f }] displays the transfer functions func , func , † † † simultaneously in a Nichol plot Command structure of NicholPlot. NicholPlot displays one or several transfer functions in a Nichol plot. A Nichol plot is similar to a Nyquist plot but shows magnitude (in dB) vs. phase with the axis origin at the point dB . Note that NicholPlot has attribute HoldFirst . NicholPlot supports additional patterns for displaying numerical data generated with the functions ACAnalysis (Section 3.7.3), NoiseAnalysis (Section 3.7.4), or ReadSimulationData (Section 3.10.3): NicholPlot[traces, {var, f , f }] displays a list of AC traces computed with e.g. ACAnalysis in a Nichol plot NicholPlot[traces, expr, {var, f , f }] displays the value of an expression in terms of AC traces NicholPlot[traces, {expr , expr , † † † }, {var, f , f }] displays the values of several expressions Displaying numerical data with NicholPlot. You can customize the appearance of Nichol plots with the following options. In addition, NicholPlot inherits many options from ListPlot and Legend. Both the options which are specific to NicholPlot as well as the inherited options can be set with SetOptions[NicholPlot, opts]. 3.9 Graphics Functions 343 option name default value FrequencyScaling Exponential whether to distribute sampling points exponentially or linearly along the frequency axis PhaseDisplay Degrees the unit for phase values ShowLegend True whether to display trace names TraceNames Automatic the trace names displayed in the plot legend Options for NicholPlot. See also: ACAnalysis (Section 3.7.3), NoiseAnalysis (Section 3.7.4), ReadSimulationData (Section 3.10.3), BodePlot (Section 3.9.1), NyquistPlot (Section 3.9.4). Options Description A detailed description of all options that are specific to NicholPlot or are used in a non-standard way is given below in alphabetical order: FrequencyScaling The option FrequencyScaling determines how sampling points are distributed over the frequency axis. Possible values are: Exponential Linear use exponentially spaced sampling points use linearly spaced sampling points Values for the FrequencyScaling option. PhaseDisplay The option PhaseDisplay specifies the unit for phase values. Possible values are: Degrees display phase values in degrees Radians display phase values in radians Values for the PhaseDisplay option. 3. Reference Manual 344 TraceNames The option TraceNames allows you to specify the labels that are shown in the plot legend for the displayed traces if ShowLegend −> True. The following values are possible: Automatic string or expr {string, † † † } or {expr, † † † } use trace names from AC sweeps computed with e.g. ACAnalysis the name for a single trace names for all traces; the number of names must equal the number of traces Values for the TraceNames option. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define two transfer functions. In[2]:= H1[s_] := (60 + 20*s)/(100*s + 45*s^2 + 15*s^3 + 2*s^4) H2[s_] := 10/(s^2 + s + 10) Draw a Nichol plot of H jΩ. In[4]:= NicholPlot[H1[I w], {w, 0.1, 5}, AspectRatio −> 0.8] dB 15 10 5 -360 -300 -240 -120 -60 -5 -10 -15 -20 Out[4]= Graphics 0 deg 3.9 Graphics Functions Display two transfer functions in a Nichol plot. 345 In[5]:= NicholPlot[{H1[I w], H2[I w]}, {w, 0.1, 100}, AspectRatio −> 0.7, PlotRange −> {{−300,0}, {−60,15}}, PlotPoints −> 100] dB 10 -300 -240 -120 -60 0 deg -10 -20 -30 -40 -50 -60 Out[5]= Graphics This defines an RLC filter circuit. In[6]:= rlcf = {V1, {R1, {L1, {C1, {R2, ]; Set up modified nodal equations. In[7]:= eqsrlcf = CircuitEquations[rlcf] Do an AC analysis from Hz to MHz. In[8]:= acsweep = ACAnalysis[eqsrlcf, {f, 10, 10^6}] Netlist[ {1, 0}, Symbolic {1, 2}, Symbolic {2, 3}, Symbolic {3, 0}, Symbolic {3, 0}, Symbolic −> −> −> −> −> V, R1, L, C, R2, Value Value Value Value Value −> −> −> −> −> 1}, 1000.}, 0.001}, 2.2*10^−6}, 1000.} Out[7]= DAEAC, 4 4 Out[8]= V$1 InterpolatingFunction10., 1. 106 , , V$2 InterpolatingFunction10., 1. 106 , , V$3 InterpolatingFunction10., 1. 106 , , I$V1 InterpolatingFunction10., 1. 106 , 3. Reference Manual 346 Display several expressions in a Nichol plot. In[9]:= NicholPlot[acsweep, {V$2[f], V$3[f]}, {f, 10, 10^6}, AspectRatio −> 0.8] dB -360-300-240 deg -120 -60 0 -20 -40 -60 -80 -100 V$2[f] V$3[f] Out[9]= Graphics 3.9.4 NyquistPlot NyquistPlot[func, {var, f , f }] displays a Nyquist plot of the transfer function func[var] as the independent variable var is swept from f to f NyquistPlot[{func , func , † † † }, {var, f , f }] displays the transfer functions func , func , † † † simultaneously in a Nyquist plot Command structure of NyquistPlot. NyquistPlot displays one or several transfer functions in a Nyquist plot. A Nyquist plot is a parametric plot of the imaginary part vs. the real part of a frequency response as the frequency is swept from f to f . Note that NyquistPlot has attribute HoldFirst . NyquistPlot supports additional patterns for displaying numerical data generated with the functions ACAnalysis (Section 3.7.3), NoiseAnalysis (Section 3.7.4), or ReadSimulationData (Section 3.10.3): 3.9 Graphics Functions 347 NyquistPlot[traces, {var, f , f }] displays a list of AC traces computed with e.g. ACAnalysis in a Nyquist plot NyquistPlot[traces, expr, {var, f , f }] displays the value of an expression in terms of AC traces NyquistPlot[traces, {expr , expr , † † † }, {var, f , f }] displays the values of several expressions Displaying numerical data with NyquistPlot. You can customize the appearance of Nyquist plots with the following options. In addition, NyquistPlot inherits many options from ListPlot and Legend. Both the options which are specific to NyquistPlot as well as the inherited options can be set with SetOptions[NyquistPlot, opts]. option name default value FrequencyScaling Exponential whether to distribute sampling points exponentially or linearly along the frequency axis ShowLegend True whether to display trace names ShowUnitCircle False whether to draw the unit circle TraceNames Automatic the trace names displayed in the plot legend UnitCircleStyle RGBColor[0., 0., .5] the plot style for the unit circle Options for NyquistPlot. See also: ACAnalysis (Section 3.7.3), NoiseAnalysis (Section 3.7.4), ReadSimulationData (Section 3.10.3), BodePlot (Section 3.9.1), NicholPlot (Section 3.9.3). Options Description A detailed description of all options that are specific to NyquistPlot or are used in a non-standard way is given below in alphabetical order: FrequencyScaling The option FrequencyScaling determines how sampling points are distributed over the frequency axis. Possible values are: 3. Reference Manual 348 Exponential Linear use exponentially spaced sampling points use linearly spaced sampling points Values for the FrequencyScaling option. ShowUnitCircle With ShowUnitCircle −> True, NyquistPlot adds the unit circle to a plot. TraceNames The option TraceNames allows you to specify the labels that are shown in the plot legend for the displayed traces if ShowLegend −> True. The following values are possible: Automatic string or expr {string, † † † } or {expr, † † † } use trace names from AC sweeps computed with e.g. ACAnalysis the name for a single trace names for all traces; the number of names must equal the number of traces Values for the TraceNames option. UnitCircleStyle With UnitCircleStyle −> style, you can change the plot style for the unit circle. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define two transfer functions. In[2]:= H1[s_] := 1/(s + 1); H2[s_] := 10/(s^2 + s + 10) Increase the number of plot points. In[4]:= SetOptions[NyquistPlot, PlotPoints −> 200]; 3.9 Graphics Functions Draw a Nyquist plot of H jΩ. 349 In[5]:= NyquistPlot[H2[I w], {w, 0.01, 100}, PlotRange −> All] Im -1 -0.5 0.5 1 Re 1.5 -0.5 -1 -1.5 -2 -2.5 -3 Out[5]= Graphics This produces a Nyquist plot of H jΩ and H jΩ. In[6]:= NyquistPlot[{H1[I w], H2[I w]}, {w, 0.01, 100}, PlotRange −> All] Im -1 -0.5 0.5 1 Re 1.5 -0.5 -1 -1.5 -2 -2.5 -3 Out[6]= Graphics This defines an RLC filter circuit. In[7]:= rlcf = {V1, {R1, {L1, {C1, {R2, ]; Set up modified nodal equations. In[8]:= eqsrlcf = CircuitEquations[rlcf] Netlist[ {1, 0}, Symbolic {1, 2}, Symbolic {2, 3}, Symbolic {3, 0}, Symbolic {3, 0}, Symbolic Out[8]= DAEAC, 4 4 −> −> −> −> −> V, R1, L, C, R2, Value Value Value Value Value −> −> −> −> −> 1}, 1000.}, 0.001}, 2.2*10^−6}, 1000.} 3. Reference Manual 350 Do an AC analysis from Hz to MHz. In[9]:= acsweep = ACAnalysis[eqsrlcf, {f, 10, 10^6}] Display the trace of V$2[f]. In[10]:= NyquistPlot[acsweep, {V$2[f]}, {f, 10, 10^6}] Out[9]= V$1 InterpolatingFunction10., 1. 106 , , V$2 InterpolatingFunction10., 1. 106 , , V$3 InterpolatingFunction10., 1. 106 , , I$V1 InterpolatingFunction10., 1. 106 , Im 0.5 0.4 0.3 0.2 0.1 0.2 0.4 0.6 0.8 Re -0.1 -0.2 V$2[f] Out[10]= Graphics Display several expressions in a Nyquist plot. In[11]:= NyquistPlot[acsweep, {V$2[f]−0.5, 0.5−V$2[f]}, {f, 10, 10^6}, Frame −> True, ShowLegend −> False] Im 0.4 0.2 Re 0 -0.2 -0.4 -0.4 -0.2 Out[11]= Graphics 0 0.2 0.4 3.9 Graphics Functions Display the unit circle. 351 In[12]:= NyquistPlot[H2[I w], {w, 0.01, 100}, PlotRange −> {{−3, 3}, {−3.5, 1.5}}, ShowUnitCircle −> True] Im 1 -3 -2 -1 1 2 3 Re -1 -2 -3 Out[12]= Graphics Display the unit circle using a different style. In[13]:= NyquistPlot[H2[I w], {w, 0.01, 100}, PlotRange −> {{−3, 3}, {−3.5, 1.5}}, ShowUnitCircle −> True, UnitCircleStyle −> {GrayLevel[0], Dashing[{0.04, 0.03}]}] Im 1 -3 -2 -1 1 -1 -2 -3 Out[13]= Graphics 2 3 Re 3. Reference Manual 352 3.9.5 RootLocusPlot RootLocusPlot[func, {k, k , k }] displays the root locus of func as k is swept from k to k RootLocusPlot[func] RootLocusPlot[rootloc] displays a pole/zero diagram of func displays a root locus calculated with RootLocusByQZ Command structure of RootLocusPlot. RootLocusPlot displays a root locus plot of a transfer function Hs k, where k denotes a realvalued parameter. A root locus plot shows the trajectories of the poles and zeros of Hs k in the complex plane as k varies from k to k . RootLocusPlot can also be used to produce a pole/zero diagram of transfer function Hs without parameters as well as to display root loci calculated with RootLocusByQZ . By default, RootLocusPlot chooses a logarithmic representation of the complex plane for better visualization of widely separated poles and zeros. However, as logarithmic scaling is inappropriate for coordinates near the axes, the regions around the axes are scaled semi-logarithmically, and the region around the origin is scaled linearly. RootLocusPlot marks the linearly scaled region with a gray background. The semi-logarithmic regions are the regions above and below as well as to the left and the right of the linear region. You can customize the appearance of root locus plots with the following options. In addition, RootLocusPlot inherits many options from Graphics . Both the options which are specific to RootLocusPlot as well as the inherited options can be set with SetOptions[RootLocusPlot, opts]. 3.9 Graphics Functions 353 option name default value LinearRegionLimit 1.0 the extent of the linearly scaled plot region LinearRegionSize 0.3 the relative size of the linearly scaled plot region LinearRegionStyle GrayLevel[0.9] the fill color used to mark the linear region PlotPoints 5 the number of points between k and k at which the poles and zeros are calculated PlotRange Automatic the plot range PoleStyle CrossMark[0.02, Hue[0.15 (1. − #1)] & , Thickness[0.007]] the mark and plot style for poles ShowLegend True ZeroStyle CircleMark[0.02, Hue[0.25 #1 + 0.3] & , Thickness[0.007]] the mark and plot style for zeros whether to display a plot legend Options for RootLocusPlot. See also: PolesAndZerosByQZ (Section 3.8.3), RootLocusByQZ (Section 3.8.6). Options Description A detailed description of all options that are specific to RootLocusPlot or are used in a non-standard way is given below in alphabetical order: LinearRegionLimit With LinearRegionLimit −> value, you can specify the extent of the linearly scaled plot region around the origin. For example, the setting LinearRegionLimit −> 100 causes the region where x and y to be scaled linearly. LinearRegionLimit −> Infinity turns off logarithmic scaling. LinearRegionSize LinearRegionSize −> size specifies the percentage of the total plot area occupied by the linear region. The option value size must be a real number between and . LinearRegionStyle With LinearRegionStyle −> style, you can specify the fill color RootLocusPlot uses for the linearly scaled region. 3. Reference Manual 354 PlotRange The meaning of the PlotRange option is the same as for other Mathematica graphics functions, but the option has slightly different formats. {{xmin, xmax}, {ymin, ymax}} {{xmin, xmax}} value Automatic or All specify individual limits for all axes directions specify plot range for the x-axis. equivalent to {{−value, value}, {−value, value}} determine plot range automatically Values for the PlotRange option. PoleStyle With the option PoleStyle −> style, you can change the appearance of the symbol RootLocusPlot uses to mark poles. The following styles are available: CrossMark[size, colorfunc, grstyle] marks a root with a cross PlusMark[size, colorfunc, grstyle] marks a root with a plus CircleMark[size, colorfunc, grstyle] marks a root with a circle SquareMark[size, colorfunc, grstyle] marks a root with a square PointMark[size, colorfunc, grstyle] marks a root with a point Styles for the PoleStyle and ZeroStyle options. In the above table, size denotes the size of a root marker in scaled coordinates, colorfunc a pure function that returns a color value for an argument between 0 and 1, and grstyle an additional list of graphics styles for the root marker. The color function is used to visualize the parameter dependency of the root. ZeroStyle With the option ZeroStyle −> style, you can change the appearance of the symbol RootLocusPlot uses to mark zeros. For a list of available styles see the description of the PoleStyle option. 3.9 Graphics Functions 355 Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define a transfer function Ha s a. In[2]:= Ha[s_, a_] := (a + 2*s + s^2)/(10 + 3*a*s + 4*s^2 + s^3) Display a root locus plot of Ha s a as a is swept from to . In[3]:= RootLocusPlot[Ha[s, a], {a, −4, 10}, PlotPoints −> 10] a = -4.000e0 .. 1.000e1 (0% .. 100%) Im s 5.0E0 Poles 0% 2.0E0 1. -5.0E0 -2.0E0 100 -1. 1. Re s Zeros 0% -1. -2.0E0 100 -5.0E0 Out[3]= Graphics Display the pole/zero distribution of Ha s a for a . In[4]:= RootLocusPlot[Ha[s, 0], PlotRange −> 6] Im s 5.0E0 2.0E0 1. -5.0E0 -2.0E0 -1. 1. -1. -2.0E0 -5.0E0 Out[4]= Graphics 2.0E0 5.0E0 Re s 3. Reference Manual 356 Change boundaries, plot size, and color of the linear region. In[5]:= RootLocusPlot[Ha[s, a], {a, −4, 10}, PlotPoints −> 10, LinearRegionLimit −> 4.0, LinearRegionSize −> 0.8, LinearRegionStyle −> GrayLevel[0.95]] a = -4.000e0 .. 1.000e1 (0% .. 100%) Im s Poles 0% 4. 2. 100 -4. -3. -2. -1. 1. Re s Zeros 0% -2. -4. 100 Out[5]= Graphics Set equal plot limits for all axes directions. In[6]:= RootLocusPlot[Ha[s, a], {a, −4, 10}, PlotPoints −> 10, PlotRange −> 100, Frame −> True] a = -4.000e0 .. 1.000e1 (0% .. 100%) Im s Poles 0% 100 Re s Zeros 0% 100 Out[6]= Graphics 3.9 Graphics Functions Change the style for pole and zero markers. 357 In[7]:= RootLocusPlot[Ha[s, a], {a, −4, 10}, PlotPoints −> 10, PoleStyle −> PlusMark[0.02, GrayLevel[1−0.8*#]&, Thickness[0.005]], ZeroStyle −> SquareMark[0.02, GrayLevel[1−0.8*#]&, Thickness[0.005]]] a = -4.000e0 .. 1.000e1 (0% .. 100%) Im s 5.0E0 Poles 0% 2.0E0 1. -5.0E0 -2.0E0 -1. 100 1. Re s Zeros 0% -1. -2.0E0 -5.0E0 100 Out[7]= Graphics 3.9.6 TransientPlot TransientPlot[func, {tvar, t , t }] displays the transient waveform func[tvar] as the independent variable tvar is swept from t to t TransientPlot[{func , func , † † † }, {tvar, t , t }] displays the transient waveforms func , func , † † † simultaneously in a single plot Command structure of TransientPlot . TransientPlot displays one or several transient waveforms in a single plot, where the signal values are usually plotted versus time. Note that TransientPlot has attribute HoldAll. Additionally, TransientPlot supports the multi-dimensional data format of Analog Insydes described in Section 3.7.1, which consists of lists of rules, where the variables are assigned InterpolatingFunction objects. Therefore, call TransientPlot where the first argument is compatible to the return value of the numerical solver functions NDAESolve (Section 3.7.5) and NDSolve , or the data interface function ReadSimulationData (Section 3.10.3): 3. Reference Manual 358 TransientPlot[traces, expr, {tvar, t , t }] displays the transient waveform of an expression in terms of the computed traces as the independent variable tvar is swept from t to t TransientPlot[traces, {expr , expr , † † † }, {tvar, t , t }] displays the transient waveforms of several expressions expr , expr , † † † simultaneously in a single plot Displaying numerical data with TransientPlot. TransientPlot inherits most of its options from Plot and GraphicsArray . Both the options which are specific to TransientPlot as well as the inherited options can be set with SetOptions[TransientPlot, opts]. option name default value Parametric False whether to carry out a parametric plot PlotRange Automatic the plot ranges for the different transient waveforms ShowLegend True whether to display a plot legend ShowSamplePoints False generates a ListPlot of the simulation data SingleDiagram True combines plots of several functions in a single diagram SweepParameters Automatic allows for filtering the multi-dimensional data Options for TransientPlot. See also: NDSolve, NDAESolve (Section 3.7.5), ReadSimulationData (Section 3.10.3). Options Description A detailed description of all options that are specific to TransientPlot or are used in a non-standard way is given below in alphabetical order: 3.9 Graphics Functions 359 Parametric Changing the default setting from False to True allows for carrying out parametric plots of transient waveforms. Therefore, specify a list of two expressions, where the first one refers to the x-axis and the second to the y-axis. The expressions are automatically added as labels to the x and y-axes. Please note that this option also supports the multi-dimensional data format. PlotRange The usage of the option PlotRange is different as compared to Plot. The PlotRange of each transient waveform can be separately modified for the setting SingleDiagram −> False. The default setting is PlotRange −> Automatic . Possible option values are as follows: Automatic or All {ymin, ymax} determine PlotRange automatically specify same PlotRange for all waveforms {Automatic | All | {ymin, ymax}, † † † } specify individual PlotRange for each waveform Values for the PlotRange option. ShowLegend The option ShowLegend allows for displaying a plot legend. The default setting is ShowLegend −> True. ShowSamplePoints Changing the default setting from False to True allows for generating a ListPlot of the simulation data. Please note that this option also supports the multi-dimensional data format. SingleDiagram The option SingleDiagram combines plots of several transient waveforms in a single diagram. Changing the default setting from True to False produces a GraphicsArray of separately plotted transient waveforms. Please note that this option also supports the multi-dimensional data format. 3. Reference Manual 360 SweepParameters The option SweepParameters allows for filtering the multi-dimensional data. The default setting is SweepParameters −> Automatic . Possible option values are as follows: Automatic leave the multi-dimensional data unchanged {param −> value | param −> _, † † † } specify explicit value or Blank[] for each valid sweep parameter Values for the SweepParameters option. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Plot two sinusoidal functions. In[2]:= S[T_] := Sin[10.T]; TransientPlot[{S[T], 2 S[T−1]}, {T, 0, 1}] 2 1 S[T] 0.2 0.4 0.6 0.8 1 T 2 S[T - 1 -1 -2 Out[3]= Graphics In the following, the transient solution of the diode rectifier circuit shown below is plotted using TransientPlot . D1 1 V0 2 C1 R1 Vout 3.9 Graphics Functions Define netlist description of a simple diode rectifier circuit. 361 In[4]:= rectifier = Circuit[ Netlist[ {V0, {1, 0}, Symbolic −> V0, Value −> 2. Sin[10^6 Time]}, {R1, {2, 0}, Symbolic −> R1, Value −> 100.}, {C1, {2, 0}, Symbolic −> C1, Value −> 1.*^−7}, {D1, {1 −> A, 2 −> C}, Model −> "Diode", Selector −> "Spice"} ] ] Out[4]= Circuit Set up system of symbolic time-domain equations. In[5]:= rectifiereqs = CircuitEquations[rectifier, AnalysisMode −> Transient, ElementValues −> Symbolic] Out[5]= DAETransient, 4 4 Perform numerical transient analysis. In[6]:= tran = NDAESolve[rectifiereqs, {t, 0., 2.*^−5}] Display the simulation result with TransientPlot for the variables V$1[t] and V$2[t]. In[7]:= TransientPlot[tran, {V$1[t], V$2[t]}, {t, 0., 2.*^−5}, Axes −> False, Frame −> True, GridLines −> Automatic] Out[6]= V$2 InterpolatingFunction0, 0.00002, , V$1 InterpolatingFunction0, 0.00002, , I$V0 InterpolatingFunction0, 0.00002, , I$AC$D1 InterpolatingFunction0, 0.00002, 2 1 V$1[t] 0 V$2[t] -1 -2 0 -6 0.00001 0.000015 0.00002 5. 10 t Out[7]= Graphics 3. Reference Manual 362 View signals separately. In[8]:= Vd[t_] := V$1[t] − V$2[t]; TransientPlot[tran, {Vd[t], V$2[t]}, {t, 0., 2.*^−5}, PlotRange −> {{−4., 2.}, {0., 1.5}}, SingleDiagram −> False] 2 1 -6 0.00001 0.000015 t 0.00002 5. 10 Vd[t -1 -2 -3 -4 1.4 1.2 1 0.8 V$2[ 0.6 0.4 0.2 -6 0.00001 0.000015 t 0.00002 5. 10 Out[9]= GraphicsArray Display the simulation data. In[10]:= TransientPlot[tran, {V$1[t], V$2[t]}, {t, 0., 2.*^−5}, ShowSamplePoints −> True] 2 1 V$1[t] -6 t 0.00001 0.000015 0.00002 5. 10 -1 -2 Out[10]= Graphics V$2[t] 3.9 Graphics Functions Generate a parametric plot. 363 In[11]:= TransientPlot[tran, {V$1[t], V$2[t]}, {t, 2.*^−6, 2.*^−5}, Parametric −> True] V$2[t] 1.2 1.1 -2 -1 1 2 V$1[t] 0.9 0.8 Out[11]= Graphics Perform parametric transient analysis. In[12]:= paramtran = NDAESolve[rectifiereqs, {t, 0., 2.*^−5}, {R1, Table[10^i, {i, 0, 3}]}] Out[12]= V$2 InterpolatingFunction0, 0.00002, , V$1 InterpolatingFunction0, 0.00002, , I$V0 InterpolatingFunction0, 0.00002, , I$AC$D1 InterpolatingFunction0, 0.00002, , SweepParameters R1 1., V$2 InterpolatingFunction0, 0.00002, , V$1 InterpolatingFunction0, 0.00002, , I$V0 InterpolatingFunction0, 0.00002, , I$AC$D1 InterpolatingFunction0, 0.00002, , SweepParameters R1 10., V$2 InterpolatingFunction0, 0.00002, , V$1 InterpolatingFunction0, 0.00002, , I$V0 InterpolatingFunction0, 0.00002, , I$AC$D1 InterpolatingFunction0, 0.00002, , SweepParameters R1 100., V$2 InterpolatingFunction0, 0.00002, , V$1 InterpolatingFunction0, 0.00002, , I$V0 InterpolatingFunction0, 0.00002, , I$AC$D1 InterpolatingFunction0, 0.00002, , SweepParameters R1 1000. 3. Reference Manual 364 Display the multi-dimensional simulation result: show all traces of the parameter sweep. In[13]:= TransientPlot[paramtran, {V$2[t]}, {t, 0., 2.*^−5}] 1.2 1 0.8 0.6 V$2[t] 0.4 0.2 t -6 0.00001 0.000015 0.00002 5. 10 Out[13]= Graphics Filter the multi-dimensional data: display only the trace corresponding to the parameter value R1=1. In[14]:= TransientPlot[paramtran, {V$2[t]}, {t, 0., 2.*^−5}, SweepParameters −> {R1 −> 1.}] 1 0.8 0.6 V$2[t] 0.4 0.2 t -6 0.00001 0.000015 0.00002 5. 10 Out[14]= Graphics 3.10 Interfaces 365 3.10 Interfaces In the following chapter the different import and export features of Analog Insydes are discussed. Section 3.10.1 describes how to translate netlists from external simulators to the internal Analog Insydes netlist format using ReadNetlist . The commands ReadSimulationData (Section 3.10.3) and WriteSimulationData (Section 3.10.4) can be used to import or export numerical simulation data. For behavioral model generation the command WriteModel (Section 3.10.5) can be used, which translates a symbolic DAEObject to an external behavioral model description language such as Saber MAST. For importing schematics stored in DXF format (Drawing Interchange File) as native Mathematica graphic objects see DXFGraphics (Section 3.13.2). 3.10.1 ReadNetlist ReadNetlist["netfile", Simulator−>sim] reads a netlist file "netfile" from a simulator sim and converts it into an Analog Insydes netlist ReadNetlist["netfile", "outfile", Simulator−>sim] additionally adds the operating-point information from the simulator output file "outfile" Command structure of ReadNetlist. This function converts a simulator-specific netlist file netfile into an Analog Insydes netlist description. Additionally, the operating-point information can be extracted from a given simulator-specific output file outfile. ReadNetlist then returns a Circuit object which can be used for setting up circuit equations by applying the function CircuitEquations (Section 3.5.1). For more information on the simulator-specific features see Section 3.10.2. ReadNetlist has the following options: 3. Reference Manual 366 option name default value CharacterMapping {"_" −> "$"} InstanceNameSeparator Inherited[AnalogInsydes] specifies the character or string Analog Insydes uses to separate name components of reference designators and node identifiers generated for instantiated subcircuit objects (see Section 3.14.2) KeepPrefix True if set to False the prefix of the reference designator introduced by the PSpice Schematics Editor and the Saber Designer will be omitted LevelSeparator "/" specifies the character or string Analog Insydes uses to separate name components of local models, parameters, and subcircuits generated by ReadNetlist LibraryPath {"."} specifies the directories which contain device model libraries Protocol Inherited[AnalogInsydes] standard Analog Insydes protocol specification (see Section 3.14.5) Simulator Inherited[AnalogInsydes] standard Analog Insydes simulator specification (see Section 3.14.6) list of translation rules for character mapping used while transforming simulator parameters to Mathematica symbols Options for ReadNetlist. See also: ReadSimulationData (Section 3.10.3), Simulator (Section 3.14.6), Section 3.10.2. Options Description A detailed description of all ReadNetlist options is given below in alphabetical order: CharacterMapping With CharacterMapping −> {charactera −> characterb } the internal character mapping scheme can be modifed. Use this option with caution, because this rule will be applied to each symbol and expression in the netlist. For example CharacterMapping −> {"." −> "$"} will replace all dots 3.10 Interfaces 367 (".") into dollar signs ("$"), even if it is a decimal dot like in "1.234" , which will lead to a syntax error ("1$234"). This option is useful if your netlist contains e.g. element names including "_" and "$" and which will be ambiguous if the "_" is mapped to a "$". You can use CharacterMapping −> {"_" −> "x"} to avoid this ambiguity. KeepPrefix Some schematic capture tools add a prefix to all element names to make sure that the element type is correct and independent from the actual element name. If KeepPrefix −> False is set, the prefix will be removed. If a Saber netlist is read, the template name is removed. Use this option with caution. It might cause ambiguous element names. LevelSeparator Locally defined subcircuits must be transformed to a top-level subcircuit with unique names. To generate unique names the value of LevelSeparator −> string is used to separate the different levels of subcircuits. Because these names are never converted to a Mathematica symbol it is possible to specifiy a non-alphanumeric character. The default is LevelSeparator −> "/". LibraryPath A netlist can contain calls to further files and libraries. With LibraryPath the search path for these files can be specified. The default is LibraryPath −> {"."}. The current working directory is set to the directory from the file name specification for netfile (see also the Mathematica command DirectoryName ). Protocol This option describes the standard Analog Insydes protocol specification (see Section 3.14.5). The top-level function for the Protocol option is ReadNetlist . The second-level function is ExpandSubcircuits . Simulator ReadNetlist supports the following simulators and file types: 3. Reference Manual 368 simulator netlist file type output file type "AnalogInsydes" *.m file "Eldo" *.cir file *.chi file "PSpice" *.cir file *.out file "Saber" *.sin file saved ssparam output Supported simulators and file types by ReadNetlist. ReadNetlist appends Simulator −> simulator to the GlobalParameters field of the returned Circuit object. This enables the Analog Insydes models to determine which simulator-specific properties of the models have to be chosen. For more information on the simulator-specific features see Section 3.10.2. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Read and convert a PSpice netlist. In[2]:= netdc = ReadNetlist[ "AnalogInsydes/DemoFiles/Multivibrator.cir", Simulator −> "PSpice"] Out[2]= Circuit Display the netlist. In[3]:= DisplayForm[netdc] Out[3]//DisplayForm= Circuit: Netlist Raw, 9 Entries: R1, 1, 2, Type Resistor, Value 4700., Symbolic R1 R2, 2, 0, Type Resistor, Value 4700., Symbolic R2 R3, 4, 0, Type Resistor, Value 39000., Symbolic R3 R4, 5, 0, Type Resistor, Value 82000., Symbolic R4 R5, 1, 3, Type Resistor, Value 18000., Symbolic R5 IC, 4, 5, Type CurrentSource, Value AC 0, DC Transient Q1, 3 C, 2 B, 4 E, Model ModelBJT, BC182, Q1, Selector Q2, 1 C, 3 B, 5 E, Model ModelBJT, BC182, Q2, Selector VCC, 1, 0, Type VoltageSource, Value AC 0, DC Transien ModelParametersName BC182, Type NPN, CJC 1. 1012 GlobalParametersSimulator PSpice Read a PSpice netlist including operating-point information. In[4]:= buffer = ReadNetlist[ "AnalogInsydes/DemoFiles/Buffer.cir", "AnalogInsydes/DemoFiles/Buffer.out", Simulator −> "PSpice"] Out[4]= Circuit 3.10 Interfaces 369 3.10.2 Simulator-Specific Remarks on ReadNetlist The command ReadNetlist translates netlists from several external simulators to the Analog Insydes netlist format. The following section describes the different features supported by ReadNetlist for each simulator. AnalogInsydes ReadNetlist["netfile", Simulator −> "AnalogInsydes"] is basically only a wrapper function for the Mathematica command Get. Additionally, ReadNetlist checks if the netfile loaded contains a Circuit object and appends Simulator −> "AnalogInsydes" to the GlobalParameters field. PSpice ReadNetlist["netfile", Simulator −> "PSpice"] supports the following devices: PSpice reference designator Analog Insydes type C Capacitor or model call D model call E VCVSource or model template F CCCSource G VCCSource or model template H CCVSource I CurrentSource J model call L Inductor or model call M model call Q model call R Resistor or model call V VoltageSource X subcircuit call PSpice reference designators supported by ReadNetlist. All model calls have functions as references for Model, Selector, and Parameters were applicable: 3. Reference Manual 370 {rd, {n1 −> p1 , }, Model −> Model[type, model, rd], Selector −> Selector[type, model, rd], Parameters −> Parameters[type, model, rd], } where type is one of "BJT", "CAP", "Diode", "IND", "JFET", "MOSFET" , or "RES". The value model is the model name, rd the reference designator of the device. Linear resistors (R), capacitors (C), and inductors (L) are converted to their generic counterpart in Analog Insydes. Model calls are generated if temperature dependencies are given or a model is defined. Linear controlled sources (E, F, G, H) are converted to their generic counterpart in Analog Insydes. In case of current controlled sources (F, H) additional nodes are introduced. In case of nonlinear voltage controlled sources (E, G) a behavioral model is generated and appended to the netlist. Supported types are POLY, VALUE, and TABLE. Independent sources (I, V) of type EXP, PULSE, PWL, SFFM, and SIN are supported (see Chapter 4.1). Parameterized subcircuits without optional nodes are also supported and may contain local model cards. The following cards are supported: PSpice card .INCLUDE .LIB action include the given file search for missing models and subcircuits .MODEL convert to ModelParameters .PARAM convert to GlobalParameters .OPTIONS .SUBCKT scan for GMIN, DEFL, DEFW, DEFAD, DEFAS, DEFPD, DEFPS, DEFNRD, DEFNRS, TNOM and convert to GlobalParameters convert to Subcircuit .TEMP convert to GlobalParameters .TRAN scan for tstep and tstop and convert to GlobalParameters .TITLE PSpice cards supported by ReadNetlist. The following cards are ignored: print title according the setting of the Protocol option 3.10 Interfaces 371 .AC .ALIASES .DC .NOISE .PLOT .PRINT .PROBE .OP .WIDTH PSpice cards ignored by ReadNetlist. Note that all temperatures like TEMP are converted from C to K. ReadNetlist["netfile", "outfile", Simulator −> "PSpice"] additionally scans the operating-point information section in the output file outfile. Afterwards the circuit is flattened via an internal call to ExpandSubcircuits and the small-signal parameters are appended to the corresponding model instance. The parameter names are postfixed with "$ac" to avoid ambiguities. Eldo ReadNetlist["netfile", Simulator −> "Eldo"] supports the following devices: 3. Reference Manual 372 Eldo reference designator Analog Insydes type C Capacitor or model call D model call E VCVSource or model template F CCCSource or model template G VCCSource H CCVSource I CurrentSource J model call L Inductor or model call M model call Q model call R Resistor or model call V VoltageSource X subcircuit call Y model call Eldo reference designators supported by ReadNetlist. All model calls have functions as references for Model, Selector , and Parameters were applicable: {rd, {n1 −> p1 , }, Model −> Model[type, model, rd], Selector −> Selector[type, model, rd], Parameters −> Parameters[type, model, rd], } where type is one of "BJT", "CAP", "Diode", "IND", "JFET", "MOSFET" , or "RES". The value model is the model name, rd the reference designator of the device. Linear resistors (R), capacitors (C), and inductors (L) are converted to their generic counterpart in Analog Insydes. Model calls are generated if temperature dependencies are given or a model is defined. Linear controlled sources (E, F, G, H) are converted to their generic counterpart in Analog Insydes. In case of current controlled sources (F, H) additional nodes are introduced. In case of nonlinear voltage controlled sources (E, G) a behavioral model is generated and appended to the netlist. Supported types are POLY, VALUE, and TABLE. Independent sources (I, V) of type EXP, PULSE, PWL, SFFM, and SIN are supported (see Chapter 4.1). 3.10 Interfaces 373 Parameterized subcircuits are also supported and may contain local model cards and local subcircuit definitions. For calls to HDLA models (Y), ReadNetlist reads the file "hdlaInfo" and scans the section [HdlaPins] to set up the correct node to port mapping: {rd, {n1 −> p1 , }, Model −> Model[entity, architecture, rd], Selector −> architecture, } with the HDLA entity name entity and the HDLA architecture name architecture. If the file cannot be found a generic port list is generated: {rd, {n1 −> 1, n2 −> 2, } Model −> Model[entity, architecture, rd], Selector −> architecture, } The environment variables HDLALIBPATH and HDLAWORKPATH are taken into account while searching for the file "hdlaInfo" . The following cards are supported: Eldo card action .ADDLIB search for missing models and subcircuits .DC scan for TEMP and convert to GlobalParameters .HDLALIB search for macro interface definitions of HDLA models .INCLUDE include the given file .LIB search for missing models and subcircuits .MODEL convert to ModelParameters .PARAM convert to GlobalParameters or subcircuit parameters .OPTIONS .SUBCKT scan for GMIN, DEFL, DEFW, DEFAD, DEFAS, DEFPD, DEFPS, DEFNRD, DEFNRS, TNOM and convert to GlobalParameters convert to Subcircuit .TEMP convert to GlobalParameters .TRAN scan for tstep and tstop and convert to GlobalParameters .TITLE Eldo cards supported by ReadNetlist. The following cards are ignored: print according the setting of the Protocol option 3. Reference Manual 374 .AC .ALIASES .NOISE .PLOT .PRINT .PROBE .OP .RAMP .VIEW .WIDTH Eldo cards ignored by ReadNetlist. Note that all temperatures like TEMP are converted from C to K. ReadNetlist["netfile", "outfile", Simulator −> "Eldo"] additionally scans the operating-point information section in the output file outfile. Afterwards the circuit is flattened via an internal call to ExpandSubcircuits and the small-signal parameters are appended to the corresponding model instance. The parameter names are postfixed with "$ac" to avoid ambiguities. Saber ReadNetlist["netfile", Simulator −> "Saber"] reads in Saber netlists. Due to the fact that all elements in Saber MAST are calls to MAST templates, ReadNetlist replaces some template calls with generic Analog Insydes elements: 3.10 Interfaces 375 MAST template name Analog Insydes type C Capacitor CL Capacitor CAP Capacitor L Inductor R Resistor RES Resistor SPI_DC CurrentSource I_DC CurrentSource I_PULSE CurrentSource I_SIN CurrentSource I CurrentSource SPV_DC VoltageSource V_DC VoltageSource V_PULSE VoltageSource V_SIN VoltageSource V VoltageSource MAST templates replaced with generic Analog Insydes elements. All other elements are converted to {name, {n1 −> p1 , }, Model −> Model[model, model, name], Selector −> Selector[model, model, name], Parameters −> Parameters[model, model, name], } where name is the name of the element and model is the template name. 3. Reference Manual 376 3.10.3 ReadSimulationData ReadSimulationData["file", Simulator−>sim] reads a data file "file" from a simulator sim and converts its content to the Analog Insydes data format ReadSimulationData["file", key, Simulator−>sim] reads data sets marked with key Command structure of ReadSimulationData . ReadSimulationData returns the result according to the Analog Insydes numerical data format described in Section 3.7.1. It consists of lists of rules, where the variables are assigned InterpolatingFunction objects. Note that Analog Insydes supports a multi-dimensional data format. The return value of ReadSimulationData can be used as first argument to most Analog Insydes graphics functions such as BodePlot (Section 3.9.1) or TransientPlot (Section 3.9.6) for visualizing the simulation data. ReadSimulationData has the following options: option name default value InterpolationOrder 1 Protocol Inherited[AnalogInsydes] standard Analog Insydes protocol specification (see Section 3.14.5) Simulator Inherited[AnalogInsydes] standard Analog Insydes simulator specification (see Section 3.14.6) specifies the interpolation order of the resulting InterpolingFunction Options for ReadSimulationData . See also: WriteSimulationData (Section 3.10.4), ReadNetlist (Section 3.10.1), BodePlot (Section 3.9.1), TransientPlot (Section 3.9.6), Simulator (Section 3.14.6), Section 3.7.1. Options Description InterpolationOrder With InterpolationOrder −> integer, you can change the interpolation order of the resulting interpolating functions. See the Mathematica object InterpolatingFunction . 3.10 Interfaces 377 The default setting is InterpolationOrder −> 1, which is linear interpolation. Simulator To distinguish between different file formats used by different simulators it is necessary to specify the simulator which generated the data file. Possible values for Simulator are: simulator "AnalogInsydes" "Eldo" "PSpice" "Saber" file type Mathematica *.m file Binary *.cou file CSDF file, *.csd or *.txt SaberScope file Supported simulators and file types by ReadSimulationData . If file contains multiple data sets like DC and AC analysis results, a key can be given as a second argument to ReadSimulationData to distinguish between these sets ("Eldo" and "PSpice" only): simulator "Eldo" "PSpice" possible keys "HERTZ", "VOLT", "SEC" "AC Sweep", "DC Sweep", "Transient" Simulator-dependent keys for ReadSimulationData . Please note that the keys may depend on the used simulator version. The return value has the data format as described in Section 3.7.1. The labels are of type String. Reading a CSDF file generated with PSpice which contains simulation data from various simulation runs, results in misleading values for SweepParameters . An Eldo "*.cou" file generated with the Eldo command line option "−dbp" (the default) contains the complex data expressed as magnitude and phase, with "−ri" as real and imaginary values. ReadSimulationData automatically adds the corresponding complex waveforms. Only Eldo "*.cou" binary files written with big endian machines are supported. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ 3. Reference Manual 378 Read simulation data from PSpice data file. In[2]:= data = ReadSimulationData[ "AnalogInsydes/DemoFiles/Multivibrator.txt", Simulator −> "PSpice"] Out[2]= V4 InterpolatingFunction0.00018, V5 InterpolatingFunction0.00018, SweepParameters VCC 0., V4 InterpolatingFunction0.00018, V5 InterpolatingFunction0.00018, SweepParameters VCC 6., V4 InterpolatingFunction0.00018, V5 InterpolatingFunction0.00018, SweepParameters VCC 12. The data can easily be plotted with TransientPlot . 0.00012, , 0.00012, , 0.00012, , 0.00012, , 0.00012, , 0.00012, , In[3]:= TransientPlot[data, {"V(4)"[IC], "V(5)"[IC]}, {IC, −0.00018, 0.00012}] 10 8 V(4)[IC] 6 V(5)[IC] 4 2 -0.00015 -0.0001 -0.00005 0.000050.0001 IC Out[3]= Graphics 3.10.4 WriteSimulationData WriteSimulationData["file", exprs, {x, xmin, xmax}, Simulator−>sim] writes sampled data of exprs to file for usage with simulator sim WriteSimulationData["file", traces, vars, {x, xmin, xmax}, Simulator−>sim] writes sampled data of the variables vars as a function of x from xmin to xmax where traces corresponds to the return value of numerical equation solvers like NDSolve or NDAESolve Command structure of WriteSimulationData . WriteSimulationData can be used for displaying Analog Insydes results in a post-processor of an external design framework. Therefore WriteSimulationData writes different file formats which are addressed by the option Simulator . WriteSimulationData does not support multi-dimensional data. 3.10 Interfaces 379 WriteSimulationData has the following options: option name default value ComplexValues False whether the data should be written as complex numbers Compiled True if exprs should be compiled DataLabels Automatic list of strings to give the traces a more convenient name InterpolationOrder 1 specifies the interpolation order of the resulting interpolating functions PlotPoints 100 number of sample points Protocol Inherited[AnalogInsydes] standard Analog Insydes protocol specification (see Section 3.14.5) Sampling Linear Simulator Inherited[AnalogInsydes] standard Analog Insydes simulator specification (see Section 3.14.6) whether to sample Linear or Exponential Options for WriteSimulationData . See also: ReadSimulationData (Section 3.10.3), Simulator (Section 3.14.6). Options Description A detailed description of all WriteSimulationData options is given below in alphabetical order: ComplexValues To generate complex-valued data from a small-signal analysis set ComplexValues −> True to write the data as complex numbers. The default ComplexValues −> False writes real numbers which can be used for DC and transient analyses. Compiled With Compiled −> True the expression exprs is compiled with the Mathematica command Compile before evaluation. 3. Reference Manual 380 DataLabels With DataLabels −> {string , string , † † † } you can specifiy new labels for the return value of exprs or for each variable in vars. This is necessary because post-processors often rely on a special name scheme for trace names. Using a Mathematica expression may irritate the post-processor. InterpolationOrder With InterpolationOrder −> integer, you can change the interpolation order of the resulting interpolating functions which are generated if the option Simulator is set to "AnalogInsydes" . See the Mathematica object InterpolatingFunction . The default setting is InterpolationOrder −> 1, which is linear interpolation. PlotPoints The option PlotPoints −> integer specifies the number of sample points. The default is 100. Sampling With Sampling −> Exponential the functions are sampled exponentially. The default is Sampling −> Linear. Simulator The following file formats are supported: simulator "AnalogInsydes" "PSpice" "Saber" file type Mathematica *.m file CSDF file, *.csd or *.txt ASCII SaberScope file Simulators and file types supported by WriteSimulationData . Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Write a SaberScope file. In[2]:= WriteSimulationData["Test.p1.dat", {(1. − Exp[−t])*Cos[t]}, {t, 0., 10.}, DataLabels −> {"F"}, Simulator −> "Saber"] 3.10 Interfaces 381 View the file "Test.p1.dat" with SaberScope. Alternatively, read it again into Mathematica with ReadSimulationData . In[3]:= data = ReadSimulationData["Test.p1.dat", Simulator −> "Saber"] Plot the data with TransientPlot . In[4]:= TransientPlot[data, "F"[t], {t, 0., 10.}] Out[3]= F InterpolatingFunction0., 10., 1 0.5 2 4 6 8 10 t F[t] -0.5 -1 Out[4]= Graphics 3.10.5 WriteModel WriteModel["file", modelname, dae, ports, connections, Simulator−>sim] converts a DAEObject dae into a simulator-specific model with respect to the ports and the defined circuit interface given by connections Command structure of WriteModel. The function WriteModel converts a DAEObject dae into a behavioral model for a given simulator. An interface can be defined which connects the model with a circuit. The connections are then given by a list of rules of the form: {param1 −> Voltage[port1 , port2 ], param2 −> Current[port3 , port4 ], var1 −> Voltage[port5 , port6 ], var2 −> Current[port7 , port8 ]} This interface definition will generate two input port branches from port to port (voltage) and from port to port (current) and two output branches from port to port (voltage) and from port to port (current). WriteModel has the following options: 3. Reference Manual 382 option name default value DesignPoint Automatic specifies a list of numerical reference values for symbolic element values in a set of circuit equations InitialConditions Automatic specifies alternative initial conditions InitialGuess Automatic specifies an alternative initial guess Simulator Inherited[AnalogInsydes] standard Analog Insydes simulator specification (see Section 3.14.6) Options for WriteModel. Options Description A detailed description of all WriteModel options is given below in alphabetical order: DesignPoint With DesignPoint −> {symbol −> value , † † † } you can overwrite the design point given in the DAEObject (see also CircuitEquations in Section 3.5.1). The default setting is DesignPoint −> Automatic , which means to use the design point given in the DAEObject. InitialConditions The option InitialConditions allows for explicitly specifying initial conditions. The default setting is InitialConditions −> Automatic , which means to use the initial conditions given in the DAEObject. Valid option values are as follows: Automatic {var == value , † † † } uses initial conditions given in the DAEObject uses specified equations as initial conditions Values for the InitialConditions option. InitialGuess The option InitialGuess allows for explicitly specifying an initial guess for the Newton iteration when computing the operating point. The default setting is InitialGuess −> Automatic , which means to use the initial guess given in the DAEObject. Possible option values are as follows: 3.10 Interfaces 383 Automatic {var −> value , † † † } uses initial guess given in the DAEObject uses specified values as initial guess Values for the InitialGuess option. Simulator The following simulator-dependent modeling languages are supported: simulator "AnalogInsydes" "PSpice" "Saber" model type Analog Insydes Model object netlist model consisting of controlled sources Saber MAST model Simulators and model types supported by WriteModel. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Read a netlist. In[2]:= net = ReadNetlist[ "AnalogInsydes/DemoFiles/Multivibrator.cir", Simulator −> "PSpice"] Out[2]= Circuit Set up a system of equations. In[3]:= dae = CircuitEquations[net, ElementValues −> Symbolic, AnalysisMode −> DC] Out[3]= DAEDC, 16 16 Display the variables of dae. These variables can be used as outputs. In[4]:= GetVariables[dae] Display the parameters of dae. These parameters can be used as inputs. In[5]:= GetParameters[dae] Out[4]= V$1, V$2, V$3, V$4, V$5, I$BS$Q1, I$CS$Q1, I$ES$Q1, ib$Q1, ic$Q1, I$BS$Q2, I$CS$Q2, I$ES$Q2, ib$Q2, ic$Q2, I$VCC Out[5]= AREA$Q1, AREA$Q2, BF$Q1, BF$Q2, BR$Q1, BR$Q2, GMIN, IS$Q1, IS$Q2, R1, R2, R3, R4, R5, TEMP, TNOM, VCC, $k, $q 384 Generate the Saber MAST model test. The first branch ("IP" −> "IN") defines IC as the corresponding input current. The second branch ("VP" −> "VN") defines an input voltage VCC and an output current I$VCC. 3. Reference Manual In[6]:= WriteModel["test.sin", "test", dae, {"IP", "IN", "VP", "VN"}, {IC −> Current["IP", "IN"], VCC −> Voltage["VP", "VN"], I$VCC −> Current["VP", "VN"]}, Simulator −> "Saber"] 3.11 Linear Simplification Techniques 385 3.11 Linear Simplification Techniques A special feature of Analog Insydes is its capability of analyzing large analog circuits symbolically by means of symbolic approximation techniques. Analog Insydes provides two different methods for computing approximated transfer functions, namely a simplification-before-generation (SBG, see function ApproximateMatrixEquation in Section 3.11.3) and a simplification-after-generation method (SAG, see function ApproximateTransferFunction in Section 3.11.2). SBG refers to methods that simplify a circuit analysis problem before a symbolic transfer function is generated from a system of equations or a network graph. SAG algorithms approximate a transfer function by discarding insignificant terms after the exact expression has been computed. Furthermore, this section contains the function ComplexityEstimate (Section 3.11.1) for estimating the number of product terms in a symbolic transfer function, and the function CompressMatrixEquation (Section 3.11.4) for compressing a system of matrix equations. 3.11.1 ComplexityEstimate ComplexityEstimate[dae] ComplexityEstimate[netlist] estimates the number of product terms in the expanded determinant of dae, which must be a system of AC circuit equations in matrix form estimates the complexity of any transfer function calculated from netlist, which must be a flat netlist Command structure of ComplexityEstimate . Before you try to solve a system of circuit equations symbolically with Solve (Section 3.5.4), you should use the function ComplexityEstimate to check whether the computation is feasible at all. ComplexityEstimate computes an estimate of the number of product terms in a transfer function computed from a symbolic matrix equation A x b. More precisely, the function computes a lower bound for the number of product terms in the determinant of A. As a rule of thumb, solving a system of circuit equations symbolically is technically feasible if the number returned by ComplexityEstimate is less than . If you expect a symbolic expression to be interpretable, its complexity should be in the range from to . See also: Statistics (Section 3.6.17). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ 3. Reference Manual 386 Define an AC model for BJTs. In[2]:= Circuit[ Model[ Name −> BJT, Selector −> AC, Scope −> Global, Ports −> {B, C, E}, Parameters −> {Rbe, Cbc, Cbe, beta, Ro, RBE, CBC, CBE, BETA, RO}, Definition −> Netlist[ {CBE, {B, E}, Symbolic −> Cbe, Value −> CBE}, {RBE, {X, E}, Symbolic −> Rbe, Value −> RBE}, {CBC, {B, C}, Symbolic −> Cbc, Value −> CBC}, {CC, {B, X, C, E}, Symbolic −> beta, Value −> BETA}, {RO, {C, E}, Symbolic −> Ro, Value −> RO} ] ] ] // ExpandSubcircuits; This netlist describes a common-emitter amplifier. In[3]:= ceamplifier = Circuit[ Netlist[ {V1, {1, 0}, 1}, {V0, {6, 0}, 0}, {C1, {1, 2}, Symbolic −> C1, Value {R1, {2, 6}, Symbolic −> R1, Value {R2, {2, 0}, Symbolic −> R2, Value {RC, {6, 3}, Symbolic −> RC, Value {RE, {4, 0}, Symbolic −> RE, Value {C2, {3, 5}, Symbolic −> C2, Value {RL, {5, 0}, Symbolic −> RL, Value {Q1, {2 −> B, 3 −> C, 4 −> E}, Model −> BJT, Selector −> AC, CBE −> 30.*^−12, CBC −> 5.*^−12, RO −> 10000., BETA −> 200.} ] ] −> −> −> −> −> −> −> 1.0*^−7}, 1.0*^5}, 47000.}, 2200.}, 1000.}, 1.0*^−6}, 47000.}, RBE −> 1000., Out[3]= Circuit Set up a system of symbolic AC equations. In[4]:= eqs = CircuitEquations[ceamplifier, ElementValues −> Symbolic] Out[4]= DAEAC, 10 10 Compute the complexity estimate. In[5]:= ComplexityEstimate[eqs] Out[5]= 132 The number returned by ComplexityEstimate indicates that solving the equations for any transfer function is feasible, but the result cannot be expected to yield much insight into circuit behavior. 3.11 Linear Simplification Techniques Compute the voltage transfer function symbolically and expand the result. 387 In[6]:= solution = Solve[eqs, V$5]; v5 = Together[V$5 /. First[solution]] Out[7]= C2 R1 R2 RC RL s C1 RE s beta$Q1 C1 Ro$Q1 s C1 Cbc$Q1 Rbe$Q1 RE s2 C1 Cbe$Q1 Rbe$Q1 RE s2 C1 Cbc$Q1 Rbe$Q1 Ro$Q1 s2 C1 Cbc$Q1 RE Ro$Q1 s2 beta$Q1 C1 Cbc$Q1 RE Ro$Q1 s2 C1 Cbc$Q1 Cbe$Q1 Rbe$Q1 RE Ro$Q1 s3 R1 R2 RC R1 Rbe$Q1 RC R2 Rbe$Q1 RC R1 R2 RE R1 Rbe$Q1 RE R2 Rbe$Q1 RE R1 RC RE R2 RC RE R1 R2 Ro$Q1 R1 Rbe$Q1 Ro$Q1 R2 Rbe$Q1 Ro$Q1 R1 RE Ro$Q1 beta$Q1 R1 RE Ro$Q1 R2 RE Ro$Q1 beta$Q1 R2 RE Ro$Q1 C1 R1 R2 Rbe$Q1 RC s Cbc$Q1 R1 R2 Rbe$Q1 RC s Cbe$Q1 R1 R2 Rbe$Q1 RC s C1 R1 R2 Rbe$Q1 RE s 94 C2 Cbe$Q1 R2 Rbe$Q1 RE RL Ro$Q1 s2 C2 Cbc$Q1 R1 RC RE RL Ro$Q1 s2 beta$Q1 C2 Cbc$Q1 R1 RC RE RL Ro$Q1 s2 C2 Cbc$Q1 R2 RC RE RL Ro$Q1 s2 beta$Q1 C2 Cbc$Q1 R2 RC RE RL Ro$Q1 s2 C1 C2 Cbc$Q1 R1 R2 Rbe$Q1 RC RE RL s3 C1 C2 Cbe$Q1 R1 R2 Rbe$Q1 RC RE RL s3 C1 C2 Cbe$Q1 R1 R2 Rbe$Q1 RC RE Ro$Q1 s3 C1 Cbc$Q1 Cbe$Q1 R1 R2 Rbe$Q1 RC RE Ro$Q1 s3 C2 Cbc$Q1 Cbe$Q1 R1 R2 Rbe$Q1 RC RE Ro$Q1 s3 C1 C2 Cbc$Q1 R1 R2 Rbe$Q1 RC RL Ro$Q1 s3 C2 Cbc$Q1 Cbe$Q1 R1 R2 Rbe$Q1 RC RL Ro$Q1 s3 C1 C2 Cbe$Q1 R1 R2 Rbe$Q1 RE RL Ro$Q1 s3 C2 Cbc$Q1 Cbe$Q1 R1 R2 Rbe$Q1 RE RL Ro$Q1 s3 C1 C2 Cbc$Q1 R1 R2 RC RE RL Ro$Q1 s3 beta$Q1 C1 C2 Cbc$Q1 R1 R2 RC RE RL Ro$Q1 s3 C2 Cbc$Q1 Cbe$Q1 R1 Rbe$Q1 RC RE RL Ro$Q1 s3 C2 Cbc$Q1 Cbe$Q1 R2 Rbe$Q1 RC RE RL Ro$Q1 s3 C1 C2 Cbc$Q1 Cbe$Q1 R1 R2 Rbe$Q1 RC RE RL Ro$Q1 s4 Here, the complexity estimate is identical to the true number of terms in the denominator of the symbolic transfer function. In the general case, the estimate yields a lower bound for this number. Determine number of terms in the denominator of the transfer function. In[8]:= Length[Denominator[v5]] Out[8]= 132 3.11.2 ApproximateTransferFunction ApproximateTransferFunction[expr, fvar, dp, error] approximates the transfer function expr by discarding insignificant terms where fvar, dp, and error denote the complex frequency variable, the design point, and the bound for the coefficient error Command structure of ApproximateTransferFunction . ApproximateTransferFunction approximates a symbolic transfer function by discarding insignificant terms from its coefficients (simplification after generation, SAG). The significance or insignificance of a term is evaluated on the basis of numerical reference values for the symbols (the design point). For each coefficient, the algorithm removes the numerically least significant terms until the maximum coefficient error is reached. 3. Reference Manual 388 The fourth argument of ApproximateTransferFunction denotes the maximum coefficient error. It does not constitute a bound on the absolute error of a transfer function. The absolute error may be larger or lower than the maximum coefficient error. See also: ApproximateMatrixEquation (Section 3.11.3). Examples Below, we approximate the transfer function of the common-emitter amplifier. We allow for a maximum error of in all coefficients of powers of the complex frequency s. Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define an AC model for BJTs. In[2]:= Circuit[ Model[ Name −> BJT, Selector −> AC, Scope −> Global, Ports −> {B, C, E}, Parameters −> {Rbe, Cbc, Cbe, beta, Ro, RBE, CBC, CBE, BETA, RO}, Definition −> Netlist[ {CBE, {B, E}, Symbolic −> Cbe, Value −> CBE}, {RBE, {X, E}, Symbolic −> Rbe, Value −> RBE}, {CBC, {B, C}, Symbolic −> Cbc, Value −> CBC}, {CC, {B, X, C, E}, Symbolic −> beta, Value −> BETA}, {RO, {C, E}, Symbolic −> Ro, Value −> RO} ] ] ] // ExpandSubcircuits; This netlist describes a common-emitter amplifier. In[3]:= ceamplifier = Circuit[ Netlist[ {V1, {1, 0}, 1}, {V0, {6, 0}, 0}, {C1, {1, 2}, Symbolic −> C1, Value {R1, {2, 6}, Symbolic −> R1, Value {R2, {2, 0}, Symbolic −> R2, Value {RC, {6, 3}, Symbolic −> RC, Value {RE, {4, 0}, Symbolic −> RE, Value {C2, {3, 5}, Symbolic −> C2, Value {RL, {5, 0}, Symbolic −> RL, Value {Q1, {2 −> B, 3 −> C, 4 −> E}, Model −> BJT, Selector −> AC, CBE −> 30.*^−12, CBC −> 5.*^−12, RO −> 10000., BETA −> 200.} ] ] Out[3]= Circuit −> −> −> −> −> −> −> 1.0*^−7}, 1.0*^5}, 47000.}, 2200.}, 1000.}, 1.0*^−6}, 47000.}, RBE −> 1000., 3.11 Linear Simplification Techniques Set up a system of symbolic AC equations. 389 In[4]:= eqs = CircuitEquations[ceamplifier, ElementValues −> Symbolic] Out[4]= DAEAC, 10 10 Compute the complexity estimate. In[5]:= ComplexityEstimate[eqs] Compute the voltage transfer function symbolically and extract the result from the solution vector. In[6]:= solution = Solve[eqs, V$5]; v5 = Together[V$5 /. First[solution]] Get the design-point information from the DAEObject. In[8]:= dp = GetDesignPoint[eqs] Discard insignificant terms in the transfer function. In[9]:= sag = ApproximateTransferFunction[v5, s, dp, 0.2] Out[5]= 132 Out[7]= C2 R1 R2 RC RL s C1 RE s beta$Q1 C1 Ro$Q1 s C1 Cbc$Q1 Rbe$Q1 RE s2 C1 Cbe$Q1 Rbe$Q1 RE s2 C1 Cbc$Q1 Rbe$Q1 Ro$Q1 s2 C1 Cbc$Q1 RE Ro$Q1 s2 beta$Q1 C1 Cbc$Q1 RE Ro$Q1 s2 C1 Cbc$Q1 Cbe$Q1 Rbe$Q1 RE Ro$Q1 s3 R1 R2 RC R1 Rbe$Q1 RC R2 Rbe$Q1 RC R1 R2 RE R1 Rbe$Q1 RE R2 Rbe$Q1 RE R1 RC RE R2 RC RE R1 R2 Ro$Q1 R1 Rbe$Q1 Ro$Q1 R2 Rbe$Q1 Ro$Q1 R1 RE Ro$Q1 beta$Q1 R1 RE Ro$Q1 R2 RE Ro$Q1 beta$Q1 R2 RE Ro$Q1 C1 R1 R2 Rbe$Q1 RC s Cbc$Q1 R1 R2 Rbe$Q1 RC s Cbe$Q1 R1 R2 Rbe$Q1 RC s C1 R1 R2 Rbe$Q1 RE s 94 C2 Cbe$Q1 R2 Rbe$Q1 RE RL Ro$Q1 s2 C2 Cbc$Q1 R1 RC RE RL Ro$Q1 s2 beta$Q1 C2 Cbc$Q1 R1 RC RE RL Ro$Q1 s2 C2 Cbc$Q1 R2 RC RE RL Ro$Q1 s2 beta$Q1 C2 Cbc$Q1 R2 RC RE RL Ro$Q1 s2 C1 C2 Cbc$Q1 R1 R2 Rbe$Q1 RC RE RL s3 C1 C2 Cbe$Q1 R1 R2 Rbe$Q1 RC RE RL s3 C1 C2 Cbe$Q1 R1 R2 Rbe$Q1 RC RE Ro$Q1 s3 C1 Cbc$Q1 Cbe$Q1 R1 R2 Rbe$Q1 RC RE Ro$Q1 s3 C2 Cbc$Q1 Cbe$Q1 R1 R2 Rbe$Q1 RC RE Ro$Q1 s3 C1 C2 Cbc$Q1 R1 R2 Rbe$Q1 RC RL Ro$Q1 s3 C2 Cbc$Q1 Cbe$Q1 R1 R2 Rbe$Q1 RC RL Ro$Q1 s3 C1 C2 Cbe$Q1 R1 R2 Rbe$Q1 RE RL Ro$Q1 s3 C2 Cbc$Q1 Cbe$Q1 R1 R2 Rbe$Q1 RE RL Ro$Q1 s3 C1 C2 Cbc$Q1 R1 R2 RC RE RL Ro$Q1 s3 beta$Q1 C1 C2 Cbc$Q1 R1 R2 RC RE RL Ro$Q1 s3 C2 Cbc$Q1 Cbe$Q1 R1 Rbe$Q1 RC RE RL Ro$Q1 s3 C2 Cbc$Q1 Cbe$Q1 R2 Rbe$Q1 RC RE RL Ro$Q1 s3 C1 C2 Cbc$Q1 Cbe$Q1 R1 R2 Rbe$Q1 RC RE RL Ro$Q1 s4 Out[8]= C1 1. 107 , R1 100000., R2 47000., RC 2200., RE 1000., C2 1. 106 , RL 47000., Cbe$Q1 3. 1011 , Rbe$Q1 1000., Cbc$Q1 5. 1012 , beta$Q1 200., Ro$Q1 10000. Out[9]= beta$Q1 C1 C2 R1 R2 RC RL Ro$Q1 s2 beta$Q1 C1 C2 Cbc$Q1 R1 R2 RC RE RL Ro$Q1 s3 C1 C2 Cbc$Q1 Cbe$Q1 R1 R2 Rbe$Q1 RC RE RL Ro$Q1 s4 R1 R2 Ro$Q1 beta$Q1 R1 RE Ro$Q1 beta$Q1 R2 RE Ro$Q1 C2 R1 R2 RL Ro$Q1 beta$Q1 C2 R1 RE RL Ro$Q1 beta$Q1 C2 R2 RE RL Ro$Q1 s beta$Q1 C1 C2 R1 R2 RE RL Ro$Q1 s2 beta$Q1 C1 C2 Cbc$Q1 R1 R2 RC RE RL Ro$Q1 s3 C1 C2 Cbc$Q1 Cbe$Q1 R1 R2 Rbe$Q1 RC RE RL Ro$Q1 s4 3. Reference Manual 390 Determine the complexity of the approximated expression. Simplify the result. In[10]:= Length[Denominator[sag]] Out[10]= 7 In[11]:= Simplify[sag] Out[11]= C1 C2 R1 R2 RC RL s2 Cbc$Q1 Cbe$Q1 Rbe$Q1 RE s2 beta$Q1 1 Cbc$Q1 RE s beta$Q1 R2 RE 1 C2 RL s R1 beta$Q1 RE 1 C2 RL s R2 1 C2 RL s beta$Q1 C1 C2 RE RL s2 beta$Q1 C1 C2 Cbc$Q1 RC RE RL s3 C1 C2 Cbc$Q1 Cbe$Q1 Rbe$Q1 RC RE RL s4 To validate the result, we compute the frequency response of the original system numerically and compare it graphically with the approximated result. Compute the frequency response numerically. In[12]:= acsweep = ACAnalysis[eqs, V$5, {f, 1, 1.0*^9}] Evaluate the approximated expression numerically. In[13]:= sagn[s_] = sag /. dp Plot the exact and approximated functions together. In[14]:= BodePlot[acsweep, {V$5[f], sagn[2 Pi I f]}, {f, 1, 1.0*^9}, TraceNames −> {"Exact", "Approximated"}] Out[12]= V$5 InterpolatingFunction1., 1. 109 , Phase (deg) Magnitude (dB) Out[13]= 9.7196 1010 s2 485.98 s3 7.2897 108 s4 3.41 1014 1.6027 1013 s 4.418 1010 s2 485.98 s3 7.2897 108 s4 1.0E0 1.0E2 1.0E4 1.0E6 1.0E8 5 2.5 0 -2.5 -5 -7.5 -10 1.0E0 1.0E2 1.0E4 1.0E6 Frequency 1.0E8 1.0E2 1.0E4 1.0E6 1.0E8 1.0E2 1.0E4 1.0E6 Frequency 1.0E8 1.0E0 0 -50 -100 -150 -200 -250 -300 -350 1.0E0 Exact Out[14]= Graphics Approximated 3.11 Linear Simplification Techniques 391 3.11.3 ApproximateMatrixEquation ApproximateMatrixEquation[dae, var, errspec] approximates a symbolic matrix equation dae with respect to the output variable var and the error specification errspec Command structure of ApproximateMatrixEquation . The function ApproximateMatrixEquation approximates a linear symbolic matrix equation by discarding insignificant matrix entries before the system is solved (simplification before generation, SBG). The significance of a symbolic matrix entry is determined by calculating its numerical influence on the magnitude of the transfer function in one or several frequency sampling points. The approximation process follows a term ranking obtained by computing the large-change sensitivities of the output variable with respect to all matrix entries and sorting the resulting list by least influence. The algorithm deletes all matrix entries whose cumulative influence is less than the user-specified error bound. The error specification errspec has to be given in the following form: {fvar−>freq, MaxError−>maxerr} error specification for a single frequency sampling point {{fvar−>freq , MaxError−>maxerr }, {fvar−>freq , MaxError−>maxerr }, † † † } error specification for several frequency sampling points Format for sampling point and error specifications. For a given errspec, the algorithm assures that the relative magnitude deviation of the output variable var measured at the frequency points fvar = freqi is less than maxerri . To approximate the frequency response of a dynamic circuit, sampling points must be placed on the imaginary axis where s jΩ, or equivalently s Πj f . Therefore, you should specify frequency sampling points in the form s −> 2. Pi I f. By placing sampling points to the left and right of a corner in a frequency response, you can use ApproximateMatrixEquation to extract poles and zeros symbolically. For optimal approximation results, you should set up circuit equations in Sparse Tableau formulation (Formulation −> SparseTableau , see Section 3.5.1). ApproximateMatrixEquation has the following options: 3. Reference Manual 392 option name default value AbsolutePivotThreshold 1.0*10^−8 the absolute pivot threshold for the sparse matrix solver used in the MathLink binary MSBG.exe CompressEquations False whether to compress the matrix equation after approximation DesignPoint Automatic the numerical reference data for the symbols NumericalAccuracy 1.0*10^−8 the numerical accuracy threshold for ranking recomputations PivotThreshold 0.01 the relative pivot threshold for the sparse matrix solver used in the MathLink binary MSBG.exe Protocol Inherited[AnalogInsydes] standard Analog Insydes protocol specification (see Section 3.14.5) Options for ApproximateMatrixEquation , Part I. option name default value QuasiSingularity 1.0*10^−15 threshold for detecting numerical singularities 2.0 threshold for triggering a ranking recomputation RecomputationThreshold SortingMethod PrimaryDesignPoint how to sort the list of matrix entry influences to obtain a term ranking StripIndependentBlocks False UseExternals whether to search for and discard algebraically independent blocks from a matrix equation after approximation Inherited[AnalogInsydes] whether to use the MathLink binary MSBG.exe (see Section 3.14.7) Options for ApproximateMatrixEquation , Part II. 3.11 Linear Simplification Techniques 393 See also: ApproximateTransferFunction (Section 3.11.2). Options Description A detailed description of all ApproximateMatrixEquation options is given below in alphabetical order: AbsolutePivotThreshold With AbsolutePivotThreshold −> posreal you can specify the minimum absolute value a matrix entry must have to be considered as a pivot candidate during LU decomposition. There is no need to change the value of this option unless ApproximateMatrixEquation reports problems with ill-conditioned equations. CompressEquations The setting CompressEquations −> True causes the matrix equation to be compressed after approximation. The option is realized by an internal call of the function CompressMatrixEquation (Section 3.11.4). You should turn matrix compression on whenever you are working with large matrices, i.e. when the matrix dimensions are significantly larger than . DesignPoint With DesignPoint −> {symbol −> value , † † † } you can overwrite the design point given in the DAEObject. The default setting is DesignPoint −> Automatic , which means to use the design point stored in the DAEObject. NumericalAccuracy The option NumericalAccuracy −> posreal specifies the minimum influence a matrix entry must have to trigger a recomputation of the term ranking. This threshold is used to prevent frequent ranking recomputations due to numerical inaccuracies in very small influence values. If the ranking is recomputed too often at the beginning of the approximation process, you should increase the value of NumericalAccuracy by an order of magnitude. Note that information about ranking recomputations is available only if UseExternals −> False and Protocol −> Notebook. See also the description of RecomputationThreshold . PivotThreshold With PivotThreshold −> posreal you can specify the minimum relative magnitude a matrix entry must have to be considered as a pivot candidate during LU decomposition. The value posreal must be a number between and . If it is , then the pivoting method becomes complete pivoting, 3. Reference Manual 394 which is very slow and tends to fill up the matrix. If it is set close to zero, the pivoting method becomes strict Markowitz with no threshold. There is no need to change the value of this option unless ApproximateMatrixEquation reports problems with ill-conditioned equations. Protocol This option describes the standard Analog Insydes protocol specification (see Section 3.14.5). Note that detailed protocol information is not available if UseExternals −> True. QuasiSingularity QuasiSingularity −> posreal specifies a threshold value for determining whether a matrix is numerically singular. In case the matrix approximation function returns a singular matrix, increase the value of QuasiSingularity by one or several orders of magnitude. RecomputationThreshold RecomputationThreshold −> posreal specifies a factor for determining whether the current term ranking should be recomputed. For example, a value of means that a ranking recomputation is triggered if the true influence of a matrix entry at the current approximation step turns out to be two times larger than predicted initially. Ranking recomputations are triggered only by influence values greater than the value of NumericalAccuracy . SortingMethod The option SortingMethod specifies how the list of matrix entry influences is sorted to obtain a term ranking. PrimaryDesignPoint sort matrix entries by least influence on the primary design-point solution LeastMeanInfluence sort matrix entries by mean influence on all design-point solutions Values for the SortingMethod option. With the default setting SortingMethod −> PrimaryDesignPoint , the influence list is sorted by influence on the solution of the matrix equation at the first sampling point specified in errspec. The setting SortingMethod −> LeastMeanInfluence causes the least to be sorted by average influence on the solutions at all sampling points. The setting of the SortingMethod option is relevant only if you specify more than one sampling point. In general, SortingMethod −> LeastMeanInfluence is the preferred setting for multiple sampling points. 3.11 Linear Simplification Techniques 395 StripIndependentBlocks With StripIndependentBlocks −> True, clusters of equations which are decoupled from the variable of interest, are searched for and discarded after approximation. This option is effective only in conjunction with the setting CompressEquations −> True. UseExternals The setting UseExternals −> True causes the MathLink application MSBG.exe to be used for matrix approximation. This is the recommended setting for all platforms for which native Analog Insydes versions exist. You can set UseExternals −> False to run Analog Insydes on other platforms or for debugging purposes in conjunction with the option Protocol . Alternatively, you can also load and unload the module manually as described in Section 3.13.3. For more information refer to UseExternals (Section 3.14.7). Examples In the following we approximate the system of nodal equations representing the small-signal equivalent circuit of the common-emitter amplifier with respect to the output variable V$5. To obtain an approximation of the amplifier’s passband voltage gain, we select a sampling frequency of kHz. At the sampling point we allow the magnitude of the solution of the approximated equations to deviate from the original design-point value by . Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define an AC model for BJTs. In[2]:= Circuit[ Model[ Name −> BJT, Selector −> AC, Scope −> Global, Ports −> {B, C, E}, Parameters −> {Rbe, Cbc, Cbe, beta, Ro, RBE, CBC, CBE, BETA, RO}, Definition −> Netlist[ {CBE, {B, E}, Symbolic −> Cbe, Value −> CBE}, {RBE, {X, E}, Symbolic −> Rbe, Value −> RBE}, {CBC, {B, C}, Symbolic −> Cbc, Value −> CBC}, {CC, {B, X, C, E}, Symbolic −> beta, Value −> BETA}, {RO, {C, E}, Symbolic −> Ro, Value −> RO} ] ] ] // ExpandSubcircuits; 3. Reference Manual 396 This netlist describes a common-emitter amplifier. In[3]:= ceamplifier = Circuit[ Netlist[ {V1, {1, 0}, 1}, {V0, {6, 0}, 0}, {C1, {1, 2}, Symbolic −> C1, Value {R1, {2, 6}, Symbolic −> R1, Value {R2, {2, 0}, Symbolic −> R2, Value {RC, {6, 3}, Symbolic −> RC, Value {RE, {4, 0}, Symbolic −> RE, Value {C2, {3, 5}, Symbolic −> C2, Value {RL, {5, 0}, Symbolic −> RL, Value {Q1, {2 −> B, 3 −> C, 4 −> E}, Model −> BJT, Selector −> AC, CBE −> 30.*^−12, CBC −> 5.*^−12, RO −> 10000., BETA −> 200.} ] ] −> −> −> −> −> −> −> 1.0*^−7}, 1.0*^5}, 47000.}, 2200.}, 1000.}, 1.0*^−6}, 47000.}, RBE −> 1000., Out[3]= Circuit Set up a system of symbolic AC equations. In[4]:= eqs = CircuitEquations[ceamplifier, ElementValues −> Symbolic] Out[4]= DAEAC, 10 10 Compute the complexity estimate. In[5]:= ComplexityEstimate[eqs] Allow for magnitude error at kHz. In[6]:= errspec = {s −> 2. Pi I 10^4, MaxError −> 0.1} Approximate the system of circuit equations. In[7]:= sbg = ApproximateMatrixEquation[eqs, V$5, errspec] Estimate the number of terms after approximation. In[8]:= ComplexityEstimate[sbg] Compute the solution of the approximated equations. In[9]:= sbgresult = Solve[sbg, V$5] Out[5]= 132 Out[6]= s 62831.9 I, MaxError 0.1 Out[7]= DAEAC, 10 10 Out[8]= 1 RC Out[9]= V$5 RE To validate the result, we compute the frequency response of the original system numerically and compare it graphically with the approximated result. Compute the frequency response numerically. In[10]:= acsweep = ACAnalysis[eqs, V$5, {f, 1, 1.0*^9}] Evaluate the approximated expression numerically. In[11]:= sbgn = V$5 /. First[sbgresult] /. GetDesignPoint[eqs] Out[10]= V$5 InterpolatingFunction1., 1. 109 , Out[11]= 2.2 Note that the approximated expression is valid only within the passband because we did not specify sampling points at low or high frequencies. 3.11 Linear Simplification Techniques In[12]:= BodePlot[acsweep, {V$5[f], sbgn}, {f, 1, 1.0*^9}, TraceNames −> {"Exact", "Approximated"}] Phase (deg) Magnitude (dB) Plot the exact and approximated functions together. 397 1.0E0 1.0E2 1.0E4 1.0E6 1.0E8 10 5 0 -5 -10 1.0E0 1.0E2 1.0E0 0 -50 -100 -150 -200 -250 -300 -350 1.0E0 1.0E4 1.0E6 Frequency 1.0E8 1.0E2 1.0E4 1.0E6 1.0E8 1.0E2 1.0E4 1.0E6 Frequency 1.0E8 Exact Approximated Out[12]= Graphics Below, we specify a second sampling point at Hz to extend the validity region of the approximation to low frequencies. Note that you may use a different error bound for each sampling point. Add a second sampling point at Hz. In[13]:= errspec2 = {errspec, {s −> 2. Pi I, MaxError −> 0.3}} Approximate the matrix equation. In[14]:= sbg2 = ApproximateMatrixEquation[eqs, V$5, errspec2, SortingMethod −> LeastMeanInfluence] Out[13]= s 62831.9 I, MaxError 0.1, s 6.28319 I, MaxError 0.3 Out[14]= DAEAC, 10 10 Estimate the number of terms after approximation. In[15]:= ComplexityEstimate[sbg2] Solve the approximated equations. In[16]:= sbgresult2 = Solve[sbg2, V$5] // Simplify Out[15]= 9 Out[16]= C1 C2 R1 R2 RC RL s2 V$5 RE R1 R2 C1 R1 R2 s 1 C2 RC RL s Extract the solution for V$5. In[17]:= v52 = V$5 /. First[sbgresult2] Evaluate the approximated expression numerically. In[18]:= sbgn2[s_] = v52 /. GetDesignPoint[eqs] C1 C2 R1 R2 RC RL s2 Out[17]= RE R1 R2 C1 R1 R2 s 1 C2 RC RL s 48.598 s2 Out[18]= 1 0.0492 s 147000. 470. s 3. Reference Manual 398 Magnitude (dB) In[19]:= BodePlot[acsweep, {V$5[f], sbgn2[2. Pi I f]}, {f, 1, 1.0*^9}, TraceNames −> {"Exact", "Approximated"}] 1.0E0 5 2.5 0 -2.5 -5 -7.5 -10 1.0E0 1.0E2 1.0E4 1.0E6 1.0E8 1.0E2 1.0E4 1.0E6 Frequency 1.0E8 1.0E0 0 -50 -100 -150 -200 -250 -300 -350 1.0E0 1.0E2 1.0E4 1.0E6 1.0E8 Phase (deg) Plot the exact and approximated functions together. 1.0E2 1.0E4 1.0E6 Frequency 1.0E8 Exact Approximated Out[19]= Graphics Note that matrix approximation has reduced the polynomial order of the transfer function from four to two. Therefore, we can now solve the transfer function for the low-frequency poles. Solve for the low-frequency poles. In[20]:= Solve[Denominator[v52] == 0, s] R1 R2 1 Out[20]= s , s C1 R1 R2 C2 RC RL 3.11.4 CompressMatrixEquation CompressMatrixEquation[dae, var] compresses the matrix equation dae with respect to the variable of interest var Command structure of CompressMatrixEquation . Computing a transfer function from a linear system of circuit equations A x b requires solving the matrix equation for one single variable xk . The values of all other variables xj , j , k, are of no interest in this context. Systems of circuit equations usually contain a significant amount of information which is only needed to determine the irrelevant variables, and the proportion of such information increases during the approximation process as equations are algebraically decoupled by removing negligible terms. To reduce the computational effort needed for solving an approximated matrix, all unnecessary information should be discarded from the equations prior to calling Solve (Section 3.5.4), using the function CompressMatrixEquation . This function performs a recursive search on a matrix equation to find and delete all rows and columns which are not needed to compute the variable of interest. Note that compressing a matrix equation is a mathematically exact operation which does not change the value of the output variable. 3.11 Linear Simplification Techniques 399 CompressMatrixEquation has the following option: option name default value StripIndependentBlocks False whether to search for and discard algebraically independent blocks which are decoupled from the variable of interest Option for CompressMatrixEquation . See also: CompressNonlinearEquations (Section 3.12.2), ApproximateMatrixEquation (Section 3.11.3). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define an AC model for BJTs. In[2]:= Circuit[ Model[ Name −> BJT, Selector −> AC, Scope −> Global, Ports −> {B, C, E}, Parameters −> {Rbe, Cbc, Cbe, beta, Ro, RBE, CBC, CBE, BETA, RO}, Definition −> Netlist[ {CBE, {B, E}, Symbolic −> Cbe, Value −> CBE}, {RBE, {X, E}, Symbolic −> Rbe, Value −> RBE}, {CBC, {B, C}, Symbolic −> Cbc, Value −> CBC}, {CC, {B, X, C, E}, Symbolic −> beta, Value −> BETA}, {RO, {C, E}, Symbolic −> Ro, Value −> RO} ] ] ] // ExpandSubcircuits; 3. Reference Manual 400 This netlist describes a common-emitter amplifier. In[3]:= ceamplifier = Circuit[ Netlist[ {V1, {1, 0}, 1}, {V0, {6, 0}, 0}, {C1, {1, 2}, Symbolic −> C1, Value {R1, {2, 6}, Symbolic −> R1, Value {R2, {2, 0}, Symbolic −> R2, Value {RC, {6, 3}, Symbolic −> RC, Value {RE, {4, 0}, Symbolic −> RE, Value {C2, {3, 5}, Symbolic −> C2, Value {RL, {5, 0}, Symbolic −> RL, Value {Q1, {2 −> B, 3 −> C, 4 −> E}, Model −> BJT, Selector −> AC, CBE −> 30.*^−12, CBC −> 5.*^−12, RO −> 10000., BETA −> 200.} ] ] −> −> −> −> −> −> −> 1.0*^−7}, 1.0*^5}, 47000.}, 2200.}, 1000.}, 1.0*^−6}, 47000.}, RBE −> 1000., Out[3]= Circuit Set up a system of symbolic AC equations. In[4]:= eqs = CircuitEquations[ceamplifier, ElementValues −> Symbolic] Out[4]= DAEAC, 10 10 Approximate the system of circuit equations. In[5]:= sbg = ApproximateMatrixEquation[eqs, V$5, {s −> 2. Pi I 10^4, MaxError −> 0.1}] Out[5]= DAEAC, 10 10 Inspect the list of unknowns in the matrix equation. In[6]:= GetVariables[sbg] Solve the equations for V$5. In[7]:= Solve[sbg, V$5] Discard rows and columns which are not needed to compute V$5. In[8]:= cmat = CompressMatrixEquation[sbg, V$5] Inspect the list of remaining unknowns. In[9]:= GetVariables[cmat] Out[6]= V$1, V$2, V$3, V$4, V$5, V$6, V$X$Q1, I$V1, I$V0, IC$CC$Q1 RC Out[7]= V$5 RE Out[8]= DAEAC, 7 7 Out[9]= V$1, V$2, V$3, V$4, V$5, V$X$Q1, IC$CC$Q1 Note that matrix compression does not change the solution of the equations. Solve the compressed equations for V$5. In[10]:= Solve[cmat, V$5] RC Out[10]= V$5 RE 3.12 Nonlinear Simplification Techniques 401 3.12 Nonlinear Simplification Techniques As of version 2, Analog Insydes provides completely new functionality for the simplification of nonlinear circuits: Besides the main functions CompressNonlinearEquations and CancelTerms , there are a number of supporting procedures. The following table shows all commands which build the simplification functionality for nonlinear circuits: NonlinearSetup (Section 3.12.1) setting up the nonlinear approximation procedure CompressNonlinearEquations (Section 3.12.2) eliminating variables in a DAEObject CancelTerms (Section 3.12.3) removing terms in different levels in a DAEObject SimplifySamplePoints (Section 3.12.4) generating sparsed sample-point grids NonlinearSettings (Section 3.12.5) showing nonlinear settings in a DAEObject ShowLevel (Section 3.12.6) showing terms of a DAEObject in different levels ShowCancellations (Section 3.12.7) showing terms of a DAEObject which have been removed 3.12.1 NonlinearSetup NonlinearSetup[dae, inputs, outputs, mode −>{settings }, † † † ] initializes the nonlinear approximation routines Command structure of NonlinearSetup . Before applying the nonlinear simplification routines the DAEObject has to be set up using NonlinearSetup . This function returns a DAEObject containing additional information which is automatically used later on by the simplification functions. Furthermore, NonlinearSetup performs the numerical reference simulations which are used for error calculation. Besides the input and output variables you have to specify which analysis modes to consider during subsequent simplifications. The DAEObject dae has to be a DC or Transient DAEObject. The argument inputs is a symbol or a list of symbols denoting the input parameters to be swept. In this context input parameters are parameters of the DAEObject (not variables). Use GetParameters (Section 3.6.9) to obtain a list of valid parameters. Further, outputs is a symbol or a list of symbols denoting the output variables which are used for error control. In this context output variables are variables of the DAEObject (not parameters). Use GetVariables (Section 3.6.7) to obtain a list of valid variables. 3. Reference Manual 402 The rules modei −> {settingsi } specify the analysis modes to be used during error control and some mode-specific settings for the simplification routines. Here, modei can be DT (DC-transfer analysis) or AC. If the AC analysis is chosen, DT settings have to be specified, too. The mode settings settingsi are given by a sequence of rules. The format is described below. Additionally, NonlinearSetup provides the following option: option name default value Protocol Inherited[AnalogInsydes] standard Analog Insydes protocol specification (see Section 3.14.5) Options for NonlinearSetup. You can use NonlinearSettings (Section 3.12.5) to inspect the settings of the nonlinear simplifications currently stored in a DAEObject. Use GetDAEOptions[dae, NonlinearOptions] to get a list of all nonlinear simplification settings stored in the DAEObject. See also: GetVariables (Section 3.6.7), GetParameters (Section 3.6.9), NonlinearSettings (Section 3.12.5), Section 3.7.2. DT mode specifications Range−>paramsweep SimulationFunction−>simfct ErrorFunction−>errfct MaxError−>errlist parameter sweep specification for all input variables simulation function used for DT analysis; default value: DefaultDTSimulation error function used for DT analysis; default value: DefaultDTError Maximum error specification for the output variables; default value: {} Settings for DT mode. The range in which to sweep the input parameters during simplification is specified by the paramsweep value of the Range option. The range specification has to be given in the standard format for Analog Insydes parameter sweeps which is described in Section 3.7.2. Note that you have to specify a range for each input parameter. SimulationFunction , ErrorFunction , and MaxError are optional, whereas Range is a required argument. If no SimulationFunction option is specified, the default function is used. The default DT simulation function DefaultDTSimulation calls NDAESolve (Section 3.7.5) to calculate the DC operating 3.12 Nonlinear Simplification Techniques 403 points. DefaultDTSimulation inherits almost all options from NDAESolve . The following options have a special meaning when used with DefaultDTSimulation : option name default value MaxIterations Inherited[NDAESolve] maximum number of iterations for NDAESolve (only used if option InitialGuess is set to Automatic ) InitialGuess None if set to Automatic , the values of the reference simulation are used as initial guess for NDAESolve Options for DefaultDTSimulation . Besides the default simulation function you can define your own DT simulation function and specify it as SimulationFunction in the DT mode settings for NonlinearSetup . During the setup and the nonlinear simplifications this function will be called with the following arguments: simfct[dae_, refsim_List:{}, opts___] Pattern for a user-defined DT simulation function. Here, dae is a DC or Transient DAEObject, refsim is the list of numerical reference values and opts are additional options. The simulation function must return the DC operating points in the same format as NDAESolve returns DC operating points of a parameter sweep (see Section 3.7.2). Similarly, you can define your own DT error function instead of the default error function and specify it as ErrorFunction in the DT mode settings for NonlinearSetup . During the simplification routines this function is used to calculate the error with the following arguments: errfct[newval_List, oldval_List, outputsymbols_List] Pattern for a user-defined DT error function. Here, newval and oldval are the numerical solutions of the simplified and the original DAE system, outputsymbols is a list of all output symbols. The error function must return a list of rules {symb −> err , † † † }, which specifies the numerical error for each output symbol. The default DT error function calculates the maximum absolute error. An example for a user-defined simulation and error function and of the corresponding call to NonlinearSetup is given in the example section below. 3. Reference Manual 404 Instead of specifying the maximum allowed error for output variables for each call to the nonlinear simplifications routines separately, you can specify global maximum errors for output variables using the MaxError argument. These values are used if no error value is given in the call to the nonlinear simplification routine. The value of this argument has to be a list of rules of the form outvar −> error. AC mode specifications Range−>{paramsweep, freqlist, sourceval} paramsweep must be a subset of the sweep given in the DT settings, freqlist is a list of frequency points and sourceval is a list of replacement rules for all AC sources SimulationFunction−>simfct ErrorFunction−>errfct MaxError−>errlist simulation function used for AC analysis; default value: DefaultACSimulation error function used for AC analysis; default value: DefaultACError Maximum error specification for the output variables; default value: {} Settings for AC mode. SimulationFunction , ErrorFunction , and MaxError are optional, whereas Range is a required argument. If you specifiy AC settings you have to specify DT settings, too. The parameter sweep settings paramsweep must be a subset of the parameter sweep given in the DT settings. The default AC simulation function is called DefaultACSimulation . This function calls ACAnalysis (Section 3.7.3) to perform the numerical calculation. DefaultACSimulation inherits almost all options from ACAnalysis . Besides the default simulation function you can define your own AC simulation function and specify it as SimulationFunction in the AC mode settings for NonlinearSetup . During the setup and the nonlinear simplifications this function will be called with the following arguments: simfct[dae_, refsim_List:{}, opts___] Pattern for a user-defined AC simulation function. Here, dae is a Transient DAEObject, refsim is the list of numerical reference values and opts are additional options. The simulation function must return a list of the AC solutions in the same format as ACAnalysis returns the result (with the option setting InterpolateResult −> False). 3.12 Nonlinear Simplification Techniques 405 Similarly, you can define your own AC error function instead of the default error function and specify it as ErrorFunction in the AC mode settings for NonlinearSetup . During the simplification routines this function is used to calculate the error with the following arguments: errfct[newval_List, oldval_List, outputsymbols_List] Pattern for a user-defined AC error function. Here, newval and oldval are the numerical solutions of the simplified and the original dae system, outputsymbols is a list of all output symbols. The error function must return a list of rules {symb −> err , † † † } which specifies the numerical error for each output symbol. The default AC error function calculates the maximum relative error. Instead of specifying the maximum allowed error for output variables for each call to the nonlinear simplifications routines separately, you can specify global maximum errors for output variables using the MaxError argument. These values are used if no error value is given in the call to the nonlinear simplification routine. The value of this argument has to be a list of rules of the form outvar −> error. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Read PSpice netlist. In[2]:= net = ReadNetlist["AnalogInsydes/DemoFiles/Sqrt.cir", Simulator −> "PSpice"] Out[2]= Circuit Set up DAE system. In[3]:= dae = CircuitEquations[net, AnalysisMode −> DC, ElementValues −> Symbolic] Out[3]= DAEDC, 27 27 Get all valid symbols that can be used as inputs for NonlinearSetup . In[4]:= GetParameters[dae] Get all valid symbols that can be used as outputs for NonlinearSetup . In[5]:= GetVariables[dae] Out[4]= AREA$Q1, AREA$Q2, AREA$Q3, AREA$Q4, BF$Q1, BF$Q2, BF$Q3, BF$Q4, BR$Q1, BR$Q2, BR$Q3, BR$Q4, GMIN, IB, II, IS$Q1, IS$Q2, IS$Q3, IS$Q4, TEMP, TNOM, VDC, VLOAD, $k, $q Out[5]= V$1, V$3, V$4, V$5, V$OUT, I$BS$Q1, I$CS$Q1, I$ES$Q1, ib$Q1, ic$Q1, I$BS$Q2, I$CS$Q2, I$ES$Q2, ib$Q2, ic$Q2, I$BS$Q3, I$CS$Q3, I$ES$Q3, ib$Q3, ic$Q3, I$BS$Q4, I$CS$Q4, I$ES$Q4, ib$Q4, ic$Q4, I$VLOAD, I$VDC In the following we choose VLOAD and II as inputs and V$5 and I$VLOAD as outputs, treating dae as a multi-input/multi-output system. We want to control the DC behavior sweeping VLOAD between V and V and II between A and A on a uniform two-dimensional grid with points. The following call to NonlinearSetup prepares a DAEObject with these settings. 3. Reference Manual 406 Specify settings for nonlinear simplifications. In[6]:= step1=NonlinearSetup[dae, {VLOAD, II}, {V$5, I$VLOAD}, DT −> {Range −> {{VLOAD, 0, 3, 1}, {II, 0, 0.003, 0.001}} }] Out[6]= DAEDC, 27 27 Display settings stored in step1. In[7]:= NonlinearSettings[step1] Input symbols : {II, VLOAD} Output symbols : {I$VLOAD, V$5} Ranking−Cache : −not set− DT range : {{VLOAD −> 0., II −> 0.}, <<15>>} DTSimulation : DefaultDTSimulation DTError : DefaultDTError DTReference : {<<16>>} OperatingPoints : {<<16>>} The following code illustrates how to define your own simulation and error function and how to call NonlinearSetup such that these functions are used during nonlinear simplifications. Define a DT simulation function. In[8]:= MyDTSimulationFct[dae_, refsim_List:{}, opts___] := Block[ {nonlinopts, indepvar, inittime}, {indepvar, inittime, nonlinopts} = GetDAEOptions[ dae, {IndependentVariable, InitialTime, NonlinearOptions} ]; NDAESolve[ dae, {indepvar, inittime}, Range /. (DT /. nonlinopts), opts ] ] Define a DT error function. In[9]:= MyDTErrorFct[newval_, oldval_, outputsymbols_] := Map[ Rule[#, Max[Abs[(# /. newval) − (# /. oldval)]]] &, outputsymbols ] Set up nonlinear simplifications using new simulation and error function. In[10]:= step1 = NonlinearSetup[dae, {VLOAD, II}, {V$5, I$VLOAD}, DT −> { Range −> {{VLOAD, 0, 3, 1}, {II, 0, 0.003, 0.001}}, SimulationFunction −> MyDTSimulationFct, ErrorFunction −> MyDTErrorFct } ] Out[10]= DAEDC, 27 27 3.12 Nonlinear Simplification Techniques Display settings stored in step1. 407 In[11]:= NonlinearSettings[step1] Input symbols : {II, VLOAD} Output symbols : {I$VLOAD, V$5} Ranking−Cache : −not set− DT range : {{VLOAD −> 0., II −> 0.}, <<15>>} DTSimulation : MyDTSimulationFct DTError : MyDTErrorFct DTReference : {<<16>>} OperatingPoints : {<<16>>} 3.12.2 CompressNonlinearEquations CompressNonlinearEquations[dae, outvars] removes equations and eliminates variables from a nonlinear DAEObject dae which are irrelevant for solving for the variables outvars CompressNonlinearEquations[dae] removes as many equations and variables as possible Command structure of CompressNonlinearEquations . This function contains a compression algorithm which allows for identification and elimination of irrelevant equations and variables and the removal of decoupled clusters of equations and variables in a system of symbolic nonlinear differential and algebraic circuit equations. The return value is again a DAEObject. Note that the argument outvars also supports string patterns. Additionally, CompressNonlinearEquations automatically retrieves the settings made by NonlinearSetup , so there is no need to specify the variables of interest as a second argument. Note that CompressNonlinearEquations also supports the data format from Release 1, where equations are given as {eqns, vars}, instead of a DAEObject: CompressNonlinearEquations[{eqns, vars}, outvars] removes equations and eliminates variables from a set of nonlinear equations eqns formulated in the variables vars which are irrelevant for solving for the variables outvars CompressNonlinearEquations[{eqns, vars}] removes as many equations and variables as possible Additional patterns of CompressNonlinearEquations . CompressNonlinearEquations has the following options: 3. Reference Manual 408 option name default value EliminateVariables Automatic Protocol Inherited[AnalogInsydes] standard Analog Insydes protocol specification (see Section 3.14.5) eliminates irrelevant variables StripIndependentBlocks removes irrelevant independent subsystems of equations True Options for CompressNonlinearEquations . See also: CompressMatrixEquation (Section 3.11.4). Options Description EliminateVariables EliminateVariables allows for eliminating variables from a set of equations. Settings are Automatic for eliminating variables occuring linear everywhere, All for eliminating variables occuring linear somewhere, and None for no variable elimination, respectively. The default setting is EliminateVariables −> Automatic . StripIndependentBlocks With StripIndependentBlocks −> True irrelevant independent subsystems of equations will be searched for and removed. The default setting is StripIndependentBlocks −> True. Examples D1 1 V0 Load Analog Insydes. 2 C1 In[1]:= <<AnalogInsydes‘ R1 Vout 3.12 Nonlinear Simplification Techniques Define netlist description of a simple diode rectifier circuit. 409 In[2]:= rectifier = Circuit[ Netlist[ {V0, {1, 0}, Symbolic −> V0, Value −> 2. Sin[10^6 Time]}, {R1, {2, 0}, Symbolic −> R1, Value −> 100.}, {C1, {2, 0}, Symbolic −> C1, Value −> 1.*^−7}, {D1, {1 −> A, 2 −> C}, Model −> "Diode", Selector −> "Spice"} ] ] Out[2]= Circuit Set up the system of symbolic time-domain equations. In[3]:= rectifiereqs = CircuitEquations[rectifier, AnalysisMode −> Transient, ElementValues −> Symbolic] // UpdateDesignPoint Out[3]= DAETransient, 4 4 Show equation system. In[4]:= DisplayForm[rectifiereqs] Out[4]//DisplayForm= V$2t I$AC$D1t I$V0t 0, I$AC$D1t C1 V$2 t 0, R1 TEMP 1.11 1. TNOM $q TEMP $k V$1t V0, I$AC$D1t AREA$D1 E 3. 1. $q V$1tV$2t TEMP TEMP $k 1 E IS$D1 GMIN V$1t V$2t, TNOM V$1t, V$2t, I$V0t, I$AC$D1t, DesignPoint V0 2. Sin1000000 t, R1 100., C1 1. 107 , AREA$D1 1., GMIN 1. 1012 , IS$D1 1. 1014 , TEMP 300.15, TNOM 300.15, $k 1.38062 1023 , $q 1.60219 1019 Eliminate variables which occur linear everywhere. In[5]:= rectifiercomp = CompressNonlinearEquations[rectifiereqs, V$2[t], EliminateVariables −> Automatic] Out[5]= DAETransient, 2 2 Show compressed equation system. In[6]:= DisplayForm[rectifiercomp] Out[6]//DisplayForm= TEMP 1.11 1. 1. $q V$1tV$2t TEMP 3. TNOM $q TEMP $k TEMP $k 1. AREA$D1 E 1. E IS$D1 TNOM V$2t 1. GMIN V$1t 1. V$2t C1 V$2 t 0, R1 V$1t V0, V$1t, V$2t, DesignPoint V0 2. Sin1000000 t, R1 100., C1 1. 107 , AREA$D1 1., GMIN 1. 1012 , IS$D1 1. 1014 , TEMP 300.15, TNOM 300.15, $k 1.38062 1023 , $q 1.60219 1019 Eliminate variables which occur linear somewhere. In[7]:= rectifiercomp = CompressNonlinearEquations[rectifiereqs, V$2[t], EliminateVariables −> All] Out[7]= DAETransient, 1 1 3. Reference Manual 410 Show compressed equation system. In[8]:= DisplayForm[rectifiercomp] Out[8]//DisplayForm= TEMP 1.11 1. 1. $q V0V$2t TEMP 3. TNOM $q TEMP $k TEMP $k 1. AREA$D1 E 1. E IS$D1 TNOM V$2t 1. GMIN V0 1. V$2t C1 V$2 t 0, V$2t, R1 DesignPoint V0 2. Sin1000000 t, R1 100., C1 1. 107 , AREA$D1 1., GMIN 1. 1012 , IS$D1 1. 1014 , TEMP 300.15, TNOM 300.15, $k 1.38062 1023 , $q 1.60219 1019 Perform numerical transient analyses with NDAESolve . In[9]:= orig = NDAESolve[rectifiereqs, {t, 0., 2.*^−5}]; comp = NDAESolve[rectifiercomp, {t, 0., 2.*^−5}]; Compare the simulation results with TransientPlot . In[11]:= V$2Orig := V$2 /. First[orig]; TransientPlot[comp, {V$2[t], V$2Orig[t]}, {t, 0., 2.*^−5}] 1.2 1 V$2[t] 0.8 0.6 0.4 V$2Orig[t 0.2 t -6 0.00001 0.000015 0.00002 5. 10 Out[12]= Graphics 3.12.3 CancelTerms CancelTerms[dae, maxerrors] CancelTerms[dae] applies cancellation of terms in dae for a given error specification maxerrors applies cancellation of terms using error specification given by NonlinearSetup Command structure of CancelTerms. CancelTerms simplifies the given DAEObject by successive removal of terms in the equation system. It assures that the behavior of the simplified system differs not more than maxerrors from the behavior of the original system. Before using CancelTerms , the DAEObject has to be prepared for nonlinear simplification using NonlinearSetup (Section 3.12.1). CancelTerms performs the numerical analyses set by the call to NonlinearSetup to calculate the error a simplification causes. The error 3.12 Nonlinear Simplification Techniques 411 list maxerrors must contain an error bound value for each analysis mode and each output variable, i.e. it has to be a list of the form {mode1 −> {var1 −> bound1 , }, } Variables for which an error value has been specified in the call to NonlinearSetup can be omitted. If error specifications have been given for each analysis mode and each output variable in the call to NonlinearSetup , the maxerrors specification can be omitted completely. If the error caused by a simplification exceeds any of the maximum errors given in the error list, the simplification is undone. Note that the error is measured by the error function specified in the call to NonlinearSetup . Removal of terms is done in the level given by the option Level (see below). CancelTerms returns the simplified DAEObject. All settings for nonlinear simplifications stored in the original system are added to the returned DAEObject, too. This means that you do not have to call NonlinearSetup again on the new system in order to apply subsequent simplifications. Note that CancelTerms reduces the number of terms only. Use CompressNonlinearEquations (Section 3.12.2) to reduce the number of equations. CancelTerms provides the following options: option name default value Clusterbound −1 logarithmic bound for cluster calculation Errorbound 3 number of successive error-bound violations before the algorithm terminates Level 0 level in which to remove terms Protocol Inherited[AnalogInsydes] standard Analog Insydes protocol specification (see Section 3.14.5) Ranking Automatic method to use for ranking RecordCancellations True whether to record term cancellations Options for CancelTerms. After removal of one or more terms a numerical simulation is performed. Comparing the result to a reference calculation yields the error on the output variables. See also: NonlinearSetup (Section 3.12.1), ShowCancellations (Section 3.12.7), ShowLevel (Section 3.12.6), Statistics (Section 3.6.17). Options Description A detailed description of all CancelTerms options is given below in alphabetical order: 3. Reference Manual 412 Clusterbound Usually, CancelTerms deletes several terms at once before performing a numerical error calculation. The computation of suitable term clusters for this is done automatically by CancelTerms . If the precasted influence of a term exceeds a given threshold, calculation of clusters is stopped and cancellation is done term by term. This threshold value is specified by the option Clusterbound . The following values are allowed: integer stop calculation of clusters if the logarithm (to base ) of the precasted term influence is bigger than integer −Infinity do not cancel terms in clusters Infinity always cancel terms in clusters Values for the Clusterbound option. The default setting is Clusterbound −> −1. Note that deletion of terms using clusters speeds up the computation significantly. Errorbound If the computed error exceeds the given error bound maxerrors, then the term or terms are re-inserted. The option Errorbound specifies the number of successive re-insertions before the algorithm terminates. Use Errorbound −> Infinity to check all terms for cancellation. The default setting is Errorbound −> 3. Level By default, CancelTerms removes terms from top-level sums (level 0). It is also possible to simplify sums in deeper levels, i.e. sums occuring inside of expressions. The option Level determines which level is affected by the simplification. Possible values are: n {n , n , † † † } All apply cancellation in level n apply cancellation in levels n , n , apply cancellation in all levels, starting on top level Level specifications for CancelTerms. If given explicitly, level specifications have to be non-negative integers. The default setting is Level −> 0. 3.12 Nonlinear Simplification Techniques 413 The level specification of CancelTerms does not correspond to the level of the internal Mathematica representation of dae. Use ShowLevel (Section 3.12.6) or Statistics (Section 3.6.17) to see which levels can be influenced by CancelTerms . Ranking Cancellation of terms is performed in a pre-calculated order which sorts the terms by increasing influence. A method which estimates the influence of a cancellation on the output behavior is called ranking. CancelTerms lets you choose which ranking method to use for each analysis mode separately by means of the Ranking option. Possible values are: {mode−>Automatic|Simulation, † † † } set mode dependent ranking functions Automatic equivalent to {_−>Automatic} Simulation equivalent to {_−>Simulation} Values for the Ranking option. The ranking method can either be Automatic , which means to use the internal implemented ranking function, or Simulation , which means to use the corresponding simulation function to calculate the influence. The former is much more efficient while the latter is more accurate. If the option value is the symbol Automatic or Simulation the corresponding ranking function is set for all analysis modes simultaneously. If you want to set the ranking function for each mode separately, you have to give a list of rules. The current analysis mode is then matched against the left hand side of the rules and the corresponding right hand sides are chosen as ranking functions. Thus, mode can either be one of the symbols DT or AC, or a pattern specification like _. The default setting is Ranking −> Automatic . RecordCancellations The value of the RecordCancellations option determines whether term cancellations are recorded during computation. If set to True, a cancellation history is written to the options section of the DAEObject given as argument to CancelTerms . Note that it is not written to the returned DAEObject. The command ShowCancellations (Section 3.12.7) can then be used to visualize the history list. If set to False, no history list is recorded. The default setting is RecordCancellations −> True. If you cancel terms in different levels, the history list of the first level will be recorded only. 3. Reference Manual 414 Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Read PSpice netlist. In[2]:= netlist = ReadNetlist[ "AnalogInsydes/DemoFiles/Sqrt.cir", Simulator −> "PSpice"] Out[2]= Circuit Set up symbolic circuit equations. In[3]:= mnaFull = CircuitEquations[netlist, AnalysisMode −> DC, ElementValues −> Symbolic, Value −> {"*" −> {TEMP, TNOM, $q, $k}}] Out[3]= DAEDC, 27 27 Prepare DAE system for nonlinear simplifications. In[4]:= step1 = NonlinearSetup[mnaFull, {II, VLOAD}, {I$VLOAD}, DT −> {Range −> {{VLOAD, 0., 3.5, 0.5}, {II, 0., 0.001, 0.0002}} }] Out[4]= DAEDC, 27 27 Display complexity information of the original system. In[5]:= Statistics[step1] Number of equations : 27 Number of variables : 27 Length of equations : {4, 4, 3, 3, 2, 3, 2, 3, 8, 8, 3, 2, 3, 9, 9, 3, 2, 3, 9, 9, 3, 2, 3, 4, 4, 3, 2} Terms with derivatives : 0 Sums in levels : {113, 20} Cancel top-level terms in the equations. In[6]:= step2 = CancelTerms[step1, {DT −> {I$VLOAD −> 25.*^−6}}] Display complexity information of the simplified system. Note that the number of terms decreased, while the number of equations stayed the same. In[7]:= Statistics[step2] Out[6]= DAEDC, 27 27 Number of equations : 27 Number of variables : 27 Length of equations : {1, 2, 2, 2, 2, 2, 1, 2, 2, 1, 1, 1, 2, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 2, 1, 2, 1} Terms with derivatives : 0 Sums in levels : {32, 4} 3.12.4 SimplifySamplePoints SimplifySamplePoints[func, range, tolerance] reduces the number of points in range for a given tolerance specification tolerance Command structure of SimplifySamplePoints . 3.12 Nonlinear Simplification Techniques 415 SimplifySamplePoints returns a sparsed list of sample points such that the function values, evaluated on adjacent points, do not exceed the given tolerance. The argument range must be a valid parameter sweep specification as described in Section 3.7.2. If range is a n-dimensional sweep range then func must be a function of n arguments which returns a single real number. SimplifySamplePoints provides the following options: option name default value ReturnSymbols True whether to return a list of rules or a list of numerical values SearchDirections All specifies the direction in which to search for adjacent points Options for SimplifySamplePoints . See also: Section 3.7.2. Options Description ReturnSymbols If ReturnSymbols is set to True, the sparsed list is returned as a flat list of rules. If it is set to False, the sparsed list is returned as a flat list of numerical values. In the former case the return value is a valid parameter sweep specification and can be used as argument to NonlinearSetup (Section 3.12.1). The default setting is ReturnSymbols −> True. SearchDirections The option SearchDirections specifies the direction in which to search for adjacent points. The value can be All or a list of symbols which appear in the given parameter sweep. If the value is a list of symbols, adjacent points are only searched for the given variables. The default setting is SearchDirections −> All which means to search in all directions. 3.12.5 NonlinearSettings NonlinearSettings[dae] Command structure of NonlinearSettings . prints all settings for nonlinear simplifications stored in dae 3. Reference Manual 416 As mentioned in the description of NonlinearSetup (Section 3.12.1) additional data has to be stored in a DAE system in order to apply the nonlinear simplification routines. The command NonlinearSettings prints the according data currently stored in a DAEObject. NonlinearSettings provides the following information: list of input symbols list of output symbols value of the ranking cache mode-specific settings (range, simulation function, error function, and reference values) See also: NonlinearSetup (Section 3.12.1). Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Read PSpice netlist. In[2]:= net = ReadNetlist["AnalogInsydes/DemoFiles/Sqrt.cir", Simulator −> "PSpice"] Out[2]= Circuit Set up DAE system. In[3]:= dae = CircuitEquations[net, AnalysisMode −> DC, ElementValues −> Symbolic] Out[3]= DAEDC, 27 27 Specify settings for nonlinear simplifications. In[4]:= setup = NonlinearSetup[dae, {VLOAD, II}, {V$5, I$VLOAD}, DT −> {Range −> {{VLOAD, 0, 3, 1}, {II, 0, 0.003, 0.001}} }] Out[4]= DAEDC, 27 27 Display settings stored in the DAEObject. In[5]:= NonlinearSettings[setup] Input symbols : {II, VLOAD} Output symbols : {I$VLOAD, V$5} Ranking−Cache : −not set− DT range : {{VLOAD −> 0., II −> 0.}, <<15>>} DTSimulation : DefaultDTSimulation DTError : DefaultDTError DTReference : {<<16>>} OperatingPoints : {<<16>>} 3.12 Nonlinear Simplification Techniques 417 3.12.6 ShowLevel ShowLevel[dae] ShowLevel[dae, level] highlights parts of dae influenced by nonlinear simplification routines for all levels highlights parts in levels of dae given by level Command structure of ShowLevel. The command ShowLevel displays the equation system dae and highlights those parts of the equations which are influenced by nonlinear simplification functions such as CancelTerms (Section 3.12.3). The second argument level can either be a number or a list of numbers. If it is a number, then exactly this level is highlighted. If it is a list of numbers {l , † † †, ln } then the levels l , , ln are highlighted. The level argument corresponds to the level argument of CancelTerms and to the output of Statistics (Section 3.6.17). The level specification of ShowLevel does not correspond to the level of the internal Mathematica representation of dae. See also: ShowCancellations (Section 3.12.7), Statistics (Section 3.6.17), CancelTerms (Section 3.12.3). 3.12.7 ShowCancellations ShowCancellations[dae] highlights those parts of dae which have been removed by nonlinear simplification routines Command structure of ShowCancellations . The command ShowCancellations displays the equation system dae and highlights those parts of the equations which have been removed by nonlinear simplification functions such as CancelTerms (Section 3.12.3). You have to set the value of the CancelTerms option RecordCancellations to True to activate the history recording feature. Note that dae is not the return value of a nonlinear simplification routine but its argument. See also: ShowLevel (Section 3.12.6), CancelTerms (Section 3.12.3). 3. Reference Manual 418 3.13 Miscellaneous Functions 3.13.1 ConvertDataTo2D ConvertDataTo2D[data] converts numerical simulation data into two-dimensional interpolating functions Command structure of ConvertDataTo2D . All Analog Insydes functions which return numerical data, e. g. ACAnalysis (Section 3.7.3), NoiseAnalysis (Section 3.7.4), NDAESolve (Section 3.7.5), or ReadSimulationData (Section 3.10.3) use the data format described in Section 3.7.1. This format is suitable for representing one, two, and multi-dimensional numerical data. As standard Mathematica graphic functions do not support the multi-dimensional Analog Insydes data format, ConvertDataTo2D converts the data such that it can be plotted with standard Mathematica graphic functions such as Plot3D. The input data must be two-dimensional data as described in Section 3.7.1, for example: Data format for two-dimensional numerical simulation data. { { V$1 −> InterpolatingFunction[{{t1, t2}}, <>], , SweepParameters −> {VIN −> v1} }, , { V$1 −> InterpolatingFunction[{{t1, t2}}, <>], , SweepParameters −> {VIN −> v2} } } The data will then be converted to a set of two-dimensional interpolating functions: Converted data format. { V$1 −> InterpolatingFunction[{{v1, v2}, {t1, t2}}, <>], , } Please note the order of the parameters for the two-dimensional interpolating function. The interpolation order is set to {1, 1}. See also: Section 3.7.1, Section 3.7.2. 3.13 Miscellaneous Functions 419 Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Read the simulation data with ReadSimulationData . In[2]:= data = ReadSimulationData[ "AnalogInsydes/DemoFiles/Multivibrator.txt", Simulator −> "PSpice"] Out[2]= V4 InterpolatingFunction0.00018, V5 InterpolatingFunction0.00018, SweepParameters VCC 0., V4 InterpolatingFunction0.00018, V5 InterpolatingFunction0.00018, SweepParameters VCC 6., V4 InterpolatingFunction0.00018, V5 InterpolatingFunction0.00018, SweepParameters VCC 12. 0.00012, , 0.00012, , 0.00012, , 0.00012, , 0.00012, , 0.00012, , Convert it into two-dimensional interpolating functions. In[3]:= data2d = ConvertDataTo2D[data] Display simulation result with Plot3D. In[4]:= Plot3D[ Evaluate[("V(4)"[VCC, IC]−"V(5)"[VCC, IC]) /. data2d], {IC, −0.00018, 0.00011}, {VCC, 0., 12.}, BoxRatios −> {1., 1., 1.}, AxesLabel −> {"IC", "VCC", "V(4)−V(5)"}] Out[3]= V4 InterpolatingFunction 0., 12., 0.00018, 0.00012, , V5 InterpolatingFunction0., 12., 0.00018, 0.00012, VCC 10 7.5 5 2.5 0 5 V(4)-V(5) 0 -5 -10 -0.0001 0.0001 IC 0 0.0001 Out[4]= SurfaceGraphics 3.13.2 DXFGraphics DXFGraphics["file"] Command structure of DXFGraphics. displays a DXF file as a native Mathematica graphic object 3. Reference Manual 420 The main purpose of importing DXF (Drawing Interchange File) is to include a schematics into a Mathematica notebook for a better understanding and documentation of circuit analysis tasks. If your schematic editor does not support the generation of DXF files it might be possible to use tools like pstoedit and hpgl2ps to convert the graphic data to DXF. The DXF file should only contain two-dimensional graphic objects. The following DXF entities are supported by DXFGraphics : ARC CIRCLE LINE POINT POLYLINE SHAPE SOLID TEXT DXF entities supported by DXFGraphics. DXFGraphics inherits all options from Graphics. Additional options for DXFGraphics are: option name default value FillColors None specifies the colors to be filled LayerColor False whether the layer color should be used LineDashingScale 5000. the line dashing scale Protocol Inherited[AnalogInsydes] standard Analog Insydes protocol specification (see Section 3.14.5) ShowColors False whether to display the legend of used colors TextSizing True whether to size the text TextStyle {FontSize −> 12} the used TextStyle ThicknessFunction AbsoluteThickness function translating the DXF line thickness into a graphics primitive ColorList {† † †} list which translates DXF colors into Mathematica colors Options for DXFGraphics. 3.13 Miscellaneous Functions 421 Options Description A detailed description of all DXFGraphics options is given below in alphabetical order: FillColors Most DXF generators are not able to convert filled graphic objects into DXF correctly. The option FillColors can be used to fill POLYLINE and CIRCLE entities by specifying a list of pairs of DXF colors and Mathematica graphic primitives. For example, FillColor −> {1, RGBColor[0, 0, 0]} will fill all converted POLYLINE and CIRCLE entities of color 1 with the Mathematica color directive RGBColor[0, 0, 0]. More fill colors can be set as lists of pairs of a DXF color and a Mathematica graphic primitive or a DXF color. If only a DXF color number is given the entity will be filled with its original color. LayerColor Each DXF entity belongs to a layer having its own color property. DXFGraphics takes the color of the entity if LayerColor −> False and the color of the layer otherwise. LineDashingScale The value given by the option LineDashingScale is directly multiplied with the DXF dashing value. The result is the argument of AbsoluteDashing used by DXFGraphics . ShowColors ShowColors −> True displays a legend of used colors which allows for identifying the wanted DXF colors easily. TextSizing If TextSizing is set to True, the text will be scaled according to the DXF data. The average size of all text primitives in the resulting Mathematica graphics object is calculated. Afterwards the text sizes are fitted such that the average equals the value of FontSize given by the option TextStyle (see below). TextStyle The option TextStyle specifies the default style and font options used for displaying text. The format is {opt −> val , † † † }. If TextStyle contains the rule TextStyle −> val, the value val denotes the average size of the font sizes if TextSizing is True. 3. Reference Manual 422 ThicknessFunction This option can be used for setting the line thickness. To generate a graphic using a ten times larger line thickness and a minimum line thickness of five specify ThicknessFunction −> (AbsoluteThickness[10.*#+5.]&) . ColorList The option ColorList can be used to modify the color translation table. For example, to set the DXF color 7 to the Mathematica color white use the option ColorList −> ReplacePart[Options[DXFColor, ColorList][[1,2]], GrayLevel[1], 7]. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Import a DXF file into Mathematica. In[2]:= DXFGraphics["AnalogInsydes/DemoFiles/Buffer.dxf"] Q2N2907a5 Q2N2907a T4 T3 Q2N2907a T5 4 3 VDB 1Q2N2222 T1 + T2 Q2N2222 2 VOUTVDD VIN + I1 I2 + + 0 Out[2]= Graphics 3.13 Miscellaneous Functions Use the option TextStyle to fit the font size. 423 In[3]:= DXFGraphics["AnalogInsydes/DemoFiles/Buffer.dxf", TextStyle −> {FontSize −> 4}] 5 Q2N2907a Q2N2907a T4 T3 Q2N2907a T5 4 3 1 Q2N2222 T1T2 2Q2N2222 VIN + - VOUTVDB I1+ I2+ - - VDD + - 0 Out[3]= Graphics With the option FillColors certain picture elements can be filled. In[4]:= DXFGraphics["AnalogInsydes/DemoFiles/colorcirc.dxf", FillColors −> {{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7, −1}, {8}, {9}, {20}, {30}, {33}, {40}, {60}, {70}, {80}, {100}, {110}, {120}, {140}, {150}, {160}, {180}, {190}, {200}, {220}, {230}, {240}, {250}, {251}, {252}, {253}, {254}}, TextStyle −> {FontSize −> 4}] Red GreenBlue Yellow Pink Cyan ’White’ Out[4]= Graphics 3. Reference Manual 424 3.13.3 MathLink Module MSBG LoadMSBG[] or LoadMSBG[False] loads and installs the MathLink module if it is not installed yet LoadMSBG[True] UnloadMSBG[] loads and installs the MathLink module; forces unloading and reinstallation if the module was already installed uninstalls the MathLink module Manually loading and unloading of the MathLink module MSBG.exe. Analog Insydes loads the MathLink SBG module automatically when it is needed, but you can also load and unload the module manually by applying one of the above functions. Note that since the SBG module is a MathLink application, the global Analog Insydes option UseExternals (Section 3.14.7) must be set to True to enable these functions. 3.13.4 MathLink Module QZ LoadQZ[] or LoadQZ[False] LoadQZ[True] UnloadQZ[] loads and installs the MathLink module if it is not installed yet loads and installs the MathLink module; forces unloading and reinstallation if the module was already installed uninstalls the MathLink module Manually loading and unloading of the MathLink module QZ.exe. Analog Insydes loads the MathLink QZ module automatically when it is needed, but you can also load and unload the module manually by applying one of the above functions. Note that since the QZ module is a MathLink application, the global Analog Insydes option UseExternals (Section 3.14.7) must be set to True to enable these functions. 3.14 Global Options 425 3.14 Global Options Analog Insydes provides a number of global options for controlling some fundamental settings shared by all program modules. An overview of the global options and their default settings (Section 3.14.1) as well as a detailed description of each option (Section 3.14.2 – Section 3.14.7) are given below. Section 3.14.8 describes the option inheritance scheme implemented in Analog Insydes. 3.14.1 Options[AnalogInsydes] The current settings of the global Analog Insydes options can be inspected with Options[AnalogInsydes] . You can change the value of a global option in a Mathematica session with SetOptions[AnalogInsydes, optname −> value]. There are the following global Analog Insydes options available: option name default value InstanceNameSeparator "$" LibraryPath Prepend[$Path, "aidir/AnalogInsydes/ModelLibrary"] the search path for device model libraries ModelLibrary "FullModels‘" the default device model library searched by ExpandSubcircuits Protocol StatusLine the amount and location of protocol information generated by Analog Insydes commands Simulator "AnalogInsydes" the source/target simulator for data import/export and circuit simulation functions UseExternals True whether to use external MathLink modules Global options for Analog Insydes. See also: Options, SetOptions . Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ separator string for name components of model variables and reference designators 3. Reference Manual 426 View global Analog Insydes option settings. In[2]:= Options[AnalogInsydes] Out[2]= InstanceNameSeparator $, LibraryPath Prepend$Path, aidirAnalogInsydesModelLibrary, ModelLibrary FullModels‘, Protocol StatusLine, Simulator AnalogInsydes, UseExternals True 3.14.2 InstanceNameSeparator The option InstanceNameSeparator −> "string" specifies the character or string Analog Insydes uses to separate name components of variables, node identifiers, and reference designators generated for device model or subcircuit instances. For example, the default setting InstanceNameSeparator −> "$" causes the transconductance gm of a transistor Q1 to be named gm$Q1 after model instantiation. The value of InstanceNameSeparator must be a valid symbol name. The given "string" may not contain characters which have a special meaning in Mathematica, such as _ or ‘. See also: CircuitEquations (Section 3.5.1). 3.14.3 LibraryPath With the option LibraryPath , you can specify the paths to be searched for device model library files. Possible values are: "path" {"path ", "path ", † † † } search for model libraries in "path" search paths "path ", "path ", † † † in the given order for model libraries Values for the LibraryPath option. The default setting is LibraryPath :> Prepend[$Path, "aidir/AnalogInsydes/ModelLibrary"] , which adds the installation path of your Analog Insydes model library to the Mathematica variable $Path. See also: Info[AnalogInsydes] (Section 3.15.6), Chapter 3.3. 3.14 Global Options 427 3.14.4 ModelLibrary With the option ModelLibrary , you can specify the names of the files or contexts searched by ExpandSubcircuits for device model definitions during netlist expansion. Possible values are: "lib" {"lib ", "lib ", † † † } select file or context "lib" as default device model library select files or contexts "lib ", "lib ", † † † as default device model libraries (files are searched in the given order) Values for the ModelLibrary option. Analog Insydes provides the following semiconductor device model libraries: "FullModels‘" "SimplifiedModels‘" "BasicModels‘" full-precision SPICE device models medium-precision device models (some parasitic effects excluded) low-precision device models (without parasitic effects) Analog Insydes device model libraries. The default setting is ModelLibrary −> "FullModels‘" , which applies the full-precision SPICE device models. See also: LibraryPath (Section 3.14.3), CircuitEquations (Section 3.5.1), Chapter 3.3, Chapter 4.3. Examples Load Analog Insydes. In[3]:= <<AnalogInsydes‘ Use basic models for all semiconductor devices. In[4]:= SetOptions[AnalogInsydes, ModelLibrary −> "BasicModels‘"] Out[4]= InstanceNameSeparator $, LibraryPath Prepend$Path, aidirAnalogInsydesModelLibrary, ModelLibrary BasicModels‘, Protocol StatusLine, Simulator AnalogInsydes, UseExternals True The fact that library files are searched in the given order and the way in which the Analog Insydes model library is organized allow you to change the default model complexity setting for a particular device type by using the ModelLibrary option as follows. 3. Reference Manual 428 Use full-precision models for diodes and basic models for all other devices. In[5]:= SetOptions[AnalogInsydes, ModelLibrary −> {"FullDiodeModels‘", "BasicModels‘"}] Out[5]= InstanceNameSeparator $, LibraryPath Prepend $Path, aidirAnalogInsydesModelLibrary, ModelLibrary FullDiodeModels‘, BasicModels‘, Protocol StatusLine, Simulator AnalogInsydes, UseExternals True 3.14.5 Protocol With the option setting Protocol −> levelspecs, you can control the amount of protocol information generated by Analog Insydes commands and specify the location on the screen where protocol messages are displayed. You can distinguish between top-level functions and lower-level functions (i.e. functions called by top-level functions). Possible values are: leveltop specify destination for protocol messages generated by top-level function; do not show protocol messages from lower levels {leveltop , level , † † † } specify destinations for protocol messages generated by top-level function and lower-level functions called by top-level function The format of levelspecs. Protocol information can be printed in a notebook or displayed in a notebook’s status line. The following values may be specified as destinations level for Protocol , where the default setting is Protocol −> StatusLine . Notebook StatusLine All None display protocol information in notebook display protocol information in status line display protocol information in both notebook and status line do not print protocol information Destinations for protocol messages. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ 3.14 Global Options 429 Turn off protocol display. In[2]:= SetOptions[AnalogInsydes, Protocol −> None] Out[2]= InstanceNameSeparator $, LibraryPath Prepend$Path, aidirAnalogInsydesModelLibrary, ModelLibrary FullModels‘, Protocol None, Simulator AnalogInsydes, UseExternals True Display top-level information in status line, send messages from second level to notebook. In[3]:= SetOptions[AnalogInsydes, Protocol −> {StatusLine, Notebook}] Out[3]= InstanceNameSeparator $, LibraryPath Prepend$Path, aidirAnalogInsydesModelLibrary, ModelLibrary FullModels‘, Protocol StatusLine, Notebook, Simulator AnalogInsydes, UseExternals True 3.14.6 Simulator The value of the option Simulator −> "string" determines the source or target simulator for Analog Insydes’ simulator interfaces and circuit analysis functions. The following simulators are supported: "AnalogInsydes" "PSpice" Analog Insydes (Fraunhofer-ITWM) PSpice (MicroSim, OrCAD) "Eldo" Eldo (Anacad) "Saber" Saber (Avant!) Supported circuit simulators. The default setting is Simulator −> "AnalogInsydes" , which disables the usage of the external simulator interface. Although the Simulator option of ReadNetlist , ReadSimulationData , etc. is inherited from the global Analog Insydes option Simulator , it is recommended to specify the Simulator option in each call of the above mentioned commands rather than altering the global value. 3.14.7 UseExternals The option UseExternals enables or disables the use of the external MathLink applications of Analog Insydes. You can set UseExternals −> False if you prefer not to use MathLink programs or if you wish to run Analog Insydes on a platform for which no native support is provided. Possible values are: 3. Reference Manual 430 True False use the MathLink extensions of Analog Insydes do not use the MathLink extensions; use internal algorithms if available Values for the UseExternals option. The default setting is UseExternals −> True, which enables the usage of the MathLink applications. If you set UseExternals −> False, some functions may not be available or run with reduced performance. Note that the external routines are called transparently for the user. There is no need to perform any additional setup. 3.14.8 Option Inheritance Analog Insydes employs an option inheritance scheme that allows you to change the values of shared options both globally and locally in a convenient way. If the value of an option optname is specified as Inherited[symbol] , then the actual value of optname will be retrieved from Options[symbol] as soon as it is needed. For example, the Analog Insydes functions ExpandSubcircuits and ReadNetlist both inherit the options InstanceNameSeparator and Protocol from Options[AnalogInsydes] . You can change the settings for both functions simultaneously by specifying new values for Options[AnalogInsydes] . You can also change any of these options locally for either function in Options[ExpandSubcircuits] or Options[ReadNetlist] . See example below. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Display the options of ExpandSubcircuits . In[2]:= Options[ExpandSubcircuits] Out[2]= AutoloadModels True, DefaultSelector None, HoldModels None, InstanceNameSeparator InheritedAnalogInsydes, KeepLocalModels False, LibraryPath InheritedAnalogInsydes, ModelLibrary InheritedAnalogInsydes, Protocol InheritedAnalogInsydes, Symbolic All, Value None Note that some of the option values are marked as Inherited[AnalogInsydes] . The values of these options will be retrieved from Options[AnalogInsydes] when they are neeeded. 3.14 Global Options 431 Display the options of ReadNetlist . In[3]:= Options[ReadNetlist] Change the value of InstanceNameSeparator globally. In[4]:= SetOptions[AnalogInsydes, InstanceNameSeparator −> "$$"] Change the value of Protocol locally for ExpandSubcircuits . In[5]:= SetOptions[ExpandSubcircuits, Protocol −> None] Out[3]= CharacterMapping _ $, InstanceNameSeparator InheritedAnalogInsydes, KeepPrefix True, LevelSeparator , LibraryPath ., Protocol InheritedAnalogInsydes, Simulator InheritedAnalogInsydes Out[4]= InstanceNameSeparator $$, LibraryPath Prepend$Path, aidirAnalogInsydesModelLibrary, ModelLibrary FullModels‘, Protocol StatusLine, Simulator AnalogInsydes, UseExternals True Out[5]= AutoloadModels True, DefaultSelector None, HoldModels None, InstanceNameSeparator InheritedAnalogInsydes, KeepLocalModels False, LibraryPath InheritedAnalogInsydes, ModelLibrary InheritedAnalogInsydes, Protocol None, Symbolic All, Value None Internally, Analog Insydes resolves inherited options by means of the function ResolveOptions . We use ResolveOptions here for documentation purposes only. Option inheritance is taken care of automatically by Analog Insydes. Below, ResolveOptions is used to determine the final values of the options for ExpandSubcircuits . Note that the local value of the Protocol option overrides the value from Options[AnalogInsydes] . Get option settings for ExpandSubcircuits . In[6]:= ResolveOptions[{}, ExpandSubcircuits, {InstanceNameSeparator, Protocol}] // InputForm Out[6]//InputForm= {"$$", None} For ReadNetlist , the values of both options are retrieved from Options[AnalogInsydes] . Get option settings for ReadNetlist . In[7]:= ResolveOptions[{}, ReadNetlist, {InstanceNameSeparator, Protocol}] // InputForm Out[7]//InputForm= {"$$", StatusLine} 3. Reference Manual 432 3.15 The Analog Insydes Environment The Analog Insydes loading procedure is completed by execution of several init files which allow for adapting Analog Insydes to your local needs. Section 3.15.1 explains the details of the initialization procedure. Once Analog Insydes is started, there are several commands for obtaining detailed information concerning your local Analog Insydes installation: ReleaseInfo[AnalogInsydes] (Section 3.15.2) Analog Insydes license type information ReleaseNumber[AnalogInsydes] (Section 3.15.3) Analog Insydes release number License[AnalogInsydes] (Section 3.15.4) Analog Insydes license number Version[AnalogInsydes] (Section 3.15.5) Analog Insydes version information Info[AnalogInsydes] (Section 3.15.6) Analog Insydes installation information Obtaining Analog Insydes release information. 3.15.1 The Initialization Procedure At the end of the Analog Insydes loading procedure, after setting up autoload declarations for all Analog Insydes functions, three configurable init files are loaded (via the Mathematica function Get) in the following order: If a file called aiinit.m exists in the Analog Insydes installation directory, this file is loaded first. If a file called .airc exists in the directory given by the Mathematica variable $HomeDirectory , this file is loaded next. If a file called .airc exists in the current working directory (i.e. the directory returned by Directory[] ; see the Mathematica command Directory ), this file is loaded last. These files allow for adapting Analog Insydes to your local needs: Simply add the corresponding Mathematica commands to one of the init files (see example below). By setting the following environment variables you can suppress loading of init files: 3.15 The Analog Insydes Environment 433 AI_NO_SITE_INIT suppress loading of init file in Analog Insydes installation directory AI_NO_USER_INIT suppress loading of init file in home directory AI_NO_WORKDIR_INIT suppress loading of init file in current working directory Environment variables for suppressing init file loading. Since the init files are loaded after installing the package autoload declarations, you can access all Analog Insydes functions and options in the init files. For example, if you always want to produce protocol output in your notebook, you can set the global Analog Insydes option Protocol by adding the following line to your user init file: Setting the default protocol. SetOptions[AnalogInsydes, Protocol −> Notebook]; If you want to configure the location of an init file by an environment variable, add the following to your user init file: Loading an init file given by an environment variable. If[ (file = Environment["MY_AI_INIT_FILE"]) =!= $Failed, Get[file]]; This loads the init file given by the environment variable MY_AI_INIT_FILE if the variable is set. 3.15.2 ReleaseInfo ReleaseInfo[AnalogInsydes] prints information on your local Analog Insydes installation Command structure of ReleaseInfo. The command ReleaseInfo[AnalogInsydes] prints general information concerning your local Analog Insydes installation such as the release number and a copyright notice. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Print information on Analog Insydes release. In[2]:= ReleaseInfo[AnalogInsydes] Analog Insydes for Mathematica, Release 2.0 Copyright (c) 1996−2001 by Fraunhofer−ITWM 3. Reference Manual 434 3.15.3 ReleaseNumber ReleaseNumber[AnalogInsydes] returns the release number of your local Analog Insydes installation Command structure of ReleaseNumber. The command ReleaseNumber[AnalogInsydes] returns the release number of your Analog Insydes installation as a real number. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Get Analog Insydes release number. In[2]:= ReleaseNumber[AnalogInsydes] Out[2]= 2. 3.15.4 License License[AnalogInsydes] returns the Analog Insydes license number currently used Command structure of License. The command License[AnalogInsydes] returns the license string used by your Analog Insydes installation. As your license file might contain a list of licenses, License[AnalogInsydes] displays the license actually used. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Get Analog Insydes license number. In[2]:= License[AnalogInsydes] Out[2]= AIM1200R0100014238592786992445254318 3.15.5 Version Version[AnalogInsydes] Command structure of Version. shows detailed information on the version of your local Analog Insydes installation 3.15 The Analog Insydes Environment 435 The command Version[AnalogInsydes] returns a list of version strings of your Analog Insydes installation. Each loaded Analog Insydes package contributes a separate version string to this list, thus the return value of this commands differs depending on the commands used during the current session. Please always state Version[AnalogInsydes] when reporting problems or bugs. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Print detailed Analog Insydes version information. In[2]:= Version[AnalogInsydes] Out[2]= Common: 2.157, Main: 2.96, Master: 2.45, Miscellaneous: 2.70 3.15.6 Info Info[AnalogInsydes] prints general information of your running Analog Insydes installation Command structure of Info. The command Info[AnalogInsydes] provides general information of the running Analog Insydes installation. It prints: path to the Analog Insydes installation directory list of all init files loaded during startup Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Print general information on Analog Insydes installation. In[2]:= Info[AnalogInsydes] Path to Analog Insydes: /usr/local/Mathematica/3.0/AddOns/Applications/AnalogIns\ ydes Init files loaded: {/usr/local/Mathematica/3.0/AddOns/App\ lications/AnalogInsydes/aiinit.m, /home/aiuser/.airc} Appendix 4.1 Stimuli Sources . . . . . . . . . . . . . . . . . . . . . . . 438 4.2 Netlist Elements 4.3 Model Library . . . . . . . . . . . . . . . . . . . . . . . 460 4.3 Credits . . . . . . . . . . . . . . . . . . . . . . . . . . . 492 . . . . . . . . . . . . . . . . . . . . . . 446 4. Appendix 438 4.1 Stimuli Sources This chapter describes time-dependent (HSPICE-compatible) sources which can be used for numerical circuit simulations. The following table shows the supported time-dependent stimuli sources and their corresponding Analog Insydes functions: AMWave (Section 4.1.1) ExpWave (Section 4.1.2) PulseWave (Section 4.1.3) PWLWave (Section 4.1.4) SFFMWave (Section 4.1.5) SinWave (Section 4.1.6) amplitude-modulated source exponential source pulse source piecewise linear source frequency-modulated source sinusoidal source 4.1.1 AMWave AMWave[time, u , u , fm, fc, td] describes a time-dependent amplitude modulation source Command structure of AMWave. AMWave returns a numerical value in case the first argument is numeric, otherwise a CheckedAMWave is returned. CheckedAMWave is a data type which marks a AMWave description as being syntactically correct. CheckedAMWave should not be defined directly. A CheckedAMWave can be displayed with standard Mathematica graphic functions such as Plot or with Analog Insydes graphic functions such as TransientPlot . AMWave has the following optional arguments: 4.1 Stimuli Sources 439 argument name default value u 0 V or A voltage or current amplitude u 0 offset constant fm 1 Hz modulation frequency fc 1 Hz carrier frequency td 0 s delay time Arguments of AMWave. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define time-dependent amplitude modulated source. In[2]:= Vam[t_] = AMWave[t, 10, 1, 100, 1.*^3, 1.*^−3] Display the signal. In[3]:= TransientPlot[Vam[t], {t, 0, 5.*^−3}] Out[2]= CheckedAMWavet, 10., 1., 100., 1000., 0.001 20 10 0.001 0.002 0.003 0.004 t 0.005 Vam[t] -10 -20 Out[3]= Graphics 4.1.2 ExpWave ExpWave[time, u , u , tdr, taur, tdf, tauf] describes a time-dependent exponential source Command structure of ExpWave. ExpWave returns a numerical value in case the first argument is numeric, otherwise a CheckedExpWave is returned. CheckedExpWave is a data type which marks a ExpWave description as being syntactically correct. CheckedExpWave should not be defined directly. 4. Appendix 440 A CheckedExpWave can be displayed with standard Mathematica graphic functions such as Plot or with Analog Insydes graphic functions such as TransientPlot . ExpWave has the following optional arguments: argument name default value u 0 V or A initial value of voltage or current u 0 V or A pulsed value of voltage or current tdr 0 s rise delay time taur 1 s rise time constant tdf 0 s fall delay time tauf 1 s fall time constant Arguments of ExpWave. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define time-dependent exponential source. In[2]:= Vexp[t_] = ExpWave[t, 1, −1, 1, 0.1, 2] Display the signal. In[3]:= TransientPlot[Vexp[t], {t, 0, 8}] Out[2]= CheckedExpWavet, 1., 1., 1., 0.1, 2., 1. 1 0.5 2 -0.5 -1 Out[3]= Graphics 4 6 8 t Vexp[t] 4.1 Stimuli Sources 441 4.1.3 PulseWave PulseWave[time, u , u , td, tr, tf, pw, per] describes a time-dependent pulse source Command structure of PulseWave. PulseWave returns a numerical value in case the first argument is numeric, otherwise a CheckedPulseWave is returned. CheckedPulseWave is a data type which marks a PulseWave description as being syntactically correct. CheckedPulseWave should not be defined directly. A CheckedPulseWave can be displayed with standard Mathematica graphic functions such as Plot or with Analog Insydes graphic functions such as TransientPlot . PulseWave has the following optional arguments: argument name default value u 0 V or A initial value for voltage or current pulse u 0 V or A pulse value for voltage or current pulse td 0 s delay time tr 0 s rise time tf 0 s fall time pw 0 s pulse width per $MaxMachineNumber s pulse period Arguments of PulseWave. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define time-dependent pulse source. In[2]:= Vpulse[t_] = PulseWave[t, 0.5, 2, 0.2, 0.2, 0.3, 0.3, 0.9] Out[2]= CheckedPulseWavet, 0.5, 2., 0.2, 0.2, 0.3, 0.3, 0.9 4. Appendix 442 Display the signal. In[3]:= TransientPlot[Vpulse[t], {t, 0, 2}] 2 1.8 1.6 1.4 Vpulse[t] 1.2 0.5 1 1.5 2 t 0.8 0.6 Out[3]= Graphics 4.1.4 PWLWave PWLWave[time, data, delay, repeat] describes a time-dependent piecewise linear source Command structure of PWLWave. PWLWave returns a numerical value in case the first argument is numeric, otherwise a CheckedPWLWave is returned. If the last argument is not specified PWLWave returns an interpolating function object. CheckedPWLWave is a data type which marks a PWLWave description as being syntactically correct. CheckedPWLWave should not be defined directly. A CheckedPWLWave can be displayed with standard Mathematica graphic functions such as Plot or with Analog Insydes graphic functions such as TransientPlot . PWLWave has the following optional arguments: argument name default value data {{0, 0}} s V or s A data pairs {{t , v }, † † † } of time values and voltage or current values delay 0 s delay time repeat Null s time point at which the waveform is to be repeated Arguments of PWLWave. 4.1 Stimuli Sources 443 Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Select data pairs. In[2]:= data = {{0.1, 0}, {0.5, 0}, {1, 1}, {1.5, 1}, {2, 0.5}, {2.5, 0.5}, {3, 0}}; Define piecewise linear source. In[3]:= Vpwl1[t_] = PWLWave[t, data] Define repeated piecewise linear source. In[4]:= Vpwl2[t_] = PWLWave[t, data, 0.5, 1] Display the signals. In[5]:= TransientPlot[{Vpwl1[t], Vpwl2[t]}, {t, −1, 7}] Out[3]= InterpolatingFunction1.79769 10308 , 1.79769 10308 , t Out[4]= CheckedPWLWavet, InterpolatingFunction1.79769 10308 , 1.79769 10308 , , 0.5, 1., 3. 1 0.8 Vpwl1[t] 0.6 0.4 Vpwl2[t] 0.2 2 4 6 t Out[5]= Graphics 4.1.5 SFFMWave SFFMWave[time, u , u , fc, mi, fs] describes a time-dependent single-frequency frequency modulation source Command structure of SFFMWave. SFFMWave returns a numerical value in case the first argument is numeric, otherwise a CheckedSFFMWave is returned. CheckedSFFMWave is a data type which marks a SFFMWave description as being syntactically correct. CheckedSFFMWave should not be defined directly. A CheckedSFFMWave can be displayed with standard Mathematica graphic functions such as Plot or with Analog Insydes graphic functions such as TransientPlot . SFFMWave has the following optional arguments: 4. Appendix 444 argument name default value u 0 V or A voltage or current offset u 0 V or A voltage or current amplitude fc 1 Hz carrier frequency mi 0 modulation index fs 1 Hz signal frequency Arguments of SFFMWave. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define time-dependent frequency modulated source. In[2]:= Vfm[t_] = SFFMWave[t, 0, 1.*^6, 2.*^4, 10, 5.*^3] Display the signal. In[3]:= TransientPlot[Vfm[t], {t, 0, 2.*^−4}] Out[2]= CheckedSFFMWavet, 0., 1. 106 , 20000., 10., 5000. 6 1. 10 500000 t 0.00005 0.0001 0.00015 0.0002 Vfm[t] -500000 6 -1. 10 Out[3]= Graphics 4.1.6 SinWave SinWave[time, u , u , freq, td, alpha, phi] describes a time-dependent sinusoidal source Command structure of SinWave. SinWave returns a numerical value in case the first argument is numeric, otherwise a CheckedSinWave is returned. CheckedSinWave is a data type which marks a SinWave description as being syntactically correct. CheckedSinWave should not be defined directly. 4.1 Stimuli Sources 445 A CheckedSinWave can be displayed with standard Mathematica graphic functions such as Plot or with Analog Insydes graphic functions such as TransientPlot . SinWave has the following optional arguments: argument name default value u 0 V or A voltage or current offset u 0 V or A voltage or current amplitude freq 1 Hz frequency td 0 s delay time alpha 0 s damping factor phi 0 phase delay Arguments of SinWave. Examples Load Analog Insydes. In[1]:= <<AnalogInsydes‘ Define time-dependent sinusoidal source. In[2]:= Vsin[t_] = SinWave[t, 0.5, 1, 2, 0.2, 1.5, 180] Display the signal. In[3]:= TransientPlot[Vsin[t], {t, 0, 3}] Out[2]= CheckedSinWavet, 0.5, 1., 2., 0.2, 1.5, 180. 1 0.8 0.6 Vsin[t] 0.4 0.2 0.5 1 -0.2 Out[3]= Graphics 1.5 2 2.5 3 t 4. Appendix 446 4.2 Netlist Elements Analog Insydes supports the following primitive electrical circuit and control network elements: element type type tag Resistor R Section 4.2.1 Conductance G Section 4.2.2 Admittance Y Section 4.2.3 Impedance Z Section 4.2.4 Capacitor C Section 4.2.5 Inductor L Section 4.2.6 OpenCircuit OC Section 4.2.7 ShortCircuit SC Section 4.2.8 Linear two-terminal elements. element type type tag CurrentSource I Section 4.2.9 VoltageSource V Section 4.2.10 Independent sources. element type type tag CCCSource CC Section 4.2.11 CCVSource CV Section 4.2.12 VCCSource VC Section 4.2.13 VCVSource VV Section 4.2.14 OPAmp OP Section 4.2.15 OTAmp OT Section 4.2.16 Controlled sources. 4.2 Netlist Elements 447 element type type tag Nullator NUL Section 4.2.17 Norator NOR Section 4.2.18 Fixator FIX Section 4.2.19 Singular network elements. element type type tag SignalSource HS Section 4.2.20 Amplifier HP Section 4.2.21 Integrator HI Section 4.2.22 Differentiator HD Section 4.2.23 TransmissionLine HT Section 4.2.24 TransferFunction H Section 4.2.25 Control network elements. 4.2.1 Resistor type name syntax Resistor {Rname, {node1, node2}, valueR } denotes a linear resistor Circuit element type Resistor. R node1 node2 Modified nodal equation setup for admittances is influenced by the value-field option Pattern. Note that the symbol Admittance is also a possible option value for the value-field option Pattern. 4. Appendix 448 4.2.2 Conductance type name syntax Conductance {Gname, {node1, node2}, valueG } denotes a linear conductance Circuit element type Conductance. G node1 node2 Modified nodal equation setup for conductances is influenced by the value-field option Pattern. 4.2.3 Admittance type name syntax Admittance {Yname, {node1, node2}, valueY } denotes a linear (complex) admittance Circuit element type Admittance. Y node1 node2 Modified nodal equation setup for admittances is influenced by the value-field option Pattern. Note that the symbol Admittance is also a possible option value for the value-field option Pattern . 4.2.4 Impedance type name syntax Impedance {Zname, {node1, node2}, valueZ } denotes a linear (complex) impedance Circuit element type Impedance. Z node1 node2 4.2 Netlist Elements 449 Modified nodal equation setup for impedances is influenced by the value-field option Pattern . Note that the symbol Impedance is also a possible option value for the value-field option Pattern . 4.2.5 Capacitor type name syntax Capacitor {Cname, {node1, node2}, valueC } denotes a linear capacitor Circuit element type Capacitor. C node1 node2 Modified nodal equation setup for capacitors is influenced by the value-field option Pattern . 4.2.6 Inductor type name syntax Inductor {Lname, {node1, node2}, valueL } denotes a linear inductor Circuit element type Inductor. L node1 node2 Modified nodal equation setup for inductors is influenced by the value-field option Pattern. 4.2.7 OpenCircuit type name syntax OpenCircuit {OCname, {node1, node2}, 0} denotes an open-circuit branch Circuit element type OpenCircuit. 4. Appendix 450 node1 V1 node2 An open-circuit branch is essentially the same as an independent current source with zero source current. The value specification is ignored. However, it should be set to 0 (zero) to reflect the fact that the source current is zero. Note that open circuits are mostly used implicitly as controlling branches of voltage-controlled sources but they may also be used explicitly in a netlist when a voltage meter is needed. In the latter case, modified nodal analysis employs a special matrix fill-in pattern which augments the vector of unknown node voltages by the branch voltage across the open circuit. This allows for directly computing the differential voltage between two nodes neither of which is ground. Without the voltage sensor, two node voltages would have to be solved for and then subtracted from one another, which would be computationally more expensive. 4.2.8 ShortCircuit type name syntax ShortCircuit {SCname, {node1, node2}, 0} denotes a short-circuit branch Circuit element type ShortCircuit . node1 I1 node2 A short-circuit branch is essentially the same as a voltage source with zero source voltage. The value specification is ignored. However, it should be set to 0 (zero) to reflect the fact that the source voltage is zero. Note that short circuits are mostly used implicitly as controlling branches of current-controlled sources. They may also be used explicitly as current meters in combination with modified nodal analysis. 4.2 Netlist Elements 451 4.2.9 CurrentSource type name syntax CurrentSource {Iname, {node+, node−}, valueI0 } denotes an independent current source Circuit element type CurrentSource. node+ I0 nodeThe positive reference direction for the source current is from node+ to node−. 4.2.10 VoltageSource type name syntax VoltageSource {Vname, {node+, node−}, valueV0 } denotes an independent voltage source Circuit element type VoltageSource. node+ V0 nodeThe positive reference direction for the source voltage as well as the current through the source is from node+ to node−. 4. Appendix 452 4.2.11 CCCSource type name syntax CCCSource {CCname, {cnode+, cnode−, node+, node−}, valuebeta } denotes a linear current-controlled current source (CCCS) with gain valuebeta Circuit element type CCCSource. node+ cnode+ I1 beta*I1 node- cnode- The terminals of the controlling branch are denoted by cnode+ and cnode−. The positive reference direction for the sensor current and the source current is from cnode+ to cnode− and from node+ to node−, respectively. Note that Analog Insydes automatically inserts a short circuit in between cnode+ and cnode− as a current meter. As opposed to the SPICE netlist format there is no need to add a sensor voltage source to the netlist. 4.2.12 CCVSource type name syntax CCVSource {CVname, {cnode+, cnode−, node+, node−}, valuer } denotes a linear current-controlled voltage source (CCVS) with transresistance valuer Circuit element type CCVSource. cnode+ node+ I1 cnode- r*I1 node- The terminals of the controlling branch are denoted by cnode+ and cnode−. The positive reference direction for the sensor current and the source voltage is from cnode+ to cnode− and from node+ to 4.2 Netlist Elements 453 node−, respectively. Note that Analog Insydes automatically inserts a short circuit in between cnode+ and cnode− as a current meter. As opposed to the SPICE netlist format there is no need to add a sensor voltage source to the netlist. 4.2.13 VCCSource type name syntax VCCSource {VCname, {cnode+, cnode−, node+, node−}, valuegm } denotes a linear voltage-controlled current source (VCCS) with transconductance valuegm Circuit element type VCCSource. cnode+ node+ V1 gm*V1 cnode- node- The terminals of the controlling branch are denoted by cnode+ and cnode−. Note that as opposed to the SPICE netlist format the controlling nodes are listed before the terminals of the controlled branch. 4.2.14 VCVSource type name syntax VCVSource {VVname, {cnode+, cnode−, node+, node−}, valuev } denotes a linear voltage-controlled voltage source (VCVS) with voltage gain valuev Circuit element type VCVSource. cnode+ V1 cnode- node+ v*V1 node- 4. Appendix 454 The terminals of the controlling branch are denoted by cnode+ and cnode−. Note that as opposed to the SPICE netlist format the controlling nodes are listed before the terminals of the controlled branch. 4.2.15 OPAmp type name syntax OPAmp {OPname, {cnode+, cnode−, node+, node−}, valuev } denotes an ideal operational amplifier with finite or infinite gain valuev Circuit element type OPAmp. cnode+ V1 node+ v*V1 cnode- node- For infinite gain, valuev must be Infinity . Note that, functionally, an OpAmp is the same as a voltage-controlled voltage source. The difference to a VCVSource is that during circuit equation setup another matrix fill-in pattern is used which makes limit calculations for large OpAmp gains easier. 4.2.16 OTAmp type name syntax OTAmp {OTname, {cnode+, cnode−, node+, node−}, valuegm } denotes an ideal operational transconductance amplifier with finite or infinite gain valuegm Circuit element type OTAmp. cnode+ gm*V1 V1 node+ cnode- node- 4.2 Netlist Elements 455 For infinite gain, valuegm must be Infinity . Note that, functionally, an OTAmp is the same as a voltage-controlled current source. The difference to a VCCSource is that during circuit equation setup another matrix fill-in pattern is used which makes limit calculations for large OTAmp gains easier. 4.2.17 Nullator type name syntax Nullator {NULname, {node1, node2}, 0} denotes a nullator Circuit element type Nullator. node1 V=0 I=0 node2 A nullator is an ideal two-terminal circuit element which enforces both a zero voltage and a zero current between its terminals. It is thus neither a voltage nor a current source but rather both at the same time. The value specification in the netlist entry of a nullator is irrelevant and should be set to 0 (zero). Note that an element with a arbitrary but fixed branch current and branch voltage is also known as a fixator. With a zero current and voltage, a nullator is a special case of a fixator. A nullator usually appears paired with a norator, thus forming a nullor. A nullor represents a controlled source of arbitrary type with infinite gain, such as an ideal operational amplifier. 4.2.18 Norator type name syntax Norator {NORname, {node1, node2}, 0} denotes a norator Circuit element type Norator. 4. Appendix 456 node1 node2 A Norator is an ideal two-terminal circuit element which imposes no constraints on its branch current and voltage. The value specification is ignored and should be set to 0 (zero). Note that a norator usually appears paired with a nullator, thus forming a nullor. A nullor represents a controlled source of arbitrary type with infinite gain, such as an ideal operational amplifier. 4.2.19 Fixator type name syntax Fixator {FIXname, {node+, node−}, {valueI0 , valueV0 }} denotes a fixator Circuit element type Fixator. node+ V0 I0 nodeA fixator is an ideal two-terminal circuit element which enforces both a fixed voltage and a fixed current between its terminals. It is thus neither a voltage nor a current source but rather both at the same time. Note that the netlist entry for fixators has a special form because two element values, a source current and a source voltage, must be specified. Fixators are hardly ever used for circuit analysis purposes. Their main application field is circuit sizing where they can be used to model operating points of nonlinear devices such as transistors. 4.2 Netlist Elements 457 4.2.20 SignalSource type name syntax SignalSource {HSname, {output}, valueX } denotes a signal source in a control network Circuit element type SignalSource. output X(s) Signal sources do not have an input node. Therefore, the connectivity field contains only the node identifier of the output node. 4.2.21 Amplifier type name syntax Amplifier {HPname, {input, output}, valueA } denotes a proportional amplifier with amplification valueA Circuit element type Amplifier. input A output 4. Appendix 458 4.2.22 Integrator type name syntax Integrator {HIname, {input, output}, valueTi } denotes an integrator with an integration time constant valueTi Circuit element type Integrator. input Ti output 4.2.23 Differentiator type name syntax Differentiator {HDname, {input, output}, valueTd } denotes a differentiator with a differentiation time constant valueTd Circuit element type Differentiator . input Td output 4.2.24 TransmissionLine type name syntax TransmissionLine {HTname, {input, output}, valueT } denotes an ideal lossless transmission line with a delay time constant valueT Circuit element type TransmissionLine . 4.2 Netlist Elements 459 input T output 4.2.25 TransferFunction type name syntax TransferFunction {Hname, {input, output}, valuetfunc } denotes a generic transfer function block Circuit element type TransferFunction . input H(s) output The transfer function valuetfunc may be any function of the Laplace frequency variable s. To avoid confusion with the other control network element types the block name must not begin with the letters S, P, I, D, or T. 4. Appendix 460 4.3 Model Library The Analog Insydes model library provides full-precision SPICE-compatible models for the most important devices such as Diodes (Section 4.3.1), BJTs (Section 4.3.2), MOSFETs (Section 4.3.3), and JFETs (Section 4.3.4). Each section contains two subsections describing the large-signal as well as the small-signal model. Following an equivalent circuit schematic the particular model parameters are introduced including their default values and a short description. Note that the default values of the small-signal parameters are given symbolically with the suffix "$ac" as they are automatically generated by ReadNetlist (Section 3.10.1). Each model section concludes with a description of those parameters which are influenced by the automatic model-complexity reduction controlled via the global Analog Insydes option ModelLibrary (Section 3.14.4). 4.3.1 Diode syntax {Dname, {n −>A, n −>C}, Model−>Diode, Selector−>selector, parameters} denotes a subcircuit reference for a Diode Subcircuit reference for Diode. A C Valid values for selector are: Spice, SpiceDC , SpiceAC, and SpiceNoise . Possible parameters are described below. Large-Signal Model The analog behavioral model included in the Analog Insydes model library has the following port characteristics: Voltage[A,C] C A Current[A,C] where A denotes the Anode and C the Cathode, respectively. The port currents can be expressed in the port variables as follows: 4.3 Model Library 461 iA t Current[A,C]t Anode: iC t Current[A,C]t Cathode: A RS CD id C Equivalent schematic for the DC and transient analysis The large-signal model includes the following model parameters: parameter name default value BV - V IBV IS N emission coefficient NBV reverse breakdown coefficient reverse breakdown voltage A A reverse breakdown current saturation current DC related model parameters. parameter name default value RS Parasitic resistance related model parameters. ohmic resistance 4. Appendix 462 parameter name default value CJO F zero-bias junction capacitance FC forward-bias depletion capacitance coefficient M grading coefficient TT s transit time VJ V junction potential Capacitance related model parameters. parameter name default value EG eV energy gap TEMP K model temperature TNOM K nominal temperature XTI saturation current temperature exponent Temperature related model parameters. parameter name default value AF flicker noise exponent KF flicker noise coefficient Noise related model parameters. parameter name default value AREA GMIN LEVEL relative device area minimum conductance model index Miscellaneous model parameters. The automatic reduction of the model complexity controlled via the global Analog Insydes option ModelLibrary influences the following parameters: 4.3 Model Library 463 parameter name FullModels SimplifiedModels BasicModels BV used used default RS used default default TT used default default Simplification related model parameters. Small-Signal Model A Rs Rd Cd C Equivalent schematic for the AC analysis The small-signal model includes the following model parameters: parameter name default value Cd CAP$ac junction and diffusion capacitance Rd REQ$ac small-signal resistance Rs RS/AREA resistance Small-signal model parameters. The automatic reduction of the model complexity controlled via the global Analog Insydes option ModelLibrary influences the following parameters: 4. Appendix 464 parameter name FullModels SimplifiedModels BasicModels Rs used ignored ignored Simplification related model parameters. 4.3.2 Bipolar Junction Transistor syntax {Qname, {n −>C, n −>B, n −>E, n −>S}, Model−>BJT, Selector−>selector, parameters} denotes a subcircuit reference for a BJT Subcircuit reference for BJT. C C B B E E Valid values for selector are: GummelPoon , GummelPoonDC , Spice, SpiceDC, SpiceAC, and SpiceNoise . Possible parameters are described below. Please note that the substrate port S is optional. Large-Signal Model The analog behavioral model included in the Analog Insydes model library has the following port characteristics: C Voltage[C,S] Current[C,S] Voltage[B,S] S B Current[B,S] Voltage[E,S] Current[E,S] E 4.3 Model Library 465 where B denotes the Base, C the Collector, E the Emitter, and S the Substrate, respectively. The port currents can be expressed in the port variables as follows: Base: iB t Current[B,S]t Collector: iC t Current[C,S]t Emitter: iE t Current[E,S]t Substrate: iS t Current[B,S]t Current[C,S]t Current[E,S]t C RC ics CBX CBC CJS RB S B CBE ic ib RE E Equivalent schematic for the DC and transient analysis for the vertical bipolar transistor (NPN, PNP) 4. Appendix 466 C RC CBC CBX RB B CXS CBE CJS ibs ic ib RE S E Equivalent schematic for the DC and transient analysis for the lateral bipolar transistor (LPNP) The large-signal model includes the following model parameters: 4.3 Model Library 467 parameter name default value BF ideal maximum forward current gain BR ideal maximum reverse current gain IKF (IK) - A corner current for forward-beta high-current roll-off IKR - A corner current for reverse-beta high-current roll-off IS ISC (C4) A base-collector leakage saturation current ISE (C2) A base-emitter leakage saturation current ISS A substrate junction saturation current NC base-collector leakage emission coefficient NE base-emitter leakage emission coefficient NF forward current emission coefficient NK high-current roll-off coefficient NR reverse current emission coefficient NS (NSS) substrate junction emission coefficient VAF (VA) - V forward early voltage VAR (VB, VBAR) - V reverse early voltage A transport saturation current DC related model parameters. parameter name default value IRB - A current at which RB falls halfway to its minimum value RB zero-bias base ohmic resistance RBM RB RC collector ohmic resistance RE emitter ohmic resistance Parasitic resistance related model parameters. minimum base ohmic resistance 4. Appendix 468 parameter name default value CJC F zero-bias base-collector depletion capacitance CJE F zero-bias base-emitter depletion capacitance CJS (CCS) F zero-bias substrate capacitance FC forward-bias depletion capacitance coefficient MJC (MC) base-collector junction grading factor MJE (ME) base-emitter junction grading factor MJS (MS) substrate junction grading factor VJC (PC) V base-collector built-in potential VJE (PE) V base-emitter built-in potential VJS (PS) V substrate junction built-in potential XCJC fraction of base-collector capacitance connected to internal base node XJBS fraction of base-substrate capacitance connected to internal base node (for lateral devices only) Junction capacitance related model parameters. parameter name default value ITF A transit time dependency on collector current PTF excess phase at f Π TF Hz TF s ideal forward transit time TR s ideal reverse transit time VTF - V transit time dependency on base-collector voltage XTF transit time bias dependence coefficient Dynamic model parameters. 4.3 Model Library 469 parameter name default value EG eV GAP1 GAP2 K energy gap eV K first bandgap correction factor second bandgap correction factor TEMP K model temperature TNOM K nominal temperature TRB1 K linear temperature coefficient for RB TRB2 K quadratic temperature coefficient for RB TRC1 (TRC) K linear temperature coefficient for RC TRC2 K quadratic temperature coefficient for RC TRE1 (TRE) K linear temperature coefficient for RE TRE2 K quadratic temperature coefficient for RE TRM1 (TRBM1) K linear temperature coefficient for RBM TRM2 (TRBM2) K quadratic temperature coefficient for RBM XTB (TB, TCB) forward and reverse beta temperature exponent XTI (PT) IS temperature effect exponent Temperature related model parameters. parameter name default value AF flicker noise exponent KF flicker noise coefficient Noise related model parameters. 4. Appendix 470 parameter name default value AREA GMIN LEVEL relative device area minimum conductance model index Miscellaneous model parameters. The automatic reduction of the model complexity controlled via the global Analog Insydes option ModelLibrary influences the following parameters: 4.3 Model Library 471 parameter name FullModels SimplifiedModels BasicModels CJS used default default IKF used default default IKR used default default IRB used default default ISC used default default ISE used used default ISS used default default ITF used default default PTF used default default RB used used default RBM used used default RC used default default RE used default default TF used default default TR used default default VAF used used default VAR used used default VTF used default default XCJC used used default XJBS used used default XTF used default default Simplification related model parameters. 4. Appendix 472 Small-Signal Model C Rc Cjs S Gmu Cbx Cbc Rx Ro B vpi Rpi gm*vpi Cbe Re E Equivalent schematic for the AC analysis for the vertical bipolar transistor (NPN, PNP) C Rc Gmu Cbx Cbc Rx Ro B Cxs Cjs vpi Rpi Cbe gm*vpi Re S E Equivalent schematic for the AC analysis for the lateral bipolar transistor (LPNP) The small-signal model includes the following model parameters: 4.3 Model Library 473 parameter name default value Cbc CBC$ac (CMU$ac) base collector capacitance Cbe CBE$ac (CPI$ac) base emitter capacitance Cbx CBX$ac external base collector capacitance Cjs CJS$ac (CBS$ac, CCS$ac) substrate capacitance Cxs CXS$ac external base substrate capacitance (for lateral devices only) gm GM$ac transconductance Gmu GMU$ac base collector conductance Rc RC/AREA collector resistance Re RE/AREA emitter resistance Ro RO$ac collector emitter resistance Rpi RPI$ac base emitter resistance Rx RX$ac base resistance Small-signal model parameters. The automatic reduction of the model complexity controlled via the global Analog Insydes option ModelLibrary influences the following parameters: parameter name FullModels SimplifiedModels BasicModels Cjs used used ignored Cxs used used ignored Gmu used ignored ignored Rc used ignored ignored Re used ignored ignored Rx used ignored ignored Simplification related model parameters. 4. Appendix 474 4.3.3 MOS Field-Effect Transistor syntax {Mname, {n −>D, n −>G, n −>S, n −>B}, Model−>MOSFET, Selector−>selector, parameters} denotes a subcircuit reference for a MOSFET Subcircuit reference for MOSFET. D G D G B B S S Valid values for selector are: Spice, SpiceDC , SpiceAC, and SpiceNoise . Possible parameters are described below. Large-Signal Model The analog behavioral model included in the Analog Insydes model library has the following port characteristics: D Voltage[D,B] Current[D,B] Voltage[G,B] B G Current[G,B] Voltage[S,B] Current[S,B] S where G denotes the Gate, D the Drain, S the Source, and B the Bulk, respectively. The port currents can be expressed in the port variables as follows: Gate: iG t Current[G,B]t Drain: iD t Current[D,B]t Source: iS t Current[S,B]t Bulk: iB t Current[G,B]t Current[D,B]t Current[S,B]t 4.3 Model Library 475 D RD CGB ibd CGD CBD G B ids CGS CBS ibs RS S Equivalent schematic for the DC and transient analysis The large-signal model includes the following model parameters: parameter name default value GAMMA V IS JS Am2 bottom bulk junction saturation current density JSSW Am sidewall bulk junction saturation current density KP LAMBDA V channel length modulation N bulk junction emission coefficient PHI V surface potential VTO V zero-bias threshold voltage DC related model parameters. bulk threshold parameter A AV2 bulk junction saturation current transconductance parameter 4. Appendix 476 parameter name default value L DEFL m channel length LD m lateral diffusion length W DEFW m channel width WD m lateral diffusion width Area related model parameters. parameter name default value NRD DEFNRD square number of squares for drain resistance NRS DEFNRS square number of squares for source resistance RD drain ohmic resistance RDS - drain source shunt resistance RS source ohmic resistance RSH square drain and source diffusion sheet resistance Parasitic resistance related model parameters. parameter name default value CBD F zero-bias bulk drain capacitance CBS F zero-bias bulk source capacitance CJ Fm2 zero-bias bottom bulk capacitance CJSW Fm zero-bias sidewall bulk capacitance FC forward-bias bulk junction capacitance coefficient MJ bulk junction bottom grading coefficient MJSW bulk junction sidewall grading coefficient PB V bulk bottom junction potential PBSW V bulk sidewall junction potential Junction capacitance related model parameters. 4.3 Model Library 477 parameter name default value CGBO Fm gate-bulk overlap capacitance CGDO Fm gate-drain overlap capacitance CGSO Fm gate-source overlap capacitance TT s transit time Dynamic model parameters. parameter name default value TEMP K TNOM model temperature K nominal temperature Temperature related model parameters. parameter name default value AF flicker noise exponent KF flicker noise coefficient Noise related model parameters. parameter name default value AD DEFAD m2 drain diffusion area AS DEFAS m2 source diffusion area GMIN LEVEL model index M DEFM device multiplier PD DEFPD m drain diffusion perimeter PS DEFPS m source diffusion perimeter Miscellaneous model parameters. minimum conductance 4. Appendix 478 parameter name default value DEFAD m2 default value for AD DEFAS m2 default value for AS DEFL DEFM default value for M DEFNRD square default value for NRD DEFNRS square default value for NRS DEFPD m default value for PD DEFPS m default value for PS DEFW m default value for L m default value for W Parameter defaults set by global options. The automatic reduction of the model complexity controlled via the global Analog Insydes option ModelLibrary influences the following parameters: parameter name FullModels SimplifiedModels BasicModels CGBO used used default CGDO used used default CGSO used used default CJSW used default default GAMMA used used default RD used default default RDS used default default RS used default default RSH used default default TT used default default Simplification related model parameters. 4.3 Model Library 479 Small-Signal Model D Cgb Rd Cgd Gbd Cbd Gds G B gm*vgs Cgs gmb*vbs Rs vgs Gbs Cbs vbs S Equivalent schematic for the AC analysis for the level 1-3 model 4. Appendix 480 s*DqdDvgb*vgb s*DqdDvdb*vdb s*DqdDvsb*vsb D Cgb vgd Rd vbd Cgd Gbd Cbd s*DqbDvgb*vgb s*DqbDvdb*vdb s*DqbDvsb*vsb Gds G B gm*vgs s*DqgDvgb*vgb s*DqgDvdb*vdb s*DqgDvsb*vsb Cgs gmb*vbs vgs Rs Gbs Cbs vbs S s*DqsDvgb*vgb s*DqsDvdb*vdb s*DqsDvsb*vsb Equivalent schematic for the AC analysis for the BSIM model (simulator PSpice) 4.3 Model Library 481 s*Cdd*vd s*Cdg*vg s*Cds*vs s*Cdb*vb D Rd vgd Gbd vbd Gds G gm*vgs gmb*vbs vgs Gbs s*Cbd*vd s*Cbg*vg B s*Cbs*vs s*Cbb*vb vbs Rs s*Cgd*vd s*Cgg*vg s*Cgs*vs s*Cgb*vb S s*Csd*vd s*Csg*vg s*Css*vs s*Csb*vb Equivalent schematic for the AC analysis for the BSIM model (simulator Eldo) The small-signal model includes the following model parameters: 4. Appendix 482 parameter name default value Cbd CBD$ac bulk drain capacitance Cbs CBS$ac bulk source capacitance Cgb CGB$ac+CGBOV$ac gate bulk capacitance Cgd CGD$ac+CGDOV$ac gate drain capacitance Cgs CGS$ac+CGSOV$ac gate source capacitance Gbd GBD$ac bulk drain conductance Gbs GBS$ac bulk source conductance Gds GDS$ac drain source conductance gm GM$ac transconductance gmb GMB$ac bulk transconductance Rd RD drain resistance Rs RS source resistance Level 1-3 small-signal model parameters. 4.3 Model Library 483 parameter name default value Cbdb DQBDVDB$ac derivative of bulk charge w.r.t. drain bulk voltage Cbgb DQBDVGB$ac derivative of bulk charge w.r.t. gate bulk voltage Cbsb DQBDVSB$ac derivative of bulk charge w.r.t. source bulk voltage Cddb DQDDVDB$ac derivative of drain charge w.r.t. drain bulk voltage Cdgb DQDDVGB$ac derivative of drain charge w.r.t. gate bulk voltage Cdsb DQDDVSB$ac derivative of drain charge w.r.t. source bulk voltage Cgdb DQGDVDB$ac derivative of gate charge w.r.t. drain bulk voltage Cggb DQGDVGB$ac derivative of gate charge w.r.t. gate bulk voltage Cgsb DQGDVSB$ac derivative of gate charge w.r.t. source bulk voltage Csdb DQSDVDB$ac derivative of source charge w.r.t. drain bulk voltage Csgb DQSDVGB$ac derivative of source charge w.r.t. gate bulk voltage Cssb DQSDVSB$ac derivative of source charge w.r.t. source bulk voltage Additional small-signal model parameters for BSIM PSpice. 4. Appendix 484 parameter name default value Cb Cbb$ac derivative of bulk charge w.r.t. bulk potential Cbd0 Cbd$ac derivative of bulk charge w.r.t. drain potential Cbg0 Cbg$ac derivative of bulk charge w.r.t. gate potential Cbs0 Cbs$ac derivative of bulk charge w.r.t. source potential Cdb0 Cdb$ac derivative of drain charge w.r.t. bulk potential Cd Cdd$ac derivative of drain charge w.r.t. drain potential Cdg0 Cdg$ac derivative of drain charge w.r.t. gate potential Cds0 Cds$ac derivative of drain charge w.r.t. source potential Cgb0 Cgb$ac derivative of gate charge w.r.t. bulk potential Cgd0 Cgd$ac derivative of gate charge w.r.t. drain potential Cg Cgg$ac derivative of gate charge w.r.t. gate potential Cgs0 Cgs$ac derivative of gate charge w.r.t. source potential Csb0 Csb$ac derivative of source charge w.r.t. bulk potential Csd0 Csd$ac derivative of source charge w.r.t. drain potential Csg0 Csg$ac derivative of source charge w.r.t. gate potential Cs Css$ac derivative of source charge w.r.t. source potential Additional small-signal model parameters for BSIM Eldo. The automatic reduction of the model complexity controlled via the global Analog Insydes option ModelLibrary influences the following parameters: 4.3 Model Library 485 parameter name FullModels SimplifiedModels BasicModels Cgb used ignored ignored Gbd used used ignored Gbs used used ignored gmb used used ignored Rd used ignored ignored Rs used ignored ignored Simplification related level 1-3 model parameters. parameter name FullModels SimplifiedModels BasicModels Cbd0 used used ignored Cbg0 used used ignored Cbs0 used used ignored Cdb0 used used ignored Cdg0 used used ignored Cds0 used used ignored Cgb0 used used ignored Cgd0 used used ignored Cgs0 used used ignored Csb0 used used ignored Csd0 used used ignored Csg0 used used ignored Simplification related BSIM Eldo model parameters. 4.3.4 Junction Field-Effect Transistor syntax {Jname, {n −>D, n −>G, n −>S}, Model−>JFET, Selector−>selector, parameters} denotes a subcircuit reference for a JFET Subcircuit reference for JFET. 4. Appendix 486 D D G G S S Valid values for selector are: Spice, SpiceDC , SpiceAC, and SpiceNoise . Possible parameters are described below. Large-Signal Model The analog behavioral model included in the Analog Insydes model library has the following port characteristics: D Voltage[D,G] Current[D,G] G Voltage[S,G] Current[S,G] S where G denotes the Gate, D the Drain, and S the Source, respectively. The port currents can be expressed in the port variables as follows: Drain: iD t Current[D,G]t Source: iS t Current[S,G]t Gate: iG t Current[D,G]t Current[S,G]t 4.3 Model Library 487 D RD igd CGD G CGS ids igs RS S Equivalent schematic for the DC and transient analysis The large-signal model includes the following model parameters: parameter name default value ALPHA V BETA IS ISR A gate junction recombination current parameter LAMBDA V channel length modulation N gate junction emission coefficient NR emission coefficient for ISR VK V ionization knee voltage VTO V threshold voltage DC related model parameters. ionization coefficient AV2 A transconductance coefficient gate junction saturation current 4. Appendix 488 parameter name default value RD drain ohmic resistance RS source ohmic resistance Parasitic resistance related model parameters. parameter name default value CGD F zero-bias gate drain junction capacitance CGS F zero-bias gate source junction capacitance FC forward depletion capacitance coefficient M gate junction grading coefficient PB V gate junction potential Capacitance related model parameters. parameter name default value BETATCE (BETATC) K BETA exponential temperature coefficient EG eV energy gap TEMP K model temperature TNOM K nominal temperature TRD1 K RD temperature coefficient TRS1 K RS temperature coefficient VTOTC V K VTO temperature coefficient XTI saturation current temperature exponent Temperature related model parameters. 4.3 Model Library 489 parameter name default value AF flicker noise exponent KF flicker noise coefficient Noise related model parameters. parameter name default value AREA GMIN LEVEL relative device area minimum conductance model index Miscellaneous model parameters. The automatic reduction of the model complexity controlled via the global Analog Insydes option ModelLibrary influences the following parameters: parameter name FullModels SimplifiedModels BasicModels ALPHA used default default ISR used used default RD used default default RS used default default VK used default default Simplification related model parameters. 4. Appendix 490 Small-Signal Model D Rd Ggd Cgd Gds G vgs Ggs Cgs gm*vgs Rs S Equivalent schematic for the AC analysis The small-signal model includes the following model parameters: parameter name default value Cgd CGD$ac gate drain capacitance Cgs CGS$ac gate source capacitance Gds GDS$ac drain source conductance Ggd GGD$ac gate drain conductance Ggs GGS$ac gate source conductance gm GM$ac transconductance Rd RD/AREA drain resistance Rs RS/AREA source resistance Small-signal model parameters. The automatic reduction of the model complexity controlled via the global Analog Insydes option ModelLibrary influences the following parameters: 4.3 Model Library 491 parameter name FullModels SimplifiedModels BasicModels Ggd used used ignored Ggs used used ignored Rd used ignored ignored Rs used ignored ignored Simplification related model parameters. Credits Developers Dipl.-Ing. Thomas Halfmann Dr.-Ing. Eckhard Hennig Dipl.-Ing. Jutta Praetorius Dr.-Ing. Ralf Sommer Dr.-Ing. Manfred Thole Dipl.-Math. Tim Wichmann Contributions Michael Brickenstein Dipl.-Math. Yves Drexlmeier Stefan Feitig Dipl.-Math. Jan Mark Tweer Dipl.-Math. Michael Wiese Anton Winterfeld Design and Cover Art Juliette Armbrecht Dipl.-Math. Steffen Grützner Dipl. BK Gertrud Schrenk Scientific Advisor Prof. Dr. Gert-Martin Greuel Director Fraunhofer-ITWM Prof. Dr. Dieter Prätzel-Wolters Index ABM (analog behavioral model), 90 AbsolutePivotThreshold, option for ApproximateMatrixEquation, 393 AbsoluteValues, option value for MagnitudeDisplay, 82, 333 AC, mode option for source value specification, 185 mode specification for NonlinearSetup, 404 option value for AnalysisMode, 230 AC analysis, 282 ACAnalysis, 282 example application, 159 examples for, 284 options description for, 283 AccuracyGoal, option for ApproximateDeterminant, 321 option for LREigenpair, 314 option for NDAESolve, 291 ACEquations, 248 examples for, 250 options description for, 249 AddElements, 256 examples for, 256 Admittance, 448 option value for Pattern, 183 option value for Type, 43 Admittance elements, 43 AI_NO_SITE_INIT, 433 AI_NO_USER_INIT, 433 AI_NO_WORKDIR_INIT, 433 aiinit.m, 432 airc, 432 Amplifier, 457 AMWave, 438 examples for, 439 Analog behavioral models (ABM), 90 AnalogInsydes, option value for Simulator, 429 AnalysisMode, option for CircuitEquations, 230 option for NDAESolve, 293 ApplyDesignPoint, 269 examples for, 271 options description for, 270 ApproximateDeterminant, 318 examples for, 327 options description for, 321 ApproximateMatrixEquation, 134, 135, 391 examples for, 395 options description for, 393 ApproximateTransferFunction, 132, 387 examples for, 388 Approximation, design point specification, 135 methods, 132 of expressions, 132 of linear circuits, 127, 385 of linear equations, ApproximateMatrixEquation, 134, 391 of nonlinear circuits, 164, 401 of nonlinear equations, CancelTerms, 165, 410 of transfer functions, ApproximateTransferFunction, 387 AspectFactor, option for BodePlot, 331 AspectRatio, option for BodePlot, 331 AutoloadModels, option for ExpandSubcircuits, 222 BasicModels, option value for ModelLibrary, 427 Behavioral models, 90 defining, 90 referencing, 94 Bias point calculation, example for, 100 Bipolar junction transistor (BJT), 464 BJT, 464 example implementation, 98 large-signal model, 464 small-signal model, 472 Bode diagram, 81, 330 BodePlot, 81, 330 examples for, 334 options description for, 332 Branch currents, naming scheme for, 70 Branch voltages, naming scheme for, 70 BranchCurrentPrefix, option for CircuitEquations, 70, 231 Branches, of controlled sources, 35, 38 BranchVoltagePrefix, option for CircuitEquations, 70, 231 BreakOnError, option for NDAESolve, 294 Bug reports, 12 494 CancelTerms — Design points CancelTerms, 165, 410 example application, 172 examples for, 414 options description for, 411 Capacitor, 449 Capacitors, initial conditions for, 44 CCCSource, 452 CCVSource, 452 CharacterMapping, option for ReadNetlist, 366 CheckedAMWave, data type returned by AMWave, 438 CheckedExpWave, data type returned by ExpWave, 440 CheckedPulseWave, data type returned by PulseWave, 441 CheckedPWLWave, data type returned by PWLWave, 442 CheckedSFFMWave, data type returned by SFFMWave, 443 CheckedSinWave, data type returned by SinWave, 445 CircleMark, marker style for options PoleStyle and ZeroStyle, 87, 354 Circuit, 46, 179 examples for, 179 Circuit equations, setting up and solving, 227 Circuit object, 178 information on, Statistics, 277 manipulating, 255 showing contents, DisplayForm, 47 Circuit-description language, 178 CircuitEquations, 71, 227, 231, 234, 235, 236 examples for, 239 options description for, 230 Cleanup, option for ApplyDesignPoint, 270 option for UpdateDesignPoint, 272 Clusterbound, option for CancelTerms, 412 CMRR, 151 ColorList, option for DXFGraphics, 422 Common-mode gain, 149 Common-mode rejection ratio, 151 Compatibility to Version 1, 29 Compiled, option for NDAESolve, 291 option for WriteSimulationData, 379 Complex frequency, 79 Complexity problem, 127 ComplexityEstimate, 129, 385 examples for, 386 ComplexValues, option for WriteSimulationData, 379 CompressEquations, option for ApproximateMatrixEquation, 393 option for NDAESolve, 294 CompressMatrixEquation, 398 examples for, 399 CompressNonlinearEquations, 95, 165, 407 example application, 171 examples for, 409 options description for, 408 Conductance, 448 Connectivity field, format for referencing subcircuits, 51 Connectivity list, 34 Index Control system description, Circuit, 179 Controlled sources, 35, 38 Controlling branch, of controlled sources, 38 Controlling currents, naming scheme for, 70 Controlling voltages, naming scheme for, 70 ControllingCurrentPrefix, option for CircuitEquations, 70, 231 ControllingVoltagePrefix, option for CircuitEquations, 70, 232 ConvertDataTo2D, 418 examples for, 419 ConvertImmittances, option for CircuitEquations, 74, 232 CrossMark, marker style for options PoleStyle and ZeroStyle, 87, 354 Current, into pin, 93 naming scheme for brach currents, 70 naming scheme for controlling currents, 70 reference direction, 155 Current, 92 Current meter, 450 Current-controlled sources, connection, 38 CurrentSource, 451 DAE (differential-algebraic equations), 104 DAEObject, information on, Statistics, 277 manipulating, 255 showing contents, DisplayForm, 40 Data format, 280 Database, for subcircuits, 62 DataLabels, option for WriteSimulationData, 380 DC, mode option for source value specification, 185 option value for AnalysisMode, 230, 293 DC analysis, 290 DC-transfer analysis, 107, 111, 290 DCEquations, 251 examples for, 252 options description for, 251 Decibels, option value for MagnitudeDisplay, 333 DefaultACError, option value for ErrorFunction, 404 DefaultACSimulation, option value for SimulationFunction, 404 DefaultDTError, option value for ErrorFunction, 402 DefaultDTSimulation, option value for SimulationFunction, 402 Defaults, parameter for Model, 196 DefaultSelector, option for CircuitEquations, 232 option for ExpandSubcircuits, 223 Definition, parameter for Model, 48, 90, 92, 200 Degrees, option value for PhaseDisplay, 333, 343 DeleteElements, 257 examples for, 258 Demo notebooks, 11 DerivativePostfix, option for ACEquations, 249 Design points, applying, ApplyDesignPoint, 269 extracting, GetDesignPoint, 268 Index Design points — GetDAEOptions for matrix approximation, 135 generation of, 158 numerical reference values, 131 updating, UpdateDesignPoint, 272 DesignPoint, option for ApproximateDeterminant, 321 option for ApproximateMatrixEquation, 393 option for CircuitEquations, 233 option for LREigenpair, 314 option for MatchSymbols, 274 option for NDAESolve, 294 option for NoiseAnalysis, 287 option for WriteModel, 382 Device mismatch, 149 Differential gain, 148 Differential-algebraic equations (DAE), 104 Differentiator, 458 Diode, 460 example model implementation, 91 large-signal model, 460 small-signal model, 463 DirectedLogError, option value for ErrorFunction, 322 DisplayForm, 34, 40, 47 Dominant pole, 159 DT analysis, 107, 111, 290 DXF, 419 DXFGraphics, 419 examples for, 422 options description for, 421 Ebers-Moll transistor model, example for, 96 Eldo, option value for Simulator, 429 Element types, 37 Element values, 36 numerical values, 41 symbolic values, 41 Elements, admittance elements, 43 impedance elements, 43 ElementTypes, 37, 185 examples for, 185 ElementValues, option for CircuitEquations, 79, 233 EliminateVariables, option for CompressNonlinearEquations, 408 Email address, 6 Environment variables, 433 Equations, compressing nonlinear equations, CompressNonlinearEquations, 165, 407 extracting, GetEquations, 260 for behavioral models, 92 setting up, CircuitEquations, 227 solving nonlinear equations, 95 solving of, 72 Equations, parameter value for Definition, 90, 92 Error, specification for equations, MaxError, 135 specification for expressions, 133 Errorbound, option for CancelTerms, 412 495 ErrorFunction, AC mode option value for NonlinearSetup, 404 DT mode option value for NonlinearSetup, 402 option for ApproximateDeterminant, 322 ESTA (extended sparse tableau analysis), 76 ExpandSubcircuits, 53, 221 examples for, 224 options description for, 222 Expansion, of subcircuits, 53 Exponential, option value for FrequencyScaling, 85, 332, 343, 348 option value for Sampling, 380 Exporting, behavioral models, WriteModel, 381 simulation data, WriteSimulationData, 378 ExpWave, 439 examples for, 440 Extended sparse tableau analysis (ESTA), 76 ExtendedTableau, option value for Formulation, 76, 234 Features, detailed description of new features, 26 overview of new features, 25 Fill-in pattern, 43 FillColors, option for DXFGraphics, 421 FindModel, 213 examples for, 213 FindModelParameters, 214 FindRoot, option value for NonlinearMethod, 297 Fixator, 456 Flat netlist, 53 Formulation, option for CircuitEquations, 74, 234 Four-terminal elements, 35 FourierPlot, 341 examples for, 341 Frequency, 186 Frequency-domain analysis, 142 FrequencyScaling, option for BodePlot, 332 option for NicholPlot, 86, 343 option for NyquistPlot, 85, 347 FrequencyVariable, option for ACAnalysis, 283 option for ACEquations, 249 option for ApproximateDeterminant, 322 option for CircuitEquations, 79, 234 option for LREigenpair, 314 option for NoiseAnalysis, 287 FullModels, option value for ModelLibrary, 427 GeneralizedEigensystem, 305 examples for, 305 option value for GEPSolver, 322 GeneralizedEigenvalues, 306 examples for, 306 GEPSolver, option for ApproximateDeterminant, 322 GEPSolverOptions, option for ApproximateDeterminant, 322 GetDAEOptions, 265 examples for, 265 496 GetDesignPoint — KeepLocalModels GetDesignPoint, 268 examples for, 269 GetElements, 258 examples for, 259 GetEquations, 260 examples for, 260 GetMatrix, 261 examples for, 262 GetParameters, 264 examples for, 264 GetRHS, 263 examples for, 263 GetVariables, 262 examples for, 262 Global, parameter specification, 196 parameter value for Scope, 62, 91, 193 Global subcircuit database, 62 examining content, GlobalSubcircuits, 62 Global subcircuits, 61 GlobalModelParameters, 215 examples for, 215 GlobalParameters, 189 GlobalSubcircuits, 62, 214 examples for, 215 Graphics, Bode plot, 81, 330 Nichol plot, 85, 342 Nyquist plot, 83, 346 root locus plot, 86, 352 transient waveform plot, 89, 106, 357 GraphicsSpacing, option for BodePlot, 332 Ground node, 34, 50, 181 missing, CircuitEquations, 235 Hierarchical circuit, keep local model data, KeepLocalModels, 224 stop expansion, HoldModels, 223 History list, recording, 413 visualization of, ShowCancellations, 417 HoldModels, 223 option for ExpandSubcircuits, 223 Home page, 6 IgnoreMissingGround, option for CircuitEquations, 235 Impedance, input, 151 output, 151 Impedance, 448 option value for Pattern, 183 option value for Type, 43 Impedance elements, 43 Importing, netlists, ReadNetlist, 365 schematics, DXFGraphics, 419 simulation data, ReadSimulationData, 376 Independent sources, examples for value specification, 186 value specification, 185 Index IndependentVariable, option for CircuitEquations, 235 Inductor, 449 Inductors, initial conditions for, 44 Info, 435 examples for, 435 Init files, 432 list of loaded init files, 435 Initial conditions, for capacitors and inductors, 44 transient analysis, 120 InitialCondition, option for netlist entries, 44, 183 InitialConditions, example application, 121, 122 option for CircuitEquations, 236 option for NDAESolve, 294 option for WriteModel, 382 parameter for Model, 203 InitialGuess, option for CircuitEquations, 229 option for DefaultDTSimulation, 403 option for LREigenpair, 315 option for NDAESolve, 118, 295 option for WriteModel, 382 parameter for Model, 202 Initialization procedure, 432 InitialLeftEigenvector, option value for ProjectionVectors, 316, 325 InitialRightEigenvector, option value for ProjectionVectors, 316, 325 InitialSolution, option for ApproximateDeterminant, 323 option for NDAESolve, 118, 295 InitialTime, option for CircuitEquations, 236 option for DCEquations, 251 Input impedance, 151 InputNoise, return value of NoiseAnalysis, 285 InstanceNameSeparator, global Analog Insydes option, 426 option for CircuitEquations, 71, 228 option for ExpandSubcircuits, 222 option for ReadNetlist, 366 option for ShortenSymbols, 277 Integrator, 458 Interfaces, 365 InterpolateResult, option for ACAnalysis, 283 InterpolationOrder, option for ACAnalysis, 283 option for NDAESolve, 295 option for NoiseAnalysis, 287 option for ReadSimulationData, 376 option for WriteSimulationData, 380 Jacobian matrix, 157 JFET, 485 large-signal model, 486 small-signal model, 490 Junction field-effect transistor (JFET), 485 KeepLocalModels, 224 Index KeepLocalModels — Model option for ExpandSubcircuits, 224 KeepPrefix, option for ReadNetlist, 367 KeepSymbolic, option for ApplyDesignPoint, 270 Laplace frequency, 79 Laplace-domain, AC equation setup, 230 Large-signal analysis, 290 introduction, 104 Large-signal model, BJT, 464 Diode, 460 JFET, 486 MOSFET, 474 LayerColor, option for DXFGraphics, 421 LeastMeanInfluence, option value for SortingMethod, 394 LeftEigenvector, option value for ProjectionVectors, 316, 325 Level, option for CancelTerms, 412 Levels, for nonlinear approximations, ShowLevel, 417 LevelSeparator, option for ReadNetlist, 367 Library, list contents, ListLibrary, 211 searching models, FindModel, 213 LibraryPath, global Analog Insydes option, 426 option for CircuitEquations, 229 option for ExpandSubcircuits, 222 option for FindModel, 213 option for FindModelParameters, 214 option for ListLibrary, 212 option for LoadModel, 216 option for LoadModelParameters, 218 option for ReadNetlist, 367 License, 434 examples for, 434 Linear, option value for FrequencyScaling, 85, 332, 343, 348 option value for MagnitudeDisplay, 82, 333 option value for Sampling, 380 Linearization, of nonlinear DAEObjects, 248 LinearRegionLimit, option for RootLocusPlot, 353 LinearRegionSize, option for RootLocusPlot, 353 LinearRegionStyle, option for RootLocusPlot, 353 LineDashingScale, option for DXFGraphics, 421 ListLibrary, 211 examples for, 212 Loading Analog Insydes, 11 Loading procedure, 432 LoadModel, 216 examples for, 217 LoadModelParameters, 217 LoadMSBG, 424 LoadQZ, 424 Local, parameter value for Scope, 62, 193 Local subcircuits, 61, 63 LogError, option value for ErrorFunction, 322 LPNP, 464 LREigenpair, 312 497 examples for, 316 option value for GEPSolver, 322 options description for, 314 MagnitudeDisplay, option for BodePlot, 82, 332 MAST, modeling language supported by WriteModel, 383 Matching, of devices, 149 precision, 150 MatchSymbols, 149, 274 example application, 149 examples for, 275 options description for, 274 Mathlink applications, MSBG.exe, 424 QZ.exe, 424 Matrix formulation, CircuitEquations, 234 MatrixEquation, option for CircuitEquations, 78, 229 MaxDelta, option for NDAESolve, 118, 296 MaxDivergentSteps, option for ApproximateDeterminant, 323 MaxError, 135 AC mode option value for NonlinearSetup, 404 DT mode option value for NonlinearSetup, 402 named parameter for error specifications in design points, 391 MaxIterations, 119 option for ApproximateDeterminant, 323 option for DefaultDTSimulation, 403 option for LREigenpair, 315 option for NDAESolve, 119, 296 MaxResidual, option for ApproximateDeterminant, 323 option for LREigenpair, 315 MaxShift, option for ApproximateDeterminant, 324 MaxSteps, 119 option for NDAESolve, 119, 296 MaxStepSize, option for NDAESolve, 119, 296 MinMAC, option for ApproximateDeterminant, 324 MinStepSize, option for NDAESolve, 119, 296 Mismatch of devices, 149 MNA (modified nodal analysis), 74 Model, behavioral models, 90 definition of, 190 exchanging device models, 187 expanding, 221 exporting, WriteModel, 381 global model library, 62 loading from library, LoadModel, 216 model library, 460 parameter cards, 189 referencing, 51, 187 variables of behavioral models, 93 Model, 47, 188, 190 argument description, 191 defining behavioral models, 90 examples for model implementation, 204 option for netlist entries, 45 498 Model library — Options Model library, 460 defining global model library, 62 library management, 211 ModelLibrary, examples for, 427 global Analog Insydes option, 427 option for CircuitEquations, 230 option for ExpandSubcircuits, 222 option for FindModel, 213 option for FindModelParameters, 214 option for ListLibrary, 212 option for LoadModel, 216 option for LoadModelParameters, 218 ModelParameters, 189 ModeValues, option for DCEquations, 251 Modified nodal analysis (MNA), 74 ModifiedNodal, option value for Formulation, 74, 234 MOS field-effect transistor, 474 MOSFET, 474 advanced modeling, 157 large-signal model, 474 modeling examples, 143 small-signal model, 142, 479 MSBG.exe, 424 Name, parameter for Model, 48, 191 Name/selector specification, 49 Naming conventions, 70 NDAESolve, 105, 115, 290 examples for, 299 implemented algorithms, 115 options description for, 118, 293 Netlist, format of, 33, 178 importing, ReadNetlist, 365 Netlist, 178, 185 examples for, 178 Netlist entries, examples for, 181 extended format, 41 format, 34, 180 format for subcircuit references, 51, 60 option examples for, 184 options, 182 Netlist object, 178 information on, Statistics, 277 manipulating, 255 showing contents, DisplayForm, 34 New features in Analog Insydes Version 2, 25 Newsletter, 6 Newton-Raphson algorithm, 116 NewtonIteration, example application, 111 option value for NonlinearMethod, 297 Nichol diagram, 85, 342 NicholPlot, 85, 342 examples for, 344 options description for, 343 NMOS, 474 small-signal model, 142 Index Node identifier, 34 Node voltages, naming scheme for, 70 Nodes, 34, 181, 194 NodeVoltagePrefix, option for CircuitEquations, 70, 236 Noise analysis, 285 NoiseAnalysis, 285 examples for, 288 options description for, 287 Nonlinear approximation, CancelTerms, 165, 410 example application for, 166 setting up, NonlinearSetup, 401 status of, NonlinearSettings, 415 term levels, ShowLevel, 417 Nonlinear equation solving, NDAESolve, 115 number of integration steps, MaxSteps, 119 number of Newton iterations, MaxIterations, 119 Nonlinear equations, compressing, CompressNonlinearEquations, 165, 407 setting up, 94 solving, 95 NonlinearMethod, option for NDAESolve, 119, 296 NonlinearSettings, 415 examples for, 416 NonlinearSetup, 401 AC mode specifications for, 404 DT mode specifications for, 402 example application, 172 examples for, 405 Norator, 455 Normalize, option for GeneralizedEigensystem, 305 Notebook, option value for Protocol, 428 NPN, 464 Nullator, 455 Numerical solving, ACAnalysis, 282 NDAESolve, 290 NoiseAnalysis, 285 NumericalAccuracy, option for ApproximateMatrixEquation, 393 Nyquist diagram, 83, 346 NyquistPlot, 83, 346 examples for, 348 options description for, 347 Online help system, 23 OP analysis, 290 OPAmp, 454 OpenCircuit, 449 Operating point, 118 Operating-point analysis, 290 OperatingPointPostfix, option for ACEquations, 249 Option inheritance, 430 examples for, 430 Optional, model port specification, 194 Options, global Analog Insydes options, 425 of netlist entries, 41 Index Options — Referencing retrieving DAEObject options, GetDAEOptions, 265 setting DAEObject options, SetDAEOptions, 266 setting default options on startup, 433 Options[AnalogInsydes], 425 examples for, 426 OTAmp, 454 Output impedance, 151 example application, 152 OutputNoise, return value of NoiseAnalysis, 285 OutputVariables, option for NDAESolve, 297 Palette, 23 Parameter sweep, 280 examples for, 281 Parameters, declaration for subcircuits, 57 implicit translation, 65 inspecting parameter database, GlobalModelParameters, 215 loading from library, LoadModelParameters, 217 of subcircuits, 56 removing, RemoveModelParameters, 219 Parameters, parameter for Model, 57, 60, 195 Parametric, option for TransientPlot, 124, 359 Parametric analysis, 290 example circuit, 113 Pattern, option for netlist entries, 43, 183 PhaseDisplay, option for BodePlot, 82, 333 option for NicholPlot, 86, 343 PivotThreshold, option for ApproximateMatrixEquation, 393 PlotPoints, option for BodePlot, 332 option for FourierPlot, 341 option for RootLocusPlot, 353 option for WriteSimulationData, 380 PlotRange, option for BodePlot, 82, 333 option for RootLocusPlot, 354 option for TransientPlot, 359 Plots, Bode plot, 81, 330 Nichol plot, 85, 342 Nyquist plot, 83, 346 root locus plot, 86, 352 transient waveform plot, 89, 106, 357 PlotStyle, option for RootLocusPlot, 354 PlusMark, marker style for options PoleStyle and ZeroStyle, 87, 354 PMOS, 474 small-signal model, 142 PNP, 464 PointMark, marker style for options PoleStyle and ZeroStyle, 87, 354 PointsPerDecade, option for ACAnalysis, 284 option for NoiseAnalysis, 287 Pole/zero analysis, 304 PolesAndZerosByQZ, 307 examples for, 307 PolesByQZ, 308 499 examples for, 309 PoleStyle, option for RootLocusPlot, 87 Ports, of behavioral models, 92 optional port nodes, 194 port currents, 92 port voltages, 92 Ports, parameter for Model, 48, 194 Prefix, customizing prefix settings, 70 for branch voltages and currents, 70 for controlling voltages and currents, 70 for node voltages, 70 specification, CircuitEquations, 231, 236 Prescaling, option for ApproximateDeterminant, 324 option for LREigenpair, 315 PrimaryDesignPoint, option value for SortingMethod, 394 ProjectionVectors, option for ApproximateDeterminant, 325 option for LREigenpair, 315 Protocol, examples for, 429 global Analog Insydes option, 428 PSpice, option value for Simulator, 429 PulseWave, 441 examples for, 441 PWLWave, 442 examples for, 443 QuasiSingularity, option for ApproximateMatrixEquation, 394 QZ.exe, 424 Radians, option value for PhaseDisplay, 333, 343 RandomFunction, option for NDAESolve, 297 Range, AC mode option value for NonlinearSetup, 404 DT mode option value for NonlinearSetup, 402 Ranking, least mean influence, 141 of terms, 140 Ranking, option for CancelTerms, 413 ReadNetlist, 365 example application, 145 examples for, 368 options description for, 366 supported features for AnalogInsydes, 369 supported features for Eldo, 371 supported features for PSpice, 369 supported features for Saber, 374 ReadSimulationData, 376 examples for, 378 options description for, 376 RecomputationThreshold, option for ApproximateMatrixEquation, 394 RecordCancellations, option for CancelTerms, 413 Reference designator, 34, 71, 180 Reference directions, for currents and voltages, 35, 155 for port branches, 92 Referencing, behavioral models, 94 500 Referencing — SortingMethod subcircuits, 51 ReleaseInfo, 433 examples for, 433 ReleaseNumber, 434 examples for, 434 RemoveModelParameters, 219 examples for, 219 RemoveSubcircuit, 63, 218 examples for, 219 RemoveSubcircuits, 63, 218 RenameNodes, 259 examples for, 259 Resistor, 447 ReturnDerivatives, option for NDAESolve, 297 ReturnSymbols, option for SimplifySamplePoints, 415 RightEigenvector, option value for ProjectionVectors, 316, 325 Root locus diagram, 86, 352 animated, 89 of transfer functions without parameters, 88 RootLocusByQZ, 310 examples for, 311 RootLocusPlot, 86, 352 examples for, 355 options description for, 353 Saber, option value for Simulator, 429 SAG (simplification after generation), 132, 385 ApproximateTransferFunction, 387 combination with SBG, 138 Sampling, option for WriteSimulationData, 380 SBG (simplification before generation), 132, 134, 385 ApproximateMatrixEquation, 391 combination with SAG, 138 Schematic pictures, 419 Scope, of subcircuit definitions, 61 Scope, option for LoadModel, 216 option for LoadModelParameters, 218 parameter for Model, 62, 63, 193 SDG (simplification during generation), 132 SearchDirections, option for SimplifySamplePoints, 415 Searching, model parameters, FindModelParameters, 214 models, FindModel, 213 Selector, parameter for Model, 48, 192 SetDAEOptions, 266 examples for, 267 SFFMWave, 443 examples for, 444 ShortCircuit, 450 ShortenSymbols, 276 options for, 276 ShowCancellations, 417 ShowColors, option for DXFGraphics, 421 ShowLegend, option for BodePlot, 332 option for NicholPlot, 343 Index option for NyquistPlot, 347 option for RootLocusPlot, 353 option for TransientPlot, 359 ShowLevel, 417 ShowSamplePoints, option for TransientPlot, 125, 359 ShowUnitCircle, option for NyquistPlot, 348 SignalSource, 457 Simplification, design point specification, 135 methods, 132 of expressions, 132 of linear circuits, 127, 385 of linear equations, ApproximateMatrixEquation, 134 of nonlinear circuits, 164, 401 of nonlinear equations, CancelTerms, 165, 410 Simplification after generation (SAG), 132, 385 combination with SBG, 138 Simplification before generation (SBG), 132, 134, 385 combination with SAG, 138 Simplification during generation (SDG), 132 SimplifiedModels, option value for ModelLibrary, 427 SimplifySamplePoints, 414 Simulation data, exporting, WriteSimulationData, 378 importing, ReadSimulationData, 376 SimulationFunction, AC mode option value for NonlinearSetup, 404 DT mode option value for NonlinearSetup, 402 Simulator, global Analog Insydes option, 429 option for NDAESolve, 297 option for ReadNetlist, 367 option for ReadSimulationData, 377 option for WriteModel, 383 option for WriteSimulationData, 380 SimulatorExecutable, option for NDAESolve, 298 SingleDiagram, option for TransientPlot, 125, 359 SingularityTest, option for ApproximateDeterminant, 326 SingularityTestByLU, option value for SingularityTest, 326 SingularityTestByQR, option value for SingularityTest, 326 SinWave, 444 examples for, 445 Small-signal analysis, 282 Small-signal model, BJT, 472 Diode, 463 JFET, 490 MOSFET, 142, 479 Solve, 72, 253 examples for, 253 Solving, ACAnalysis, 282 NDAESolve, 290 NoiseAnalysis, 285 Solve, 253 SortingMethod, option for ApproximateMatrixEquation, 140, 394 Index Sources — Type tag Sources, stimuli for two-port calculations, 155 Sparse tableau analysis (STA), 75 extended sparse tableau analysis (ESTA), 76 SparseTableau, option value for Formulation, 75, 234 SquareMark, marker style for options PoleStyle and ZeroStyle, 87, 354 STA (sparse tableau analysis), 75 Stability analysis, 83 Starting Analog Insydes, 432 StartingStepSize, option for NDAESolve, 120, 298 Statistics, 277 examples for, 278 StatusLine, option value for Protocol, 428 StepSizeFactor, option for NDAESolve, 120, 298 Stimulus sources, 155 StripIndependentBlocks, option for ApproximateMatrixEquation, 395 option for CompressMatrixEquation, 399 option for CompressNonlinearEquations, 408 Subcircuit, definition of, 190 expanding, 53, 221 generic selectors, 52 global and local definitions, 61 global database for, 62 inspecting subcircuit database, GlobalSubcircuits, 214 local overrides, 63 parameters, 56, 57 passing parameter values to, 60 redefining global subcircuits, 63 referencing, 51 removing, RemoveSubcircuits, 63, 218 translation of parameters, 65 Subcircuit, 47, 188, 210 option for netlist entries, 45 SweepParameters, Analog Insydes data format, 280 option for TransientPlot, 360 SweepPath, option for ACAnalysis, 284 option for NoiseAnalysis, 287 Symbolic, option for CircuitEquations, 237 option for ExpandSubcircuits, 222 option for netlist entries, 41, 183 option for source value specification, 185 option value for ElementValues, 79, 234 parameter for Model, 198 Symbolic approximation, complexity problem, 127 design point specification, 135 introduction, 127 methods, 132 of expressions, 132 of linear circuits, 127, 385 of linear equations, ApproximateMatrixEquation, 134 of nonlinear circuits, 401 of nonlinear equations, CancelTerms, 410 Symbolic expressions, approximation of, 129 501 Symbolic solving, Solve, 253 TestFrequency, option for ApproximateDeterminant, 326 TextSizing, option for DXFGraphics, 421 TextStyle, option for DXFGraphics, 421 ThicknessFunction, option for DXFGraphics, 422 Time, 186 Time variable, 105 Time-domain analysis, 104 TimeConstraint, option for Statistics, 278 TimeVariable, option for CircuitEquations, 238 Tolerance, option for ApproximateDeterminant, 327 option for LREigenpair, 316 option for MatchSymbols, 275 TraceNames, option for BodePlot, 333 option for NicholPlot, 344 option for NyquistPlot, 348 Transfer function, approximation, ApproximateTransferFunction, 132 complexity, ComplexityEstimate, 129 example application, 162 plotting gain vs. phase, NicholPlot, 85, 342 plotting magnitude and phase, BodePlot, 81, 330 plotting real vs. imaginary part, NyquistPlot, 83, 346 TransferFunction, 459 Transient, mode option for source value specification, 185 option value for AnalysisMode, 230, 293 Transient analysis, 290 example circuit, 106, 108 initial conditions, 120 introduction, 104 procedure, 115 Transient waveforms, 89, 357 TransientPlot, 106, 357 examples for, 360 options description for, 124, 358 Transistor models, 142 advanced modeling, 157 Translation, of subcircuit parameters, 65 Translation, parameter for Model, 65, 197 TransmissionLine, 458 Trapezoidal rule, 115 Two-port parameters, 154 Two-port representation, admittance form, 154 cascade form, 154 hybrid form, 154 impedance form, 154 Two-terminal elements, 35 Type, option for netlist entries, 42, 184 Type tag, 34 for controlled sources, 38 overriding default type, 42 502 UnitCircleStyle — ZeroStyle UnitCircleStyle, option for NyquistPlot, 348 Units, 36 UnloadMSBG, 424 UnloadQZ, 424 UnwrapPhase, option for BodePlot, 334 UnwrapTolerance, option for BodePlot, 334 UpdateDesignPoint, 272 examples for, 273 options description for, 272 UseExternals, global Analog Insydes option, 429 option for ApproximateMatrixEquation, 395 Value, option for CircuitEquations, 238 option for ExpandSubcircuits, 222 option for netlist entries, 41, 181 option for source value specification, 185 option value for ElementValues, 79, 234 Value field, 41 Value specification, for different analysis modes, Netlist, 185 Variables, independent, CircuitEquations, 235 of behavioral model equations, 93 Variables, parameter for Model, 93, 199 VCCSource, 453 VCVSource, 453 Version, 434 examples for, 435 Voltage, naming scheme for branch voltages, 70 naming scheme for controlling voltages, 70 naming scheme for node voltages, 70 reference direction, 155 Voltage, 92 Voltage gain, 146 Voltage meter, 450 VoltageSource, 451 Web page, 6 WorkingPrecision, option for NDAESolve, 291 WriteModel, 381 examples for, 383 options description for, 382 WriteSimulationData, 378 examples for, 380 options description for, 379 Y-parameters, 155 Zero node, 34, 50 Zero-state response, 41 ZerosByQZ, 309 examples for, 310 ZeroStyle, option for RootLocusPlot, 87, 354 Index