GSoC Week 12 and Wrap-up

Hello all! This is officially the last week for Google Summer of Code 2016. The submission and final evaluation has already started. Last week I was busy with fixing bugs and preparing documentation for the beam module.

The things that I have implemented till now

  • DiracDelta can be represented in piecewise form.
  • DiracDelta and Heaviside have a detailed docstring.
  • DiracDelta can be pretty printed using δ(x).
  • Singularity Function module which can perform all sort of mathematical operations on discontinuity functions.
  • Beam module which can solve 2D beam bending problems.

Future Plans

Jason has came up with some new ideas for beam module:

  • Plot the shear, bending, slope and deflection diagrams..
  • Compute the strain and stress at any location in the beam.
  • Improve the beam module for more complicated loads.

I have planed for a long term association with SymPy, I am taking the full responsibilty of my code and I will try to contribute as much as I can. I will help the new developers with the Sympy code paradigms and the development workflow.

I have been able to meet all the target that I had mentioned in my proposal and all of my pull requests have got merged except PR 11494. It was great working with Sympy. Jason, Sartaj, Aaron, Kalevi, Isuru and all other sympy members have helped me a lot. Many of the times, I used to get stuck with some implementation, testing or with the Travis CI build but, for everytime they have always tried to help me fix them. My mentors have always appreciated and motivated me. I got to learn many new thing about the software development workflow. Thank you Sympy for making this summer an awesome journey of learning and coding.

That’s all folks.

Happy Coding.

Advertisement

GSoC Week 11

Hi there! It’s been eleven weeks into GSoC . The module for solving beam bending problems is almost ready. Now, I am focusing fully on example documentation part because it’s very important to let others know what can be done.

So Far

Let us see the capabilities:-

  • Can create a beam object of certain length, second moment of area and modulus of elasticity. A symbol can also be passed for further uses.
  • Can apply loads using its value, start, end and order.
  • Can set boundary conditions for the beam.
  • Can find the load distribution function.
  • Can find the shear force function.
  • Can find the bending moment function.
  • Can find the slope function.
  • Can find the deflection function.
  • Can represent each of those function in the Piecewise form.
  • Can perform all sorts of mathematical operations on these functions.

A full fledged documentation of tutorial and example for this module is on its way.

Next Week

  • To complete documenting examples and tutorials.
  • Get PR 11374 merged.

That’s all for now, looking forward for week 12.

Happy Coding.

GSoC Week 10

Hello, guys. Welcome back. It’s been ten weeks into the coding period. I had a meeting with Jason on 25th of this month. We discussed many new changed on the API that I had implemented before this week. Now, the beam bending module is almost ready to solve beam bending problems.

Let us see how to solve a beam bending problem using this module.

Problem Statement :

Loaded beam.svg

The deflection is restricted at the end of the beam.

Solution :

>>> from sympy.physics.continuum_mechanics.beam import Beam

>>> from sympy import Symbol, Piecewise
 
>>> x = Symbol('x')

>>> E = Symbol('E')

>>> I = Symbol('I')

>>> b = Beam(4, E, I)

>>> b.apply_load(value=-9, start=4, order=-1)

>>> b.apply_load(value=-3, start=0, order=-1)

>>> b.apply_load(order=0, start=2, value=6)

>>> b.bc_deflection = [(4, 0)]

>>> b.boundary_conditions
 {'deflection': [(4, 0)], 'moment': [], 'slope': []}

>>> b.load
 -3*SingularityFunction(x, 0, -1) + 6*SingularityFunction(x, 2, 0) - 9*SingularityFunction(x, 4, -1)

>>> b.shear_force()
 -3*SingularityFunction(x, 0, 0) + 6*SingularityFunction(x, 2, 1) - 9*SingularityFunction(x, 4, 0)

>>> b.bending_moment()
 3*SingularityFunction(x, 0, 1) - 3*SingularityFunction(x, 2, 2) + 9*SingularityFunction(x, 4, 1)

