Main Content

interpolateMagneticPotential

Interpolate magnetic potential in magnetostatic result at arbitrary spatial locations

    Description

    example

    Aintrp = interpolateMagneticPotential(magnetostaticresults,xq,yq) returns the interpolated magnetic potential values at the points specified in xq and yq.

    example

    Aintrp = interpolateMagneticPotential(magnetostaticresults,querypoints) returns the interpolated magnetic potential values at the points specified in querypoints.

    Examples

    collapse all

    Create an electromagnetic model for magnetostatic analysis.

    emagmodel = createpde('electromagnetic','magnetostatic');

    Create a square geometry and include it in the model. Plot the geometry with the edge labels.

    R1 = [3,4,-1,1,1,-1,1,1,-1,-1]';
    g = decsg(R1,'R1',('R1')');
    geometryFromEdges(emagmodel,g);
    pdegplot(emagmodel,'EdgeLabels','on')
    xlim([-1.5 1.5])
    axis equal

    Figure contains an axes. The axes contains 5 objects of type line, text.

    Specify the vacuum permeability in the SI system of units.

    emagmodel.VacuumPermeability = 1.2566370614E-6;

    Specify the relative permeability of the material.

    electromagneticProperties(emagmodel,'RelativePermeability',5000);

    Apply the magnetic potential boundary conditions on the boundaries of the square.

    electromagneticBC(emagmodel,'MagneticPotential',0,'Edge',[1 3]); 
    electromagneticBC(emagmodel,'MagneticPotential',0.01,'Edge',[2 4]);

    Specify the current density for the entire geometry.

    electromagneticSource(emagmodel,'CurrentDensity',0.5);

    Generate the mesh.

    generateMesh(emagmodel);

    Solve the model and plot the magnetic potential.

    R = solve(emagmodel);
    pdeplot(emagmodel,'XYData',R.MagneticPotential, ...
                      'Contour','on')
    axis equal

    Figure contains an axes. The axes contains 12 objects of type patch, line.

    Interpolate the resulting magnetic potential to a grid covering the central portion of the geometry, for x and y from -0.5 to 0.5.

    v = linspace(-0.5,0.5,51);
    [X,Y] = meshgrid(v);
    Aintrp = interpolateMagneticPotential(R,X,Y)
    Aintrp = 2601×1
    
        0.0056
        0.0057
        0.0058
        0.0059
        0.0060
        0.0061
        0.0062
        0.0063
        0.0064
        0.0065
          ⋮
    
    

    Reshape Aintrp and plot the resulting magnetic potential.

    Aintrp = reshape(Aintrp,size(X));
    figure
    contourf(X,Y,Aintrp)
    colormap(cool)
    colorbar

    Figure contains an axes. The axes contains an object of type contour.

    Alternatively, you can specify the grid by using a matrix of query points.

    querypoints = [X(:),Y(:)]';
    Aintrp = interpolateMagneticPotential(R,querypoints);

    Input Arguments

    collapse all

    Solution of a magnetostatic problem, specified as a MagnetostaticResults object. Create magnetostaticresults using the solve function.

    Example: magnetostaticresults = solve(emagmodel)

    x-coordinate query points, specified as a real array. interpolateMagneticPotential evaluates the magnetic potential at the coordinate points [xq(i) yq(i)] for every i. Because of this, xq and yq must have the same number of entries.

    interpolateMagneticPotential converts query points to column vectors xq(:) and yq(:). It returns magnetic potential values as a column vector of the same size. To ensure that the dimensions of the returned solution are consistent with the dimensions of the original query points, use reshape. For example, use Aintrp = reshape(Aintrp,size(xq)).

    Example: xq = [0.5 0.5 0.75 0.75]

    Data Types: double

    y-coordinate query points, specified as a real array. interpolateMagneticPotential evaluates the magnetic potential at the coordinate points [xq(i),yq(i)] for every i. Because of this, xq and yq must have the same number of entries.

    interpolateMagneticPotential converts query points to column vectors xq(:) and yq(:). It returns magnetic potential values as a column vector of the same size. To ensure that the dimensions of the returned solution are consistent with the dimensions of the original query points, use reshape. For example, use Aintrp = reshape(Aintrp,size(xq)).

    Example: yq = [1 2 0 0.5]

    Data Types: double

    Query points, specified as a real matrix with two rows for 2-D geometry. interpolateMagneticPotential evaluates the magnetic potential at the coordinate points querypoints(:,i) for every i, so each column of querypoints contains exactly one 2-D query point.

    Example: querypoints = [0.5 0.5 0.75 0.75; 1 2 0 0.5]

    Data Types: double

    Output Arguments

    collapse all

    Magnetic potential at query points, returned as an FEStruct object with the properties representing spatial components of the magnetic potential at the query points. For query points that are outside the geometry, Aintrp(i) = NaN. Properties of an FEStruct object are read-only.

    Introduced in R2021a