Skip to content

GSOC 2013 Application: Sachin Joglekar: Electromagnetism module

srjoglekar246 edited this page Apr 4, 2013 · 2 revisions

Personal Details

Name: Sachin Joglekar

Email: [email protected]

IRC: srjoglekar246 (occasionally online)

Github: srjoglekar246

Background and Skills

I am a second year undergraduate computer science student studying at Birla Institute of Technology and Science-Pilani, Goa campus. As a coder, I am at my most comfortable programming in Python, while having a good amount of experience with C++ and Java as well. I have used C++ and Java primarily for academic courses (Object Oriented Programming, Data structures and Algorithms, CS Logic etc.), and Python for all other work.

I started out with Python while coding for a project involving waveform feature extraction and classification, and acquired knowledge of coding styles and conventions during the course of my work for SymPy. I have been using Python for about two years now, and I am sure I can handle all the language features well.

I mainly work on a Windows machine, even though I am quite comfortable with Linux Mint as well. I have used git for version control for a long time now, and I can say that I am proficient with its basics.

I can be reached at any time at my email address or on Google Talk. I am only occasionally online via the IRC.

Contributions to SymPy

All my past merged work for SymPy has been for sympy.logic, primarily under the guidance of Christopher Smith (@smichr). My PRs that were merged-

My un-merged PRs-

The Project

A few months back, inspired by sympy.physics.mechanics, I started working on a module for sympy.physics based on concepts from electromagnetism. The code I wrote was quite rudimentary, and I couldn’t take it further at that time due to other commitments. That branch can be seen at-

https://github.com/sympy/sympy/pull/1695

For my GSoC project, I plan to build the basic infrastructure needed to handle electric and magnetic fields, their relationships with each other and their interactions with particle charges. Not only will this help a user in the study of electromagnetic fields, but also in the symbolic calculations pertaining to mechanics of charges under their influence. Considering the potential of the sympy.physics library, I think addition of electromagnetism features would be an important plus for SymPy.

Moreover, my work could be the foundation for further effort in this direction, helping build a stable and powerful electromagnetism module for SymPy. I also hope this module would be integrated with sympy.physics.mechanics in the future, aiding the study of physical bodies in an electro-magnetic environment.

As a part of my first year undergraduate curriculum, I have completed a course on Electrical Sciences and am currently reading up relevant texts on electromagnetism. This knowledge, along with my grasp over the object oriented paradigm will ensure that I am able to build the required class structure and helper methods for the proposed module.

Implementation and timeline

This is a tentative schedule that I intend to follow during the summer. I have kept the expected timeline a little pessimistic to accommodate uncertainties. Each of the components (except the Community Bonding Period) would roughly correspond to one pull request from my side. I will have no problem in dedicating the required 40 hours per week to this project.

Community Bonding Period

I intend to extend this part backwards up to the day I write this, to ensure that I get sufficiently acquainted with the concepts related to the project well before I start coding. I would mainly be focussing on doing the following-

  • Research various aspects of Electric and Magnetic fields and their interactions. For this part, I plan to thoroughly read through the relevant parts of ‘Classical Electrodynamics for Undergraduates’ by Prof. John Norbury and use ‘Introduction to Electrodynamics’ by David Griffiths as a reference book.

  • Based on my research, identify the features that would be essential and useful to a symbolic electromagnetism module.

  • Chalk out the basic class structure and set of methods that I would be expected to implement during summer, with the help of the sympy.physics community and my mentor(after May 27).

  • Figure out ways to implement functions of line, surface and volume integrals of vector fields.

Week 1

Objectives-

  • Construction of a basic framework to handle coordinate and time variables for vector field calculations. This framework would essentially produce special types of Symbols to distinguish them from ordinary Symbols which the user may use in his definitions of vector fields. Please refer to the shown prototype below to get an idea of how this would work.

  • Plan and implement the methods/API to derive quantities like curl, gradient, divergence and time derivatives of any vector field V of the type V(x, y, z, t).

  • Plan and implement the methods/API to derive line, surface(area) and volume integrals of any vector field V of type V(x, y, z, t).

API –

a. line_integral(vfield, curve, Point1, Point2)

b. Implementaion of surface and volume integrals would take some planning to do.

In the worst case, I will implement all the special cases like spheres and circles, cubes and squares etc using equations of curves in space. (I have tried to demonstrate a surface integral in the prototype during the usage of EMF_induced, using intersection of two curves.) Further work done on Vector Calculus would aid my code in that case.

  • Implement methods to handle different units systems like MKS, Heaviside-Lorents and CGS(Gaussian) during calculations on electromagnetic quantities.

Week 2-3

Objectives-

  1. Implementation of ScalarPotential class, to generate corresponding ElectricFields and to study the scalar potential fields produced by an existing ElectricField.

  2. Implementation of features of conservative ElectricField(is_conservative = True), including-

  • Vectorial value and magnitude.

API –

efield.value() would return symbolic vectorial value of the field in space, while efield.value(p, origin) where p is a Point would return the calculated value of the field at that Point in space. p’s coordinates would be calculated with respect to the specified Point origin.

  • Corresponding ScalarPotentials (and potential difference between two Points). Also helpful would be option of an arbitrary datum (may be defined at oo) in calculation of absolute potential at any given Point.

API –

a. efield.scalar_potential(c) would return ScalarPotential with added constant ‘c’.

b. efield.potential_difference(Point1, Point2)

c. efield.scalar_potential(p, datumpoint, valueatdatum) would return value of scalar potential at Point p with respect to specified datum, which may be infinity as remarked earlier.

  • Field energy density at a Point, Field energy in a given volume

API –

efield.energy_density() would give value of energy density in terms of coordinate variables, while efield.energy_density(p) would give value of the energy density at Point p.

  • Flux of the ElectricField through a given area