>>> b.slope()
 (3*SingularityFunction(x, 0, 2)/2 - SingularityFunction(x, 2, 3) + 9*SingularityFunction(x, 4, 2)/2 - 7)/(E*I)

>>> b.deflection()
 (-7*x + SingularityFunction(x, 0, 3)/2 - SingularityFunction(x, 2, 4)/4 + 3*SingularityFunction(x, 4, 3)/2)/(E*I)

If the user wants to represent the deflection in the piecewise form, then:

>>> b.deflection().rewrite(Piecewise)
 (-7*x + Piecewise((x**3, x > 0), (0, True))/2
 + 3*Piecewise(((x - 4)**3, x - 4 > 0), (0, True))/2
 - Piecewise(((x - 2)**4, x - 2 > 0), (0, True))/4)/(E*I)

 

Next week 

  • Add the end argument in the apply_load method.
  • Add Sphinx documentations.

That’s all for this week. Cheers !!

Happy Coding.

GSoC Week 9

Hello, guys. Welcome back. It’s been nine weeks into the coding period. I had a meeting with Jason on 17th  of this month. He was attending the code sprints at Scipy and I am very glad to meet other Sympy developers.

So Far

  • I have closed the PR 11266.
  • In PR 11374, I have removed the use of mechanics Point.
  • I have made boundary_conditions as property and the inputs are no longer as **kwargs. Each of the inputs namely moment, slope and deflection are initiated as an empty list. But I have some doubts regarding the behaviour of this method. I feel that this should be used only in the case when a full new set of boundary conditions are given as input. Since to input dynamically, there exists some methods already which would handle each of the cases explicitly. Those methods appends the new inputs whereas this method would delete the existing boundary conditions and apply the newer one. This way the property of being mutable would remain.
  • Replaced the solve function by linsolve. Since solve is going to be depreciated in the mear future.
  • I have added the docstrings for slope and deflection method as well as for the beam class.
  • In deflection method, I have added a new case where if there is no slope boundary condition but there is deflection boundary conditions, it would give operate.

Next Week

  • I will be working on adding a documentation file for this beam bending problem module exclusively.
  • Add some more test for checking the corner cases.

That’s all for this week. Cheers !!

Happy Coding.

GSoC Week 8

Hello, guys. Welcome back. It’s been eight weeks into the coding period and this week I enjoyed a lot while working. I learned to build a list without using a loop, in case, it can be done more concisely with a list comprehension such as:

Instead of doing :

In [ ]: b = []
In [ ]: for x in a:
       b.append(10 * x)
 ....:

we can do :

In [ ]: b = [10 * x for x in a]

I came to know about stuff , like using zip for transposing a matrix and dividing a list into groups of nThis week I had my weekly meeting with Jason and Sartaj on 13th of this month. They were in Austin, Texas attending Scipy 2016, the 15th annual Scientific Computing with Python conference.

So Far

  •  PR 11178  and PR 11237 got merged. So, now the master branch is updated with a module of singularity functions which can handle almost all the mathematical operations.
  • I have used the Singularity Functions  to continue developing the beam bending module at PR 11374. I have added the following methods:
    • load_as_SingularityFunction : This is a private method which represents a PointLoad and DistributedLoad object into a Singularity Function object and stores in the load beam object attribute.
    • load_distribution : This is a public method which outputs a load distribution curve of a beam.
    • shear_force : This is also a public method. It at first checks whether the moment list in boundary conditions dictionary have elements. If it has then it call the bending_moment method and then differentiate the output w.r.t to the free symbol else it just integrates the output of load_distribution method.
    • bending_moment : The initial part of this method is similar to the method shear_force. If the test passes then it integrates the load_distibution twice using contants of integrations and later the contants are solved else it just integrates the output of shear_force method.
    • slope : It outputs the slope of a beam by solving the constants.
    • deflection : It outputs the elastic curve of the beam.

Next Week

  • Modify the Beam Module.
  • Add Sphinx documentations.

That’s all for this week. Cheers !!

Happy Coding.

GSoc Week 7

