Phyth v0.1.0
A dimensional safe C++ header-only mechanics and electromagnetics simulation library.
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Phyth::Electromagnetics::SurfaceCharge Class Reference

Uniform surface charge distribution on a rectangular patch. More...

#include <SurfaceCharge.hpp>

Inheritance diagram for Phyth::Electromagnetics::SurfaceCharge:
Inheritance graph
[legend]
Collaboration diagram for Phyth::Electromagnetics::SurfaceCharge:
Collaboration graph
[legend]

Public Member Functions

 SurfaceCharge (const Vector3< Quantity< Meter > > &center, const Vector3< Scalar > &u_axis, const Vector3< Scalar > &v_axis, const Quantity< Meter > width, const Quantity< Meter > height, const Quantity< CoulombPerSquareMeter > sigma)
 Construct a rectangular surface charge.
 
Vector3< Quantity< NewtonPerCoulomb > > GetElectricFieldAt (const Vector3< Quantity< Meter > > &point) const override
 Compute the electric field at a point using numerical integration.
 
Quantity< Volt > GetElectricPotentialAt (const Vector3< Quantity< Meter > > &point) const override
 Compute the electric potential at a point using numerical integration.
 
Quantity< Coulomb > GetTotalChargeValue () const override
 Get the total charge of the surface.
 
Quantity< Meter > GetMinimumDistanceTo (const Vector3< Quantity< Meter > > &point) const override
 Get the minimum distance from a point to the rectangular surface.
 
Quantity< CoulombPerSquareMeter > GetSurfaceDensity () const
 
- Public Member Functions inherited from Phyth::Electromagnetics::ChargeSource
virtual ~ChargeSource ()=default
 
virtual Quantity< CoulombPerCubicMeter > GetChargeDensityAt (const Vector3< Quantity< Meter > > &point) const
 Get the charge density at a point.
 

Private Member Functions

Vector3< Quantity< NewtonPerCoulomb > > NumericalIntegrateField (const Vector3< Quantity< Meter > > &point, const int nu, const int nv) const
 Numerical integration of electric field over the surface.
 
Quantity< Volt > NumericalIntegratePotential (const Vector3< Quantity< Meter > > &point, const int nu, const int nv) const
 Numerical integration of electric potential over the surface.
 

Private Attributes

Vector3< Quantity< Meter > > center_
 
Vector3< Scalar > u_axis_
 
Vector3< Scalar > v_axis_
 
Quantity< Meter > width_
 
Quantity< Meter > height_
 
Quantity< CoulombPerSquareMeter > sigma_
 

Detailed Description

Uniform surface charge distribution on a rectangular patch.

SurfaceCharge represents a flat rectangular surface with uniform charge density sigma (C/m^2). The surface is defined by its center, two orthogonal axes (u and v), and dimensions (width and height).

Field and potential are computed by numerical integration over the surface using the midpoint rule. Default resolution is 32x32 segments.

Example: auto center = Vector3<Quantity<Meter>>(0_m, 0_m, 0_m); auto u_axis = Vector3<Scalar>(1, 0, 0); auto v_axis = Vector3<Scalar>(0, 1, 0); auto sigma = 1.0e-9_C/m2;

SurfaceCharge surface(center, u_axis, v_axis, 1.0_m, 1.0_m, sigma); auto point = Vector3<Quantity<Meter>>(0_m, 0_m, 0.1_m); auto E = surface.GetElectricFieldAt(point); auto V = surface.GetElectricPotentialAt(point);

Note: The field is evaluated numerically, so accuracy depends on the integration resolution.

Definition at line 34 of file SurfaceCharge.hpp.

Constructor & Destructor Documentation

◆ SurfaceCharge()

Phyth::Electromagnetics::SurfaceCharge::SurfaceCharge ( const Vector3< Quantity< Meter > > &  center,
const Vector3< Scalar > &  u_axis,
const Vector3< Scalar > &  v_axis,
const Quantity< Meter >  width,
const Quantity< Meter >  height,
const Quantity< CoulombPerSquareMeter >  sigma 
)
inline

Construct a rectangular surface charge.

Parameters
centerCenter of the rectangle (meters)
u_axisDirection of the width axis (must be unit vector)
v_axisDirection of the height axis (must be unit vector)
widthLength along u_axis (meters)
heightLength along v_axis (meters)
sigmaSurface charge density (C/m^2)

u_axis and v_axis must be orthogonal. This is checked at runtime with an assert.

Definition at line 49 of file SurfaceCharge.hpp.

Member Function Documentation

◆ GetElectricFieldAt()

Vector3< Quantity< NewtonPerCoulomb > > Phyth::Electromagnetics::SurfaceCharge::GetElectricFieldAt ( const Vector3< Quantity< Meter > > &  point) const
inlineoverridevirtual

