-
Notifications
You must be signed in to change notification settings - Fork 0
GSOC 2013 Application: Sachin Joglekar: Electromagnetism module
Name: Sachin Joglekar
Email: [email protected]
IRC: srjoglekar246 (occasionally online)
Github: srjoglekar246
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.
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-
- Boolean function generation(SOP and POS) and simplification– (My first PR, took a long time to merge but made me aware of git intricacies and pep8 conventions.) https://github.com/sympy/sympy/pull/1543
- Boolean function equality checking and mapping of variables- https://github.com/sympy/sympy/pull/1619
- Fixing issue 3155- https://github.com/sympy/sympy/pull/1715
- Improved handling of Boolean literals- https://github.com/sympy/sympy/pull/1865
- Functions for disjunctive normal forms- https://github.com/sympy/sympy/pull/1730
- Improving handling of args for logic classes (included in PR 1962)- https://github.com/sympy/sympy/pull/1882
My un-merged PRs-
- Binomial expansion for non-integers- https://github.com/sympy/sympy/pull/1579 (Was an inefficient way of binomial expansion, hence closed)
- Addition of coordinate functions to ReferenceFrame- https://github.com/sympy/sympy/pull/1702 (This PR led to a good discussion on the problems related to implementation of coordinate systems for SymPy)
- Sub-module for physics dealing with electrical concepts (Crude work done in the direction of my GSoC project- https://github.com/sympy/sympy/pull/1695
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.
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.
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.
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.
Objectives-
-
Implementation of
ScalarPotential
class, to generate correspondingElectricFields
and to study the scalar potential fields produced by an existingElectricField
. -
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
Objectives-
-
Implementation of a
VectorPotential
class in analogy withScalarPotential
. -
Implementation of classes to represent
CurrentDensity
(j) of magnetization andChargeDensity
(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. -
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.
- 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)
Objectives-
-
Adding methods to
ElectricField
to generateMagneticField
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 magneticVectorPotentials
. -
Overloading of constructor for
MagneticField
in a similar way. -
Ensuring complete consistency of infrastructure created till this week.
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.
Objectives-
- Implementation of
ParticleCharge
as a class, extending Particle from sympy.physics.mechanics. This class would have methods to simulate its interactions withElectricField
andMagneticField
, 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’.
Objectives-
- 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.
Buffer period.
Objectives-
-
Make sure previous code is bug free.
-
Write detailed tests for
ParticleCharge
code. -
Add docstrings to Sphinx documentation.
-
Write a tutorial on the use of the code written during GSoC, along with sufficient examples for illustration.
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
- 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.
- Classical Electrodynamics for Undergraduates, John Norbury
- Introduction to Electrodynamics, David Griffiths
- http://en.wikipedia.org/wiki/Electric_field
- http://en.wikipedia.org/wiki/Magnetic_field
- http://en.wikipedia.org/wiki/Amp%C3%A8re's_circuital_law