dipole module
Module contains the Dipole class.
The Dipole class represents a pair of oscillating point charges whose
trajectories are updated at each time step during the simulation. The positive
and negative charge pair are represented as _DipoleCharge objects, which
are a subclass of the Charge base class. The trajectories of these charges
are determined at each time step using the run method from the instantiated
Simulation object, which accepts Charge and Dipole objects as
initialization parameters.
All units are in SI.
Dipole
Oscillating dipole with a moment that is dependent on driving E field.
Class simulates an oscillating dipole with a time-dependent origin and
has a dipole moment that is determined by the Lorentz oscillator equation
of motion. The dipole moment is updated at each time step in the simulation
by the Simulation object.
The Lorentz oscillator equation of motion is given by (Novotny Eq. 8.135):
\(d''(t) + \gamma_0*d'(t) + \omega_0^2*d(t) = E_d(t)*q^2/m_{eff}\)
where \(E_d(t)\) is the driving electric field (i.e. the component of the external electric field along the dipole's axis of polarization).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
omega_0 |
float
|
Natural angular frequency of dipole (units: rad/s). |
required |
origin |
Union[Tuple[float, float, float], Callable[[float], ndarray]]
|
List of x, y, and z values of dipole's origin (center of mass) or function with one input parameter for time that returns a 3 element list for x, y, and z values. |
required |
initial_r |
Tuple[float, float, float]
|
List of x, y, and z values for the initial displacement vector between the two point charges. |
required |
q |
float
|
Magnitude of the charge value of each point charge. Default
is |
e
|
m |
Union[float, Tuple[float, float]]
|
Mass of the two point charges or
a 2 element list of the two masses if they are different. Default
is |
m_e
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Raised if the magnitude of the initial moment is zero. |
Example
Below is an origin function that oscillates along the x-axis with an
amplitude of 1e-10 m and angular frequency of 1e12*2*pi rad/s:
def fun_origin(t):
return np.array((1e-10*np.cos(1e12*2*np.pi*t), 0, 0))
Source code in pycharge/dipole.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | |
get_E_driving(field_type='Total')
Return the magnitude of the driving electric field.
The driving electric field is the component of the external electric
field experienced by the charge along the direction of polarization.
The returned field type (Total, Velocity, or Acceleration) can
be specified.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field_type |
str
|
Return either the |
'Total'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Input for |
Returns:
| Type | Description |
|---|---|
ndarray
|
Magnitude of the driving electric field at each time step. |
Source code in pycharge/dipole.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
get_kinetic_energy(exclude_origin=True)
Return the kinetic energy of the dipole at each time step.
The kinetic energy of just the dipole moment can be determined by excluding the kinetic energy from the origin's movement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exclude_origin |
bool
|
Kinetic energy calculation excludes the movement of
the dipole's origin. Defaults to |
True
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Kinetic energy at each time step. |
Source code in pycharge/dipole.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
get_origin_position(magnitude=False)
Return the position of the dipole's origin at each time step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
magnitude |
bool
|
Return the magnitude of the origin position instead of a
3D vector if |
False
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Origin at each time step, either the magnitude of the position (1D |
ndarray
|
array of size N) or the position vector (2D array of size 3 x N). |
Source code in pycharge/dipole.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
reset(timesteps, dt, save_E)
Initialize the moment and E arrays, and _DipoleCharge pair.
Source code in pycharge/dipole.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
update_timestep(moment_disp, moment_vel, moment_acc, E_driving)
Update the array attributes at each time step.
Source code in pycharge/dipole.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |