System for solving differential equations with algebraic constraints

Abstract: This invention uses a system model to take one integration step while disregarding algebraic constraints, followed by a correction step that uses the technique for computing consistent initial values for the reduced state. It also claims the integration of such a correction step into numerical solvers. In mixed-mode simulation, i.e., simulation of systems with piecewise continuous behavior, algebraic constraints may become active during simulation, requiring a consistent mapping of the system state onto the reduced state of the new piecewise behavior. The invented simulation interface uses the same technique to compute consistent initial values for the reduced state to compute consistent state variable values when such changes in the system occur during simulation. The invention is useful for the simulation of physical systems relying on differential and algebraic equations (DAE).

Description: The present invention relates to a numerical simulation model structure of physical systems relying on differential equations supplemented by algebraic constraints on state variables. For such systems, behavior trajectories are generated by numerical solvers that use integration algorithms such as, e.g. a Forward Euler and Runge-Kutta. These solvers require as input the system state and its gradient to evolve behavior over a desired interval of time. In this mathematical context, the system state represents a minimal set of variables that allows computation of the gradient of behavior evolution. In other words, the number of state variables matches the number of degrees of freedom of the system. Once the system state is known, all previous behavior of the differential and algebraic equations (DAE) is captured and future behavior can be derived. From a physical modeling perspective, state variables correspond to energy storing elements, e.g., the charge stored by a capacitor in the electrical domain and the momentum stored by a mass in the mechanical domain. Behavior of those variables is expressed by a time derivative relation, e.g., for a mass m, p ˙ = F , where p ˙ is the time derivative of the momentum and F the force acting on the mass. These relations can be written in time integral form as well, requiring an initial value of which the modeler has specific knowledge, e.g. the initial charge on a capacitor or initial velocity of a mass. Therefore, these relations introduce a physical state. In this patent application, the set of variables with modeled time derivative behavior, the physical state, is referred to as the extended set of state variables X . In case no algebraic constraints between those states exist, e.g. in the mechanical domain when there are no ideal rigid connections between masses, this extended set of state variables equals the set of state variables used by the numerical solver. However, in case of algebraic constraints between state variables in the extended set, their gradients cannot be computed without accounting for the effect of the algebraically related state variables. In effect, the algebraic equations constitute a manifold in state space to which behavior evolution is constrained. Because of the direct, algebraic, relation between the state variables, they embody a reduced degree of behavioral freedom, and, therefore, a reduced set of state variables X exists that completely specifies future behavior. This reduced set of state variables is supplied to the numerical solver to generate continuous behavior. Efficient algorithms exist to derive the reduced set of states from the extended set [Constantinos C. Pantelides: "The consistent initialization of differential-algebraic systems", SIAM Journal of Scientific and Statistical Computing, 9(2):213-231, March 1988]. When a DAE with a reduced number of states is to be simulated, it requires initial values for the state variables. However, the reduced state only has a partial bearing on the physical model that was designed from first principles. Therefore, there need not be a one to one correspondence between the requested initial values and the initial values of the physical model. In general, a user specified model may include a number of state variables that has to be reduced for numerical solvers to be able to simulate. The modeler typically has well defined knowledge about initial values of the chosen state variables, but the required use of a set of reduced states makes it difficult for the modeler to specify corresponding values related to the values of the initially chosen state variables. The invention uses an algorithm to compute the initial value of the reduced set of state variables based on initial values of the state variables chosen by the modeler. This allows the modeler to specify intuitive and meaningful initial values for behavior generation. The initial values are computed using the instantaneous equivalent of the continuous dynamics as specified by the modeler, and, therefore, a mapping between the extended and reduced state variable values is achieved that is consistent with modeled dynamic behavior. When algebraic constraints on state variables are present, a reduced state of the system has to be derived for numerical solvers to be able to generate correct behaviors. The invention eliminates the need for this step by applying the algorithm for deriving consistent state variable values after each integration time step. In this approach, the model with extended state variables is used by the numerical solver to calculate a first guess of state variable values without taking the algebraic constraints into account. These values are then corrected by using the same algorithm to derive consistent initial conditions. In mixed-mode simulation, behaviors are generated for systems with piecewise continuous behavior. At well defined points in time, the DAE that describes continuous behavior evolution may change. This may cause discontinuous changes in gradients of behavior and discontinuous changes in the state variables that may be explicitly specified by the modeler, or implicitly result from algebraic constraints between state variables that become active. When algebraic constraints between state variables become active, and the additional correction step is not applied, the computation of a reduced state may be required during simulation. In this case, the invention utilizes a generalized form of the algorithm used to compute initial state values for starting a simulation and applies this algorithm during simulation. In this setup, the specified values of the extended state are not user prescribed, but correspond to the final values of the previous piecewise continuous behavior, computed by the numerical solver. The instantaneous equivalent of the equations that describe behavior in the new piecewise continuous interval is used to compute initial state variable values for this new behavior based on the inherent dynamics of the system. Explicitly specified state variable value changes are described in the same form, allowing for direct integration into the overall system of equations to compute the consistent initial values. Continuous behavior of dynamic systems is often modeled by differential equations supplemented by algebraic constraints. In its general form, this can be described by a system of equations where u represents the known input variables, x represents the unknowns, x ˙ represents the time derivatives of the unknowns, t is the time, and f is the time variant nonlinear relationship between the quantities. All quantities may be time variant, but their explicit time dependence is not shown. In certain cases, Equation (1) can be written in explicit ordinary differential equation (ODE) form as x = f(x,u,t) which can be solved by numerical simulation algorithms ranging from a simple Forward Euler approach to complex Runge-Kutta methods. However, in many cases such an explicit formulation is not possible without algebraic manipulation of the relations. This occurs, e.g., when there are algebraic constraints on state variables, resulting in a system of equations of the form f' ( x , x , u , t ) = 0 g ( x , u , t )=0 where f' is the function f without the constraints in g . The function g imposes restrictions on the behavior of x and, therefore, decreases the number of degrees of freedom and corresponding state variables required for simulation of the system. Note that all variables x in g have a time derivative counterpart x ˙ in the function f. Variables that do not have a time derivative counterpart in a given system of equations will be referred to as y . To illustrate, consider the two parallel capacitors in Fig.1. The voltage drop across the capacitors C 1 and C 2 is v 1 and v 2 , respectively. The input variable is the current, i in , the current into C 2 is i , and, therefore, the current into C 1 is i in -i . The charge stored by C 1 and C 2 is q 1 and q 2 , respectively. The system of equations for this circuit is After adding the top two rows, this can be written as where the equation in the top row is in the form of Equation (3) and the bottom row in the form of Equation (4), i.e. this equation puts a constraint on the state variables x , with and the input variable u = [ i in ]. The algebraic equations (in case of the two parallel capacitors v 1 = v 2 ) define a manifold in state space to which behavior evolution is confined. The numerical solver requires the gradient of behavior along this manifold. This gradient can be found numerically by relying on sophisticated error control, however, this may fail for complex constraints. Alternatively, the gradient can be explicitly calculated by algebraic manipulations prior to simulation. To this end, efficient algorithms exist that differentiate the algebraic constraints until a regular solvable system of equations is obtained [Constantinos C. Pantelides: "The consistent initialization of differential-algebraic systems", SIAM Journal of Scientific and Statistical Computing, 9(2):213-231, March 1988]. Simulation is performed using the reduced state vector with gradient along the manifold, combined with the algebraic constraints to determine the corresponding values of the original, higher dimension, state vector variables. This is illustrated in Fig.2 for the two parallel capacitors in Fig.1. Behavior in the two dimensional state space is constrained to the one dimensional v 1 = v 2 manifold. Therefore, the system has one degree of freedom and the corresponding gradient is calculated by algebraic manipulations. Differentiating the bottom row in Equation (6) results in which can be solved to give behavior evolution along the manifold as v 1 = i in C 1 + C 2 v 2 = i in C 1 + C 2 and either one of these equations can be used to describe the reduced state behavior, which, combined with the v 1 = v 2 constraint, determines both modeled state variable values. In principle, Equation (10) and Equation (11) could be used simultaneously by the numerical solver, without the v 1 = v 2 constraint, but this results in a larger numerical error. Once behavior evolution is on the manifold, the gradient in the newly derived system of equations ensures it remains there. However, the initial values of the modeled state variables that are algebraically related may be such that they are not on this manifold. Presently, two solutions are practiced: State of the art numerical solvers [Peter Kunkel, Volker Mehrmann, Werner Rath, and Jörg Weickert: "A new software package for linear differential-algebraic equations", SIAM Journal of Scientific Computing, 18(1):115-138, January 1997] may use a least mean square fit to project the initial state onto the nearest point of the manifold. In many cases, this projection violates the instantaneous equivalent of the inherent continuous dynamics. Therefore, the initial values used for simulation do not correspond to the desired behavior trajectory and may violate implicit physical principles. Furthermore, the modeler can only implicitly control the actual initial values used for simulation. In certain simulation tools, e.g., 20sim [Jan F. Broenink: "Modelling, simulation and analysis with 20-sim", Journal A, 38(3):22-25, January 1998, Special CACSD issue] and Dymola [H. Elmqvist, D. Brück, and M. Otter: "Dymola - User's Manual", Dynasim AB, Research Park Ideon, Lund, 1996], the modeler can only specify the initial values of the reduced set of state variables. In case the set of reduced state variables is a subset of the extended states ( X r c X ), there is a partial physical correspondence of a number of states only, and the modeler cannot initialize the remaining original state variables. In both of these cases, the modeler has to compute manually initial values for the set of reduced state variables that are on the manifold, while ensuring that this computation corresponds to the modeled system dynamics and given initial values of the extended state. This is a cumbersome and error-prone activity, especially when the algebraic constraints that determine the manifold become complex and involve multiple state variables, i.e. are of high dimension. In mixed-mode simulation, the issue manifests even more prominently because the initial values of the reduced state variables have to be computed during simulation based on the manifold projection. Mixed-mode simulation relies on different systems of equations to describe continuous behavior in piecewise intervals, f α i ( x , x , u , t ) = 0 where α i indicates the interval of piecewise behavior to which the system of equations applies. The function f α i may change because of external events and because of system variables crossing threshold values, internal events. External events are typically generated by time reaching a pre-specified threshold value (e.g. in batch control processes where stirring a mixture is required for a given time), and their time of occurrence is known a priori. Therefore, these can be handled efficiently. Internal events have to be detected and located with a desired accuracy during continuous integration (e.g., two masses that collide when their circumferences touch), and a number of algorithms exist to handle this. When algebraic constraints change during simulation, e.g. at t i in Fig.3, it is required to automatically find initial values for the reduced state vector of the new piecewise continuous behavior from the final values of the previous continuous behavior. Again, in case of explicit relations between state variables, this can be written as f' α i ( x , x , u , t ) = 0 g α i ( x , u , t ) = 0 for each piecewise interval α i , where f' α i is the function f α i without the constraints in g α i . Now, a consistent mapping is required from the final state of continuous behavior in the interval α i -1 to the initial state in the interval α i . Furthermore, when discontinuous changes occur that are explicitly specified by the modeler, additional initialization equations are supplied. Though efficient methods exist to compute the reduced set of state variables, these are cumbersome and difficult to apply, not in the least because of the required equation differentiation. Moreover, in case of variable structure systems, i.e. those with dynamically changing algebraic constraints that require mixed-mode simulation, the algebraic manipulations to derive the required state have to be performed during simulation and in compiled environments require a compilation stage during simulation, which is prohibitively inefficient. It is an object of the invention to simplify the initialization of the simulation model requiring the calculation of consistent values for the reduced order and to mitigate the mentioned problems by considering all states to be independent and explicitly correcting the resulting error. According to the present invention there is disclosed computer system containing a numerical simulation model structure of physical systems as defined in appended claim 1. The simulator interface may handle a system in the general differential and algebraic equation (DAE) form f ( x , x , u , t ) = 0 , wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f is the time variant nonlinear relationship between the quantities. Further the simulator interface may handle a system in the case where explicit constraints on state variables x exist f' ( x , x , u , t ) = 0 g ( x , u , t ) = 0, wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f' is the function f of the time variant nonlinear relationship between the previous quantities without the constraints in the function g imposing restrictions on the behavior of x . Further the simulator interface may handle a system in the case where variables are present that do not have a time derivative counterpart y f ( x , x , y , u , t ) = 0, wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f is the time variant nonlinear relationship between the quantities. Moreover the simulator interface may handle a system in the case where variables are present that do not have a time derivative counterpart y, and there are explicit constraints on the state variables x f '( x , x , y,u , t ) = 0 g ( x , y , u , t ) = 0, wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f' is the function f of the time variant nonlinear relationship between the previous quantities without the constraints in the function g imposing restrictions on the behavior of x . Another aspect of said method according to this invention is characterized by using said simulator interface in the case, where algebraic constraints on these state variables change during mixed-mode simulation, to compute initial values for state variables x s in a system whose function describes behavior in different piecewise continuous intervals. In this case, said simulator interface may handle a system in the general differential and algebraic equation (DAE) form f α i ( x , x , u , t ) = 0, wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f α i are different functions describing behavior in different piecewise continuous intervals and being time variant nonlinear relationships between the quantities. Further the simulator interface may handle a system in the case where explicit constraints on state variables x exist f ' α i ( x , x , u , t ) = 0 g α i ( x , u , t ) = 0, wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f α i are different functions describing behavior in different piecewise continuous intervals and being time variant nonlinear relationships between the previous quantities without the constraints in the function g α i imposing restrictions on the behavior of x . Further the simulator interface may handle a system in the case where variables are present that do not have a time derivative counterpart y f α i ( x , x , y , u , t ) = 0, wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f α i are different functions describing behavior in different piecewise continuous intervals and being time variant nonlinear relationships between the quantities. Moreover the simulator interface may handle a system in the case where variables are present that do not have a time derivative counterpart y , and there are explicit constraints on the state variables x f ' α i ( x , x , y , u , t ) = 0 g α i ( x , y , u , t ) = 0, wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f α i are different functions describing behavior in different piecewise continuous intervals and being time variant nonlinear relationships between the previous quantities without the constraints in the function g α i imposing restrictions on the behavior of x . Another aspect of the computer system according to the present invention is characterized by using said simulator interface to compute values for the state variables x , the algebraic constraints being neglected to first compute a guess for the state variables x , and if the time derivatives of x are underconstrained, equations of the form x ˙ i = 0 are added, applying a correction after one integration time step to calculate the new x values without accounting for the algebraic constraints, the values calculated by this correction being consistent with said algebraic consistents. In this case, said simulator interface may handle a system in the general differential and algebraic equation (DAE) form f α i ( x , x , u , t ) = 0, wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f α i are different functions describing behavior in different piecewise continuous intervals and being time variant nonlinear relationships between the quantities. Further the simulator interface may handle a system in the case where explicit constraints on state variables x exist f' α i ( x , x , u , t ) = 0 g α i ( x , u , t ) = 0, wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f α i are different functions describing behavior in different piecewise continuous intervals and being time variant nonlinear relationships between the previous quantities without the constraints in the function g α i imposing restrictions on the behavior of x . Further the simulator interface may handle a system in the case where variables are present that do not have a time derivative counterpart y f α i ( x , x , y , u , t ) = 0, wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f α i are different functions describing behavior in different piecewise continuous intervals and being time variant nonlinear relationships between the quantities. Moreover the simulator interface may handle a system in the case where variables are present that do not have a time derivative counterpart y, and there are explicit constraints on the state variables x f' α i ( x , x , y , u , t ) = 0 g α i ( x , y , u , t ) = 0, wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f α i are different functions describing behavior in different piecewise continuous intervals and being time variant nonlinear relationships between the previous quantities without the constraints in the function g α i imposing restrictions on the behavior of x . Thus, when discontinuous changes occur that are explicitly specified by the modeler, additional initialization equations are supplied. The invented interface takes these constraints into account to find new initial values by using the continuous dynamics as specified by f' α i , i.e. behavior evolution for the new piecewise continuous interval. The difference between generated mixed-mode behaviors by state of the art approaches and the invented interface is twofold: The initial conditions of the generated behavior may be different, and, therefore, the entire continuous behavior solution as computed by the numerical solver may differ. When multiple changes of f' α i occur before continuous behavior evolution continues because the new consistent state variable values are such that thresholds are crossed, immediate further changes are invoked in the system of equations that describes behavior. In case the new initial values are not computed correctly, significant differences in generated behavior may ensue because incorrect continuous behavior equations are used. The invention uses an algorithm to compute the initial value of the reduced set of state variables based on initial values of the state variables chosen by the modeler. This allows the modeler to specify intuitive and meaningful initial values for behavior generation. The initial values are computed using the instantaneous equivalent of the continuous dynamics as specified by the modeler, and, therefore, a mapping between the extended and reduced state variable values is achieved that is consistent with modeled dynamic behavior. When algebraic constraints on state variables are present, a reduced state of the system has to be derived for numerical solvers to be able to generate correct behaviors. The invention eliminates the need for this step by applying the algorithm for deriving consistent state variable values after each integration time step. In this approach, the model with extended state variables is used by the numerical solver to calculate a first guess of state variable values without taking the algebraic constraints into account. These values are then corrected by using the same algorithm to derive consistent initial conditions. In mixed-mode simulation, behaviors are generated for systems with piecewise continuous behavior. At well defined points in time, the DAE that describes continuous behavior evolution may change. This may cause discontinuous changes in gradients of behavior and discontinuous changes in the state variables that may be explicitly specified by the modeler, or implicitly result from algebraic constraints between state variables that become active. When algebraic constraints between state variables become active, and the additional correction step is not applied, the computation of a reduced state may be required during simulation. In this case, the invention utilizes a generalized form of the algorithm used to compute initial state values for starting a simulation and applies this algorithm during simulation. In this setup, the specified values of the extended state are not user prescribed, but correspond to the final values of the previous piecewise continuous behavior, computed by the numerical solver. The instantaneous equivalent of the equations that describe behavior in the new piecewise continuous interval is used to compute initial state variable values for this new behavior based on the inherent dynamics of the system. Explicitly specified state variable value changes are described in the same form, allowing for direct integration into the overall system of equations to compute the consistent initial values. Further preferred features of the invention will appear from the claims 16 to 23. The invented solution will now be described in more detail with reference to accompanying drawings in which: Fig. 1 is a previously described circuit including two parallel capacitors; Fig.2 is a previously described diagram illustrating an algebraic equations constrain behavior to a manifold; Fig. 3 is a previously described diagram showing a mixedmode simulation; Fig.4 is a diagram showing a comparison of projection onto a manifold; Fig. 5 is a diagram showing a numerical integration using the instantaneous projection; Fig.6 is a circuit in which algebraic constraints may change dynamically; Fig.7 shows an elastic collision between two masses; Fig.8 depicts an architecture realizing the method of the invention; and Fig.9 shows the flow chart of an algorithm carrying out the operation of the simulator interface according to the invention. The invented solution applies the instantaneous equivalent of the continuous dynamics as specified by the DAE to derive consistent initial conditions of the reduced set of state variables based on user specified initial values for the extended set of state variables. Consistent state variable values are a point on the manifold of continuous behavior that is computed by applying the inherent dynamics of continuous behavior as an instantaneous projection to the specified initial state variable values. Using the extended set of state variables for initialization greatly improves usability of simulation packages for DAE models that contain algebraic constraints between state variables. To compute state variable values that are consistent with the continuous system dynamics, an instantaneous projection is required from the extended state, x , to the reduced state, x r , as illustrated in Fig.4, before continuous simulation starts. This projection can be said to occur during an infinitesimal time interval from t 0 to t 0 , where t 0 is the simulation start time and t 0 is a point in time immediately preceding to. The DAE in Equation (3) can now be solved over this infinitesimal period of time. Because integration is over an infinitesimal period of time, only the time derivatives of variables with a discontinuous change are nonzero, therefore, only x ˙ variables may have a nonzero value, viz., x(t 0 ) - x(t 0 ), which causes impulsive behavior of Methods for numerical simulation of physical systems relying on differential and algebraic equations (DAE) x ˙ if x(t 0 ) ≠ x ( t 0 ). If no cross product terms with x ˙ are present in f' and the input, u , has no impulsive component, this results in f' (x(t 0 ) - x ( t 0 ),0,0, t 0 ) = 0 where x ( t 0 ) are known as the modeler specified initial values and f' represents the instantaneous field component at t 0 . Combined with the algebraic constraints g ( x ( t 0 ), u ( t 0 ), t 0 ) = 0 it can be solved for x ( t 0 ), the desired initial values that are consistent with the algebraic constraints, and, therefore, on the manifold of state space behavior. Note that x represents the extended state vector, and will be reduced to x r by accounting for g , either numerically or algebraically before simulation can be applied to generate behaviors. This results in the system of equations used for simulation that is of the form f ( x r , x r , y , u , t ) = 0 with y the variables that have no time derivative counterpart. In the preferred approach, x r is chosen as a subset of x such that X = X r ∩ Y . Integration over an infinitesimal interval of time has been applied to time invariant semi-explicit systems with linear constraints to compute state variable values that are consistent with physical conservation principles. This invention applies the integration technique to systems in general to compute initial values consistent with inherent dynamics instead of systematically deriving physical conservation laws. It furthermore uses this technique as part of a numerical simulation system with an interface where it is the preferred approach to find a consistent projection. However, any other technique to find a projection consistent with the inherent dynamics may be applied in the interface that can be used in the framework of existing commercial simulation packages. For example, in many cases the constraints are explicitly incorporated by the modeler as physical conservation laws. To illustrate the projection technique for the linear time invariant case, consider the two parallel capacitors in Fig. 1. Before continuous simulation can be started, consistent values of v 1 ( t 0 ) and v 2 ( t o ) have to be computed using initial values v 1 ( t 0 ) and v 2 ( t 0 ) as specified by the modeler. The DAE in Equation (6) contains the algebraic constraint v 1 ( t 0 ) = v 2 ( t 0 ), and, therefore, discontinuous changes of v 1 and v 2 may occur. Consequently, the derivatives of both these variables that appear in f , may have nonzero values when integrated from t 0 to t 0 , which yields or, This equation is the result of using the substitution in Equation (16) for Equation (6). The constraint that the capacitor voltages are equal when continuous integration starts is v 1 ( t 0 ) = v 2 ( t 0 ) and combined with Equation (20) v 1 ( t 0 ) and v 2 ( t 0 ) can be derived such that they are on the manifold of behavior Note that this derives the physical conservation of charge, q, constraint because v = q / C , and, therefore, So, q 1 ( t 0 ) + q 2 ( t 0 ) = q 1 ( t 0 ) + q 2 ( t 0 ) and charge is conserved under the projection that was derived. If C 1 ≠ C 2 , this projection differs from a least mean square fit, which, therefore, violates the inherent continuous dynamics modeled by the system as well as the macroscopic physical principle of conservation of charge. This is illustrated in Fig.2 where the projection that computes consistent values is along the dashed line with tan() = - C 1 / C 2 whereas the least mean square projection is along the line with tan () = -1 perpendicular to v 1 = v 2 . After mapping the extended state variables onto the manifold, the interface uses these values to initialize the reduced states of the simulation model applied by the conventional initialization approaches described previously. The initialization based on a reduced number of states is now consistent since the projection on the manifold has become trivial. This makes the invented interface amenable to direct application in common simulation tools. An additional feature of the invented interface is that it may be used to eliminate the need for algebraic manipulations to find a minimal set of state variables for simulation. This is implemented by using Equation (3) for numerical integration, neglecting the constraints between the state variables in Equation (4) After the numerical solver has computed an initial guess of the state variable values, x k +1 , a correction is applied that corresponds to the manifold projection to compute the actual values, x k +1 (see Fig.5). This allows the use of even very simple integration methods without algebraic manipulations to formulate the system with a minimal set of states. For the two capacitors C 1 and C 2 , this means the top row in Equation (6) is used by the numerical solver without taking the constraint in the bottom row into account. Because the equation C 1 v ˙ 1 + C 2 v ˙ 2 = i in is underconstrained an additional default equation, v ˙ 2 = 0, is chosen. This results in the explicit form and this can be integrated over one integration step by any integration algorithm. Because of the neglected algebraic constraints, the new state values x k +1 , computed from x k , are incorrect with respect to the actual model, see Fig.5, where x k +1 is not on the manifold. This is corrected by taking the algebraic constraints into account in a consecutive step. In this example, Equation (22) is applied with v 1 ( t 0 ) and v 2 ( t 0 ) the guesses calculated by the numerical integration, x k +1 , illustrated in Fig.5. The dashed lines represent the sequence of integration computations and the empty circles intermediate points. The actual computed values of the state variables are represented by the solid circles. Using this technique, mixed-mode simulation behavior generation is inherently facilitated and variable structure models with dynamically changing algebraic constraints can be conveniently solved. When algebraic constraints change, the only change to the system model is the instantaneous projection but the set of state variables remains unchanged, preventing complex algebraic manipulations. A disadvantage of the approach is that sophisticated error control mechanisms built into numerical solvers operate on different dynamics than those of the actual system because the algebraic constraints are not accounted for, and, therefore, may not be accurate. Additionally, built-in root finding mechanisms of numerical solvers to detect and locate zero crossings cannot be used because they would operate on the first guess values, x k . These disadvantages can be overcome by integrating the correction step into the numerical solver. If the minimal order system is used by the numerical solver, the state projection may still be required when algebraic constraints change during simulation, e.g. a switch between two parallel capacitors, shown in Fig.6, may close at a certain time, t i . Suppose that the interval of continuous behavior with the switch closed is described by the function f α i , with algebraic constraints g α i , starting at time t i and these algebraic constraints are different from those in the previous piecewise continuous interval, g α i -1 (i.e., the switch was open). This may cause a discontinuous change in state variable values at t i corresponding to the projection onto the newly activated manifold, g α i . If a minimal order system is used for simulation, the instantaneous equivalent of the dynamics of the new continuous behavior can be used to find these consistent values. Similar to computing consistent initial values before starting simulation and at each integration time step, the discontinuous change is computed by integrating over an infinitesimal interval, that now ranges from t i to t i . In other words, the instantaneous equivalent is derived for an infinitesimal period of time when the system of equations that describes the piecewise continuous behavior changes. In case no cross product terms with x ˙ and no impulsive inputs, u , are present, this yields where are the known values of the extended set of state variables in the previous piecewise continuous interval, α i -1 , and f' α i is used to compute the instantaneous equivalent of the continuous dynamics that becomes active at t i . Combined with the algebraic constraints g α i ( x ( t i ), u ( t i ), t i ) = 0 it can be solved for x ( t i ), the desired initial values that are consistent with the algebraic constraints, and, therefore, on the manifold of state space behavior in the new piecewise continuous interval, α i . In certain cases, the modeler may wish to explicitly reinitialize state variables. For example, for an elastic collision between the two masses in Fig.7, Newton's collision rule states that the velocities v 1 and v 2 of masses m 1 and m 2 , respectively, change according to where ∈ is the coefficient of restitution (∈ = 1 for a perfectly elastic collision) and the values immediately before the collision are denoted by a '-' superscript. This instantaneous reinitialization can be represented in terms of an infinitely fast change from v - to v over an infinitesimal interval used to compute the instantaneous vector field equation. So, the collision rule can be written as In general, such explicit reinitialization constraints can be formulated as which seamlessly fits the resulting constraints after integrating f' α i from t i to t i , and, therefore, the combined system of equations can be solved in a straight-forward manner. Note that the modeler has responsibility not to overspecify the model, i.e. the number of unknowns and equations has to be the same. This leads to Algorithm 1 for initializing state variables with algebraic constraints in general DAE systems of the form in Equation (3) and Equation (4). Note that initialization of a continuous simulator is a special case of initialization of a mixed-mode simulator. Algorithm 1: Computing consistent initial values. Require: active system of equations f In other work [Pieter J. Mosterman and Gautam Biswas: "A Java Implementation of an Environment for Hybrid Modelling and Simulation of Physical Systems", ICBGM99 pages 157-162, San Francisco, January 1999], consistent values are computed for hybrid bond graphs based on physical conservation principles. In a macroscopic view, extensive physical quantities such as charge, momentum, and mass are considered to be conserved. An iteration procedure applies this constraint to generate new initial values for a limited fixed set of element types with state behavior. This approach requires an interpretive graph distributed simulation approach which makes it not suitable for implementation in a compiled environment, and, also, makes it incompatible with existing commercial simulation packages. The invented interface is not restricted to bond graph models, but more general and applies to user defined state variables. Also, it does not rely on iteration which may fail in certain cases and slow down simulation, but applies a more efficient analytic approach. Most importantly, the invented interface is compatible with commercial simulation packages, e.g., MATLAB, and can be used in conjunction with sophisticated existing numerical solvers. In case the original DAE in Equation (1) cannot be partitioned into the form of Equation (3) and Equation (4), the method can be applied by integrating Equation (1) directly and when there are no cross products with x ˙ and no impulsive input, u , this results in which embodies the manifold constraints on x . Furthermore, in case algebraic variables, y, are not yet solved for in the DAE in Equation (3) and Equation (4), the DAE can be written as f' ( x , x , y , u , t )=0 g ( x , y , u , t )=0 where, again, time dependency of x , y , and u is suppressed. Integrating Equation (34) results in where because y may be a function of x ˙ , y ( t 0 ) may be a function of ( t 0 ) - x ( t 0 ). This system of equations can again be solved for x ( t 0 ), and, therefore, y ( t 0 ), by adding the manifold equation g ( x ( t 0 ), y ( t 0 ), u ( t 0 ), t 0 )=0 This form is illustrated by the system of equations for the two parallel capacitors in Equation (5) with y = [ i ] and u = [ i in ]. Now a preferred embodiment will be described. It should be appreciated that although the preferred embodiment is described in term of a mixed-mode simulator, it also applies to finding consistent initial conditions for just continuous system simulation as well as to correct the state variable values at each integration time step. In the latter case, a discrete event to correct the state is invoked after each integration time step. Fig.8 depicts the architecture of the invention. It consists of six modules: Active Model Selection: For each mode α i , this module selects the active set of equations f α i , that describe continuous system behavior as well as the set of explicit reinitialization equations, h α i . Initial Value Calculation: Given the active equations and current values of the extended set of system state variables, this module calculates new values for the state variables consistent with the instantaneous equations of the active continuous dynamic behavior. Algebraic Engine: This module manipulates the active model equations into a form with complexity that can be handled by the numerical solver that is used. If the extended set of state variables, x , is used, the algebraic constraints are neglected and state variable derivatives set to 0 until all state variable derivatives can be computed. If a minimal order system is used, differentiation of equations may be required to arrive at a reduced state vector, x r . The resulting state vector that is used for simulation, either x or x r , is called x s . Initial Value Mapping: This module maps the computed consistent initial values, x , onto the state vector for simulation, x s , as determined by the system of equations that is supplied to the numerical solver. Numerical Solver: Given a system of equations and a set of initial states, this module generates continuous behaviors until a given stop time is reached or a discrete event is detected. Discrete Event Detection and Location: This module detects whether discrete events occur, locates their time of occurrence and the corresponding values of the system variables, x , and changes the system of active equations. The execution algorithm is specified in Fig.9. First, the equations that describe system behavior have to be provided by the modeler by means of an input device. Often, this is a graphical model editor. The equations describing system behavior may be guarded by Boolean conditions activating and deactivating one or a set of equations. An equation with a guard that is true is active and is part of the present continuous model behavior definition. Next, the initial values for the modeler specified states, x , have to be provided. Typically, this is done by means of a dialog box of the simulation tool. In case of mixed-mode simulation with sequential logic that selects the active equations, the modeler has also to specify the initial values of the discrete states, σ. After the continuous and discrete states are initialized, the values of the Boolean conditions that guard which equations are active are known, and the set of active equations can be compiled by the active model selection module. These equations may contain explicit reinitialization equations, and, furthermore, enforce algebraic constraints on modeler specified initial values. Therefore, the state variable values have to be computed that are consistent with the active set of equations. This is executed by the initial value calculation module which relies on Algorithm 1. The new system state may consist of values that cause guards of the active equations to become false and also guards of inactive equations to become true. If this occurs, another discrete event is generated, and the new system of active equations is determined by the active model selection module. Again, the system state has to be made consistent with the system of active equations by the initial value calculation module. This process repeats until consistent values of the system state variables are derived that do not cause further Boolean value changes of the guards. To avoid a nonterminating loop, a counter may be implemented to monitor the iteration number and abort simulation when a critical value is reached. If simulation is not aborted and no further discrete events occur, the use of a reduced number of states, x s = x r , requires the algebraic engine to manipulate the active system of equations to achieve complexity that the numerical solver can handle to generate continuous behaviors. In case of explicit integration routines in the solver, this means that an explicit ODE representation is required, whereas the availability of implicit integration routines with error control (such as e.g., DASSL) allow DAE systems with a certain complexity to be solved. In the preferred implementation, the algebraic manipulations are such that a subset of the extended set of states is chosen as the reduced set of state variables. Then the initial value mapping module can initialize the reduced set of state variables by copying the consistent value of the corresponding state in the extended set. This is compatible with the approach taken by, e.g., 20sim and Dymola and allows for a straightforward implementation of the invented interface. Otherwise, the algebraic engine has to supply the algebraic relation between reduced states and the extended states. If the extended set of states is used, x s = x , the desired complexity is achieved by removing the algebraic constraints and choosing a number of state variables to have 0 time derivative, x ˙ i = 0, so that all x ˙ can be computed. Now, the system of equations for simulation and the corresponding initial values of its states can be supplied to the numerical solver to advance time and generate a continuous behavior trajectory. The numerical solver is active until a discrete event occurs or the stop time is reached. While evolving in continuous time, the discrete event detection and location module monitors whether guards change their truth value or whether state correction is required to generate discrete events. If so, the current system variable values are reported to the initial value calculation module as the present state. If guards changed their truth value, the new guard values are used to select the new system of active equations by the active model selection module. If state correction is required, the correction step is executed followed by detection whether guards changed their truth value. In this case, detection of truth value changes does not operate on the value as computed by the numerical solver at each integration time step. Instead, event detection only applies after the correction step has triggered the initial value calculation module to compute new consistent state variables. This implies that root finding functionality of the numerical solver to precisely locate the time the event occurred can not be exploited in this configuration. External root finding, e.g., by means of a bisectional search, has to be applied instead. Note that to increase efficiency, the simulation model, f s , is not recomputed when numerical simulation was halted to correct the state vector values and no single guard changed its truth value. This process continues until the numerical solver has reached the simulation end time as specified by the modeler. It should be appreciated that the correction step can be integrated in the numerical solver. The numerical solver then takes two functions, one to compute the initial guess and the other to perform the correction. This novel approach to numerical simulation allows the projection technique to be integrated in a multi-step numerical integration algorithm. The advantage of this is that the error control of the numerical solver operates on the consistent values instead of their guesses. Furthermore, improved performance can be achieved compared to the configuration where the correction is applied separately. Additionally, numerical solvers often have built-in event detection and location. If the correction is applied externally this mechanism has to be external as well. However, if the correction is integrated into the numerical solver, this facility can be exploited. In the following the most important facts of the invention will be summed up. Analysis of physical systems often relies on numerical simulation to generate behavior trajectories. This is achieved by numerical solvers that generate behaviors for a system model. The order of the system model is related to its number of state variables and initial values have to be provided for each of these states. In many cases, algebraic constraints exist between modeled states, causing a reduced number of degrees of freedom. Therefore, the simulation model is of a lower order and there is no direct one-to-one correspondence between the modeled states and the states used for simulation. This complicates initialization of the simulation model by the modeler, because consistent values for the reduced order have to be calculated. This invention claims the use of a simulation interface for calculating consistent values for the reduced state by using inherent constraints in the simulation model. Models with algebraic constraints on the state variables have to be algebraically manipulated into a simulation model with a minimal number of state variables before it can be used by a numerical solver. This invention claims a two-stage methodology for numerical simulation that avoids these manipulations. It uses the system model to (1) take one integration step while disregarding the algebraic constraints, followed by (2) a correction step that uses the technique for computing consistent initial values for the reduced state. It also claims the integration of such a correction step into numerical solvers. In mixed-mode simulation, i.e., simulation of systems with piecewise continuous behavior, algebraic constraints may become active during simulation, requiring a consistent mapping of the system state onto the reduced state of the new piecewise behavior. The invented simulation interface uses the same technique to compute consistent initial values for the reduced state to compute consistent state variable values when such changes in the system occur during simulation.

