What is wrong about my "specifyCoefficients" function use for PDEModel?
17 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jan Schäppi
am 29 Nov. 2018
Kommentiert: Jan Schäppi
am 29 Nov. 2018
I am trying to solve the Schnakenberg Model, a (nonlinear) PDE system in 2D:
=
=
My code by now is the following:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Define Model
nEquations = 2;
model = createpde(nEquations);
%% Define Geometry
geometryFromEdges(model,@lshapeg);
%% Define Schnakenberg Model Nonlinear Function
a = 1; b = 0.5; gamma = 200; d = 20;
R = @(c) gamma*[a - c(1)+c(1)*c(2)*c(2);
b - c(1)*c(2)*c(2)];
D = [1 0; 0 d];
%% Solve Problem on Model
m_mod = zeros(2); d_mod = eye(2); a_mod = zeros(2);
c_mod = [D(1,1) 0 0 0;
0 0 0 0;
0 0 0 0;
0 0 0 D(2,2)];
f_mod = @(location,state) R(state.u);
specifyCoefficients(model,'m',m_mod,'d',d_mod,'c',c_mod,'a',a_mod,'f',f_mod);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
However as an output I get the following:
Error using pde.CoefficientAssignment/checkMCoefSize (line 398)
Size of the matrix 'm' is not consistent with
the pde.PDEModel/PDESystemSize property.
Error in pde.CoefficientAssignment/checkAllMatrixCoefSizes (line 240)
self.checkMCoefSize(self.m, systemsize);
Error in pde.CoefficientAssignment (line 103)
obj.checkAllMatrixCoefSizes(systemsize, numdims);
Error in pde.PDEModel/specifyCoefficients (line 139)
coef = pde.CoefficientAssignment(coefcont,argsToPass{:});
Error in ForumAttempt (line 21)
specifyCoefficients(model,'m',m_mod,'d',d_mod,'c',c_mod,'a',a_mod,'f',f_mod);
Where did I go wrong? I think I followed the Instructions at https://ch.mathworks.com/help/pde/ug/equations-you-can-solve.html
where it states "For systems of N equations, the coefficients m, d, and a are N-by-N matrices, f is an N-by-1 vector, and c is a 2N-by-2N tensor (2-D geometry)"
0 Kommentare
Akzeptierte Antwort
Ravi Kumar
am 29 Nov. 2018
Can you try using:
specifyCoefficients(model,'m',0,'d',d_mod,'c',c_mod,'a',0,'f',f_mod);
and see if you get the solution?
Regards,
Ravi
5 Kommentare
Ravi Kumar
am 29 Nov. 2018
Sorry didn't notice this earler.This shold be the final one.
specifyCoefficients(model,'m',0,'d',d_mod(:),'c',c_mod(:),'a',0,'f',f_mod);
"To write the coefficient c for inclusion in the PDE model via specifyCoefficients, give c as either of the following:
- If c is constant, give a column vector representing the elements in the tensor.
- If c is not constant, give a function handle. The function must be of the form"
You need to arrage c-coefficient correctly so that c_mod(:) represent the correct tensor.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu General PDEs finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!