Phyth v0.1.0
A dimensional safe C++ header-only mechanics and electromagnetics simulation library.
Loading...
Searching...
No Matches
DipoleCharge.hpp
Go to the documentation of this file.
1#ifndef PHYTH_DIPOLE_CHARGE_HPP
2#define PHYTH_DIPOLE_CHARGE_HPP
3
4#include "ChargeSource.hpp"
6
30 class DipoleCharge : public ChargeSource {
31 public:
42
56 const auto r = point - position_;
57 const auto dist = r.Length();
59 throw std::runtime_error("DipoleCharge: field diverges at dipole location");
60 }
61
62 const auto hat_r = r.Normalized();
63 return Consts::k_E * (3 * p_.Dot(hat_r) * hat_r - p_) / (dist * dist * dist);
64 }
65
79 const auto r = point - position_;
80 const auto dist = r.Length();
82 throw std::runtime_error("DipoleCharge: potential diverges at dipole location");
83 }
84
85 const auto hat_r = r.Normalized();
86 return Consts::k_E * p_.Dot(hat_r) / (dist * dist);
87 }
88
95 return 0_C;
96 }
97
106 return (point - position_).Length();
107 }
108
113
114 private:
117 };
118} // namespace Phyth::Electromagnetics
119
120#endif // PHYTH_DIPOLE_CHARGE_HPP
Abstract base class for all charge distributions.
Ideal electric dipole with zero net charge.
Vector3< Quantity< NewtonPerCoulomb > > GetElectricFieldAt(const Vector3< Quantity< Meter > > &point) const override
Compute the electric field of the dipole.
Vector3< Quantity< CoulombMeter > > GetDipoleMoment() const
Vector3< Quantity< Meter > > position_
Vector3< Quantity< CoulombMeter > > p_
DipoleCharge(const Vector3< Quantity< Meter > > &position, const Vector3< Quantity< CoulombMeter > > &dipole_moment)
Construct an electric dipole.
Quantity< Meter > GetMinimumDistanceTo(const Vector3< Quantity< Meter > > &point) const override
Get the minimum distance from a point to the dipole location.
Quantity< Coulomb > GetTotalChargeValue() const override
Get the total charge of the dipole.
Quantity< Volt > GetElectricPotentialAt(const Vector3< Quantity< Meter > > &point) const override
Compute the electric potential of the dipole.
double epsilon
Definition Config.hpp:13
constexpr auto k_E
constexpr bool is_unit_v
Definition Unit.hpp:79
Physical quantity with a value and a compile-time unit.
Definition Quantity.hpp:27
3D vector with Quantity components
Definition Vector3.hpp:28