% Preallocate g vector of derivative values. The function movingMeshODE goes through these steps to evaluate the right-hand sides of all the equations in the system: The first N elements correspond to Burgers' equations, while the last N elements are for the moving mesh equations. The derivative function for this problem returns a vector with 2 N elements. Note: All functions are included as local functions at the end of the example. The second derivative in M4 is % approximated using a finite difference Laplacian matrix. Since the mesh functions only involve d/dt(dx/dt), % the M3 portion of the mass matrix is all zeros. % M3 and M4 define the equations for mesh point evolution, corresponding to % MMPDE6 in the reference paper. % The derivative du/dx is approximated with finite differences, using % single-sided differences on the edges and centered differences in between. % M1 and M2 are the portions of the mass matrix for Burgers' equation. % Boundary values of solution u and mesh x % Extract the components of y for the solution u and mesh x This formulation shows that M 1 and M 2 form the left side of Burgers' equations (the first N equations in the system), while M 3 and M 4 form the left side of the mesh equations (the last N equations in the system). The mass matrix is composed of four blocks, each of which is a square matrix of order N: Set the left side of the system of equations equal to M y ′ to extract the form of the mass matrix. The left side of the system of equations involves linear combinations of first derivatives, so a mass matrix is required to represent all of the terms. You can either include the required functions as local functions at the end of a file (as done here), or save them as separate, named files in a directory on the MATLAB path. To solve this equation in MATLAB®, write a derivative function, a mass matrix function, a function for the sparsity pattern of the Jacobian dF / dy, and a function for the sparsity pattern of d ( Mv ) / dy. Supplying these sparsity patterns helps the solver operate more efficiently.įinite differences are used to approximate several partial derivatives. The sparsity patterns of the Jacobian dF / dy and the derivative of the mass matrix multiplied with a vector d ( Mv ) / dy are supplied to the solver as functions. The derivative function not only includes the equations for Burgers' equation, but also a set of equations governing the moving mesh selection. The mass matrix is provided to the ode15s solver as a function. Necessary.The system of equations is expressed using a mass matrix formulation, M y ′ = f ( t, y ). How to provide additional parameters to the function mfun, if To use a function handle, use the function signature function y = Preconditioner matrix, making the calculation more efficient. Handle performs matrix-vector operations instead of forming the entire M2 as function handles instead of matrices. You can optionally specify any of M, M1, or For more information on preconditioners, see Iterative Methods for Linear Systems.Ĭgs treats unspecified preconditioners as identity You also can use equilibrate prior to factorization to improve the condition number of YouĬan use the incomplete matrix factorization functions ilu and ichol to generate preconditioner System and make it easier for cgs to converge quickly. You can specify a preconditioner matrix M or its matrixįactors M = M1*M2 to improve the numerical aspects of the linear Preconditioner matrices, specified as separate arguments of matrices or function In MATLAB®, write a function that creates these vectors and adds them together, thus giving the value of A*x: The resulting vector can be written as the sum of three vectors:Īx = + +. Moreover, only the main diagonal has nonzeros that are not equal to 1.Īx =. The nonzero elements in the result correspond with the nonzero tridiagonal elements of A. When A multiplies a vector, most of the elements in the resulting vector are zeros. The Wilkinson matrix has a special structure, so you can represent the operation A*x with a function handle.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |