Main Content

findElectromagneticSource

Find electromagnetic source assigned to geometric region

Since R2021a

    Domain-specific electromagnetic workflow is not recommended. New features might not be compatible with this workflow. For help migrating your existing code to the unified finite element workflow, see Migration from Domain-Specific to Unified Workflow.

    Description

    emSource = findElectromagneticSource(sources,RegionType,RegionID) returns the change or current density emSource assigned to the specified region of the specified model.

    example

    Examples

    collapse all

    Create an electromagnetic model for magnetostatic analysis.

    emagmodel = createpde("electromagnetic","magnetostatic");

    Include the L-shaped membrane geometry in the model and plot it with the face labels.

    geometryFromEdges(emagmodel,@lshapeg);
    pdegplot(emagmodel,"FaceLabels","on")
    ylim([-1.1 1.1])
    axis equal

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

    Specify a different current density for each face.

    electromagneticSource(emagmodel,"Face",1,"CurrentDensity",10);
    electromagneticSource(emagmodel,"Face",2,"CurrentDensity",20);
    electromagneticSource(emagmodel,"Face",3,"CurrentDensity",30);

    Check the electromagnetic source specification for each face.

    findElectromagneticSource(emagmodel.Sources,"Face",1)
    ans = 
      ElectromagneticSourceAssignment with properties:
    
            RegionType: 'Face'
              RegionID: 1
         ChargeDensity: []
        CurrentDensity: 10
         Magnetization: []
    
    
    findElectromagneticSource(emagmodel.Sources,"Face",2)
    ans = 
      ElectromagneticSourceAssignment with properties:
    
            RegionType: 'Face'
              RegionID: 2
         ChargeDensity: []
        CurrentDensity: 20
         Magnetization: []
    
    
    findElectromagneticSource(emagmodel.Sources,"Face",3)
    ans = 
      ElectromagneticSourceAssignment with properties:
    
            RegionType: 'Face'
              RegionID: 3
         ChargeDensity: []
        CurrentDensity: 30
         Magnetization: []
    
    

    Create and plot a geometry consisting of two nested spheres.

    gm = multisphere([5 15]);
    pdegplot(gm,"CellLabels","on","FaceAlpha",0.3)

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

    Create an electromagnetic model for electrostatic analysis.

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

    Include the geometry in the model.

    emagmodel.Geometry = gm;

    Specify the charge density for the inner sphere.

    electromagneticSource(emagmodel,"Cell",1,"ChargeDensity",10);

    Check the electromagnetic source specification for each cell.

    findElectromagneticSource(emagmodel.Sources,"Cell",1)
    ans = 
      ElectromagneticSourceAssignment with properties:
    
            RegionType: 'Cell'
              RegionID: 1
         ChargeDensity: 10
        CurrentDensity: []
         Magnetization: []
    
    
    findElectromagneticSource(emagmodel.Sources,"Cell",2)
    ans = 
    
      0x1 ElectromagneticSourceAssignment array with properties:
    
        RegionType
        RegionID
        ChargeDensity
        CurrentDensity
        Magnetization
    

    Input Arguments

    collapse all

    Source in an electromagnetic model, specified as the Sources property of the model.

    Example: findElectromagneticSource(emagmodel.Sources,"Face",1)

    Geometric region type, specified as "Face" for a 2-D model or "Cell" for a 3-D model.

    Data Types: char | string

    Region ID, specified as a vector of positive integers. Find the face or cell IDs by using pdegplot with the "FaceLabels" or "CellLabels" name-value argument set to "on".

    Data Types: double

    Output Arguments

    collapse all

    Electromagnetic source assignment, returned as an ElectromagneticSourceAssignment object. For more information, see ElectromagneticSourceAssignment Properties.

    Version History

    Introduced in R2021a