1#ifndef PHYTH_LINE_CHARGE_HPP
2#define PHYTH_LINE_CHARGE_HPP
127 throw std::runtime_error(
"LineCharge: potential diverges on line charge");
134 throw std::runtime_error(
"LineCharge: point lies on the line charge");
159 const auto dist =
r.Length();
Abstract base class for all charge distributions.
Uniform line charge along a straight segment.
Quantity< Coulomb > GetTotalChargeValue() const override
Get the total charge of the line.
Vector3< Quantity< Meter > > start_
Vector3< Quantity< NewtonPerCoulomb > > GetElectricFieldAt(const Vector3< Quantity< Meter > > &point) const override
Compute the electric field at a point using numerical integration.
LineCharge(const Vector3< Quantity< Meter > > &start, const Vector3< Quantity< Meter > > &end, const Quantity< CoulombPerMeter > lambda)
Construct a uniform line charge.
Quantity< Meter > GetMinimumDistanceTo(const Vector3< Quantity< Meter > > &point) const override
Get the minimum distance from a point to the line segment.
Vector3< Scalar > direction_
Quantity< Volt > AnalyticPotential(const Vector3< Quantity< Meter > > &point) const
Analytic potential for finite line charge.
Vector3< Quantity< Meter > > end_
Quantity< CoulombPerMeter > lambda_
Quantity< Volt > GetElectricPotentialAt(const Vector3< Quantity< Meter > > &point) const override
Compute the electric potential at a point using analytic formula.
Vector3< Quantity< NewtonPerCoulomb > > NumericalIntegrateField(const Vector3< Quantity< Meter > > &point, const int segments) const
Numerical integration of electric field along the line.
Quantity< Meter > length_
Scalar log(const Scalar q)
Natural logarithm (base e)
Quantity< UnitT > clamp(Quantity< UnitT > x, Quantity< UnitT > min, Quantity< UnitT > max)
Clamp a quantity between min and max bounds.
Dimension< std::ratio< 1 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 > > Length
Physical quantity with a value and a compile-time unit.
3D vector with Quantity components