Main Content

HarmonicResults

Harmonic electromagnetic solution

Since R2022a

    Description

    A HarmonicResults object contains the electric or magnetic field, frequency, and mesh values in a form convenient for plotting and postprocessing.

    The electric or magnetic field values are calculated at the nodes of the triangular or tetrahedral mesh generated by generateMesh. Electric field values at the nodes appear in the ElectricField property. Magnetic field values at the nodes appear in the MagneticField property.

    To interpolate the electric or magnetic field to a custom grid, such as the one specified by meshgrid, use the interpolateHarmonicField function.

    Creation

    Solve a harmonic electromagnetic analysis problem using the solve function. This function returns a solution as a HarmonicResults object.

    Properties

    expand all

    This property is read-only.

    Electric field values at nodes, returned as an FEStruct object. The properties of this object contain the components of the electric field 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.

    Solution frequencies, returned as a vector.

    Data Types: double

    This property is read-only.

    Finite element mesh, returned as an FEMesh object.

    Object Functions

    interpolateHarmonicFieldInterpolate electric or magnetic field in harmonic result at arbitrary spatial locations

    Examples

    collapse all

    For an electromagnetic harmonic analysis problem, find the x- and y-components of the electric field. Solve the problem on a domain consisting of a square with a circular hole.

    For the geometry, define a circle in a square, place them in one matrix, and create a set formula that subtracts the circle from the square.

    SQ = [3,4,-5,-5,5,5,-5,5,5,-5]';
    C = [1,0,0,1]';
    C = [C;zeros(length(SQ) - length(C),1)];
    gm = [SQ,C];
    sf = 'SQ-C';

    Create the geometry.

    ns = char('SQ','C');
    ns = ns';
    g = decsg(gm,sf,ns);

    Create an femodel object for electromagnetic harmonic analysis with an electric field type. Include the geometry in the model.

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

    Plot the geometry with the edge labels.

    pdegplot(model.Geometry,EdgeLabels="on")
    xlim([-5.5 5.5])
    ylim([-5.5 5.5])

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

    Specify the vacuum permittivity and permeability values as 1.

    model.VacuumPermittivity = 1;
    model.VacuumPermeability = 1;

    Specify the relative permittivity, relative permeability, and conductivity of the material.

    model.MaterialProperties = ...
        materialProperties(RelativePermittivity=1, ...
                           RelativePermeability=1, ...
                           ElectricalConductivity=0);

    Apply the absorbing boundary condition with a thickness of 2 on the edges of the square. Use the default attenuation rate for the absorbing region.

    ffbc = farFieldBC(Thickness=2);
    model.EdgeBC(1:4) = edgeBC(FarField=ffbc);

    Specify an electric field on the edges of the hole.

    E = @(location,state) [1;0]*exp(-1i*2*pi*location.y); 
    model.EdgeBC(5:8) = edgeBC(ElectricField=E);

    Generate a mesh.

    model = generateMesh(model,Hmax=1/2^3);

    Solve the model for a frequency of 2π.

    result = solve(model,2*pi);

    Plot the real part of the x-component of the resulting electric field.

    figure
    pdeplot(result.Mesh,XYData=real(result.ElectricField.Ex));
    title("Real Part of x-Component of Electric Field")

    Figure contains an axes object. The axes object with title Real Part of x-Component of Electric Field contains an object of type patch.

    Plot the real part of the y-component of the resulting electric field.

    figure
    pdeplot(result.Mesh,XYData=real(result.ElectricField.Ey));
    title("Real Part of y-Component of Electric Field")

    Figure contains an axes object. The axes object with title Real Part of y-Component of Electric Field contains an object of type patch.

    Version History

    Introduced in R2022a