Main Content

interpolateElectricFlux

Interpolate electric flux density in electrostatic result at arbitrary spatial locations

    Description

    example

    Dintrp = interpolateElectricFlux(electrostaticresults,xq,yq) returns the interpolated electric flux density at the points specified in xq and yq.

    example

    Dintrp = interpolateElectricFlux(electrostaticresults,querypoints) returns the interpolated electric flux density at the points specified in querypoints.

    Examples

    collapse all

    Create an electromagnetic model for electrostatic analysis.

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

    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 permittivity in the SI system of units.

    emagmodel.VacuumPermittivity = 8.8541878128E-12;

    Specify the relative permittivity of the material.

    electromagneticProperties(emagmodel,'RelativePermittivity',1);

    Apply the voltage boundary conditions on the edges of the square.

    electromagneticBC(emagmodel,'Voltage',0,'Edge',[1 3]);
    electromagneticBC(emagmodel,'Voltage',1000,'Edge',[2 4]);

    Specify the charge density for the entire geometry.

    electromagneticSource(emagmodel,'ChargeDensity',5E-9);

    Generate the mesh.

    generateMesh(emagmodel);

    Solve the model and plot the electric flux density.

    R = solve(emagmodel);
    pdeplot(emagmodel,'FlowData',[R.ElectricFluxDensity.Dx ...
                                  R.ElectricFluxDensity.Dy])
    axis equal

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

    Interpolate the resulting electric flux density 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);
    
    Dintrp = interpolateElectricFlux(R,X,Y)
    Dintrp = 
      FEStruct with properties:
    
        Dx: [2601x1 double]
        Dy: [2601x1 double]
    
    

    Reshape Dintrp.Dx and Dintrp.Dy and plot the resulting electric flux density.

    DintrpX = reshape(Dintrp.Dx,size(X));
    DintrpY = reshape(Dintrp.Dy,size(Y));
    
    figure
    quiver(X,Y,DintrpX,DintrpY,'Color','red')

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

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

    querypoints = [X(:),Y(:)]';
    Dintrp = interpolateElectricFlux(R,querypoints);

    Input Arguments

    collapse all

    Solution of thermal problem, specified as an ElectrostaticResults object. Create electrostaticresults using the solve function.

    Example: electrostaticresults = solve(emagmodel)

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

    interpolateElectricFlux converts the query points to column vectors xq(:) and yq(:). It returns electric flux density 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 DintrpX = reshape(Dintrp.Dx,size(xq)).

    Example: xq = [0.5 0.5 0.75 0.75]

    Data Types: double

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

    interpolateElectricFlux converts the query points to column vectors xq(:) and yq(:). It returns electric flux density 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 DintrpY = reshape(Dintrp.Dy,size(yq)).

    Example: yq = [1 2 0 0.5]

    Data Types: double

    Query points, specified as a real matrix with two rows for 2-D geometry. interpolateElectricFlux evaluates the electric flux density 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

    Electric flux density at query points, returned as an FEStruct object with the properties representing the spatial components of the electric flux density at the query points. For query points that are outside the geometry, Dintrp.Dx(i) and Dintrp.Dy(i) are NaN. Properties of an FEStruct object are read-only.

    Introduced in R2021a