Hi there! It’s been seven weeks into the coding period and the second half has started now. I had a meeting with Jason on 3rd of July. We discussed some modifications that were needed to be done in the existing PRs. Further, we had a conversation on the beam bending module. We ended up with some good ideas regarding the implementation of beam object.

So Far

  • In PR  PR 11178  and PR 11237, I have added the suggested modifications.
  • In PR  11266, I have done some modifications in the DistributedLoad class. Initially, it had “start”,” end” and “value” as its attribute but Jason suggested me to add an attribute which would denote the order of the load. This attribute would help while representing a load in the form of Singularity Functions. Such as:
    • Order = 0 will denote Step Function,
    • Order = 1 will denote Ramp Function,
    • Order = 2 will denote Parabolic Ramp Function and
    • so on …
  • In the same PR, I have added some more method for taking boundary conditions explicitly for different cases such as for deflection, slope and moment as inputs. I made a private attribute _boundary_conditions and initiated as an empty dictionary of lists with keywords  deflection, slope and moment. Later on each of the methods, namely,
    • apply_boundary_conditions
    • apply_moment_boundary_conditions
    • apply_slope_boundary_conditions
    • apply_deflection_boundary_conditions

    just updates that dictionary. The method boundary_conditions would return the dictionary itself.

Next Week

  • I will try to get  PR 11178  and PR 11237 merged.
  • Add apply_load method to the Beam class.
  • Successfully convert all the load inputs through the  apply_load method into Singularity Functions.
  • Write methods which would output load curve, shear curve and moment curve.

That’s all for this week. Cheers !!

Happy Coding.

GSoc Week 6

Hi there! It’s been six weeks into the coding period, and it marks the half of GSoC. The Midterm evaluations have been done now and I have passed the mid-term evaluations. I am very much thankful to my mentors. This week I was having some physical illness due to this reason I was not able to attend the meeting with my mentors. This affected my workflow too. I was not able to work for almost 3 days. I will try to compensate the time lag by working some extra hours in the upcoming days.

So Far

  • Until last week, I have completed the implementation of PointLoad and  DistributedLoad. This week I started implementing the class for the principle object of the Beam Bending problems. I have implemented the Beam class. The work is not completed yet. I have initiated the class with length, Young’s Modulus and Moment of Inertia. I have to discuss with the mentor about the mutability of this class.
  • BoundaryConditions :- It is a public method of the beam class which takes the boundary conditions of the beam bending problem as input. I found out that there are only three types of boundary conditions : Deflection, Shear and Moment. So, I made them input in the form of keyword arguments and for each key, the value would be a list of tuples where each of the tuples would contain location and value in this format : (location, value). This method returns the boundary conditions in the form of a python dictionary. For example:  Let a problem have boundary conditions as: Moment(x = 0) = 1, Deflection(x = 0) = 0, Deflection(x = 4) = 0. Then the API is:
  • >>> from sympy.physics.mechanics.beam import Beam
    >>> from sympy import Symbol
    >>> E = Symbol('E')
    >>> I = Symbol('I')
    >>> b = Beam(4, E, I)
    >>> b.BoundaryConditions(moment = [(0, 1)], deflection = [(0, 0), (4, 0)])
    {'deflection': [(0, 0), (4, 0)], 'moment': [(0, 1)]}

Next Week

  • I will try to get  PR 11178  and PR 11237 merged.
  • Modify the Beam class with new methods.

That’s all for this week. Cheers !!

Happy Coding.

GSoC Week 5

Hi there! It’s been five weeks and midterm evaluations are going on. I have completed the implementations of Singularity Function module and headed towards the Implementation of Beam Bending Module.

So far

  • In PR 11266 , I have implemented three major classes :
    • DistributedLoad : Have the attributes start, end and value. This object can be used to generate a distributed load. It is a mutable object. The start and  end attribute should be the instance of mechanics Point. The value can take any function as input. This Load can be represented as a Singularity Function (i have not implemented this functionality yet) and used for solving the beam bending problems.
    • PointLoad : There are two types : Moment and Point Load. Moments are basically the couple of forces and are represented by the Doublet function whereas Point Load is the force which acts on a single unique point of the Beam and is represented as a DiracDelta Function.
    • Beam : It is the principle object of the Beam Bending problems. I have started working on it.

