Main Content

MagnetostaticResults

Magnetostatic solution and derived quantities

Since R2021a

    Description

    A MagnetostaticResults object contains the magnetic potential, magnetic field, magnetic flux density, and mesh values in a form convenient for plotting and postprocessing.

    The magnetic potential, magnetic field, and magnetic flux density are calculated at the nodes of the triangular or tetrahedral mesh generated by generateMesh. Magnetic potential values at the nodes appear in the MagneticPotential property. Magnetic field values at the nodes appear in the MagneticField property. Magnetic flux density values at the nodes appear in the MagneticFluxDensity property.

    To interpolate the magnetic potential, magnetic field, and magnetic flux density to a custom grid, such as the one specified by meshgrid, use the interpolateMagneticPotential, interpolateMagneticField, and interpolateMagneticFlux functions.

    Creation

    Solve a magnetostatic problem using the solve function. This function returns a solution as a MagnetostaticResults object.

    Properties

    expand all

    This property is read-only.

    Magnetic potential values at nodes, returned as a vector for a 2-D problem or an FEStruct object for a 3-D problem. The properties of this object contain the components of the magnetic potential at nodes.

    This property is read-only.

    Magnetic field values at nodes, returned as an FEStruct object. The properties of this object contain the components of the magnetic field at nodes.

    This property is read-only.

    Magnetic flux density values at nodes, returned as an FEStruct object. The properties of this object contain the components of the magnetic flux density at nodes.

    This property is read-only.

    Maxwell stress tensor at nodes, 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 nodes.

    By default, this property is empty and not displayed. The toolbox displays this property of the MagnetostaticResults object only after you call the generateMaxwellStressTensor function.

    Data Types: double

    This property is read-only.

    Finite element mesh, returned as an FEMesh object. For a 3-D geometry, the mesh must be linear.

    Object Functions

    generateMaxwellStressTensorCompute Maxwell stress tensor at nodal locations
    interpolateMagneticPotentialInterpolate magnetic potential in magnetostatic result at arbitrary spatial locations
    interpolateMagneticFieldInterpolate magnetic field in magnetostatic result at arbitrary spatial locations
    interpolateMagneticFluxInterpolate magnetic flux density in magnetostatic result at arbitrary spatial locations
    interpolateMaxwellStressTensorInterpolate Maxwell stress tensor at arbitrary spatial locations

    Examples

    collapse all

    Solve a 2-D electromagnetic problem on a geometry representing a plate with a hole in its center. Plot the resulting magnetic potential and field distribution.

    Create an femodel object for magnetostatic analysis and include a geometry representing a plate with a hole.

    model = femodel(AnalysisType="magnetostatic", ...
                    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 vacuum permeability value 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 edges framing the rectangle and the circle.

    model.EdgeBC(1:4) = edgeBC(MagneticPotential=0); 
    model.EdgeBC(5) = edgeBC(MagneticPotential=0.01);

    Specify the current density for the entire geometry.

    model.FaceLoad = faceLoad(CurrentDensity=0.5);

    Generate the mesh.

    model = generateMesh(model);

    Solve the problem.

    R = solve(model)
    R = 
      MagnetostaticResults with properties:
    
          MagneticPotential: [1231x1 double]
              MagneticField: [1x1 FEStruct]
        MagneticFluxDensity: [1x1 FEStruct]
                       Mesh: [1x1 FEMesh]
    
    

    Plot the magnetic potential and field.

    pdeplot(R.Mesh,XYData=R.MagneticPotential, ...
                   FlowData=[R.MagneticField.Hx ...
                             R.MagneticField.Hy])
    axis equal

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

    Solve a 3-D electromagnetic problem on a geometry representing a plate with a hole in its center. Plot the resulting magnetic potential and field distribution.

    Create an femodel object for magnetostatic analysis and include a geometry representing a plate with a hole.

    model = femodel(AnalysisType="magnetostatic", ...
                    Geometry="PlateHoleSolid.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 vacuum permeability value 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 side faces and the face bordering the hole.

    model.FaceBC(3:6) = faceBC(MagneticPotential=[0;0;0]); 
    model.FaceBC(7) = faceBC(MagneticPotential=[0;0;0.01]);

    Specify the current density for the entire geometry.

    model.CellLoad = cellLoad(CurrentDensity=[0;0;0.5]);

    Generate the mesh.

    model = generateMesh(model);

    Solve the model.

    R = solve(model)
    R = 
      MagnetostaticResults with properties:
    
          MagneticPotential: [1x1 FEStruct]
              MagneticField: [1x1 FEStruct]
        MagneticFluxDensity: [1x1 FEStruct]
                       Mesh: [1x1 FEMesh]
    
    

    Plot the z-component of the magnetic potential.

    pdeplot3D(R.Mesh,ColormapData=R.MagneticPotential.Az)

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

    Plot the magnetic field.

    pdeplot3D(R.Mesh,FlowData=[R.MagneticField.Hx ...
                               R.MagneticField.Hy ...
                               R.MagneticField.Hz])

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

    Use a solution obtained by performing a DC conduction analysis to specify current density for a magnetostatic problem.

    Create an femodel object for DC conduction analysis and include a geometry representing a plate with a hole.

    model = femodel(AnalysisType="dcConduction", ...
                    Geometry="PlateHoleSolid.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 left, right, top, and bottom faces of the plate.

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

    Specify the surface current density on the face bordering the hole.

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

    Generate the mesh.

    model = generateMesh(model);

    Solve the model.

    R = solve(model);

    Change the analysis type of the model to magnetostatic.

    model.AnalysisType = "magnetostatic";

    This model already has a quadratic mesh that you generated for the DC conduction analysis. For a 3-D magnetostatic model, the mesh must be linear. Generate a new linear mesh. The generateMesh function creates a linear mesh by default if the model is 3-D and magnetostatic.

    model = generateMesh(model);

    Specify the vacuum permeability value 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 side faces and the face bordering the hole.

    model.FaceBC(3:6) = faceBC(MagneticPotential=[0;0;0]);
    model.FaceBC(7) = faceBC(MagneticPotential=[0;0;0.01]);

    Specify the current density for the entire geometry using the DC conduction solution.

    model.CellLoad = cellLoad(CurrentDensity=R);

    Solve the problem.

    Rmagnetostatic = solve(model);

    Plot the x- and z-components of the magnetic potential.

    pdeplot3D(Rmagnetostatic.Mesh, ...
              ColormapData=Rmagnetostatic.MagneticPotential.Ax)

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

    pdeplot3D(Rmagnetostatic.Mesh, ...
              ColormapData=Rmagnetostatic.MagneticPotential.Az)

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

    Solve a magnetostatic problem of a copper square with a permanent neodymium magnet in its center.

    Create the unit square geometry with a circle in its center.

    L = 0.8;
    r = 0.25;
    sq = [3 4 -L L L -L -L -L L L]';
    circ = [1 0 0 r 0 0 0 0 0 0]';
    gd = [sq,circ];
    sf = "sq + circ";
    ns = char('sq','circ');
    ns = ns';
    g = decsg(gd,sf,ns);

    Plot the geometry with the face and edge labels.

    pdegplot(g,FaceLabels="on",EdgeLabels="on")

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

    Create an femodel object for magnetostatic analysis and include the geometry in the model.

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

    Specify the vacuum permeability value in the SI system of units.

    model.VacuumPermeability = 1.2566370614e-6;

    Specify the relative permeability of the copper for the square.

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

    Specify the relative permeability of the neodymium for the circle.

    model.MaterialProperties(2) = ...
        materialProperties(RelativePermeability=1.05);

    Specify the magnetization magnitude for the neodymium magnet.

    M = 1e6;

    Specify magnetization on the circular face in the positive x-direction. Magnetization for a 2-D model is a column vector of two elements.

    dir = [1;0];
    model.FaceLoad(2) = faceLoad(Magnetization=M*dir);

    Apply the magnetic potential boundary conditions on the edges framing the square.

    model.EdgeBC(1:4) = edgeBC(MagneticPotential=0);

    Generate the mesh with finer meshing near the edges of the circle.

    model = generateMesh(model,Hedge={5:8,0.007});
    figure
    pdemesh(model)

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

    Solve the problem, and find the resulting magnetic fields B and H. Here, B=μH+μ0M, where μ is the absolute magnetic permeability of the material, μ0 is the vacuum permeability, and M is the magnetization.

    R = solve(model);
    Bmag = sqrt(R.MagneticFluxDensity.Bx.^2 + R.MagneticFluxDensity.By.^2);
    Hmag = sqrt(R.MagneticField.Hx.^2 + R.MagneticField.Hy.^2);

    Plot the magnetic field B.

    figure
    pdeplot(R.Mesh,XYData=Bmag, ...
                   FlowData=[R.MagneticFluxDensity.Bx ...
                             R.MagneticFluxDensity.By])

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

    Plot the magnetic field H.

    figure
    pdeplot(R.Mesh,XYData=Hmag, ...
                   FlowData=[R.MagneticField.Hx R.MagneticField.Hy])

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

    Version History

    Introduced in R2021a