How to get AssembleFEMatrices for a nonlinear and Time dependent PDE problem in PDEtool box
6 views (last 30 days)
Show older comments
In MATLAB pde tool box, To get the assemble matrices for time dependent pde or nonlinear pde - ''FEM = assembleFEMatrices(___,state) '' this command is used. But how to get a assemble matrices for a pde with time dependent and nonlinear.
, k = 0.7 + 0.003*T, tlist = linespace(0,0.5,20); therefore my pde coefficients wills be d = 1, m = a = 0, c = k, f = 1; since c coefficent is non linear (dependent on T, temperature); How am i going to get AssembleFEMtrices at tlist(1) i.e. at t = 0 ?
clear,clc,close all;
model = createpde();
%% Geometry
R1 = [3;4;-1;1;1;-1;-1;-1;1;1];
g = decsg(R1);
heatmodel_geom = geometryFromEdges(model,g);
%% Mesh
msh = generateMesh(model,'GeometricOrder','linear');
[P,E,T] = meshToPet( msh );
%% Specify Coefficients
c = @(~,state) 0.7+0.003*state.u; % nonlinear coefficient
specifyCoefficients(model,'m',0,'d',1,'c',c,'a',0,'f',1);
%% Spacial BC
applyBoundaryCondition(model,'dirichlet','edge',[1 2 3 4],'u',0);
%% Initial guess
setInitialConditions(model,0);
%% assemble the finite elements matrices with imposed spacial BC
tlist = linspace(0,0.1,20);
Rnonlin = solvepde(model,tlist);
state.u = Rnonlin.NodalSolution;
state.time = tlist(1);
FEMn = assembleFEMatrices(model,'nullspace',state);
I could see lot of errors when i run this code. Am not sure if this approch is correct or not to get assemble FEMatrices... Please help me with a way to get assemble matrices for a pde which is nonlinear and time dependent?
My commands are based on the link given below
Thank you
0 Comments
Answers (1)
Ravi Kumar
on 4 Mar 2021
Solution matrix must of of the size NumPDEs x NumNodes. In your case, you are providing several solutions at all the time-steps as inputs. Change the line:.
state.u = Rnonlin.NodalSolution;
to
state.u = Rnonlin.NodalSolution(:,1)';
If you want matrices at multuple time steps, you need to updated state struct with corresponding solution and time values and call assembleFEMatrices.
Regards,
Ravi
0 Comments
See Also
Categories
Find more on Geometry and Mesh 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!