Main Content

interpolateMaxwellStressTensor

Interpolate Maxwell stress tensor at arbitrary spatial locations

Since R2024a

Description

MSTintrp = interpolateMaxwellStressTensor(results,xq,yq) returns the interpolated Maxwell stress tensor values at the 2-D points specified in xq and yq. To enable the interpolation, the results object must contain the Maxwell stress tensor data in its MaxwellStressTensor property.

example

MSTintrp = interpolateMaxwellStressTensor(results,xq,yq,zq) uses the 3-D points specified in xq, yq, and zq.

example

MSTintrp = interpolateMaxwellStressTensor(results,querypoints) uses the points specified in querypoints.

Examples

collapse all

Compute the Maxwell stress tensor at nodal locations, and then interpolate it to the specified grid.

Create a square geometry.

R1 = [3,4,-1,1,1,-1,1,1,-1,-1]';
g = decsg(R1,'R1',('R1')');

Create an femodel object for magnetostatic analysis. Include the square geometry.

model = femodel(AnalysisType="magnetostatic", ...
                    Geometry=g);

Plot the geometry with edge labels.

pdegplot(model,EdgeLabels="on")
xlim([-1.1 1.1])
ylim([-1.1 1.1])

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

Specify the vacuum permeability in the SI system of units.

model.VacuumPermeability = 1.2566370614e-6;

Specify the relative permeability of the material.

model.MaterialProperties = ...
        materialProperties(RelativePermeability=5000);

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

model.EdgeBC([1 3]) = edgeBC(MagneticPotential=0);
model.EdgeBC([2 4]) = edgeBC(MagneticPotential=0.01);

Specify the current density for the entire geometry.

model.FaceLoad = faceLoad(CurrentDensity=0.5);

Generate the mesh. This assignment updates the mesh stored in the Geometry property of the model.

model = generateMesh(model);

Solve the model. The solution R is a MagnetostaticResults object. It does not include the Maxwell stress tensor by default.

R = solve(model)
R = 
  MagnetostaticResults with properties:

      MagneticPotential: [1529x1 double]
          MagneticField: [1x1 FEStruct]
    MagneticFluxDensity: [1x1 FEStruct]
                   Mesh: [1x1 FEMesh]

Generate the Maxwell stress tensor and store it as a property of the results object R.

R = generateMaxwellStressTensor(R)
R = 
  MagnetostaticResults with properties:

      MagneticPotential: [1529x1 double]
          MagneticField: [1x1 FEStruct]
    MagneticFluxDensity: [1x1 FEStruct]
                   Mesh: [1x1 FEMesh]
    MaxwellStressTensor: [2x2x1529 double]

Interpolate the resulting Maxwell stress tensor 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);

MSTintrp = interpolateMaxwellStressTensor(R,X,Y);

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

querypoints = [X(:),Y(:)]';
MSTintrp = interpolateMaxwellStressTensor(R,querypoints);

Compute the Maxwell stress tensor at nodal locations, and then interpolate it to the specified grid.

Create an femodel object for electrostatic analysis. Include a geometry representing a plate with a hole.

model = femodel(AnalysisType="electrostatic", ...
                    Geometry="PlateHoleSolid.stl");

Plot the geometry of the plate with face labels.

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

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

Specify the vacuum permittivity in the SI system of units.

model.VacuumPermittivity = 8.8541878128e-12;

Specify the relative permittivity of the material

model.MaterialProperties = ...
        materialProperties(RelativePermittivity=1);

Specify the charge density for the entire geometry.

model.CellLoad = cellLoad(ChargeDensity=5e-9);

Apply the voltage boundary conditions on the side faces and the face bordering the hole.

model.FaceBC(3:6) = faceBC(Voltage=0);
model.FaceBC(7) = faceBC(Voltage=1000);

Generate the mesh. This assignment updates the mesh stored in the Geometry property of the model.

model = generateMesh(model);

Solve the model. The solution R is an ElectrostaticResults object. It does not include the Maxwell stress tensor by default.

R = solve(model)
R = 
  ElectrostaticResults with properties:

      ElectricPotential: [4747x1 double]
          ElectricField: [1x1 FEStruct]
    ElectricFluxDensity: [1x1 FEStruct]
                   Mesh: [1x1 FEMesh]

Generate the Maxwell stress tensor and store it as a property of the results object R.

R = generateMaxwellStressTensor(R)
R = 
  ElectrostaticResults with properties:

      ElectricPotential: [4747x1 double]
          ElectricField: [1x1 FEStruct]
    ElectricFluxDensity: [1x1 FEStruct]
                   Mesh: [1x1 FEMesh]
    MaxwellStressTensor: [3x3x4747 double]

Interpolate the resulting Maxwell stress tensor to a grid covering the entire geometry, for x, y, and z.

x = linspace(0,10,11);
y = linspace(0,1,5);
z = linspace(0,20,11);
[X,Y,Z] = meshgrid(x,y,z);

MSTintrp = interpolateMaxwellStressTensor(R,X,Y,Z);

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

querypoints = [X(:),Y(:),Z(:)]';
MSTintrp = interpolateMaxwellStressTensor(R,querypoints);

Input Arguments

collapse all

Electrostatic or magnetostatic solution, specified as an ElectrostaticResults or MagnetostaticResults object containing the Maxwell stress tensor at mesh nodes in its MaxwellStressTensor property.

Create results by first using the solve function to solve an electrostatic or magnetostatic problem and then using generateMaxwellStressTensor to add the Maxwell stress tensor to the resulting object.

x-coordinate query points, specified as a real array. interpolateMaxwellStressTensor evaluates the Maxwell stress tensor 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. Therefore, xq, yq, and (if present) zq must have the same number of entries.

Data Types: double

y-coordinate query points, specified as a real array. interpolateMaxwellStressTensor evaluates the Maxwell stress tensor 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. Therefore, xq, yq, and (if present) zq must have the same number of entries.

Data Types: double

z-coordinate query points, specified as a real array. interpolateMaxwellStressTensor evaluates the Maxwell stress tensor at the 3-D coordinate points [xq(i) yq(i) zq(i)] for every i. Therefore, xq, yq, and zq must have the same number of entries.

Data Types: double

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

Data Types: double

Output Arguments

collapse all

Maxwell stress tensor at query points, returned as a 2-by-2-by-N real array for a 2-D geometry or a 3-by-3-by-N real array for a 3-D geometry. Here, N is the number of query points. For query points i that are outside the geometry, MSTintrp(:,:,i) are NaN.

Data Types: double

Tips

  • Generate the Maxwell stress tensor at nodal locations by using generateMaxwellStressTensor before interpolating the Maxwell stress tensor at arbitrary spatial locations. The interpolateMaxwellStressTensor function errors if the ElectrostaticResults or MagnetostaticResults object does not have data in its MaxwellStressTensor property.

Version History

Introduced in R2024a