How to use solvepde with non constant coefficient?

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)

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

MarionJ
MarionJ on 30 Jun 2017
Edited: MarionJ on 30 Jun 2017
Thank you for your answer.
I had already read the instructions but they could not help me with my Problem. However the example helped me to understand how to define the coefficents by a functionhandle if it is nonconstant.
Nevertheless I have still the Problem what to do, if the coefficients are not only dependent on the result, let's say on temperature, but also on the location.
For example d is dependent on the subdomain and c is dependent on temperature and Location. With parabolic-solver I define c per triangle-center of the mesh [p,e,t]. But solvepde requires the the initial condition and the coefficients to be as long as the PDESystemSize. Does that mean I have to define c,f etc. per FEM-Node and not per triangle?
To continue with the presented example: how to define c, if the plate consists of two materials with different thickness and different thermal conductivity?
And: what if the conductivity of material 1 changes locally?
Thank you for further help. LF
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
First, what is the difference between a Region and a subdomain? When I create a three layer System (layers lie on one another without intersection) in the pdetool, I thought this means I will have three subdomains. What is Region then?
I do not think the documentation is unclear, but I am just a Little bit slow on the uptake...
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
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.
I suggest that you contact technical support.
Alan Weiss
MATLAB mathematical toolbox documentation

Sign in to comment.

Asked:

on 29 Jun 2017

Commented:

on 7 Jul 2017

Community Treasure Hunt

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

Start Hunting!