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.