Next Week

Thats all for this week. Cheers !!

Happy Coding.

 

GSoC Week 4

Hi there! It’s been four weeks at GSoC. This week, I have been working on integrations. I had a meeting with my mentors on 12th June. It was great. I got stuck while implementing the integrations of Singularity Function earlier. I had already discussed that in my previous blog post. But at the meeting, I got some good ideas from Sartaj and Jason which not only cleared my doubts but also helped me to complete the implementation of integration of Singularity Functions. Firstly, they suggested me to start with the integration part in a new PR, since PR 11178 was quite good enough to get merged. Secondly, to integrate the Singularity Functions having exponents -1, we need to rewrite it as  DiracDeltas and then to use the methods of integration which are already available at sympy and then again rewrite it back as Singularity Functions.  Now I am almost completed with the “Implementation of Singularity Functions”.

So Far

  • In  PR 11178, I have added the changes that Jason had suggested. This PR is now ready.
  • In PR 11237, I have almost completed implementing the integrations of Singularity Function both definite and indefinite. I have implemented methods to rewrite DiracDeltas and Heaviside back to Singularity Functions.  The arguments of DiracDeltas and Heavisides should be a linear polynomial to use these methods.
  • I have added a module named “singularityfunctions” in the integrals directory. In there I have defined a function “singularityintegrate”. This one is the core function to integrate the Singularity Functions. SingularityFunction(x, a, -1) perfectly behaves as DiracDelta(x – a).

Next Week

  • To polish PR 11178  and PR 11237 and get them merged.
  • To start working with Beam Bending Module.

Looking forward toward an another great week. Cheers!

Midterm Evaluation is Coming !!! All the best.

Happy Coding.

GSoC Week 3

Hi! It’s been three weeks into the coding period, & I have managed to get some pace.I had a meeting with Jason and Sartaj on 5th of this month. We exchanged our thoughts on implementing the integration of Singularity Function objects. Then our discussion moved on towards the implementation of the Beam Bending Module. We focused on whether a Beam object will be mutable or immutable.We ended up discussing two approaches for the implementation of the integration of Singularity Function objects.

So far

  •  PR 11103 and PR 11137 has finally got merged.
  • In  PR 11178, I have added two important methods under  Singularity Function class.
      • rewrite(Heaviside)
      • rewrite(DiracDelta)

    These would help to convert a Singularity Function object into a mixture of DiracDeltas and Heavisides.

    But while doing the inverse i.e. rewriting DiracDeltas and Heavisides I got stuck. I have implemented that in a way which can’t handle a bit complex expressions,but good for simple DiracDelta and Heaviside expressions. I need to work on this method.

  • In the same PR, I am also working on the integration of the Singularity Functions. There are two approaches which I have discussed with my mentors.
    • Directly use the rules of integrations:- I mean if the exponent is greater than zero then increase the exponent by 1 and divide the whole by the resulting exponent. Else just increase the exponent by 1.
      The issue with this approach is if we perform Sympy integrations over SingularityFunction(x, a, 0) ,which is basically DiracDelta(x – a), then it doesn’t satisfy the fundamentals properties of DiracDelta integrations. For the purpose, I am trying the next approach.
    • Using Heaviside and DiracDelta :- Convert the Singularity function into expressions containing DiracDeltas and Heavisides and then integrate that. Integrations of DiracDeltas and Heavisides are already there in Sympy. Then rewrite that result back into the Singularity Function. Lastly, just output that resulting expression.
      Currently, I am working on rewriting the DiracDeltas and Heavisides back into the Singularity Function.

Next Week

  • Continue with the implementation of integrations of Singularity Functions.

That’s all for now, looking forward to week 4.

Cheers. Happy Coding.