Documentation of Examples and Tutorials for Beam Module. #11494

Merged
merged 12 commits into from Aug 22, 2016

Projects

None yet

2 participants

@sampadsaha5
Contributor
sampadsaha5 commented Aug 8, 2016 edited

At first PR #11374 should be merged. This PR is built on #11374.

@sampadsaha5
Contributor
@moorepants moorepants commented on the diff Aug 10, 2016
doc/src/tutorial/beam_problems.rst
+===========================================================
+Solving Beam Bending Problems using Discontinuity Functions
+===========================================================
+
+To make this document easier to read, we are going to enable pretty printing.
+
+ >>> from sympy import *
+ >>> x, y, z = symbols('x y z')
+ >>> init_printing(use_unicode=True)
+
+Beam
+====
+
+A Beam is a structural element that is capable of withstanding load
+primarily by resisting against bending. Beams are characterized by
+their second moment of area, their length and their elastic modulus.
@moorepants
moorepants Aug 10, 2016 Member

Be sure to mention that these are 2D beams.

@sampadsaha5 sampadsaha5 changed the title from [WIP] Documenting Examples and Tutorials for Beam Module. to Documentation of Examples and Tutorials for Beam Module. Aug 17, 2016
@moorepants moorepants commented on an outdated diff Aug 19, 2016
doc/src/tutorial/beam_problems.rst
+Beam
+====
+
+A Beam is a structural element that is capable of withstanding load
+primarily by resisting against bending. Beams are characterized by
+their second moment of area, their length and their elastic modulus.
+
+In Sympy, we can constuct a 2D beam objects with the following properties :
+
+- Length
+- Elastic Modulus
+- Second Moment of Area
+- Variable : A symbol that can be used as a variable along the length. By default,
+ this is set to ``Symbol(x)``.
+- Boundary Conditions
+ - bc_moment : Boundary conditions for moment.
@moorepants
moorepants Aug 19, 2016 Member

No longer there.

@moorepants moorepants and 1 other commented on an outdated diff Aug 19, 2016
doc/src/tutorial/beam_problems.rst
+- slope
+- deflection
+
+
+Examples
+========
+
+Let us solve some beam bending problems using this module :
+
+**Example 1**
+
+A beam of length 9 meters is having a fixed support at the start.
+A distributed constant load of 8 kN/m is applied downward from the starting
+point till 5 meters away from the start. A clockwise moment of 50 kN.m is
+applied at 5 meters away from the start of the beam. A downward point load
+of 12 kN is applied at the end.
@moorepants
moorepants Aug 19, 2016 Member

It'd really be nice to have some simple sketches of these beams for a visual description.

@sampadsaha5
sampadsaha5 Aug 20, 2016 Contributor

Yah, I also felt so while documenting example problems. But how do we add sketches in the .rst file?

@moorepants
moorepants Aug 20, 2016 Member

You can include a png, gif, or svg file using the image directive.

@moorepants moorepants commented on an outdated diff Aug 19, 2016
doc/src/tutorial/beam_problems.rst
+- shear_force
+- bending_moment
+- slope
+- deflection
+
+
+Examples
+========
+
+Let us solve some beam bending problems using this module :
+
+**Example 1**
+
+A beam of length 9 meters is having a fixed support at the start.
+A distributed constant load of 8 kN/m is applied downward from the starting
+point till 5 meters away from the start. A clockwise moment of 50 kN.m is
@moorepants
moorepants Aug 19, 2016 Member

kN.m > kNm or kN-m

@moorepants moorepants commented on an outdated diff Aug 19, 2016
doc/src/tutorial/beam_problems.rst
+ the upward forces and clockwise bending moment being positive.
+
+
+>>> from sympy.physics.continuum_mechanics.beam import Beam
+>>> from sympy import symbols
+>>> E, I = symbols('E, I')
+>>> R1, M1 = symbols('R1, M1')
+>>> b = Beam(9, E, I)
+>>> b.apply_load(R1, 0, -1)
+>>> b.apply_load(M1, 0, -2)
+>>> b.apply_load(-8, 0, 0, end=5)
+>>> b.apply_load(50, 5, -2)
+>>> b.apply_load(-12, 9, -1)
+>>> b.bc_slope = [(0, 0)]
+>>> b.bc_deflection = [(0, 0)]
+>>> b.evaluate_reaction_forces(R1, M1)
@moorepants
moorepants Aug 19, 2016 Member

I think this method name would be better as solve_for_reaction_loads or solve_reaction_loads.

