19. Differntial Algebraic Equations 3 by MIT OpenCourseWare

Description

19. Differntial Algebraic Equations 3 by MIT OpenCourseWare

Summary by www.lecturesummary.com: 19. Differntial Algebraic Equations 3 by MIT OpenCourseWare


  • Administrative Matters

    • 0:00 - 0:22 Quizzes were returned, with encouragement to think over answers and problems in relation to the sample quiz. The quiz was deemed fair and similar to previous exams, with care taken to eliminate chemical engineering context so that numerical methods could be emphasized.
    • 0:22 - 0:31 Questions regarding the quiz are open.
    • 0:31 - 0:44 The previous homework was quite lengthy, as the speaker recognizes (although not authored by them), and this is symptomatic of issues judging completion duration, particularly in relation to coding facility.
    • 0:44 - 0:58 Homework this week, on the subject of DAEs, should be simpler, with only two problems as opposed to three, and hopefully involving borrowing code from the previous assignment.
    • 0:58 - 1:15 One particular section of the first problem dealing with energy balances on reactors is traditionally challenging for first-year graduate students; clarifying at office hours is recommended in order to avoid solving the wrong systems of equations.

    Lecture and Course Format Changes

    • 1:04 - 1:12 The majority of the remaining lectures will be conducted by Professor Green, and the speaker will fill in for two review sessions prior to the second quiz and final.
    • 1:12 - 1:15 Professor Green will be primarily in charge of coming up with homework assignments, and the speaker will help as possible.
    • 1:15 - 1:19 Today's lecture is the last formal lecture given by the speaker this term.

    Introduction to Differential Algebraic Equations (DAEs)

    • 1:28 - 1:39 DAEs are generally quite complicated, and when they become sufficiently complex, it is necessary to use existing codes designed to solve particular classes of DAEs.
    • 1:39 - 2:04 To students, it is more crucial to recognize when complications set in in developed models and know the key ingredients of the model required for these solvers to deliver valuable outputs. Examples galore will be seen in today's lecture.

    Summary of DAE Simulation with Backward Difference Formulas and Error Propagation

    • 2:04 - 2:16 Review of where complications arise. Last time, semi-explicit and fully implicit DAEs were discussed.
    • 2:16 - 2:25 In principle, DAEs can be simulated using backwards difference formulas and solving nonlinear equations at each time step, similar to ODE IVPs.
    • 2:25 - 2:40 There was a catch to this method, demonstrated at the end of the last lecture.
    • 2:40 - 3:36 Stirred Tank Example 1: A stirred tank process was taken as an example. If C1 concentration is measured to forecast C2 concentration. Using the backward Euler method (lowest order backward difference formula), C1 is calculated exactly (assuming a parameter gamma is calculated exactly), and C2 is calculated with an error of order delta t^2. The local truncation error was order delta t^2.
    • 3:36 - 4:58 Stirred Tank Example 2: The model is slightly modified, now measuring concentration out (C2) to forecast concentration in (C1).
    • Using the backward Euler method, C2 is found exactly from the algebraic equation by default. The calculation of C1 from the derivative approximation brings in an error proportional to delta t. C1 is determined to within order delta t, not order delta t^2 as with the earlier model. This indicates a fundamental difference between the two cases depending on which variable the algebraic equation contains.
    • 4:58 - 6:47 DAE Example 3: A third example system is given: C1 = dC2/dt, C2 = dC3/dt, C3 = gamma(t). Using the backward Euler method, C3 is solved exactly by the algebraic equation.
    • C2 is tied to the derivative of C3, with an error of order delta t picked up. C1 is equal to the derivative of C2. Approximating the derivative of C2 (which itself has an error of order delta t) leads to an error in C1 of order delta t / delta t, which is order one. No resolution of C1 is obtained. If C1 is needed for control, this method is useless.

    Summary of Errors

    • Stirred Tank Example 1: local truncation error order delta t^2.
    • Stirred Tank Example 2: local truncation error order delta t.
    • DAE Example 3: local truncation error order one.

      Backward Difference Formula

      Using the backward difference formula directly on the equations, without algebraic manipulation, results in a system of equations that provides solutions for:

      • C1 and C2 (with delta t2 order error)
      • C3 (with delta t order error)

      Executing Successive Approximations

      Executing successive approximations (many steps of time) does not guarantee that the constraint (e.g., C1 + C2 = 0) is fulfilled exactly due to error propagation. The formulation of the model is crucial. This problem, where C3 = 0, is similar to the Stirred Tank Problem 2, losing one order of accuracy.

      Using Constraints

      Using constraints to simplify equations and eliminate variables can be beneficial, but it may lead to numerical solutions that no longer satisfy the constraint exactly, drifting away from the algebraic equation.

      Differential Index

      This behavior is referred to as the Differential Index of a DAE system.

      Defining and Calculating Differential Index

      The index of a DAE system is characterized by how many time derivatives are required to transform it into a system of independent ODEs with differentials of all the unknowns.

      Stirred Tank Example 1 Index

      Two unknowns: C1, C2.

      There is one equation with a differential of C2.

      Differentiating the algebraic equation (eq 2) gives a differential equation for C1.

      Now, there are ODEs for C1 and C2. Just one derivative of the algebraic constraint was required. DAEs of this form are referred to as index one DAE. Index one DAEs are simple to solve and act like ODE IVPs, with identical local truncation error (order delta t2).

      Stirred Tank Example 2 Index

      Same equations, but use C2 in the algebraic equation instead of C1. Differentiate the algebraic equation to provide a differential equation for C2, but there already is one. To obtain an ODE for C1, substitute the known DC2DT into the derived equation and solve for C1.

      Take another derivative of this resulting equation to obtain a differential equation for C1. Two derivatives were required to produce a system of independent ODEs. This is referred to as index 2. Index 2 problems are more likely to drop an order of accuracy and are more sensitive.

      DAE Example 3 Index

      C1 = DC2DT, C2 = DC3DT, C3 = gamma(t). There is a missing ODE for C1. Take a derivative of the algebraic equation C3 = gamma. Obtain DC3DT = gamma dot. Plug into C2 = DC3DT to obtain C2 = gamma dot.

      This is not an ODE for C1. Take the derivative once more to obtain C2 dot = gamma dot dot. C2 dot equals C1 (from the original equation). Plug in again and take a third derivative of the original algebraic constraint (three derivatives total). This results in a differential equation for C1 (DC1DT = gamma dot dot dot). ODEs can be created for C1, C2, and C3. This is an index 3 DAE. Substituting the DAE with these derivatives is not always advisable because solutions may drift away from the constraints. Solutions need to be restricted to the manifold described by the DAE, so additional initial conditions or constraints are needed. This relates to consistent initialization. The calculation of the index aids in comprehending the system's sensitivity.

      Formal Definition (Semi-Explicit DAE)

      For a semi-explicit DAE system (x dot = f(x, y, t), 0 = g(x, y, t)), the differential index is the minimum number of differentiations needed to transform it into a system of independent ODEs. Differentiating the algebraic equation g = 0 with respect to time gives an equation depending on dx/dt, dy/dt, x, y, and t. Inserting dx/dt = f provides an equation that can be solved for dy/dt. If the Jacobian of g with respect to y (dg/dy) is of full rank (invertible), then dy/dt can be solved for, and the system is of index one. Issues occur when dg/dy is not full rank (singular), making it difficult to solve for y using techniques such as Newton-Raphson since the Jacobian becomes singular. Index one DAEs share this invertible Jacobian characteristic; higher index DAEs do not.

      Examples of Index Calculation (Mixing Tanks)

      The differential index is the most important thing to know about a model, as it indicates its sensitivity to perturbations.

      Mixing Tanks Example 1:

      Two mixing tanks with flows and concentrations. Material balances give differential equations for C2 and C4. Algebraic constraints: C1 = gamma1(t), C3 = gamma2(t) (inputs are measured/prescribed).

      Example 2: Same tanks, different algebraic constraints:

      • C3=gamma1(t), C4=gamma2(t) (outputs are measured/prescribed).
      • Take a derivative of the algebraic equations (DC3DT, DC4DT).
      • DC3DT=gamma1 dot is known, but there was previously an equation for DC3DT.
      • Need ODEs for C1 and C2.
      • DC4DT=gamma2 dot is known; plug this into the C4 material balance.
      • This results in a new algebraic equation.
      • Take a derivative of this new equation.
      • Plug in known derivatives (DC2DT, DC3DT, DC4DT).

      This results in an algebraic equation in terms of C1. Take an additional derivative (total three derivatives of the initial algebraic constraints). This provides a DC1DT term, so an ODE for C1 results. ODEs can be constructed for all the variables. It's differential index three. This is to be expected since taking a measure of a downstream output (C4) to estimate an initial input (C1) is sensitive by its nature.

      Sensitivity and Solvers

      Sensitivity increases with index:

      • Index 1 solutions are like ODEs, not sensitive.
      • Index 2 solutions indicate sensitivity to the derivative of the forcing function (gamma dot).
      • Index 3 solutions indicate enormous sensitivity to the second derivative of the forcing function (gamma dot dot).

      Mechanical Systems and Consistent Initialization

      Constrained mechanical systems are usually index 3 DAE. A back-and-forth swinging pendulum is one example.

      • Equations: dx/dt=v, dv/dt equals gravity and spring force (spring constant k).
      • Algebraic constraint on the position (constant arm length).
      • Differential variables are velocity (v) and position (x), the algebraic variable is the spring constant k.
      • k needs to change dynamically.

      This system is demonstrated to be index 3. Derivatives of the algebraic constraint produce the hidden constraints:

      • 1st derivative -> v and p are orthogonal
      • 2nd derivative -> the relationship between k, x, and v
      • 3rd derivative -> ODE for k.

      Initial Conditions

      Being converted into an equivalent ODE system is not necessarily desirable; the solutions may wander away from the original constraints. Solutions need the correct initial conditions. When initial conditions are in conflict, there will be:

      • Step jumps
      • Erratic behavior
      • Solver error
      • Divergence on a different manifold

      Pendulum Initial Conditions

      Can the initial position be random?

      No, it has to obey the algebraic constraint (constant arm length).

      Can the initial velocity be random?

      No. The "hidden constraint" (velocity is orthogonal to position, determined through the 1st derivative of the algebraic constraint) has to be obeyed. Initial conditions need to be solutions to the equations, including the hidden ones.

      Can k, the initial stiffness, be set arbitrarily?

      No. The implicit constraint in the 2nd derivative ties k to position and velocity at first.

      These implicit constraints are within the DAE framework.

      Solving DAEs

      Index one, semi-explicit DAEs can usually be treated safely by vanilla ODE solvers in MATLAB (such as ODExx) by giving a mass matrix.

      If the DAE isn't index one, MATLAB might find it. Special DAE solvers such as Sundials or DAEpack are specially geared for higher index problems. They're rooted in schemes such as backward difference formulas but employ thoughtful examination to reduce errors and remain on the correct solution manifold. They need initial conditions.

      Consistent Initialization Formalism

      For an ODE IVP, initial values of the state (x) and its derivative (x dot) specify the beginning. For a fully implicit DAE F(x, x_dot, t)=0 with N unknowns (x, x_dot), there are N equations.

      Constraints in Index Analysis

      A constraint hidden from the index analysis (to obtain the ODE for C1) restricts DC2DT(0) (DC2DT(0)=gamma dot(0)).

      Unknowns and Constraints

      There are three unknowns:

      • C1(0)
      • C2(0)
      • DC2DT(0)

      Additionally, there are three known constraints.

      Final Examples on Initial Conditions

      No free variables to define; initial conditions are known by the measured signal (gamma and its derivative).

      Example 1: Index 2

      Timeframe: 43:20 - 45:20

      In the example given above (index 2), there was an implicit constraint that:

      • Initial values of C1 and C2 add up to zero
      • C3 initially equals zero

      This constraint is obtained from index analysis. There are five possible unknowns:

      • C1(0)
      • C2(0)
      • C3(0)
      • C1dot(0)
      • C2dot(0)

      And four constraints from DAE structure and index analysis. This provides one degree of freedom to assign one additional initial condition consistently. Overconstrained is fine; underconstrained is not.

      Example 2: ODE for C3

      Timeframe: 45:20 - 46:44

      As a second example, reducing to an ODE for C3 does not add new constraints on the initial values/derivatives of C1, C2, and C3 from the initial DAE equations. There are:

      • Five possible initial unknowns (C1(0), C2(0), C3(0), C1dot(0), C2dot(0))
      • Three from the initial equations

      This leaves two degrees of freedom to select initial conditions consistently.

      Timeframe: 46:44 - 46:48 - Lecture end.