Unformatted text preview:

Produced using MATLAB software TR 1D model1 SS DAE SS solver 1 Page 1 of 18 TR 1D model1 SS DAE SS solver 1 m TR 1D model1 ss DAE SS solver 1 m function x state iflag converge f f init DAE SS solver 1 x guess Solver func calc A int func calc b int func implement BC epsilon Param This procedure is a generic solver for a DAE system arising from a discretized set of PDE s of the form epsilon k df dt k b k sum j A k j x state j The procedure is passed an initial guess of the state vector x state a structure of the system parameters and the names of the subroutines that calculate from this information the A matrix the b vector and the Jacobian of the b vector First if Solver max iter time is not 0 the solver starts off with a stage of implicit Euler time integration that robustly approaches the vicinity of a stable steady state If the norm of the function b Ax vector drops below a magnitude Solver atol time then the time integration stage ends If the time integration procedure has reduced the function vector to an acceptable magnitude or if Solver max iter time is 0 signifies that Newton s method is to be performed directly then the Newton s method stage begins If the function vector norm drops below a magnitude of Solver atol Newton then convergence to steady state is deemed to have occurred and the routine exists with iflag converge 1 Otherwise the Newton s method stage ends after a maximum of Solver max iter Newton number of iterations with iflag converge remaining zero or negative if an error occurred If Solver iflag Adepend is non zero then the value of the A matrix is state dependent and must be recalculated at each iteration If Solver iflag nonneg is non zero then the 7 16 2002 TR 1D model1 SS DAE SS solver 1 Page 2 of 18 state variables are enforced to be non negative at every iteration INPUT x guess REAL num DOF This is the initial guess of the state vector Solver This data structure contains the parameters that control the operation of the solver The fields of this structure are max iter time INT the maximum number of implicit Euler time steps If 0 then no time simulation is performed and the solver goes immediately to Newton s method dt REAL the time step to be used in the implicit Euler simulation atol time REAL the norm of the function time derivative vector at which the time integration procedure is deemed to have been sufficiently converged max iter Newton INT the maximum number of Newton s method iterations atol Newton REAL the norm of the function time derivative vector at which convergence to the steady state solution is deemed to have been achieved iflag Adepend INT if this integer flag is non zero then the A matrix is assumed to be state dependent and so must be recalculated at every iteration iflag nonneg INT if this integer flag is non zero then the elements of the state vector are enforced to be non negative at every iteration iflag verbose INT if this integer flag is non zero then the solver routine is instructed to print to the screen the progress of the solution process otherwise it runs silent func calc A int FUNCTION NAME This is the name of the function that takes the master state vector and the system parameters and returns the A matrix that discretizes the transport terms func calc b int FUNCTION NAME This is the name of the function that takes the master state vector and the system parameters and returns the b vector that typically arises from the source term in a PDE 7 16 2002 TR 1D model1 SS DAE SS solver 1 Page 3 of 18 It also returns the Jacobian of the b vector whose m n element is the partial of b m with respect to x state n func implement BC FUNCTION NAME This is the name of the function that returns the values of A b and bJac for the boundary conditions which are found where epsilon has values of zero epsilon INT num DOF length x guess this is a 1 D array of integers of the same size as x state It contains a 1 at position k for every equation that is an ordinary differential equation and a 0 for every algebraic equation which in this problem arise from the boundary conditions Param This data structure contains the system parameters that are passed to the functions for calculating the DAE system elements OUTPUT x state REAL num DOF This is the output estimate of the steady state solution of the DAE system iflag converge INT This integer flag is set equal to 1 if the solution procedure has converged A value of 0 means that the method did not converge A negative value indicates an error f REAL num DOF This is the time derivative vector for boundary points it is a measure of error in the boundary condition whose magnitude tells how far the output estimate is from the steady state f init REAL num DOF The time derivative vector for State init Kenneth Beers Massachusetts Institute of Technology Department of Chemical Engineering 7 2 2001 Version as of 7 23 2001 function x state iflag converge f f init DAE SS solver 1 x guess Solver func calc A int func calc b int func implement BC epsilon Param 7 16 2002 TR 1D model1 SS DAE SS solver 1 Page 4 of 18 iflag converge 0 func name DAE SS solver This integer flag controls what action to take in case of an assertion failure See the assertion routines for further details i error 2 check input data signify not yet completed checking of initial data iflag converge 1 check data structure that contains solver parameters We do this with a routine that performs the appropriate assertions on a structure SolverType num fields 8 max iter time ifield 1 FieldType name max iter time FieldType is numeric 1 FieldType num rows 1 FieldType num columns 1 FieldType check real 1 FieldType check sign 2 FieldType check int 1 SolverType field ifield FieldType dt ifield 2 FieldType name dt FieldType is numeric 1 FieldType num rows 1 FieldType num columns 1 FieldType check real 1 FieldType check sign 1 FieldType check int 0 SolverType field ifield FieldType atol time ifield 3 FieldType name atol time FieldType is numeric 1 FieldType num rows 1 FieldType num columns 1 7 16 2002 TR 1D model1 SS DAE SS solver 1 Page 5 of 18 FieldType check real 1 FieldType check sign 1 FieldType check int 0 SolverType field ifield FieldType max iter Newton ifield 4 FieldType name max iter Newton FieldType is numeric 1 FieldType num rows 1 FieldType num columns 1 FieldType check real 1 FieldType check sign 2 FieldType check int 1 SolverType field ifield FieldType atol Newton ifield 5 FieldType name atol Newton FieldType is …


View Full Document

MIT 10 34 - Lecture Notes

Documents in this Course
Load more
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?