|
Phyth v0.1.0
A dimensional safe C++ header-only mechanics and electromagnetics simulation library.
|
Uniform volume charge distribution in a rectangular box. More...
#include <VolumeSource.hpp>


Private Member Functions | |
| Vector3< Quantity< NewtonPerCoulomb > > | NumericalIntegrateField (const Vector3< Quantity< Meter > > &point, const int nx, const int ny, const int nz) const |
| Numerical integration of electric field over the volume. | |
| Quantity< Volt > | NumericalIntegratePotential (const Vector3< Quantity< Meter > > &point, const int nx, const int ny, const int nz) const |
| Numerical integration of electric potential over the volume. | |
Private Attributes | |
| Vector3< Quantity< Meter > > | center_ |
| Vector3< Scalar > | axis_x_ |
| Vector3< Scalar > | axis_y_ |
| Vector3< Scalar > | axis_z_ |
| Quantity< Meter > | size_x_ |
| Quantity< Meter > | size_y_ |
| Quantity< Meter > | size_z_ |
| Quantity< CoulombPerCubicMeter > | rho_ |
Uniform volume charge distribution in a rectangular box.
VolumeCharge represents a rectangular box with uniform volume charge density rho (C/m^3). The box is defined by its center, three orthogonal axes, and dimensions along each axis.
Field and potential are computed by numerical integration over the volume using the midpoint rule. Default resolution is 16x16x16 segments.
Example: auto center = Vector3<Quantity<Meter>>(0_m, 0_m, 0_m); auto ex = Vector3<Scalar>(1, 0, 0); auto ey = Vector3<Scalar>(0, 1, 0); auto ez = Vector3<Scalar>(0, 0, 1); auto rho = 1.0e-6_C/m3;
VolumeCharge volume(center, ex, ey, ez, 1.0_m, 1.0_m, 1.0_m, rho); auto point = Vector3<Quantity<Meter>>(0_m, 0_m, 0.5_m); auto E = volume.GetElectricFieldAt(point); auto V = volume.GetElectricPotentialAt(point);
Note: The field is evaluated numerically, so accuracy depends on the integration resolution. Higher resolution improves accuracy but increases computation time.
Definition at line 36 of file VolumeSource.hpp.
|
inline |
Construct a rectangular volume charge.
| center | Center of the box (meters) |
| axis_x | Direction of the x-axis (must be unit vector) |
| axis_y | Direction of the y-axis (must be unit vector) |
| axis_z | Direction of the z-axis (must be unit vector) |
| size_x | Length along axis_x (meters) |
| size_y | Length along axis_y (meters) |
| size_z | Length along axis_z (meters) |
| rho | Volume charge density (C/m^3) |
The three axes must be mutually orthogonal. This is checked at runtime with asserts.
Definition at line 53 of file VolumeSource.hpp.
|
inlineoverridevirtual |
Get the charge density at a point.
| point | Position to evaluate (meters) |
This overrides the default implementation to return the actual charge density for points inside the volume.
Reimplemented from Phyth::Electromagnetics::ChargeSource.
Definition at line 141 of file VolumeSource.hpp.
|
inlineoverridevirtual |
Compute the electric field at a point using numerical integration.
| point | Position to evaluate the field (meters) |
The field is integrated using the midpoint rule with 16x16x16 segments. Points inside the volume are skipped (their contribution is ignored).
Implements Phyth::Electromagnetics::ChargeSource.
Definition at line 79 of file VolumeSource.hpp.
|
inlineoverridevirtual |
Compute the electric potential at a point using numerical integration.
| point | Position to evaluate the potential (meters) |
The potential is integrated using the midpoint rule with 16x16x16 segments. Points inside the volume are skipped (their contribution is ignored).
Implements Phyth::Electromagnetics::ChargeSource.
Definition at line 93 of file VolumeSource.hpp.
|
inlineoverridevirtual |
Get the minimum distance from a point to the rectangular box.
| point | Position to compute distance from |
The closest point is found by projecting the point onto the box axes and clamping to the box bounds. If the point is inside the box, the minimum distance is 0.
Implements Phyth::Electromagnetics::ChargeSource.
Definition at line 117 of file VolumeSource.hpp.
|
inlineoverridevirtual |
Get the total charge of the volume.
Implements Phyth::Electromagnetics::ChargeSource.
Definition at line 102 of file VolumeSource.hpp.
|
inlineprivate |
Numerical integration of electric field over the volume.
Uses the midpoint rule with nx * ny * nz segments. Each segment contributes dE = k_E * dq / r^2 * hat_r.
| point | Evaluation point |
| nx | Number of segments along x axis |
| ny | Number of segments along y axis |
| nz | Number of segments along z axis |
Definition at line 172 of file VolumeSource.hpp.
|
inlineprivate |
Numerical integration of electric potential over the volume.
Uses the midpoint rule with nx * ny * nz segments. Each segment contributes dV = k_E * dq / r.
| point | Evaluation point |
| nx | Number of segments along x axis |
| ny | Number of segments along y axis |
| nz | Number of segments along z axis |
Definition at line 214 of file VolumeSource.hpp.
Definition at line 155 of file VolumeSource.hpp.
Definition at line 155 of file VolumeSource.hpp.
Definition at line 155 of file VolumeSource.hpp.
Definition at line 154 of file VolumeSource.hpp.
|
private |
Definition at line 157 of file VolumeSource.hpp.
Definition at line 156 of file VolumeSource.hpp.
Definition at line 156 of file VolumeSource.hpp.
Definition at line 156 of file VolumeSource.hpp.