How to set the coefficient of PDE equation as a user-defined matlab function?
3 ビュー (過去 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
0 件のコメント
採用された回答
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
0 件のコメント
その他の回答 (2 件)
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".
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Geometry and Mesh についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!