60 likes | 553 Views
Matlab: Nonlinear Algebraic Equations. fzero scalar nonlinear equation solverSyntax: x = fzero(fun',xo)fun' is the name of the user provided Matlab m-file function (fun.m) that evaluates and returns the LHS of f(x) = 0xo is an initial guess for the solution of f(x) = 0Discussed last lecture
E N D
1. Matlab: Nonlinear Algebraic Systems Nonlinear algebraic equation solvers
Exothermic chemical reactor example
2. Matlab: Nonlinear Algebraic Equations fzero scalar nonlinear equation solver
Syntax: x = fzero(fun,xo)
fun is the name of the user provided Matlab m-file function (fun.m) that evaluates and returns the LHS of f(x) = 0
xo is an initial guess for the solution of f(x) = 0
Discussed last lecture
fsolve multivariable nonlinear equation solver
Function for solving system of nonlinear algebraic equations
Syntax: x = fsolve(fun,xo)
Same syntax as fzero, but x is a vector of variables and the function, fun, returns a vector of equation values, f(x)
Part of the Matlab Optimization toolbox
Multiple algorithms available in options settings (e.g. trust-region dogleg, Gauss-Newton, Levenberg-Marquardt)
3. Exothermic Chemical Reactor Example Steady-state model
Parameter values
k0 = 3.493x107 h-1, E = 11843 kcal/kmol
(-DH) = 5960 kcal/kmol, rCp = 500 kcal/m3/K
UA = 150 kcal/h/K, R = 1.987 kcal/kmol/K
V = 1 m3, q =1 m3/h,
CAf = 10 kmol/m3, Tf = 298 K, Tj = 298 K.
Problem
Find all steady-state points:
4. x = fsolve('cstr',xo,options)
'cstr' name of the Matlab m-file function (cstr.m) for the CSTR model
xo initial guess of steady-state solution: xo = [CA T] '
options Matlab structure of optimization parameter values created with the optimset function
Example usage
>> xo = [10 300]';
>> x = fsolve('cstr',xo,optimset('Display','iter'))
Solution of CSTR Model with fsolve
5. Create m-file cstr.m