Effacer les filtres
Effacer les filtres

PDE toolbox coefficients in functional form

4 vues (au cours des 30 derniers jours)
Ollie A
Ollie A le 22 Sep 2020
Commenté : Vimal Rathod le 30 Sep 2020
I am using PDE toolbox to simulate current flow through a 2D conductive medium.
I want to use my results from this model as a functional coefficient value for a second model, which simulates Joule heating due to the current flow. My code is as follows:
% First model to simulate current flow in conductive medium.
model = createpde(); % Create model.
geometryFromEdges(model,dl); % Assign model geometry.
generateMesh(model,'Hmax',1e-7); % Generate mesh.
% Apply Neumann boundary conditions. Set 2 edges to have current flow in and out of the geometry.
applyBoundaryCondition(model,'neumann','Edge',1:model.Geometry.NumEdges,'q',0,'g',0);
applyBoundaryCondition(model,'neumann','Edge',8,'q',0,'g',1);
applyBoundaryCondition(model,'neumann','Edge',7,'q',0,'g',-1);
% Specify differential coefficients. In this case the Laplace equation.
specifyCoefficients(model,'m',0,'d',0,'c',1,'a',0,'f',0);
results = solvepde(model); % Model solutions.
% Second model to simulate Joule heating.
% Same model geometry and mesh conditions.
model2 = createpde();
geometryFromEdges(model2,dl);
generateMesh(model2,'Hmax',1e-7);
% Boundary conditions set to only consider heating within the geometry.
applyBoundaryCondition(model2,'neumann','Edge',1:model2.Geometry.NumEdges,'q',0,'g',0);
% Call my function to use as coefficient f.
f = @(region,state)myfun(region,state,c,results);
specifyCoefficients(model2,'m',0,'d',0,'c',1,'a',0,'f',f);
results2 = solvepde(model2); % Model 2 solutions.
% Define function for coefficient f.
function f = myfun(region,state,results) % Inputs are region, state, and results from first model.
[gradx,grady] = evaluateGradient(results,region.x,region.y); % Evaluate gradient solution at region.x and region.y.
f = (gradx.^2 + grady.^2)'; % Functional form of coefficient f.
end
My issue is model 2 cannot produce a usable function for coefficient f. The error I am currently given is:
Error using pde.EquationModel/solveStationaryNonlinear (line 32)
Unsuitable initial guess U0 (default: U0=0).
Any suggestions on how to fix this issue are appreciated. Thanks!
  1 commentaire
Vimal Rathod
Vimal Rathod le 30 Sep 2020
You haven't given the variable dl for us to debug it. It would be better if you provided that.

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by