Specify time-dependent PDE coefficients
18 次查看(过去 30 天)
显示 更早的评论
Hello,
I would ask help concerning the analysis of a reaction-diffusion system with Matlab, with two coupled PDEs. In my problem, I have a defined function for the temperature T(t) (mixed ramps and constants values) that I don't need to solve just because it is imposed. In the PDE system that I need to solve there are two parameters k1 and k2 (entering the coefficient a) that are dependent on T (and then on t, because of T is imposed and not solved as PDE). I have tried to define two functions and then to add a as vector a = [k1(t); k2(t)] as follow:
k1 = @k1f; % First external function
k2 = @k2f; % Second external function
m = 0; % Second derivative null
d = [1;1]; % First derivative 1
c = [0.2;0.1]; % Diffusion
a = [k1(t);k2(t)]; % Reaction term
f = [0;0]; % No generation
pdec = specifyCoefficients(pdem, 'm', m, 'd', d, 'c', c, 'a', a, 'f', f);
but it doesn't work.
In the PDETool it is simple to do this because I have just to add the function in the user interface and it generates the command pdeseteq(TYPE,C,A,F,D,TLIST,U0,UT0,RANGE).
I would like to know if I can define this parameter without using the PDETool.
Thank you
0 个评论
采纳的回答
Alan Weiss
2017-3-14
I am not sure what you are trying to do. Is the "t" that you "impose" equal to the time in your PDE? Or is there an outer loop that we cannot see that sets "t" for some other purpose?
Also, while you say that you are setting the c coefficient to be a function of "t", it seems in your code that you are setting a as a function of "t". I am going to assume that you made a mistake in setting a, and that you really meant to set c.
If "t" is the time in your PDE, then you have some syntax errors. For a c coefficient that is a function, you need to define the function as
function c = ccoeff(region,state)
It seems that you want a "short" 2-element c output. But, as the documentation clearly states, the returned c is a matrix of size N1-by-Nr, where N1 = 2 for your case, and Nr is the number of elements in each region structure that MATLAB passes to your solver. So your c coefficient function should be something like this:
function c = ccoeff(region,state)
t = state.time;
k1 = k1f(t);
k2 = k2f(t);
c = repmat([k1;k2],1,length(region.x)); % 2-by-Nr matrix c
When you set coefficients, set c as @ccoeff.
I hope that this enables you to continue with your work.
Alan Weiss
MATLAB mathematical toolbox documentation
7 个评论
Alan Weiss
2017-3-14
Thank you for supplying the details.
Functions Tc and k1f are NOT functions of two input variables. They are functions of ONE variable, usually called t. Each should be written as something like
function k1 = k1f(t)
% do NOT put a call to region or state here
Similarly,
function Tc = Tcf(t)
% These are functions of one input only
One more thing: did you write the ramp function? Or are you calling the Simulink ramp block? I am asking because that part of your function is something that I still do not understand. I see that you have a transpose as the last operation in the function when you call it in Tc, but I would expect the function to return a scalar value, so I am suspicious. If you are calling Simulink, well, that is yet another problem.
Your acoef function looks good to me.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
更多回答(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!