How to use solvepde with non constant coefficient?
Show older comments
Hello I want to use solvepde, but do not understand how to create the PDE-ModelObject or rather how to calculate the coefficent if they are not constant.
I first create the model:
model=createpde(size(u0,1));
geometryFromEdges(model,g);
setInitialConditions(model,u0);
bToBoundCond(model,b); % transforms b from PDE-GUI in boundary conditions for PDE Model-Container
generateMesh(model);
Everything works until now. Next I want to define the coeffcients of my PDE. m and a are zero. d is dependent of the Subdomain (number of 8) c and f are dependent on solution u and dependent on Subdomain.
So first, how can I define d in dependence on the subdomain? An second how can I define c and f when I create the model, but the model is not yet called by solvepde? How does solvepde Change the coefficients c and f when solving the System?
Thank you very much for any help. I am a Little bit smitten and puzzled at the Moment...
LF
Answers (1)
Alan Weiss
on 29 Jun 2017
0 votes
If you have a relatively recent toolbox version, you can find out how to write coefficients here. In particular, nonconstant m, d, and a coefficients, nonconstant f coefficient, and nonconstant c coefficient have the coefficient-specific instructions.
There is an example of a nonconstant a coefficient here. While it is not completely applicable, it should help guide you.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
5 Comments
Alan Weiss
on 30 Jun 2017
I am not sure what you find unclear in the documentation, so I am not sure how I can help. But I will try.
During solution, solvepde passes regions to your coefficient functions to evaluate. You do not give the coefficients for fixed locations, such as the nodes. solvepde passes the locations that it wants to evaluate, and your coefficient functions should give the coefficient values at those locations. If your functions depend on the solution u, then solvepde passes the current value of u for the requested locations. If your functions depend on the subdomains, then solvepde passes the appropriate subdomains. The example at the end of this page shows a vectorized calculation that includes both state.u and region.subdomain arguments being used.
I am afraid that I did not answer your question satisfactorily. Sorry if it is still not clear.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
MarionJ
on 6 Jul 2017
Alan Weiss
on 6 Jul 2017
I believe that the vocabulary we use is, perhaps, not defined well enough. Sorry about that.
In PDE Toolbox, you have exactly one geometry that defines the spatial domain over which the PDE exists. This geometry, in 2-D, may be further divided into subdomains, such as the left and right halves of a rectangle, or any other set of contiguous 2-D geometric areas whose union is the geometry. So a subdomain is a contiguous region in 2-D space. Furthermore, the intersection of a subdomain with any other subdomain is either empty or is edges, but has no area. In other words, you can think of the geometry as being a completed jigsaw puzzle, and each jigsaw puzzle piece is a subdomain.
In addition, you can have any number of PDE equations that apply to the geometry. So if you have "layers" that lie on top of each other, I believe that you mean that you have several equations, not several subdomains.
When solvepde passes regions to your coefficient functions, each "region" is a location given in terms of (x,y) coordinates. These coordinates may also correspond to a particular subdomain, and so if your coefficient functions use subdomains, you will get both the (x,y) "region" and the subdomain number.
Is that clearer?
Alan Weiss
MATLAB mathematical toolbox documentation
Alan Weiss
on 7 Jul 2017
I am afraid that I cannot help you any further. It seems that you have been following the progress of the solver using the debugger, but still do not understand what you see. I, too, do not understand what you report. Any guesses that I have are as likely to be misleading as they are to be helpful.
Alan Weiss
MATLAB mathematical toolbox documentation
Categories
Find more on General PDEs in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!