Compute the electric field at a point using numerical integration.

Parameters
pointPosition to evaluate the field (meters)
Returns
Electric field intensity E (N/C)

The field is integrated using the midpoint rule with 32x32 segments. Points on the surface are skipped (their contribution is ignored).

Implements Phyth::Electromagnetics::ChargeSource.

Definition at line 71 of file SurfaceCharge.hpp.

◆ GetElectricPotentialAt()

Quantity< Volt > Phyth::Electromagnetics::SurfaceCharge::GetElectricPotentialAt ( const Vector3< Quantity< Meter > > &  point) const
inlineoverridevirtual

Compute the electric potential at a point using numerical integration.

Parameters
pointPosition to evaluate the potential (meters)
Returns
Electric potential V (Volts)

The potential is integrated using the midpoint rule with 32x32 segments. Points on the surface are skipped (their contribution is ignored).

Implements Phyth::Electromagnetics::ChargeSource.

Definition at line 85 of file SurfaceCharge.hpp.

◆ GetMinimumDistanceTo()

Quantity< Meter > Phyth::Electromagnetics::SurfaceCharge::GetMinimumDistanceTo ( const Vector3< Quantity< Meter > > &  point) const
inlineoverridevirtual

Get the minimum distance from a point to the rectangular surface.

Parameters
pointPosition to compute distance from
Returns
Distance to the closest point on the surface (meters)

The closest point is found by projecting the point onto the surface plane and clamping to the rectangle bounds.

Implements Phyth::Electromagnetics::ChargeSource.

Definition at line 108 of file SurfaceCharge.hpp.

◆ GetSurfaceDensity()

Quantity< CoulombPerSquareMeter > Phyth::Electromagnetics::SurfaceCharge::GetSurfaceDensity ( ) const
inline
Returns
The surface charge density sigma (C/m^2)

Definition at line 122 of file SurfaceCharge.hpp.

◆ GetTotalChargeValue()

Quantity< Coulomb > Phyth::Electromagnetics::SurfaceCharge::GetTotalChargeValue ( ) const
inlineoverridevirtual

Get the total charge of the surface.

Returns
sigma * width * height (Coulombs)

Implements Phyth::Electromagnetics::ChargeSource.

Definition at line 94 of file SurfaceCharge.hpp.

◆ NumericalIntegrateField()

Vector3< Quantity< NewtonPerCoulomb > > Phyth::Electromagnetics::SurfaceCharge::NumericalIntegrateField ( const Vector3< Quantity< Meter > > &  point,
const int  nu,
const int  nv 
) const
inlineprivate

Numerical integration of electric field over the surface.

Uses the midpoint rule with nu * nv segments. Each segment contributes dE = k_E * dq / r^2 * hat_r.

Parameters
pointEvaluation point
nuNumber of segments along u axis
nvNumber of segments along v axis
Returns
Electric field intensity E (N/C)

Definition at line 142 of file SurfaceCharge.hpp.

◆ NumericalIntegratePotential()

Quantity< Volt > Phyth::Electromagnetics::SurfaceCharge::NumericalIntegratePotential ( const Vector3< Quantity< Meter > > &  point,
const int  nu,
const int  nv 
) const
inlineprivate

Numerical integration of electric potential over the surface.

Uses the midpoint rule with nu * nv segments. Each segment contributes dV = k_E * dq / r.

Parameters
pointEvaluation point
nuNumber of segments along u axis
nvNumber of segments along v axis
Returns
Electric potential V (Volts)

Definition at line 178 of file SurfaceCharge.hpp.

Member Data Documentation

◆ center_

Vector3<Quantity<Meter> > Phyth::Electromagnetics::SurfaceCharge::center_
private

Definition at line 125 of file SurfaceCharge.hpp.

◆ height_

Quantity<Meter> Phyth::Electromagnetics::SurfaceCharge::height_
private

Definition at line 127 of file SurfaceCharge.hpp.

◆ sigma_

Quantity<CoulombPerSquareMeter> Phyth::Electromagnetics::SurfaceCharge::sigma_
private

Definition at line 128 of file SurfaceCharge.hpp.

◆ u_axis_

Vector3<Scalar> Phyth::Electromagnetics::SurfaceCharge::u_axis_
private

Definition at line 126 of file SurfaceCharge.hpp.

◆ v_axis_

Vector3<Scalar> Phyth::Electromagnetics::SurfaceCharge::v_axis_
private

Definition at line 126 of file SurfaceCharge.hpp.

◆ width_

Quantity<Meter> Phyth::Electromagnetics::SurfaceCharge::width_
private

Definition at line 127 of file SurfaceCharge.hpp.


The documentation for this class was generated from the following file: