Matlab:制作一个PDE系数

时间:2015-12-10 17:20:52

标签: matlab data-fitting pde

标题几乎说明了我要做的事情。我正在尝试解决2D椭圆方程:

$$ - \ nabla \ dot(x \ dot \ nabla u)= x * f $$

我希望在哪里放入一组xyz数据,并使其符合f。然后解决pde。

以下是我的练习功能,其中F = ['x', ???];行最相关。

function ExerciseFun

    RMax = 20;
    RL = 1;
    RU = 0.5;
    HN = 5;
    HL = 2;
    HTT = 3;
    HU = 1.5;
    VL = -150;

    p = [RL,0;RL,HN;0,HN+HL;0,HN+HL+HTT;RU,HN+HL+HTT+HU;RMax,HN+HL+HTT+HU;RMax,0];

    t = [1;1;0;1;1;0;0];
    v = [VL;VL;0;0;0;0;0];

    bc = {  {'u', VL};
        {'u', VL};
        {'g', 0, 'q', 1};
        {'u', 0};
        {'u', 0};
        {'g', 0, 'q', 1};
        {'g', 0, 'q', 1} };

    model = Initialize_LaPlace2D(p, bc);

    X = [1, 2, 4];
    Y = [2, 5];

    [x, y] = meshgrid(X,Y);
    sc = zeros(size(x));

    Run_LaPlace2D(model, x,y,sc);

end

function Run_LaPlace2D(model, x,y,sc)

f = generateApproximate(x,y,sc);

c = 'x';
a = 0;
F = ['x', ???];

u = assempde( model , c , a , f );
pdeplot(model,'xydata',u)
end


function fitresult = generateApproximate(X,Y,Z)
    [xData, yData, zData] = prepareSurfaceData( X, Y, Z );

    % Set up fittype and options.
    ft = 'thinplateinterp';

    % Fit model to data.
    [fitresult, ~] = fit( [xData, yData], zData, ft, 'Normalize', 'on' );
end

function model = Initialize_LaPlace2D(p, bc)
model = createpde;

gd = [2; size(p,1); p(:,1) ; p(:,2)];
ns = char('domain')';
sf = 'domain';

g = decsg(gd,sf,ns);
geometryFromEdges(model,g);

generateMesh(model, 'Hmax', 0.05, 'MesherVersion','R2013a');

for i = 1:size(bc,1)
    applyBoundaryCondition(model, 'Edge', i, bc{i}{:});
end

end

1 个答案:

答案 0 :(得分:0)

我将f放在自己的函数中,然后将其称为'myFunction(x,y)'