Skip to content

Charge Density Condition

The charge density condition specifies the distribution of charge density \(\rho\) in a volume, on a surface, or along a line (wire) depending on the provided marker:

\[ \left. \rho \right|_{\Omega} = \rho_0(x,y,z), \]

where \(\Omega\) is the given region of space (volume, surface, or line) and \(\rho_0(x,y,z)\) is the desired charge density (in C/m³, C/m², or C/m respectively).

When to use this

  • Surface charges on dielectric or floating-conductor surfaces (electrostatic-discharge studies, verification cases).
  • Space charge in semiconductors and insulators — supply a spatially varying \(\rho\) from a doping or carrier-density model.
  • Line charges for thin wires when meshing the full cross-section would be wasteful.
  • Benchmark cases with prescribed analytic distributions.

Usage

A scalar value is auto-wrapped into a coefficient:

from mufem.electromagnetics.electrostatics import ChargeDensityCondition

charge_bc = ChargeDensityCondition(
    name="Surface Charge",
    marker="DielectricInterface" @ Bnd,
    charge_density=1.0e-6,  # C/m^2 on a boundary marker
)

electrostatics_model.add_condition(charge_bc)

A coefficient function can be passed directly for non-uniform distributions:

import mufem

cff_rho = mufem.CffExpressionScalar(
    "1e-3 * exp(-(x()^2 + y()^2) / 0.01)"
)

charge_bc = ChargeDensityCondition(
    name="Gaussian Volume Charge",
    marker="Insulator" @ Vol,
    charge_density=cff_rho,
)