Main Content

electromagneticSource

(To be removed) Specify current density, charge density, and magnetization for electromagnetic model

Since R2021a

    electromagneticSource will be removed. Use cellLoad and faceLoad instead. (since R2023a) For more information on updating your code, see Version History.

    Description

    electromagneticSource(emagmodel,"ChargeDensity",rho) specifies the charge density. The solver uses a charge density for an electrostatic analysis.

    example

    electromagneticSource(emagmodel,"CurrentDensity",J) specifies the current density. The solver uses a current density for magnetostatic or harmonic (time-harmonic) analyses.

    For a 3-D magnetostatic analysis, you can specify current density by using the DC conduction results. See ConductionResults. The toolbox does not support conduction results as a source of current density for a 2-D magnetostatic analysis, in which case current density must be a scalar or a function handle returning a scalar that represents out-of-plane current.

    electromagneticSource(emagmodel,"Magnetization",M) specifies the magnetization. The solver uses a magnetization to model permanent magnets in a magnetostatic workflow.

    electromagneticSource(___,RegionType,RegionID) specifies the charge or current density for the specified geometry region. Use this syntax with any of the input argument combinations in the previous syntaxes.

    emagSource = electromagneticSource(___) returns the electromagnetic source object.

    Examples

    collapse all

    Specify charge density on the entire geometry for an electrostatic analysis.

    emagmodel = createpde("electromagnetic","electrostatic");
    importGeometry(emagmodel,"PlateHoleSolid.stl");
    electromagneticSource(emagmodel,"ChargeDensity",10)
    ans = 
      ElectromagneticSourceAssignment with properties:
    
            RegionType: 'Cell'
              RegionID: 1
         ChargeDensity: 10
        CurrentDensity: []
         Magnetization: []
    
    

    Input Arguments

    collapse all

    Electromagnetic model, specified as an ElectromagneticModel object. The model contains a geometry, a mesh, the electromagnetic properties of the material, the electromagnetic sources, and the boundary conditions.

    Charge density, specified as a real number or a function handle. Use a function handle to specify a charge density that depends on the coordinates. For details, see More About.

    Data Types: double | function_handle

    Current density, specified as a real number, a column vector, a function handle, or a ConductionResults object. Use a function handle to specify a nonconstant current density.

    For magnetostatic analysis, the current density must be

    • A real number or a function handle for a 2-D model. The toolbox does not support conduction results as a source of current density for a 2-D magnetostatic analysis.

    • A column vector of three elements, a ConductionResults object, or a function handle for a 3-D model.

    For harmonic analysis with the electric field type, the toolbox multiplies the specified current density by -i and by frequency. The current density must be

    • A column vector of two elements or a function handle that depends on the coordinates for a 2-D model.

    • A column vector of three elements or a function handle that depends on the coordinates for a 3-D model.

    For harmonic analysis with the magnetic field type, the toolbox uses the curl of the specified current density. The current density must be

    • A scalar or a function handle that depends on the coordinates for a 2-D model.

    • A column vector of three elements or a function handle that depends on the coordinates for a 3-D model.

    For details, see More About.

    Data Types: double | function_handle

    Magnetization, specified as a column vector of two elements for a 2-D model, a column vector of three elements for a 3-D model, or a function handle. Use a function handle to specify a magnetization that depends on the coordinates. For details, see More About.

    Data Types: double | function_handle

    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".

    Example: electromagneticSource(emagmodel,"CurrentDensity",10,"Face",1:3)

    Data Types: double

    Output Arguments

    collapse all

    Handle to the electromagnetic source, returned as an ElectromagneticSourceAssignment object. For more information, see ElectromagneticSourceAssignment Properties.

    More About

    collapse all

    Version History

    Introduced in R2021a

    expand all