MATLAB Answers

How to get AssembleFEMatrices for a nonlinear and Time dependent PDE problem in PDEtool box

조회 수: 13(최근 30일)
Sravan Kumar Putta
Sravan Kumar Putta 4 Mar 2021
답변: Ravi Kumar 4 Mar 2021
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
%% Spacial BC
applyBoundaryCondition(model,'dirichlet','edge',[1 2 3 4],'u',0);
%% Initial guess
%% 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


Ravi Kumar
Ravi Kumar 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;
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.

Community Treasure Hunt

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

Start Hunting!

Translated by