Week 4-5

Objectives-

  1. Implementation of a VectorPotential class in analogy with ScalarPotential.

  2. Implementation of classes to represent CurrentDensity(j) of magnetization and ChargeDensity(rho). For the time being, I plan to handle all the usual, ‘simple to handle’ charge densities like spherically symmetrical, constant etc. Some functions on the rest would return ‘NotImplementedError’. Also included will be mechanisms to implement Principle of Charge Conservation.

  3. Implementation of features of MagneticField class, including-

  • Vectorial value and magnitude.

API would be similar to that of ElectricField.

  • Corresponding VectorPotentials.

  • Field energy density at a Point, Field energy in a volume.

API of the above would be similar to that of ElectricField.

  • Induced ElectricField based on Faradays Law/ Amperes Law. The condition assumed would be that of free space, unless the user specifies a current density.

API-

mfield.induced_electric_field(j) where j is the current density, would produce return the ElectricField induced by the MagneticField mfield.

  1. Addition of auxiliary functions like-
  • total_Electric_Field_at(Point, *factors) -based on principle of superposition
  • total_Magnetic_Field_at(Point, *factors)
  • EMF_induced(curve, *magneticfields)

Week 6

Objectives-

  • Adding methods to ElectricField to generate MagneticField based on its time-varying nature and current density of environment, using Ampere’s Law.

  • Overloading of the constructor for ElectricField to accept different arguments like Vectors, ScalarPotentials and magnetic VectorPotentials.

  • Overloading of constructor for MagneticField in a similar way.

  • Ensuring complete consistency of infrastructure created till this week.

MID-TERM EVALUATION

Week 7

Objectives-

  • Write detailed tests for work done so far.

  • Add docstrings to Sphinx documentation.

  • Fix any bugs if found.

  • Make any further tweaks as per mentor’s reviews on code.

Week 8-10

Objectives-

  1. Implementation of ParticleCharge as a class, extending Particle from sympy.physics.mechanics. This class would have methods to simulate its interactions with ElectricField and MagneticField, such as-
  • set_motion(*factors, time = 0)

This method would just set the ParticleCharge’s velocities and accelerations according to fields provided, if no time is specified. If time is positive, would also set Point of ParticleCharge with respect to its earlier position.

This part would take some time, especially considering handling of different ReferenceFrames and complexity of operations.

  • lorentz_force(*fields)

  • electric_field_at()

Would return ElectricField produced by the ParticleCharge itself.

  • magnetic_field_at()

Would return the MagneticField produced by ParticleCharge as per Biot-Savart law.

  • potential_energy()

potential_energy of the ParticleCharge would be set to zero by default, or set by user. It would change with calls to ‘set_motion’.

Week 11

Objectives-

  1. Implementation of functions to study interactions of instances of ParticleCharge with each other. For example, work done in assembly of charges, charged-particle distributions in electric fields, etc.

Week 12-13

Buffer period.

Objectives-

  1. Make sure previous code is bug free.

  2. Write detailed tests for ParticleCharge code.

  3. Add docstrings to Sphinx documentation.

  4. Write a tutorial on the use of the code written during GSoC, along with sufficient examples for illustration.

Example of usage (Prototype)

Below I have described examples of some basic operations that could be performed with my code.

/*Define coordinate and time variables*/

x_v, y_v, z_v, t_v = CoordinateSymbols(‘ x_v y_v z_v t_v’)

R = ReferenceFrame(‘R’)

vector1 = 2 * x_v * R.x + 3 * y_v**2 * R.y – sin(z_v) * R.z

gradient(vector1)

Output –> 2 * R.x + 6 * y_v * R.y – cos(z_v) * R.z

vector2 = 3 * t_v**2 * R.x

time_derivative(vector2, 2)


/*time_derivative would automatically find the time variable and differentiate. In case of multiple time variables, raise error.*/

Output -> 6 * R.x

sfield = ScalarPotential(6 * x_v**2 * y_v)

sfield.vector_gradient(R)

Output -> 12 * x_v * y_v * R.x + 6 * x_v**2 * R.y


/*Define ElectricField with respect to ScalarPotential*/

efield = ElectricField(sfield)

origin = Point(‘origin’)

p = Point(‘p’)

q = Point('q')

p.set_pos(origin, 1 * R.x)

q.set_pos(origin, -R.x)

efield.energy_density_at(p, origin, ‘MKS’)

Output -> 2.65625635e-11


/*Define magnetic field with vector*/

mfield = MagneticField(3 * R.y)


/*Find EMF induced in circle in X-Y plane*/

EMF_induced( [x_v  ** 2 + y_v ** 2 = 4, z_v = 0], mfield)

Output -> 0


/*Define ParticleCharges having charge 1 Coulomb at Points p and q*/

P1 = ParticleCharge('P1', p, 1)

Q1 = ParticleCharge('Q1', q, 1)


/*The vectorial value of field due to P1 and Q1 has no component along R.x*/

(P1.electric_field_at(r) + Q1.electric_field_at(r)).get_vector().dot(R.x)

Output -> 0

Notes-

  • Prasoon’s project on Vector Calculus, if accepted, may aid my work with basic functions of vector fields and coordinate frames. I will interact with him and get the relevant functions from his API to insert into my code. This would speed up my timeline, especially in the first week. In such a case, I plan to implement dipoles and wires as a part of the module, considering they are quite relevant to the understanding of electromagnetic fields in space. I will have an API of these classes ready by the end of the community bonding period. In the unfortunate case that Prasoon’s project does not get accepted, I would be implementing those vector functions in 3 dimensions in the manner I have specified before. If any work is done in the future regarding vector calculus, the relevant API would gel easily into my code.

References-

Clone this wiki locally