@moorepants moorepants commented on an outdated diff Aug 19, 2016
doc/src/tutorial/beam_problems.rst
+
+
+>>> from sympy.physics.continuum_mechanics.beam import Beam
+>>> from sympy import symbols
+>>> E, I = symbols('E, I')
+>>> R1, M1 = symbols('R1, M1')
+>>> b = Beam(9, E, I)
+>>> b.apply_load(R1, 0, -1)
+>>> b.apply_load(M1, 0, -2)
+>>> b.apply_load(-8, 0, 0, end=5)
+>>> b.apply_load(50, 5, -2)
+>>> b.apply_load(-12, 9, -1)
+>>> b.bc_slope = [(0, 0)]
+>>> b.bc_deflection = [(0, 0)]
+>>> b.evaluate_reaction_forces(R1, M1)
+>>> b.reaction_forces
@moorepants
moorepants Aug 19, 2016 Member

This should be reaction_loads.

@moorepants moorepants commented on an outdated diff Aug 19, 2016
doc/src/tutorial/beam_problems.rst
+ Since a user is free to choose its own sign convention we are considering
+ the upward forces and clockwise bending moment being positive.
+
+
+>>> from sympy.physics.continuum_mechanics.beam import Beam
+>>> from sympy import symbols
+>>> E, I = symbols('E, I')
+>>> R1, M1 = symbols('R1, M1')
+>>> b = Beam(9, E, I)
+>>> b.apply_load(R1, 0, -1)
+>>> b.apply_load(M1, 0, -2)
+>>> b.apply_load(-8, 0, 0, end=5)
+>>> b.apply_load(50, 5, -2)
+>>> b.apply_load(-12, 9, -1)
+>>> b.bc_slope = [(0, 0)]
+>>> b.bc_deflection = [(0, 0)]
@moorepants
moorepants Aug 19, 2016 Member

When I do:

In [30]: b.bc_deflection?
Type:        property
String form: <property object at 0x7fab4b156368>
Docstring:   <no docstring>

I don't get any kind of useful docstring. It should show me how to set this attribute properly.

@moorepants
moorepants Aug 19, 2016 Member

I also think it'd be better to show this:

b.bc_slope.append((0, 0))

You shouldn't really be overwriting this property, only adding or removing boundary conditions.

@moorepants moorepants commented on the diff Aug 19, 2016
doc/src/tutorial/beam_problems.rst
+ 0 1 2 0 2 1
+ - 258⋅<x> + 52⋅<x> - 4⋅<x> + 50⋅<x - 5> + 4⋅<x - 5> - 12⋅<x - 9>
+>>> b.slope()
+ 3 3
+ 1 2 4⋅<x> 1 4⋅<x - 5> 2
+ - 258⋅<x> + 26⋅<x> - ────── + 50⋅<x - 5> + ────────── - 6⋅<x - 9>
+ 3 3
+ ─────────────────────────────────────────────────────────────────────
+ E⋅I
+>>> b.deflection()
+ 3 4 4
+ 2 26⋅<x> <x> 2 <x - 5> 3
+ - 129⋅<x> + ─────── - ──── + 25⋅<x - 5> + ──────── - 2⋅<x - 9>
+ 3 3 3
+ ─────────────────────────────────────────────────────────────────
+ E⋅I
@moorepants
moorepants Aug 19, 2016 Member

It'd really be nice if this worked:

In [41]: plot(b.deflection().rewrite(Piecewise).subs({E: 207E9, I: 10}), (0, 9))
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-41-d233ba84faab> in <module>()
----> 1 plot(b.deflection().rewrite(Piecewise).subs({E: 207E9, I: 10}), (0, 9))

/home/moorepants/src/sympy/sympy/plotting/plot.py in plot(*args, **kwargs)
   1289     series = []
   1290     plot_expr = check_arguments(args, 1, 1)
-> 1291     series = [LineOver1DRangeSeries(*arg, **kwargs) for arg in plot_expr]
   1292 
   1293     plots = Plot(*series, **kwargs)

/home/moorepants/src/sympy/sympy/plotting/plot.py in <listcomp>(.0)
   1289     series = []
   1290     plot_expr = check_arguments(args, 1, 1)
-> 1291     series = [LineOver1DRangeSeries(*arg, **kwargs) for arg in plot_expr]
   1292 
   1293     plots = Plot(*series, **kwargs)

/home/moorepants/src/sympy/sympy/plotting/plot.py in __init__(self, expr, var_start_end, **kwargs)
    438         self.var = sympify(var_start_end[0])
    439         self.start = float(var_start_end[1])
