Main Content

interpolateCurrentDensity

Interpolate current density in DC conduction result at arbitrary spatial locations

Since R2022b

    Description

    Jintrp = interpolateCurrentDensity(results,xq,yq) returns the interpolated current density values at the 2-D points specified in xq and yq.

    example

    Jintrp = interpolateCurrentDensity(results,xq,yq,zq) uses 3-D points specified in xq, yq, and zq.

    example

    Jintrp = interpolateCurrentDensity(results,querypoints) returns the interpolated current density values at the points specified in querypoints.

    example

    Examples

    collapse all

    Create an femodel object for DC conduction analysis and include a 2-D geometry of a plate with a hole into the model.

    model = femodel(AnalysisType="dcConduction", ...
                    Geometry="PlateHolePlanar.stl");

    Plot the geometry.

    pdegplot(model.Geometry,EdgeLabels="on");

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

    Specify the conductivity of the material.

    model.MaterialProperties = ...
        materialProperties(ElectricalConductivity=6e4);

    Apply the voltage boundary conditions on the top and bottom edges of the plate.

    model.EdgeBC(3) = edgeBC(Voltage=100);
    model.EdgeBC(2) = edgeBC(Voltage=200);

    Specify the surface current density on the edge representing the hole.

    model.EdgeLoad(5) = edgeLoad(SurfaceCurrentDensity=200000);

    Generate a mesh.

    model = generateMesh(model);

    Solve the problem.

    R = solve(model);

    Plot the electric potential and current density.

    figure
    pdeplot(R.Mesh,XYData=R.ElectricPotential,ColorMap="jet", ...
                   FlowData=[R.CurrentDensity.Jx R.CurrentDensity.Jy])
    axis equal

    Figure contains an axes object. The axes object contains 2 objects of type patch, quiver.

    Interpolate the resulting current density to a grid covering the central portion of the geometry.

    [X,Y] = meshgrid(2:0.25:8,8:0.25:12);
    Jintrp = interpolateCurrentDensity(R,X,Y)
    Jintrp = 
      FEStruct with properties:
    
        Jx: [425x1 double]
        Jy: [425x1 double]
    
    

    Reshape Jintrp.Jx and Jintrp.Jy, and plot the resulting current density.

    JintrpX = reshape(Jintrp.Jx,size(X));
    JintrpY = reshape(Jintrp.Jy,size(Y));
    quiver(X,Y,JintrpX,JintrpY,Color="red")
    axis equal

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

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

    querypoints = [X(:),Y(:)]';
    Jintrp = interpolateCurrentDensity(R,querypoints);

    Create an femodel object for DC conduction analysis and include a geometry representing a 10-by-10-by-1 solid plate into the model.

    model = femodel(AnalysisType="dcConduction", ...
                    Geometry="Plate10x10x1.stl");

    Plot the geometry.

    pdegplot(model.Geometry,FaceLabels="on",FaceAlpha=0.3)

    Figure contains an axes object. The axes object contains 6 objects of type quiver, text, patch, line.

    Specify the conductivity of the material.

    model.MaterialProperties = ...
        materialProperties(ElectricalConductivity=6e4);

    Apply the voltage boundary conditions on the two faces of the plate.

    model.FaceBC([1 3]) = faceBC(Voltage=0);

    Specify the surface current density on the top of the plate.

    model.FaceLoad(5) = faceLoad(SurfaceCurrentDensity=100);

    Generate a mesh.

    model = generateMesh(model);

    Solve the problem.

    R = solve(model);

    Plot the electric potential.

    figure
    pdeplot3D(R.Mesh,ColorMapData=R.ElectricPotential)

    Figure contains an axes object. The hidden axes object contains 5 objects of type patch, quiver, text.

    Plot the current density.

    figure
    pdeplot3D(R.Mesh,FlowData=[R.CurrentDensity.Jx, ...
                               R.CurrentDensity.Jy, ...
                               R.CurrentDensity.Jz])

    Figure contains an axes object. The hidden axes object contains 5 objects of type quiver, text.

    Interpolate the resulting current density to a coarser grid.

    [X,Y,Z] = meshgrid(0:10,0:10,0:0.5:1);
    Jintrp = interpolateCurrentDensity(R,X,Y,Z)
    Jintrp = 
      FEStruct with properties:
    
        Jx: [363x1 double]
        Jy: [363x1 double]
        Jz: [363x1 double]
    
    

    Reshape Jintrp.Jx, Jintrp.Jy, and Jintrp.Jz.

    JintrpX = reshape(Jintrp.Jx,size(X));
    JintrpY = reshape(Jintrp.Jy,size(Y));
    JintrpZ = reshape(Jintrp.Jz,size(Z));

    Plot the resulting current density.

    figure
    quiver3(X,Y,Z,JintrpX,JintrpY,JintrpZ,Color="red")

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

    Input Arguments

    collapse all

    Solution of a DC conduction problem, specified as a ConductionResults object. Create results using the solve function.

    x-coordinate query points, specified as a real array. interpolateCurrentDensity evaluates the current density at the 2-D coordinate points [xq(i) yq(i)] or at the 3-D coordinate points [xq(i) yq(i) zq(i)] for every i. Because of this, xq, yq, and (if present) zq must have the same number of entries.

    interpolateCurrentDensity converts the query points to column vectors xq(:), yq(:), and (if present) zq(:). It returns current density 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 Jintrp = reshape(Jintrp,size(xq)).

    Example: xq = [0.5 0.5 0.75 0.75]

    Data Types: double

    y-coordinate query points, specified as a real array. interpolateCurrentDensity evaluates the current density at the 2-D coordinate points [xq(i) yq(i)] or at the 3-D coordinate points [xq(i) yq(i) zq(i)] for every i. Because of this, xq, yq, and (if present) zq must have the same number of entries.

    interpolateCurrentDensity converts the query points to column vectors xq(:), yq(:), and (if present) zq(:). It returns current density 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 Jintrp = reshape(Jintrp,size(yq)).

    Example: yq = [1 2 0 0.5]

    Data Types: double

    z-coordinate query points, specified as a real array. interpolateCurrentDensity evaluates the current density at the 3-D coordinate points [xq(i) yq(i) zq(i)]. Therefore, xq, yq, and zq must have the same number of entries.

    interpolateCurrentDensity converts the query points to column vectors xq(:), yq(:), and zq(:). It returns current density 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 Jintrp = reshape(Jintrp,size(zq)).

    Example: zq = [1 1 0 1.5]

    Data Types: double

    Query points, specified as a real matrix with either two rows for 2-D geometry or three rows for 3-D geometry. interpolateCurrentDensity evaluates the current density at the coordinate points querypoints(:,i) for every i, so each column of querypoints contains exactly one 2-D or 3-D query point.

    Example: For a 2-D geometry, querypoints = [0.5 0.5 0.75 0.75; 1 2 0 0.5]

    Data Types: double

    Output Arguments

    collapse all

    Current density at query points, returned as an FEStruct object with the properties representing the spatial components of the current density at the query points. For query points that are outside the geometry, Jintrp.Jx(i), Jintrp.Jy(i), and Jintrp.Jz(i) are NaN. Properties of an FEStruct object are read-only.

    Version History

    Introduced in R2022b