nonlinear coefficient in custom PDE.

2 次查看(过去 30 天)
I am trying to solve a variation of 2D steady state heat conduction PDE using PDE toolbox
Here , to simulate nonlinear behaviour.
Here is my code.
syms T(x,y)
syms k
pdeeq = diff(diff(T,x),x) + k*diff(diff(T,y),y)
symCoeffs = pdeCoefficients(pdeeq,T,'Symbolic',true)
symVars = [k]
symVals = [@(~,state) 0.01+1*state.u];
symCoeffs = subs(symCoeffs,symVars,symVals);
I get the following error, which does make sense
Error using sym/subs>normalize
Substitution expression X must be a symbolic, cell, or numeric array.
Error in sym/subs>mupadsubs (line 165)
[X2,Y2,symX,symY] = normalize(X,Y); %#ok
Error in sym/subs (line 153)
G = mupadsubs(F,X,Y);
Error in sym/subs>@(value)subs(value,X,Y) (line 64)
G = structfun(@(value) subs(value, X, Y), F, 'UniformOutput', false);
Error in sym/subs (line 64)
G = structfun(@(value) subs(value, X, Y), F, 'UniformOutput', false);
In case of standard heat transfer I can write this.
k = @(~,state) 0.01+1*state.u
thermalProperties(model,'ThermalConductivity', k);
How to do the same with my custom PDE?

回答(1 个)

Brahmadev
Brahmadev 2023-9-25
Hi Prakhar,
I understand that you would like to model a custom PDE. The error "Substitution expression X must be a symbolic, cell, or numeric array." is caused due to the passing of a function handle instead of a Symbolic Variable to the "subs" function. An alternate way to model this PDE is as shown below:
syms T(x,y)
syms k
pdeeq = diff(diff(T,x),x) + k*diff(diff(T,y),y) == 0
symCoeffs = pdeCoefficients(pdeeq,T,'Symbolic',true)
symVars = k
symVals = x+10*y^2 % Assuming the variable 'k' is some nonlinear function of x and y
pdeeq = subs(pdeeq,symVars,symVals) % Directly updating the equation pdeeq with new variable
Post this, the PDE can be solved using the "solve" function with appropriate boundary conditions. You can refer to the following documentation to know more about “solve” function..
Hope this helps in resolving your issue.

Community Treasure Hunt

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

Start Hunting!

Translated by