Skip to content

saipavanc/efvisual

Repository files navigation

efvisual

Tool to visualize the electric field of a relativistic particle whose trajectory is predefined. This code only generates the electric fields generated by a particle in 2D, and does not visualise B or the Poynting's vector, though they can be generated by tweaking the code slightly.

Objects

Two objects, particle and reference_frame are defined in this code. Any particle can be visualised by the following definition

from efvisual import *

p = particle(1, ["cos(0.6*t)", "sin(0.6*t)"])

In the above definition, the first parameter denotes the charge of the particle and the second list of strings denote the trajecgtory of the particle in the x-y plane. Do note, that any relativistic-checks are not implemented in the code, for example if the trajectory is such that the velocity of the particle is greater than the speed of light (taken as 1 here) the result might be weird and unphysical. The code internally converts these strings into functions of velocities and accelerations using the Sympy library. These functions are later used to deduce the Electric field in the rest frame. Make sure to not leave an empty string, if the particle is not moving in y then the input parameter should be ["x_trajectory", "0"].

The reference frame can be initialized by the following command.

rf = reference_frame(3, 20)

The first parameter sets the range of the x and y axis and the second parameter shows the number of points considered on each axis. The code is not very efficient. so increasing the number beyond 30 might make it very slow. I found that 20 points are enough to visualise the fields on a quivr plot.

The object reference_frame also has a method E_fields to generate the fields in a given frame. One challenge was to calculate the retarded times for an arbitrary trajectory. This got me held up, but finally I was able to use scipy.fsolve to find the zeros of an expression which calculates the retarded times. This is not an efficient implementation, but seemed okay with a small number of points like 20 in each dimension.

The method anim_video of the reference_frame object makes a video of the fields generated with the particle moving in the given trajectory. It is called in the following way:

rf.anim_video(p, 4, "circle_0.6_beta")

The first parameter is the particle itself, which was defined earlier. The second parameter shows the time interval for which the video needs to be made. The output is a 6 second video with 4 fps. This can be alterated in the code if needed.

How to use this package

The code can be cloned using this command:

git clone https://github.com/saipavanc/efvisual
cd ./efvisual

An example usage is shown below for a moving charge with a velocity of 0.8*beta is as follows:

from efvisual import *
p = particle(1, ["0.6*t", "0"])
rf = reference_frame(3, 20)
rf.anim_video(p, 4, "uniform_vel_0.6_beta")

I have added some video output examples along with a demo file to this repository.

About

Tool to visualize the electric field of a relativistic particle whose trajectory is predefined.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published