An adaptive time-stepping method is widely used in a computer-based simulation of a system. Generally used in a transient analysis of the system, the adaptive time-stepping method refines a size of a time step accordingly so as to cause simulated results to satisfy a predefined condition.
Systems and methods to determine a step size in a simulator are disclosed herein. In an embodiment, a method includes: receiving a set of nonlinear algebraic equations for a system at a current time point, and calculating a set of solutions to the set of nonlinear algebraic equations by using a first time step, wherein each of the solutions corresponds to a node of the system and a time step is an interval between a previous time point and the current time point. Further, the method includes determining whether a maximum value of a local truncation error associated with a first solution of the set of solutions is greater than a threshold. Based on the maximum value of the local truncation error being greater than the threshold, the method includes iteratively calculating a coupled set of equations to generate a second time step so as to make a maximum value of local truncation error associated with a set of solutions to the coupled set of equations not greater than the threshold, wherein the coupled set of equations comprises the received set of nonlinear algebraic equations and a local truncation error equation corresponding to the first solution, with a time step that is an unknown variable in the coupled set of equations.
In another embodiment, a system includes an input device, a processor, and a storage device coupled to the processor. The input device is configured to receive a set of nonlinear differential algebraic equations that describes the system, and a set of control parameters, such as start time and stop time for a transient simulation. The storage device is configured to store a plurality of software instructions. While the software instructions being executed by the processor, the software instructions cause the processor to calculate a set of solutions to the set of nonlinear algebraic equations by using a value for a first time step, wherein each of the solutions corresponds to a node of the system and a time step is an interval between a previous time point and the current time point, determine whether a maximum value of local truncation error associated with a first solution of the set of solutions is greater than a threshold. Further, based on the maximum value of the local truncation error being greater than the threshold, the software instructions cause the processor to iteratively calculate a coupled set of equations to generate a second time step so as to make a maximum value of local truncation error associated with a set of solutions to the coupled set of equations not greater than the threshold, wherein the coupled set of equations comprises the received set of nonlinear algebraic equations and a local truncation error equation corresponding to the first solution, with a time step that is an unknown variable in the coupled set of equations.
In a further embodiment, a non-transitory, computer-readable storage device containing instructions that, when executed by a processor, cause the processor to calculate a set of solutions to the set of nonlinear algebraic equations by using a value for a first time step, wherein each of the solutions corresponds to a node of the system and a time step is an interval between a previous time point and the current time point, determine whether maximum value of local truncation error associated with a first solution of the set of solutions is greater than a threshold, and based on the maximum value of the local truncation error being greater than the threshold, iteratively calculate a coupled set of equations to generate a second time step so as to make a maximum value of local truncation error associated with a set of solutions to the coupled set of equations not greater than the threshold, wherein the coupled set of equations comprises the received set of nonlinear algebraic equations and a local truncation error equation corresponding to the first solution, with a time step that is an unknown variable in the coupled set of equations.
For a detailed description of exemplary embodiments of the invention, reference will now be made to the accompanying drawings in which:
Certain terms are used throughout the following description and claims to refer to particular system components. As one skilled in the art will appreciate, companies may refer to a component by different names. This document does not intend to distinguish between components that differ in name but not function. In the following discussion and in the claims, the terms “including” and “comprising” are used in an open-ended fashion, and thus should be interpreted to mean “including, but not limited to . . . . ” Also, the term “couple” or “couples” is intended to mean either an indirect or direct connection. Thus, if a first device couples to a second device, that connection may be through a direct connection, or through an indirect connection via other devices and connections.
The following discussion is directed to various embodiments of the invention. Although one or more of these embodiments may be preferred, the embodiments disclosed should not be interpreted, or otherwise used, as limiting the scope of the disclosure, including the claims. In addition, one skilled in the art will understand that the following description has broad application, and the discussion of any embodiment is meant only to be exemplary of that embodiment, and not intended to intimate that the scope of the disclosure, including the claims, is limited to that embodiment.
Computer-based simulation enables the analysis of complex systems before time and expense of actually implementing the systems is incurred. Generally, a simulator is a system or an engine executing a software application that analyzes a system (e.g., a circuit design) based on a description of that system to predict behaviors of the system under a given set of conditions. Thus, the simulator is not just software. Typically, the system description is made up of equations describing the desired behavior of the system. The simulator solves these equations in the context of simulated conditions represented by stimuli applied to the system so that the system is operated under the simulated conditions.
In one example, a circuit simulator is frequently used to simulate a circuit design. The circuit simulator constructs circuit equations from mathematical models of components in a circuit. The mathematical models may be provided in the circuit simulator (e.g., semiconductor device models of SPICE-like simulators), and/or may be specified by a user using a hardware description language (e.g., Verilog-A). The circuit simulator combines the mathematical models of the components with equations that describe the interconnections of the components to construct a set of nonlinear differential algebraic equations (DAEs) that describe the circuit. In many circuit simulators, the interconnection equations are derived from Kirchoff's voltage and current laws which require that the sum of all currents flowing out of a node at any instant is zero and the algebraic sum of all branch voltages around a loop at any instant in time is zero. The node in a circuit design is a physical point of the circuit design; the loop is made up of at least two nodes in the circuit design, wherein the loop includes the same starting node and ending node.
A variety of types of analyses of a circuit design may be implemented by using the circuit simulator, for example, transient analysis, direct current (DC) analysis, alternative current (AC) analysis, Monte Carlo analysis, etc. For the transient analysis, the circuit simulator computes the response of a circuit as a function of time. To perform the transient analysis, the differential algebraic equations (DAEs) describing the circuit are discretized in time to convert the solution of equations into a problem of solving a sequence of systems of nonlinear algebraic equations (NAEs). In other words, the differential equations are numerically integrated to replace the time derivative operator with a discrete-time approximation and the resulting finite difference equations are solved one time point at a time starting from an initial condition.
More particularly, the transient analysis determines the time domain response of the circuit design over a time interval [0, T]. The transient solution to the system of differential equations is computed by dividing this time interval into discrete time points [0, t1, t2, . . . , T], and applying a numerical integration method at each time point to transform the differential equations into equivalent algebraic equations. The circuit simulator solves these nonlinear algebraic equations (NAEs) on every time point of a transient analysis. The solution to the NAEs is obtained by executing an iterative sequence of linearized solutions.
The Newton-Raphson method, also called the “Newton method” or “Newton iteration,” is a commonly used linearization method. The Newton-Raphson method begins with an initial guess for the solutions to the NAEs. The NAEs are then linearized around that guess, and the resulting linear system is solved. One common technique used to solve such a linear system in circuit simulators is Lower Upper (LU) factorization. LU factorization is a modified version of Gaussian elimination. The linear equations of the linear system are presented as a circuit matrix, i.e., a modified nodal analysis (MNA) circuit matrix which is typically a Jacobian matrix, and the matrix is factorized into a product of lower- and upper-triangular matrices. Subsequently, forward and backward substitutions are performed to obtain the solution. Once the solution is obtained, the NAEs are then re-linearized around the solution and the procedure repeats until the process converges.
As mentioned above, numerical integrations with the discrete-time approximation are used to replace the time derivative operators in the DAEs. Several numerical integration methods are frequently used, including but not limited to, the trapezoid rule, backward Euler, and backward difference formulas. Regardless of which method is used, a time step is needed to discretize the time interval [0, T] into distinct time points [0, t1, t2, . . . , T]. The time points may be equally spaced, which means that there is only one fixed value, or size, for the time step. However, modern analog and mixed signal circuits are typically “stiff” systems characterized by a wide range of time constants. Thus, in a transient analysis, it may be desirable to dynamically vary the size of time step. For example, taking small time steps when the circuit performs in a state of fast transition may advantageously preserve accuracy; on the other hand, taking large time steps may be advantageous in terms of time when the circuit is performing in a state with less activity. As such, an adaptive time-stepping process may be desirable in order to enhance the efficiency of the circuit simulator. The adaptive time-stepping may be a method to be implemented in the circuit simulator to thereby dynamically vary the size of time step so as to satisfy conditions of stability and local truncation error (LTE). Hereinafter, the size of time step is referred to as a “step size” for clarity purposes.
Generally, the LTE is associated with using the discrete-time approximation to solve the NAEs. The LTE of a numerical method is an estimate of the error introduced in a single iteration of the method, assuming that all inputs and data provided to the method are accurate. Details of the implementation of LTE in are discussed below.
Although a variety types of adaptive time-stepping method or algorithm have been proposed and implemented in the circuit simulator over many years, such methods are implemented to predict a step size for a current time point based on prior information, such as step sizes and local truncation errors from previous time point(s) and based on a violation of satisfying a LTE condition, to refine (i.e., decrease) the step size until no violation is present. In some examples, especially in a stiff circuit, these methods may become inefficient since the stiff circuit may be characterized with strong nonlinearity, causing a dramatic change of the DAEs from time point to time point. Moreover, conventional methods are derived based on solving an initial condition problem, that is, no external stimulus present. In reality, some circuits are driven by one or more time-varying independent sources for transient simulation. Thus, a system and/or a method capable of determining the step size, instead of being based on a random guess, for solving the DAEs may advantageously enhance the efficiency of the circuit simulator.
Based on a violation of a predefined LTE condition (i.e., solved solutions using an initial step size including an inacceptable LTE), embodiments of the disclosed invention provide systems and methods to determine the step size in the transient analysis of a circuit design by solving a coupled NAEs and LTE equations. As such, the step size may be more efficiently and precisely determined so that the disclosed systems and methods may advantageously provide a more efficient way to simulate the circuit design. More particularly, the disclosed system and method may be generalized to analyze the transient response of a system in any suitable scientific and engineering applications that can be described by analogous DAEs.
In
where ūεRN is the vector of input sources,
Still referring to
As shown in the example of
As mentioned above, the LTE occurs when the derivative operator in the DAEs is replaced with the discrete-time approximation. More particularly, the LTE is the error incurred in a single step (e.g., time step) assuming all previous steps are accurate. Modern circuit simulators calculate a difference between a computed solution and a polynomial extrapolation from previous time steps. A maximum difference εm is estimated and expressed as in equation (2),
εm=|vi(tm)−vi,extrapolated| (2)
where i is an index of solution variables with the maximum difference. Generally, in some preferred embodiments, the solution variable is a node voltage. The corresponding node (i.e., the node with the maximum difference) may be referred to as a controlling LTE node. More particularly, the controlling LTE node may vary from time point to time point. For example, a controlling LTE node at a first time point may be different from a controlling LTE node at a second time point. Still in some preferred embodiments, equation (3) below provides an LTE condition to determine whether a step size is acceptable:
εm<γ·τm (3)
where τm is the tolerance for the LTE and γ is a coefficient greater than 1. Details of various implementations of the LTE condition in the adaptive step size generation module 108 will be explained with respect to the flow chart in
Still referring to
Still referring to block 402, more specifically, to perform the transient analysis, the time derivate term of the DAEs is discretized using a time integration scheme such as the trapezoidal rule, backward Euler, or backward difference formulas (i.e., Gera's methods). For illustration purposes, discretization using backward Euler is described. In a preferred embodiment, the backward Euler time integration scheme is:
where m is the time index, hm is a time step at time point of time index m (tm), is used to discretize the time derivative term of the DAEs, vm and vm−1 are node voltages at the time point tm and tm−1 respectively. The resulting NAEs at the time index m may be expressed as equation (5),
As a result of executing the equation calculation module 202 by the computing resource 104, the flow diagram 400 first routes to block 404 to evaluate the nonlinear devices in the circuit. After evaluating the nonlinear devices in the circuit, the flow diagram routes to block 406 to form a linear system of equations from the NAEs. Subsequently, the flow diagram 400 continues at block 408 to solve the formed linear system of equations to generate the vector of solution variables,
In some preferred embodiments, at block 104, the nonlinear devices in the circuit are evaluated based on the current solution
At block 410, the solutions in the vector
Referring back to block 410, if the LTE condition is not satisfied for the LTE controlling node, as a result of executing the coupled equation calculation module 208, the flow diagram 400 routes to block 416 to form a coupled set of equations, wherein the coupled equations includes the formed NAEs as of equation (5) and a generalized equation associate with the LTE condition (equation (3)) for the LTE controlling node. More specifically, the generalized equation associate with the LTE condition may be expressed as, flte(
In a preferred embodiment, blocks 404, 406, and 408 may result from executing the equation calculation module 202. More particularly, from block 404 to block 408, the Newton-Raphson approach is used to solve the NAEs at the time point tm. Essentially, the approach attempts to converge on the solution
More particularly at block 410, the LTE condition check may include two criteria for the LTE equation. The first criterion is to set an upper and a lower bounds for the LTE, which may be expressed as,
γminτm≦εmk(vmk,hmk)≦γmaxτmin (6)
where γmax is a coefficient greater than 1, and γmin is a coefficient between 0 and 1. By setting the lower bound, the step size may be prevented to be unnecessarily small. In a preferred embodiment, the coefficient γmax and γmin may be predetermined by the user to precisely control the LTE at each step. The second criterion is to assure that a change of the step size between two iterations is small enough, which may be expressed as,
|Δhmk+1|≦η·hmk (7)
where η is a relative tolerance for the step size.
The above discussion is meant to be illustrative of the principles and various embodiments of the present invention. Numerous variations and modifications will become apparent to those skilled in the art once the above disclosure is fully appreciated.
It is intended that the following claims be interpreted to embrace all such variations and modifications.
This application claims priority to U.S. Provisional Application 61/819,339 filed May 3, 2013, titled “An Adaptive Time-Step Control Method for Simulation”, and incorporated herein by reference.