--> 440         self.end = float(var_start_end[2])
    441         self.nb_of_points = kwargs.get('nb_of_points', 300)
    442         self.adaptive = kwargs.get('adaptive', True)

/home/moorepants/src/sympy/sympy/core/containers.py in __getitem__(self, i)
     42             indices = i.indices(len(self))
     43             return Tuple(*[self.args[j] for j in range(*indices)])
---> 44         return self.args[i]
     45 
     46     def __len__(self):

IndexError: tuple index out of range

I'm not yet sure why it doesn't.

@moorepants
moorepants Aug 19, 2016 Member

This works!

plot(b.deflection().rewrite(Piecewise).subs({E: 207E9, I: 10}), (b.variable, 0, 9))

beam-deflection

@moorepants
moorepants Aug 19, 2016 edited Member

You don't even have to rewrite it:

plot(b.deflection().subs({E: 207E9, I: 10}), (b.variable, 0, 9))
@sampadsaha5
sampadsaha5 Aug 20, 2016 Contributor

Yah. Without rewriting also it can be plotted.

@moorepants
Member

Please update wrt to master.

@moorepants moorepants commented on the diff Aug 19, 2016
doc/src/tutorial/beam_problems.rst
+>>> b.apply_load(R1, 0, -1)
+>>> b.apply_load(M1, 0, -2)
+>>> b.apply_load(-8, 0, 0, end=5)
+>>> b.apply_load(50, 5, -2)
+>>> b.apply_load(-12, 9, -1)
+>>> b.bc_slope = [(0, 0)]
+>>> b.bc_deflection = [(0, 0)]
+>>> b.evaluate_reaction_forces(R1, M1)
+>>> b.reaction_forces
+ {M₁: -258, R₁: 52}
+>>> b.load
+ -2 -1 0 -2 0 -1
+ - 258⋅<x> + 52⋅<x> - 8⋅<x> + 50⋅<x - 5> + 8⋅<x - 5> - 12⋅<x - 9>
+>>> b.shear_force()
+ -1 0 1 -1 1 0
+ - 258⋅<x> + 52⋅<x> - 8⋅<x> + 50⋅<x - 5> + 8⋅<x - 5> - 12⋅<x - 9>
@moorepants
moorepants Aug 19, 2016 Member

For the shear I get this plot:

plot(b.shear_force(), (b.variable, 0, b.length))

beam-shear

If I want to evaluate the function at specific values of x I get:

In [59]: b.shear_force().subs({b.variable: 0})
Out[59]: -∞

In [60]: b.shear_force().subs({b.variable: 2})
Out[60]: 36000

In [61]: b.shear_force().subs({b.variable: 5})
Out[61]: ∞

In [62]: b.shear_force().subs({b.variable: 7})
Out[62]: 12000

In [63]: b.shear_force().subs({b.variable: 9})
Out[63]: 0

Which gives odd results for the discontinuous points. It'd be nice if this gave the correct values. Why is this?

@sampadsaha5
sampadsaha5 Aug 20, 2016 edited Contributor

It is all due to the fact of this :

In [26]: SingularityFunction(0, 0, -1)
Out[26]: ∞

In [27]: SingularityFunction(5, 5, -1)
Out[27]: ∞
@moorepants moorepants commented on an outdated diff Aug 21, 2016
doc/src/tutorial/beam_problems.rst
@@ -0,0 +1,202 @@
+===========================================================
+Solving Beam Bending Problems using Discontinuity Functions
@moorepants
moorepants Aug 21, 2016 Member

Discontinuity > Singularity

@moorepants moorepants commented on an outdated diff Aug 21, 2016
doc/src/tutorial/beam_problems.rst
+We have following methods under the beam class:
+
+- apply_load
+- evaluate_reaction_forces
+- shear_force
+- bending_moment
+- slope
+- deflection
+
+
+Examples
+========
+
+Let us solve some beam bending problems using this module :
+
+**Example 1**
@moorepants
moorepants Aug 21, 2016 edited Member

Change to:

Example 1
---------
@moorepants
Member

@sampadsaha5 Please add a note about this new package to the release notes: https://github.com/sympy/sympy/wiki/Release-Notes-for-1.1

@moorepants moorepants merged commit 1a1485d into sympy:master Aug 22, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@sampadsaha5
Contributor

Sure. Thank You @moorepants .

@skirpichev skirpichev referenced this pull request in diofant/diofant Dec 7, 2016
Open

[wip] Backport some sympy fixes #390

81 of 99 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment