How to set the coefficient of PDE equation as a user-defined matlab function?

조회 수: 2 (최근 30일)
Hi,
My problem is Possion's equation. I use assempde function to solve my problem in command lines. The coefficient c is denpended on coordinate x,y. But, c cannot be writed as a simple expression with x,y. So I write a function to interpolate the value.
I looked up in the help documnent of "assempde". It says that "The name of a user-defined MATLAB function that accepts the arguments (p,t,u,t0). "
Does it mean I cannot use the coordinate value x,y?
What should the function return? A matrix or a vector??Could you give me more details?
Thanks!
Qingyuan

채택된 답변

Bill Greene
Bill Greene 2012년 1월 3일
Qingyuan,
As you've observed, supplying a MATLAB function for the c coefficients is somewhat different than if you just directly type a MATLAB expression for the c coefficients in the dialog box.
But, yes, c can be a function of x and y. You have the correct set of input arguments for the required function-- (p,t,u,t0). The first argument p contains the x and y locations of all nodes in the mesh and t contains the 3 nodal indices for all triangle elements in the mesh. From these two arguments you can compute the x and y locations for the centroid of each triangle element.
The return parameter for this function is a matrix of c coefficients at each element centroid. The number of columns in the returned c matrix is equal the number of elements in the mesh. The number of rows depends on the characteristics of the c matrix. For example, for the scalar Poisson equation for an isotropic material, the number of rows is one. The different forms of the c matrix for a single PDE as well as a system of PDEs are described on pages 5-21 and 5-22 of the PDE Toolbox User's Guide.
Bill

추가 답변 (2개)

Ruslan
Ruslan 2011년 12월 8일
"The expression is evaluated in a context where the variables x, y, sd, u, ux, uy, and t are row vectors representing values at the triangle centers of mass (t is a scalar). The row vectors contain x- and y-coordinates, subdomain label, solution, x and y derivatives of the solution, and time. u, ux, and uy can only be used if u0 has been passed to assempde. The same applies to the scalar t, which is passed to assempde as time."
What's your version of MATLAB? You can use 'x' and 'y' in your analytical expression in coefficients or as a "row vector of values at the triangle centers of mass".

zhao qingyuan
zhao qingyuan 2012년 1월 3일
I have resolved this problem. Thank you for all your help!

카테고리

Help CenterFile Exchange에서 Boundary Conditions에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by