Claims: Computer system containing a numerical simulation model structure of physical systems relying on differential equations supplemented by algebraic constraints on state variables representing physical quantities to generate behavior trajectories for a system model by numerical solvers, said system model being of a reduced order as to its number of modeled state variables x , that appear in time derivative form in the system of equations, said algebraic constraints imposing restrictions on the behavior of x and therefore decreasing its number of degrees of freedom, and initial values being provided for each of these state variables x , whereby the provided initial values may be not consistent with said algebraic constraints, said system model structure comprising a simulator interface including six interacting modules, specifically: an active model selection module selecting for each mode α i an active set of equations f α i , that describe continuous system behavior as well as a set of explicit reinitialization equations, h α i ; an initial value calculation module calculating new values for the state variables consistent with the instantaneous equations of the active continuous dynamic behavior, provided that the active set of model equations and current values of the extended set of system state variables are given; an algebraic engine module manipulating said active model equations into a form with complexity that can be handled by the used numerical solver, said algebraic constraints being neglected and state variable derivatives being set to 0 until all state variable derivatives can be computed, if the extended set of state variables, x , is used, and differentiation of equations being required to arrive at a reduced state vector, x r , if a minimal order system is used, the resulting state vector that is used for simulation, either x or x r , being called x s ; an initial value mapping module mapping the computed consistent initial values, x , onto the state vector for simulation, x s , as determined by the system of equations that is supplied to said numerical solver; a numerical solver module generating continuous behaviors until a given stop time is reached or a discrete event is detected, provided that a system of equations and a set of initial states are given; and a discrete event detection and location module detecting whether discrete events occur, locating their time of occurrence and the corresponding values of the system variables, x , and changing the system of active equations; wherein the output of said active model selection module is applied to the input of said initial value calculation module as well as to the input of said algebraic engine module, the output of said algebraic engine module is applied to the input of said initial value mapping module as well as to the input of said numerical solver module, the output of said initial value calculating module is applied to the input of said discrete event detection and location module as well as to the input of said initial value mapping module, the output of said initial value mapping module is applied to the input of said numerical solver module, the output of said numerical solver module is applied to the input of said discrete event detection and location module, and the output of said discrete event detection and location module is applied to the input of said active model selection module as well as to the input of said initial value calculation module, and computing, based on the provided initial values of the modeled state variables x , initial values for state variables x s that are consistent with said algebraic constraints, by integrating said differential equations for said modeled state variables x over an infinitesimal interval in time from t 0 to t 0 , immediately preceding the start time t 0 of continuous behavior, leading to equations relating x ( t 0 ) and x ( t 0 ), where x ( t 0 ) are known as the provided initial values for the modeled state variables x and x ( t 0 ) are the desired initial values of the state variables x s to be consistent with the algebraic constraints, and computing from these equations in combination with said algebraic constraints the x ( t 0 ). Computer system according to claim 1, characterized in that said simulator interface handles a system in the general differential and algebraic equation (DAE) form f ( x , x , u , t ) = 0, wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f is the time variant nonlinear relationship between the quantities. Computer system according to claim 1, characterized in that the simulator interface handles a system in the case where explicit constraints on state variables x exist f' ( x , x , u , t ) = 0 g ( x , u , t ) = 0, wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f' is the function f of the time variant nonlinear relationship between the previous quantities without the constraints in the function g imposing restrictions on the behavior of x . Computer system according to claim 1, characterized in that the simulator interface handles a system in the case where variables are present that do not have a time derivative counterpart y f ( x , x , y , u , t ) = 0, wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f is the time variant nonlinear relationship between the quantities. Computer system according to claim 1, characterized in that the simulator interface handles a system in the case where variables are present that do not have a time derivative counterpart y , and there are explicit constraints on the state variables x f' ( x , x , y , u , t ) = 0 g ( x , y , u , t ) = 0, wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f' is the function f of the time variant nonlinear relationship between the previous quantities without the constraints in the function g imposing restrictions on the behavior of x . Computer system according to claim 1, characterized by using said simulator interface in the case, where algebraic constraints on these state variables change during mixed-mode simulation, to compute initial values for state variables x s in a system whose function describes behavior in different piecewise continuous intervals. Computer system according to claim 6, characterized in that the simulator interface handles a system in the general differential and algebraic equation (DAE) form f α i ( x , x,u , t ) = 0 , wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f α i are different functions describing behavior in different piecewise continuous intervals and being time variant nonlinear relationships between the quantities. Computer system according to claim 6, characterized in that the simulator interface handles a system in the case where explicit constraints on state variables x exist f' α i ( x , x , u , t ) = 0 g α i ( x , u , t ) = 0, wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f α i are different functions describing behavior in different piecewise continuous intervals and being time variant nonlinear relationships between the previous quantities without the constraints in the function g α i imposing restrictions on the behavior of x . Computer system according to claim 6, characterized in that the simulator interface handles a system in the case where variables are present that do not have a time derivative counterpart y f α i ( x , x , y , u , t ) = 0, wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f α i are different functions describing behavior in different piecewise continuous intervals and being time variant nonlinear relationships between the quantities. Computer system according to claim 6, characterized in that the simulator interface handles a system in the case where variables are present that do not have a time derivative counterpart y , and there are explicit constraints on the state variables x f' α i ( x , x , y , u , t ) = 0 g α i ( x , y , u , t ) = 0 , wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f α i are different functions describing behavior in different piecewise continuous intervals and being time variant nonlinear relationships between the previous quantities without the constraints in the function g α i imposing restrictions on the behavior of x . Computer system according to claim 1, characterized by using said simulator interface to compute values for the state variables x, the algebraic constraints being neglected to first compute a guess for the state variables x , and if the time derivatives of x are underconstrained, equations of the form x ˙ i = 0 are added, applying a correction after one integration time step to calculate the new x values without accounting for the algebraic constraints, the values calculated by this correction being consistent with said algebraic consistents. Computer system according to claim 11, characterized in that the simulator interface handles a system in the general differential and algebraic equation (DAE) form f α i ( x , x , u , t ) = 0, wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f α i are different functions describing behavior in different piecewise continuous intervals and being time variant nonlinear relationships between the quantities. Computer system according to claim 11, characterized in that the simulator interface handles a system in the case where explicit constraints on state variables x exist f' α i ( x , x , u , t ) = 0 g α i ( x , u , t ) = 0, wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f α i are different functions describing behavior in different piecewise continuous intervals and being time variant nonlinear relationships between the previous quantities without the constraints in the function g α i imposing restrictions on the behavior of x . Computer system according to claim 11, characterized in that the simulator interface handles a system in the case where variables are present that do not have a time derivative counterpart y f α i ( x , x , y , u , t ) = 0, wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f α i are different functions describing behavior in different piecewise continuous intervals and being time variant nonlinear relationships between the quantities. Computer system according to claim 11, characterized in that the simulator interface handles a system in the case where variables are present that do not have a time derivative counterpart y , and there are explicit constraints on the state variables x f ' α i ( x , x , y , u , t ) = 0 g α i ( x , y , u , t ) = 0, wherein u represents the known input variables, x represents the unknown variables, x ˙ represents the time derivatives of the unknown variables, t is the time, and f α i are different functions describing behavior in different piecewise continuous intervals and being time variant nonlinear relationships between the previous quantities without the constraints in the function g α i imposing restrictions on the behavior of x . Computer system according to any of claims 1 to 15, characterized by the integration of a correction step into a numerical solver by use of an additional correction function, this correction step operating on all intermediate integration points, including those that are not accepted by the solver because they would result in too large an error. Computer system according to any of claims 1 to 16, characterized by a means for by-passing the simulator interface for initialization of the first piecewise continuous behavior to allow direct initialization of the simulator state variables by the modeler. Computer system according to any of claims 6 to 15, characterized by a discrete event iteration mechanism in the simulation interface to ensure the system of active equations is consistent with the state variable values used to select the active system of equations. Computer system according to any of claims 1 to 18, characterized in that the systems of equations are supplemented with explicit initialization constraints of the form wherein x ( t - ) is the left limit value in time of x ( t ). Computer system according to claim 19, characterized by a mechanism to allow immediate further discrete events to be invoked to select a new system of equations α i +1 , before advancing time by means of a numerical solver if equations of the form are present. Computer system according to any of claims 1 to 20, characterized by an interface for transferring the consistent initial values x of the extended state to the state variables x s as used by the numerical solver, algebraically manipulating the system of equations before it is supplied to the numerical solver to be in explicit ODE (ordinary differential equation) form, or being a DAE of complexity that the numerical solver can handle, in case of a reduced set of states x r the preferred implementation takes a subset of x as x r , such that X r X , and in case another set of reduced states is chosen, the algebraic engine needs to supply the corresponding algebraic relations to be able to transfer the consistent initial conditions to the reduced state variables values. Computer system according to any of claims 6 to 15, characterized by a simulation interface to mix DAEs in different form to be active during different stages α i of the simulation, this operation including variables that change from being part of X r to being part of Y. Computer system according to any of claims 6 to 15, characterized by a simulation interface to mix DAEs in different form and with different variables such that the number of extended state variables changes and the number of algebraic variables do not match, these systems requiring an explicit mapping between the variables in different intervals of operation α i .

Inventors: MOSTERMANN PIETER, MOSTERMANN, PIETER
Applicants: DEUTSCH ZENTR LUFT & RAUMFAHRT, DEUTSCHES ZENTRUM FUER LUFT- UND RAUMFAHRT E.V.
Application year: 2000
Main classification: G06F17
IPC codes: G06F17, G05B17