
    \hp                    p   S r SSKJrJrJrJr  SSKJr  SSKJ	r	  SSK
JrJr  SSKJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJrJrJr  SSKJ r   SSK!J"r"  SSK#J$r$J%r%  SSK&J'r'  SSK(J)r)  SSK*J+r+  SSK,J-r-  SSK.J/r/  SSK0J1r1  SSK2r2SS/0r3\)" SSS/0S9r4 " S S5      r5 " S  S!\55      r6g)"zd
This module can be used to solve 2D beam bending problems with
singularity functions in mechanics.
    )SSymboldiffsymbols)Add)Expr)
DerivativeFunction)Mul)Eq)sympify)linsolve)dsolve)solve)sstr)SingularityFunction	Piecewise	factorial)	integrate)limit)plotPlotGrid)GeometryEntity)import_module)Interval)lambdify)doctest_depends_on)iterableN)z	Beam.drawzBeam.plot_bending_momentzBeam.plot_deflectionzBeam.plot_ild_momentzBeam.plot_ild_shearzBeam.plot_shear_forcezBeam.plot_shear_stresszBeam.plot_slope
matplotlibnumpyfromlistarange)import_kwargsc                   (   \ rS rSrSr\" S5      \" S5      S\" S5      4S jrS r\S	 5       r	\S
 5       r
\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\R$                  S 5       r\S 5       r\R$                  S 5       r\S 5       r\R$                  S 5       r\S 5       r\R$                  S 5       r\S 5       r\R$                  S 5       r\S 5       r\R$                  S 5       r\S 5       r\S 5       r\R$                  S 5       r\S  5       r\R$                  S! 5       r\S" 5       r\R$                  S# 5       r\S$ 5       r\R$                  S% 5       rSOS& jrSOS' jrS( rS) r S* r!SPS, jr"SPS- jr#S. r$\S/ 5       r%\S0 5       r&S1 r'S2 r(S3 r)S4 r*S5 r+S6 r,S7 r-S8 r.S9 r/S: r0SPS; jr1SPS< jr2SPS= jr3SPS> jr4SPS? jr5SPS@ jr6SA r7SB r8SPSC jr9SD r:SPSE jr;SF r<SPSG jr=\>" SHSI9SQSJ j5       r?SK r@SL rASM rBSNrCg+)RBeam-   a0  
A Beam is a structural element that is capable of withstanding load
primarily by resisting against bending. Beams are characterized by
their cross sectional profile(Second moment of area), their length
and their material.

.. note::
   A consistent sign convention must be used while solving a beam
   bending problem; the results will
   automatically follow the chosen sign convention. However, the
   chosen sign convention must respect the rule that, on the positive
   side of beam's axis (in respect to current section), a loading force
   giving positive shear yields a negative moment, as below (the
   curved arrow shows the positive moment and rotation):

.. image:: allowed-sign-conventions.png

Examples
========
There is a beam of length 4 meters. A constant distributed load of 6 N/m
is applied from half of the beam till the end. There are two simple supports
below the beam, one at the starting point and another at the ending point
of the beam. The deflection of the beam at the end is restricted.

Using the sign convention of downwards forces being positive.

>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols, Piecewise
>>> E, I = symbols('E, I')
>>> R1, R2 = symbols('R1, R2')
>>> b = Beam(4, E, I)
>>> b.apply_load(R1, 0, -1)
>>> b.apply_load(6, 2, 0)
>>> b.apply_load(R2, 4, -1)
>>> b.bc_deflection = [(0, 0), (4, 0)]
>>> b.boundary_conditions
{'bending_moment': [], 'deflection': [(0, 0), (4, 0)], 'shear_force': [], 'slope': []}
>>> b.load
R1*SingularityFunction(x, 0, -1) + R2*SingularityFunction(x, 4, -1) + 6*SingularityFunction(x, 2, 0)
>>> b.solve_for_reaction_loads(R1, R2)
>>> 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)
>>> b.deflection().rewrite(Piecewise)
(7*x - Piecewise((x**3, x >= 0), (0, True))/2
     - 3*Piecewise(((x - 4)**3, x >= 4), (0, True))/2
     + Piecewise(((x - 2)**4, x >= 2), (0, True))/4)/(E*I)

Calculate the support reactions for a fully symbolic beam of length L.
There are two simple supports below the beam, one at the starting point
and another at the ending point of the beam. The deflection of the beam
at the end is restricted. The beam is loaded with:

* a downward point load P1 applied at L/4
* an upward point load P2 applied at L/8
* a counterclockwise moment M1 applied at L/2
* a clockwise moment M2 applied at 3*L/4
* a distributed constant load q1, applied downward, starting from L/2
  up to 3*L/4
* a distributed constant load q2, applied upward, starting from 3*L/4
  up to L

No assumptions are needed for symbolic loads. However, defining a positive
length will help the algorithm to compute the solution.

>>> E, I = symbols('E, I')
>>> L = symbols("L", positive=True)
>>> P1, P2, M1, M2, q1, q2 = symbols("P1, P2, M1, M2, q1, q2")
>>> R1, R2 = symbols('R1, R2')
>>> b = Beam(L, E, I)
>>> b.apply_load(R1, 0, -1)
>>> b.apply_load(R2, L, -1)
>>> b.apply_load(P1, L/4, -1)
>>> b.apply_load(-P2, L/8, -1)
>>> b.apply_load(M1, L/2, -2)
>>> b.apply_load(-M2, 3*L/4, -2)
>>> b.apply_load(q1, L/2, 0, 3*L/4)
>>> b.apply_load(-q2, 3*L/4, 0, L)
>>> b.bc_deflection = [(0, 0), (L, 0)]
>>> b.solve_for_reaction_loads(R1, R2)
>>> print(b.reaction_loads[R1])
(-3*L**2*q1 + L**2*q2 - 24*L*P1 + 28*L*P2 - 32*M1 + 32*M2)/(32*L)
>>> print(b.reaction_loads[R2])
(-5*L**2*q1 + 7*L**2*q2 - 8*L*P1 + 4*L*P2 + 32*M1 - 32*M2)/(32*L)
AxCac                 z   Xl         X l        [        U[        5      (       a  X0l        OSU l        X0l        XPl        Xpl        X`l        / / / / S.U l	        SU l
        X@l        / U l        / U l        / U l        / U l        / U l        / U l        / U l        0 U l        0 U l        SU l        SU l        SU l        SU l        g)a  Initializes the class.

Parameters
==========

length : Sympifyable
    A Symbol or value representing the Beam's length.

elastic_modulus : Sympifyable
    A SymPy expression representing the Beam's Modulus of Elasticity.
    It is a measure of the stiffness of the Beam material. It can
    also be a continuous function of position along the beam.

second_moment : Sympifyable or Geometry object
    Describes the cross-section of the beam via a SymPy expression
    representing the Beam's second moment of area. It is a geometrical
    property of an area which reflects how its points are distributed
    with respect to its neutral axis. It can also be a continuous
    function of position along the beam. Alternatively ``second_moment``
    can be a shape object such as a ``Polygon`` from the geometry module
    representing the shape of the cross-section of the beam. In such cases,
    it is assumed that the x-axis of the shape object is aligned with the
    bending axis of the beam. The second moment of area will be computed
    from the shape object internally.

area : Symbol/float
    Represents the cross-section area of beam

variable : Symbol, optional
    A Symbol object that will be used as the variable along the beam
    while representing the load, shear, moment, slope and deflection
    curve. By default, it is set to ``Symbol('x')``.

base_char : String, optional
    A String that will be used as base character to generate sequential
    symbols for integration constants in cases where boundary conditions
    are not sufficient to solve them.

ild_variable : Symbol, optional
    A Symbol object that will be used as the variable specifying the
    location of the moving load in ILD calculations. By default, it
    is set to ``Symbol('a')``.
N)
deflectionslopebending_momentshear_forcer   F)lengthelastic_modulus
isinstancer   cross_sectionsecond_momentvariableild_variable
_base_char_boundary_conditions_loadarea_applied_supports_applied_rotation_hinges_applied_sliding_hinges_rotation_hinge_symbols_sliding_hinge_symbols_support_as_loads_applied_loads_reaction_loads_ild_reactions
_ild_shear_ild_moment_original_load_joined_beam)selfr0   r1   r4   r:   r5   	base_charr6   s           ^/var/www/auris/envauris/lib/python3.13/site-packages/sympy/physics/continuum_mechanics/beam.py__init__Beam.__init__   s    X .m^44!.!%D!. (#35VXik$l!
	!#(*%')$')$&(#!# !   !    c                     U R                   (       a  U R                   OU R                  nSR                  [        U R                  5      [        U R
                  5      [        U5      5      nU$ )NzBeam({}, {}, {}))_cross_section_second_momentformatr   _length_elastic_modulus)rH   shape_descriptionstr_sols      rJ   __str__Beam.__str__   sR    373F3FD//DL_L_$++D,>TEZEZ@[]abs]turM   c                     U R                   $ )z,Returns the reaction forces in a dictionary.)rB   rH   s    rJ   reaction_loadsBeam.reaction_loads   s     ###rM   c                     U R                   $ )z
Returns the value for the rotation jumps in rotation hinges in a dictionary.
The rotation jump is the rotation (in radian) in a rotation hinge. This can
be seen as a jump in the slope plot.
)_rotation_jumpsrY   s    rJ   rotation_jumpsBeam.rotation_jumps   s     ###rM   c                     U R                   $ )z
Returns the deflection jumps in sliding hinges in a dictionary.
The deflection jump is the deflection (in meters) in a sliding hinge.
This can be seen as a jump in the deflection plot.
)_deflection_jumpsrY   s    rJ   deflection_jumpsBeam.deflection_jumps   s     %%%rM   c                     U R                   $ )z"Returns the I.L.D. shear equation.)rD   rY   s    rJ   	ild_shearBeam.ild_shear   s     rM   c                     U R                   $ )z3Returns the I.L.D. reaction forces in a dictionary.)rC   rY   s    rJ   ild_reactionsBeam.ild_reactions        """rM   c                     U R                   $ )z
Returns the I.L.D. rotation jumps in rotation hinges in a dictionary.
The rotation jump is the rotation (in radian) in a rotation hinge. This can
be seen as a jump in the slope plot.
)_ild_rotations_jumpsrY   s    rJ   ild_rotation_jumpsBeam.ild_rotation_jumps   s     (((rM   c                     U R                   $ )z
Returns the I.L.D. deflection jumps in sliding hinges in a dictionary.
The deflection jump is the deflection (in meters) in a sliding hinge.
This can be seen as a jump in the deflection plot.
)_ild_deflection_jumpsrY   s    rJ   ild_deflection_jumpsBeam.ild_deflection_jumps  s     )))rM   c                     U R                   $ )z#Returns the I.L.D. moment equation.)rE   rY   s    rJ   
ild_momentBeam.ild_moment  s     rM   c                     U R                   $ )zLength of the Beam.)rR   rY   s    rJ   r0   Beam.length  s     ||rM   c                 $    [        U5      U l        g N)r   rR   )rH   ls     rJ   r0   rw     s    qzrM   c                     U R                   $ z"Cross-sectional area of the Beam. _arearY   s    rJ   r:   	Beam.area       zzrM   c                 $    [        U5      U l        g ry   r   r~   rH   r*   s     rJ   r:   r         QZ
rM   c                     U R                   $ )a%  
A symbol that can be used as a variable along the length of the beam
while representing load distribution, shear force curve, bending
moment, slope curve and the deflection curve. By default, it is set
to ``Symbol('x')``, but this property is mutable.

Examples
========

>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I, A = symbols('E, I, A')
>>> x, y, z = symbols('x, y, z')
>>> b = Beam(4, E, I)
>>> b.variable
x
>>> b.variable = y
>>> b.variable
y
>>> b = Beam(4, E, I, A, z)
>>> b.variable
z
)	_variablerY   s    rJ   r5   Beam.variable#  s    2 ~~rM   c                 P    [        U[        5      (       a  Xl        g [        S5      e)Nz'The variable should be a Symbol object.)r2   r   r   	TypeError)rH   vs     rJ   r5   r   >  s     a  NIJJrM   c                     U R                   $ zYoung's Modulus of the Beam. )rS   rY   s    rJ   r1   Beam.elastic_modulusE  s     $$$rM   c                 $    [        U5      U l        g ry   )r   rS   rH   es     rJ   r1   r   J  s     '
rM   c                     U R                   $ z#Second moment of area of the Beam. rP   rY   s    rJ   r4   Beam.second_momentN  rj   rM   c                 r    S U l         [        U[        5      (       a  [        S5      e[	        U5      U l        g )Nz>To update cross-section geometry use `cross_section` attribute)rO   r2   r   
ValueErrorr   rP   )rH   is     rJ   r4   r   S  s/    "a((]^^")!*DrM   c                     U R                   $ )zCross-section of the beam)rO   rY   s    rJ   r3   Beam.cross_section[  rj   rM   c                 N    U(       a  UR                  5       S   U l        Xl        g )Nr   )second_moment_of_arearP   rO   )rH   ss     rJ   r3   r   `  s!    "#"9"9";A">DrM   c                     U R                   $ )a  
Returns a dictionary of boundary conditions applied on the beam.
The dictionary has three keywords namely moment, slope and deflection.
The value of each keyword is a list of tuple, where each tuple
contains location and value of a boundary condition in the format
(location, value).

Examples
========
There is a beam of length 4 meters. The bending moment at 0 should be 4
and at 4 it should be 0. The slope of the beam should be 1 at 0. The
deflection should be 2 at 0.

>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> b = Beam(4, E, I)
>>> b.bc_deflection = [(0, 2)]
>>> b.bc_slope = [(0, 1)]
>>> b.boundary_conditions
{'bending_moment': [], 'deflection': [(0, 2)], 'shear_force': [], 'slope': [(0, 1)]}

Here the deflection of the beam should be ``2`` at ``0``.
Similarly, the slope of the beam should be ``1`` at ``0``.
r8   rY   s    rJ   boundary_conditionsBeam.boundary_conditionsf  s    6 (((rM   c                      U R                   S   $ Nr/   r   rY   s    rJ   bc_shear_forceBeam.bc_shear_force  s    ((77rM   c                      XR                   S'   g r   r   )rH   sf_bcss     rJ   r   r     s    39!!-0rM   c                      U R                   S   $ Nr.   r   rY   s    rJ   bc_bending_momentBeam.bc_bending_moment  s    (()9::rM   c                      XR                   S'   g r   r   )rH   bm_bcss     rJ   r   r     s    6<!!"23rM   c                      U R                   S   $ Nr-   r   rY   s    rJ   bc_slopeBeam.bc_slope  s    ((11rM   c                      XR                   S'   g r   r   )rH   s_bcss     rJ   r   r     s    -2!!'*rM   c                      U R                   S   $ Nr,   r   rY   s    rJ   bc_deflectionBeam.bc_deflection  s    ((66rM   c                      XR                   S'   g r   r   )rH   d_bcss     rJ   r   r     s    27!!,/rM   c                    U R                   nU R                  nU R                  UR                  -   nU R                  UR                  :w  a  [        S5      eU R                  UR                  :w  a3  [        U R                  X0R                  :*  4UR                  X5:*  45      nOU R                  nUS:X  a  [        XTXc5      nSUl        U$ US:X  a0  [        XTXc5      nSUl        UR                  U R                  5        U$ g)a  
This method joins two beams to make a new composite beam system.
Passed Beam class instance is attached to the right end of calling
object. This method can be used to form beams having Discontinuous
values of Elastic modulus or Second moment.

Parameters
==========
beam : Beam class object
    The Beam object which would be connected to the right of calling
    object.
via : String
    States the way two Beam object would get connected
    - For axially fixed Beams, via="fixed"
    - For Beams connected via rotation hinge, via="hinge"

Examples
========
There is a cantilever beam of length 4 meters. For first 2 meters
its moment of inertia is `1.5*I` and `I` for the other end.
A pointload of magnitude 4 N is applied from the top at its free end.

>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> R1, R2 = symbols('R1, R2')
>>> b1 = Beam(2, E, 1.5*I)
>>> b2 = Beam(2, E, I)
>>> b = b1.join(b2, "fixed")
>>> b.apply_load(20, 4, -1)
>>> b.apply_load(R1, 0, -1)
>>> b.apply_load(R2, 0, -2)
>>> b.bc_slope = [(0, 0)]
>>> b.bc_deflection = [(0, 0)]
>>> b.solve_for_reaction_loads(R1, R2)
>>> b.load
80*SingularityFunction(x, 0, -2) - 20*SingularityFunction(x, 0, -1) + 20*SingularityFunction(x, 4, -1)
>>> b.slope()
(-((-80*SingularityFunction(x, 0, 1) + 10*SingularityFunction(x, 0, 2) - 10*SingularityFunction(x, 4, 2))/I + 120/I)/E + 80.0/(E*I))*SingularityFunction(x, 2, 0)
- 0.666666666666667*(-80*SingularityFunction(x, 0, 1) + 10*SingularityFunction(x, 0, 2) - 10*SingularityFunction(x, 4, 2))*SingularityFunction(x, 0, 0)/(E*I)
+ 0.666666666666667*(-80*SingularityFunction(x, 0, 1) + 10*SingularityFunction(x, 0, 2) - 10*SingularityFunction(x, 4, 2))*SingularityFunction(x, 2, 0)/(E*I)
z@Joining beams with different Elastic modulus is not implemented.fixedThingeN)	r5   r1   r0   NotImplementedErrorr4   r   r%   rG   apply_rotation_hinge)rH   beamviar(   E
new_lengthnew_second_momentnew_beams           rJ   join	Beam.join  s    V MM  [[4;;.
4#7#77%&hii!3!33 )4+=+=q++~*N%)%7%7$G!I !% 2 2'>J+<@H$(H!O'>J+<@H$(H!))$++6O	 rM   c                    [        U5      nU R                  R                  X45        US;   aG  [        S[	        U5      -   5      nU R                  X1S5        U R                  R                  US45        O[        S[	        U5      -   5      n[        S[	        U5      -   5      nU R                  X1S5        U R                  XAS5        U R                  R                  US45        U R                  R                  US45        U R                  R                  XASS45        U R                  R                  X1SS45        US;   a  U$ UW4$ )aa  
This method applies support to a particular beam object and returns
the symbol of the unknown reaction load(s).

Parameters
==========
loc : Sympifyable
    Location of point at which support is applied.
type : String
    Determines type of Beam support applied. To apply support structure
    with
    - zero degree of freedom, type = "fixed"
    - one degree of freedom, type = "pin"
    - two degrees of freedom, type = "roller"

Returns
=======
Symbol or tuple of Symbol
    The unknown reaction load as a symbol.
    - Symbol(reaction_force) if type = "pin" or "roller"
    - Symbol(reaction_force), Symbol(reaction_moment) if type = "fixed"

Examples
========
There is a beam of length 20 meters. A moment of magnitude 100 Nm is
applied in the clockwise direction at the end of the beam. A pointload
of magnitude 8 N is applied from the top of the beam at a distance of 10 meters.
There is one fixed support at the start of the beam and a roller at the end.

Using the sign convention of upward forces and clockwise moment
being positive.

>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> b = Beam(20, E, I)
>>> p0, m0 = b.apply_support(0, 'fixed')
>>> p1 = b.apply_support(20, 'roller')
>>> b.apply_load(-8, 10, -1)
>>> b.apply_load(100, 20, -2)
>>> b.solve_for_reaction_loads(p0, m0, p1)
>>> b.reaction_loads
{M_0: 20, R_0: -2, R_20: 10}
>>> b.reaction_loads[p0]
-2
>>> b.load
20*SingularityFunction(x, 0, -2) - 2*SingularityFunction(x, 0, -1)
- 8*SingularityFunction(x, 10, -1) + 100*SingularityFunction(x, 20, -2)
+ 10*SingularityFunction(x, 20, -1)
pinrollerR_r   M_N)	r   r;   appendr   str
apply_loadr   r   r@   rH   loctypereaction_loadreaction_moments        rJ   apply_supportBeam.apply_support  s#   f cl%%sk2$$"4C=1MOOM3%%sAh/"4C=1M$T#c(]3OOOM3OOO"5%%sAh/MM  #q*""))?T*JK%%}2t&DE$$   /11rM   c                     U R                   n[        U[        5      (       d  U$ [        [	        UR
                  5      5       H9  nXR
                  U   S   R
                  S   ::  d  M'  UR
                  U   S   s  $    g)zO
Helper function that returns the Second moment (I) at a location in the beam.
   r   N)r4   r2   r   rangelenargs)rH   r   Ir   s       rJ   _get_IBeam._get_I/  sg     !Y''H3qvv;'&&)A,++A..66!9Q<' (rM   c                 Z   [        U5      nU R                  nU R                  U5      n[        S[	        U5      -   5      nU R
                  R                  U5        U R                  R                  U5        U R                  X#-  U-  US5        U R                  R                  US45        U$ )a  
This method applies a rotation hinge at a single location on the beam.

Parameters
----------
loc : Sympifyable
    Location of point at which hinge is applied.

Returns
=======
Symbol
    The unknown rotation jump multiplied by the elastic modulus and second moment as a symbol.

Examples
========
There is a beam of length 15 meters. Pin supports are placed at distances
of 0 and 10 meters. There is a fixed support at the end. There are two rotation hinges
in the structure, one at 5 meters and one at 10 meters. A pointload of magnitude
10 kN is applied on the hinge at 5 meters. A distributed load of 5 kN works on
the structure from 10 meters to the end.

Using the sign convention of upward forces and clockwise moment
being positive.

>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import Symbol
>>> E = Symbol('E')
>>> I = Symbol('I')
>>> b = Beam(15, E, I)
>>> r0 = b.apply_support(0, type='pin')
>>> r10 = b.apply_support(10, type='pin')
>>> r15, m15 = b.apply_support(15, type='fixed')
>>> p5 = b.apply_rotation_hinge(5)
>>> p12 = b.apply_rotation_hinge(12)
>>> b.apply_load(-10, 5, -1)
>>> b.apply_load(-5, 10, 0, 15)
>>> b.solve_for_reaction_loads(r0, r10, r15, m15)
>>> b.reaction_loads
{M_15: -75/2, R_0: 0, R_10: 40, R_15: -5}
>>> b.rotation_jumps
{P_12: -1875/(16*E*I), P_5: 9625/(24*E*I)}
>>> b.rotation_jumps[p12]
-1875/(16*E*I)
>>> b.bending_moment()
-9625*SingularityFunction(x, 5, -1)/24 + 10*SingularityFunction(x, 5, 1)
- 40*SingularityFunction(x, 10, 1) + 5*SingularityFunction(x, 10, 2)/2
+ 1875*SingularityFunction(x, 12, -1)/16 + 75*SingularityFunction(x, 15, 0)/2
+ 5*SingularityFunction(x, 15, 1) - 5*SingularityFunction(x, 15, 2)/2
P_r   )
r   r1   r   r   r   r<   r   r>   r   r   )rH   r   r   r   rotation_jumps        rJ   r   Beam.apply_rotation_hinge;  s    d cl  KKtCH}-%%,,S1$$++M:-sB7%%sAh/rM   c                 Z   [        U5      nU R                  nU R                  U5      n[        S[	        U5      -   5      nU R
                  R                  U5        U R                  R                  U5        U R                  X#-  U-  US5        U R                  R                  US45        U$ )a;  
This method applies a sliding hinge at a single location on the beam.

Parameters
----------
loc : Sympifyable
    Location of point at which hinge is applied.

Returns
=======
Symbol
    The unknown deflection jump multiplied by the elastic modulus and second moment as a symbol.

Examples
========
There is a beam of length 13 meters. A fixed support is placed at the beginning.
There is a pin support at the end. There is a sliding hinge at a location of 8 meters.
A pointload of magnitude 10 kN is applied on the hinge at 5 meters.

Using the sign convention of upward forces and clockwise moment
being positive.

>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> b = Beam(13, 20, 20)
>>> r0, m0 = b.apply_support(0, type="fixed")
>>> s8 = b.apply_sliding_hinge(8)
>>> r13 = b.apply_support(13, type="pin")
>>> b.apply_load(-10, 5, -1)
>>> b.solve_for_reaction_loads(r0, m0, r13)
>>> b.reaction_loads
{M_0: -50, R_0: 10, R_13: 0}
>>> b.deflection_jumps
{W_8: 85/24}
>>> b.deflection_jumps[s8]
85/24
>>> b.bending_moment()
50*SingularityFunction(x, 0, 0) - 10*SingularityFunction(x, 0, 1)
+ 10*SingularityFunction(x, 5, 1) - 4250*SingularityFunction(x, 8, -2)/3
>>> b.deflection()
-SingularityFunction(x, 0, 2)/16 + SingularityFunction(x, 0, 3)/240
- SingularityFunction(x, 5, 3)/240 + 85*SingularityFunction(x, 8, 0)/24
W_r   )
r   r1   r   r   r   r=   r   r?   r   r   )rH   r   r   r   deflection_jumps        rJ   apply_sliding_hingeBeam.apply_sliding_hingex  s    V cl  KK C1$$++C0##**?;/b9""C8,rM   Nc           	      T   U R                   n[        U5      n[        U5      n[        U5      nU R                  R                  XX445        U =R                  U[        XRU5      -  -  sl        U =R                  U[        XRU5      -  -  sl        U(       a  U R                  XQX#USS9  gg)aS  
This method adds up the loads given to a particular beam object.

Parameters
==========
value : Sympifyable
    The value inserted should have the units [Force/(Distance**(n+1)]
    where n is the order of applied load.
    Units for applied loads:

       - For moments, unit = kN*m
       - For point loads, unit = kN
       - For constant distributed load, unit = kN/m
       - For ramp loads, unit = kN/m/m
       - For parabolic ramp loads, unit = kN/m/m/m
       - ... so on.

start : Sympifyable
    The starting point of the applied load. For point moments and
    point forces this is the location of application.
order : Integer
    The order of the applied load.

       - For moments, order = -2
       - For point loads, order =-1
       - For constant distributed load, order = 0
       - For ramp loads, order = 1
       - For parabolic ramp loads, order = 2
       - ... so on.

end : Sympifyable, optional
    An optional argument that can be used if the load has an end point
    within the length of the beam.

Examples
========
There is a beam of length 4 meters. A moment of magnitude 3 Nm is
applied in the clockwise direction at the starting point of the beam.
A point load of magnitude 4 N is applied from the top of the beam at
2 meters from the starting point and a parabolic ramp load of magnitude
2 N/m is applied below the beam starting from 2 meters to 3 meters
away from the starting point of the beam.

>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> b = Beam(4, E, I)
>>> b.apply_load(-3, 0, -2)
>>> b.apply_load(4, 2, -1)
>>> b.apply_load(-2, 2, 2, end=3)
>>> b.load
-3*SingularityFunction(x, 0, -2) + 4*SingularityFunction(x, 2, -1) - 2*SingularityFunction(x, 2, 2) + 2*SingularityFunction(x, 3, 0) + 4*SingularityFunction(x, 3, 1) + 2*SingularityFunction(x, 3, 2)

applyr   N)r5   r   rA   r   r9   r   rF   _handle_end)rH   valuestartorderendr(   s         rJ   r   Beam.apply_load  s    n MM""E%#=>

e/%@@@
u%85%IIIQuSwG rM   c           	         U R                   n[        U5      n[        U5      n[        U5      nXX44U R                  ;   ab  U =R                  U[	        XRU5      -  -  sl        U =R
                  U[	        XRU5      -  -  sl        U R                  R                  XX445        OSn[        U5      eU(       a  U R                  XQX#USS9  gg)a  
This method removes a particular load present on the beam object.
Returns a ValueError if the load passed as an argument is not
present on the beam.

Parameters
==========
value : Sympifyable
    The magnitude of an applied load.
start : Sympifyable
    The starting point of the applied load. For point moments and
    point forces this is the location of application.
order : Integer
    The order of the applied load.
    - For moments, order= -2
    - For point loads, order=-1
    - For constant distributed load, order=0
    - For ramp loads, order=1
    - For parabolic ramp loads, order=2
    - ... so on.
end : Sympifyable, optional
    An optional argument that can be used if the load has an end point
    within the length of the beam.

Examples
========
There is a beam of length 4 meters. A moment of magnitude 3 Nm is
applied in the clockwise direction at the starting point of the beam.
A pointload of magnitude 4 N is applied from the top of the beam at
2 meters from the starting point and a parabolic ramp load of magnitude
2 N/m is applied below the beam starting from 2 meters to 3 meters
away from the starting point of the beam.

>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> b = Beam(4, E, I)
>>> b.apply_load(-3, 0, -2)
>>> b.apply_load(4, 2, -1)
>>> b.apply_load(-2, 2, 2, end=3)
>>> b.load
-3*SingularityFunction(x, 0, -2) + 4*SingularityFunction(x, 2, -1) - 2*SingularityFunction(x, 2, 2) + 2*SingularityFunction(x, 3, 0) + 4*SingularityFunction(x, 3, 1) + 2*SingularityFunction(x, 3, 2)
>>> b.remove_load(-2, 2, 2, end = 3)
>>> b.load
-3*SingularityFunction(x, 0, -2) + 4*SingularityFunction(x, 2, -1)
z4No such load distribution exists on the beam object.remover   N)	r5   r   rA   r9   r   rF   r   r   r   )rH   r   r   r   r   r(   msgs          rJ   remove_loadBeam.remove_load  s    ^ MM%%)<)<<JJ% 3Ae DDDJ5)<Qu)M#MM&&e'ABHCS/!QuSxH rM   c           	      :   UR                   (       a  Sn[        U5      eX!U-  -  nUS:X  a  [        SUS-   5       H  n	U =R                  UR	                  X5      R                  XU-
  5      [        XU	5      -  [        U	5      -  -  sl        U =R                  UR	                  X5      R                  XU-
  5      [        XU	5      -  [        U	5      -  -  sl        M     gUS:X  a  [        SUS-   5       H  n	U =R                  UR	                  X5      R                  XU-
  5      [        XU	5      -  [        U	5      -  -  sl        U =R                  UR	                  X5      R                  XU-
  5      [        XU	5      -  [        U	5      -  -  sl        M     gg)z
This functions handles the optional `end` value in the
`apply_load` and `remove_load` functions. When the value
of end is not NULL, this function will be executed.
zpIf 'end' is provided the 'order' of the load cannot be negative, i.e. 'end' is only valid for distributed loads.r   r   r   r   N)	is_negativer   r   r9   r   subsr   r   rF   )
rH   r(   r   r   r   r   r   r   fr   s
             rJ   r   Beam._handle_end2  s    C S/! U(N7?1eai(

qvva|00%K@ 3AA > ??H| L M
##q(9(9!5[(I 3AA >)??H|)L M# )
 X1eai(

qvva|00%K@ 3AA > ??H| L M
##q(9(9!5[(I 3AA >)??H|)L M# ) rM   c                     U R                   $ )aB  
Returns a Singularity Function expression which represents
the load distribution curve of the Beam object.

Examples
========
There is a beam of length 4 meters. A moment of magnitude 3 Nm is
applied in the clockwise direction at the starting point of the beam.
A point load of magnitude 4 N is applied from the top of the beam at
2 meters from the starting point and a parabolic ramp load of magnitude
2 N/m is applied below the beam starting from 3 meters away from the
starting point of the beam.

>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> b = Beam(4, E, I)
>>> b.apply_load(-3, 0, -2)
>>> b.apply_load(4, 2, -1)
>>> b.apply_load(-2, 3, 2)
>>> b.load
-3*SingularityFunction(x, 0, -2) + 4*SingularityFunction(x, 2, -1) - 2*SingularityFunction(x, 3, 2)
)r9   rY   s    rJ   load	Beam.loadR  s    2 zzrM   c                     U R                   $ )a7  
Returns a list of all loads applied on the beam object.
Each load in the list is a tuple of form (value, start, order, end).

Examples
========
There is a beam of length 4 meters. A moment of magnitude 3 Nm is
applied in the clockwise direction at the starting point of the beam.
A pointload of magnitude 4 N is applied from the top of the beam at
2 meters from the starting point. Another pointload of magnitude 5 N
is applied at same position.

>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> b = Beam(4, E, I)
>>> b.apply_load(-3, 0, -2)
>>> b.apply_load(4, 2, -1)
>>> b.apply_load(5, 2, -1)
>>> b.load
-3*SingularityFunction(x, 0, -2) + 9*SingularityFunction(x, 2, -1)
>>> b.applied_loads
[(-3, 0, -2, None), (4, 2, -1, None), (5, 2, -1, None)]
)rA   rY   s    rJ   applied_loadsBeam.applied_loadsm  s    4 """rM   c                 t   U R                   nU R                  n[        S5      n[        S5      n[        U R                  5      n[        U R
                  5      n[        U R                  5       X#5      n[        U R                  5       X#5      n	/ n
/ n/ n/ nU R                  S    HT  u  pU R                  5       R                  X.5      U-
  n[        S UR                   5       5      nU
R                  U5        MV     U R                  S    HT  u  pU R                  5       R                  X.5      U-
  n[        S UR                   5       5      nUR                  U5        MV     [        U R                  5       U5      U-   nU R                  S    H*  u  pUR                  X.5      U-
  nUR                  U5        M,     [        UU5      U-   nU R                  S    H*  u  pUR                  X.5      U-
  nUR                  U5        M,     [        [!        X/U
-   U-   U-   U-   XE4U-   U-   U-   5      R                  S	   5      nS
[#        U5      -   nU[#        U5      -   nUS
U nUUU nUUS n[%        ['        UU5      5      U l        [%        ['        UU5      5      U l        [%        ['        UU5      5      U l        U R.                  R                  U R(                  5      U l        U R.                  R                  U R*                  5      U l        U R.                  R                  U R,                  5      U l        g)a  
Solves for the reaction forces.

Examples
========
There is a beam of length 30 meters. A moment of magnitude 120 Nm is
applied in the clockwise direction at the end of the beam. A pointload
of magnitude 8 N is applied from the top of the beam at the starting
point. There are two simple supports below the beam. One at the end
and another one at a distance of 10 meters from the start. The
deflection is restricted at both the supports.

Using the sign convention of upward forces and clockwise moment
being positive.

>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> R1, R2 = symbols('R1, R2')
>>> b = Beam(30, E, I)
>>> b.apply_load(-8, 0, -1)
>>> b.apply_load(R1, 10, -1)  # Reaction force at x = 10
>>> b.apply_load(R2, 30, -1)  # Reaction force at x = 30
>>> b.apply_load(120, 30, -2)
>>> b.bc_deflection = [(10, 0), (30, 0)]
>>> b.load
R1*SingularityFunction(x, 10, -1) + R2*SingularityFunction(x, 30, -1)
    - 8*SingularityFunction(x, 0, -1) + 120*SingularityFunction(x, 30, -2)
>>> b.solve_for_reaction_loads(R1, R2)
>>> b.reaction_loads
{R1: 6, R2: 2}
>>> b.load
-8*SingularityFunction(x, 0, -1) + 6*SingularityFunction(x, 10, -1)
    + 120*SingularityFunction(x, 30, -2) + 2*SingularityFunction(x, 30, -1)
C3C4r/   c              3   l   #    U  H*  n[        S  UR                   5       5      (       a  M&  Uv   M,     g7f)c              3   8   #    U  H  oR                   v   M     g 7fry   is_infinite.0nums     rJ   	<genexpr>:Beam.solve_for_reaction_loads.<locals>.<genexpr>.<genexpr>       <aX`QT__X`   Nanyr   r  args     rJ   r  0Beam.solve_for_reaction_loads.<locals>.<genexpr>  &     b#<aX[X`X`<a9a##   %4	4r.   c              3   l   #    U  H*  n[        S  UR                   5       5      (       a  M&  Uv   M,     g7f)c              3   8   #    U  H  oR                   v   M     g 7fry   r	  r  s     rJ   r  r    r  r  Nr  r  s     rJ   r  r    r  r  r-   r,   r      N)r5   r0   r   tupler>   r?   r   r/   r.   r8   r   sumr   r   r   listr   r   dictziprB   r]   ra   r9   )rH   	reactionsr(   rz   r  r  r^   rb   shear_curvemoment_curveshear_force_eqsbending_moment_eqs	slope_eqsdeflection_eqspositionr   eqsnew_eqsslope_curvedeflection_curvesolutionreaction_indexrotation_indexreaction_solutionrotation_solutiondeflection_solutions                             rJ   solve_for_reaction_loadsBeam.solve_for_reaction_loads  s   J MMKKD\D\t;;< !<!<=D,,.5T002A9	#88GOH""$))!6>CbbbG""7+  H
  $889IJOH%%',,Q9EACbbbG%%g.  K
   3 3 5q9B>#88AOH""1/%7CS!  B %[!4r9#88FOH"''4u<C!!#&  G ;"="ORd"dgp"p,#-/1h.B^.SVf.fhhlhlnoq r3y>)'#n*==$Q~6$^NC&~7#C	3D$EF#C8I$JK!%c*:<O&P!QZZ__T%9%9:
ZZ__T%9%9:
ZZ__T%;%;<
rM   c                 H    U R                   n[        U R                  U5      * $ )aY  
Returns a Singularity Function expression which represents
the shear force curve of the Beam object.

Examples
========
There is a beam of length 30 meters. A moment of magnitude 120 Nm is
applied in the clockwise direction at the end of the beam. A pointload
of magnitude 8 N is applied from the top of the beam at the starting
point. There are two simple supports below the beam. One at the end
and another one at a distance of 10 meters from the start. The
deflection is restricted at both the supports.

Using the sign convention of upward forces and clockwise moment
being positive.

>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> R1, R2 = symbols('R1, R2')
>>> b = Beam(30, E, I)
>>> b.apply_load(-8, 0, -1)
>>> b.apply_load(R1, 10, -1)
>>> b.apply_load(R2, 30, -1)
>>> b.apply_load(120, 30, -2)
>>> b.bc_deflection = [(10, 0), (30, 0)]
>>> b.solve_for_reaction_loads(R1, R2)
>>> b.shear_force()
8*SingularityFunction(x, 0, 0) - 6*SingularityFunction(x, 10, 0) - 120*SingularityFunction(x, 30, -1) - 2*SingularityFunction(x, 30, 0)
)r5   r   r   rH   r(   s     rJ   r/   Beam.shear_force  s!    > MM$))Q'''rM   c                    U R                  5       nU R                  nUR                  n/ nU HE  n[        U[        5      (       a  UR                  S   nUR                  UR                  S   5        MG     [        [        U5      5      nUR                  5         / n/ n[        U5       GH$  u  pU	S:X  a  M   [        [        S5      X$US-
     :*  4U R                  R                  [        5      X):  4[        S5      S45      n
[        X5      n/ nU H,  nUR                  [        UR!                  X-5      5      5        M.     UR#                  XHS-
     U	/5        U[        [%        XXHS-
     S5      5      [        [%        XU	S5      5      /-  n['        U5      nUR                  U5        UR                  XR)                  U5         5        GM'     [        [/        [        U5      5      n['        U5      nXgR)                  U5         nUU4$ ! [*         a    [%        XXHS-
     S5      n[%        XU	S5      nUR!                  X$US-
     U	-   S-  5      UU-   S-  :X  a5  UU:w  a/  UR#                  UU/5        UR#                  XHS-
     U	/5         GM  UR                  U5        UR                  [-        XHS-
     U	5      5         GM  f = f	zBReturns maximum Shear force and its coordinate
in the Beam object.r   r   r   nanT+-r  )r/   r5   r   r2   r   r   r  setsort	enumerater   floatr9   rewriter   absr   extendr   maxindexr   r   map)rH   r"  r(   termssingularityterm	intervalsshear_valuesr   r   shear_slopepointsvalpoint	max_shearinitial_shearfinal_shearmaximum_shears                     rJ   max_shear_forceBeam.max_shear_force  s    &&(MM  D$$$yy}tyy|,  3{+,	k*DAAvD'uqac:J7J(KTZZM_M_`iMjlmloLpsxy~s  BF  sG  H{.#EJJs;#3#3A#=>? ${Q3/34E++c2BCHI3uU`efhkOlKmnnH	##I.  		)(<!=> +8 C\23L),,];<}%% ' 	D %kkA#6F L#KAs;##AAaC(81(<a'?@]U`E`bcDcchu  zE  iE ''(DE$$kA#&6%:;; ''4$$XkA#.>%BCC	Ds   8DHBK1KKc                 N    U R                   n[        U R                  5       U5      $ )a^  
Returns a Singularity Function expression which represents
the bending moment curve of the Beam object.

Examples
========
There is a beam of length 30 meters. A moment of magnitude 120 Nm is
applied in the clockwise direction at the end of the beam. A pointload
of magnitude 8 N is applied from the top of the beam at the starting
point. There are two simple supports below the beam. One at the end
and another one at a distance of 10 meters from the start. The
deflection is restricted at both the supports.

Using the sign convention of upward forces and clockwise moment
being positive.

>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> R1, R2 = symbols('R1, R2')
>>> b = Beam(30, E, I)
>>> b.apply_load(-8, 0, -1)
>>> b.apply_load(R1, 10, -1)
>>> b.apply_load(R2, 30, -1)
>>> b.apply_load(120, 30, -2)
>>> b.bc_deflection = [(10, 0), (30, 0)]
>>> b.solve_for_reaction_loads(R1, R2)
>>> b.bending_moment()
8*SingularityFunction(x, 0, 1) - 6*SingularityFunction(x, 10, 1) - 120*SingularityFunction(x, 30, 0) - 2*SingularityFunction(x, 30, 1)
)r5   r   r/   r6  s     rJ   r.   Beam.bending_moment4  s#    > MM))+Q//rM   c                    U R                  5       nU R                  nUR                  n/ nU HE  n[        U[        5      (       a  UR                  S   nUR                  UR                  S   5        MG     [        [        U5      5      nUR                  5         / n/ n[        U5       GH(  u  pU	S:X  a  M   [        [        S5      X$US-
     :*  4U R                  5       R                  [        5      X):  4[        S5      S45      n
[        X5      n/ nU H,  nUR                  [        UR!                  X-5      5      5        M.     UR#                  XHS-
     U	/5        U[        [%        XXHS-
     S5      5      [        [%        XU	S5      5      /-  n['        U5      nUR                  U5        UR                  XR)                  U5         5        GM+     [        [/        [        U5      5      n['        U5      nXgR)                  U5         nUU4$ ! [*         a    [%        XXHS-
     S5      n[%        XU	S5      nUR!                  X$US-
     U	-   S-  5      UU-   S-  :X  a5  UU:w  a/  UR#                  UU/5        UR#                  XHS-
     U	/5         GM  UR                  U5        UR                  [-        XHS-
     U	5      5         GM"  f = fr9  )r.   r5   r   r2   r   r   r  r=  r>  r?  r   r@  r/   rA  r   rB  r   rC  r   rD  rE  r   r   rF  )rH   bending_curver(   rG  rH  rI  rJ  moment_valuesr   r   moment_sloperM  rN  rO  
max_momentinitial_momentfinal_momentmaximum_moments                     rJ   max_bmomentBeam.max_bmomentV  s    ++-MM""D$$$yy}tyy|,  3{+,	k*DAAvD(5\1AE(:#:;%%'//	:AEB5\4( * |/#EJJs=#5#5a#?@A ${Q3/34E-K!4DcJKSQVWdijloQpMqrr X
$$Z0  		*(=!>?! +@ Sm45]+--n=>~&& ' 	D!&}qS9I3!O$]q#> %%aac*:Q*>)AB~XdGdfgFgglz  K  mK!((.,)GH$$kA#&6%:;;!((6$$XkA#.>%BCC	Ds   8DHBK1KKc                    [        S U R                  5       R                   5       5      n[        [	        S5      U R
                  S:*  4XR
                  U R                  :  4[	        S5      S45      n [        UR                  [        5      U R
                  [        R                  S9nU$ ! [         a   nS[        U5      ;   a  [        S5      ee SnAff = f)	a  
Returns a Set of point(s) with zero bending moment and
where bending moment curve of the beam object changes
its sign from negative to positive or vice versa.

Examples
========
There is is 10 meter long overhanging beam. There are
two simple supports below the beam. One at the start
and another one at a distance of 6 meters from the start.
Point loads of magnitude 10KN and 20KN are applied at
2 meters and 4 meters from start respectively. A Uniformly
distribute load of magnitude of magnitude 3KN/m is also
applied on top starting from 6 meters away from starting
point till end.
Using the sign convention of upward forces and clockwise moment
being positive.

>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> b = Beam(10, E, I)
>>> b.apply_load(-4, 0, -1)
>>> b.apply_load(-46, 6, -1)
>>> b.apply_load(10, 2, -1)
>>> b.apply_load(20, 4, -1)
>>> b.apply_load(3, 6, 0)
>>> b.point_cflexure()
[10/3]
c              3   h   #    U  H(  oR                   S    R                   S   S:  a  M$  Uv   M*     g7f)r   r  r   N)r   r  s     rJ   r  &Beam.point_cflexure.<locals>.<genexpr>  s2     )s9S#[c[cde[f[k[klm[nqr[r##9Ss   #2	2r:  r   Tdomainz"An expression is already zero whenzXThis method cannot be used when a whole region of the bending moment line is equal to 0.N)r  r.   r   r   r@  r5   r0   r   rA  r   Realsr   r   )rH   non_singular_bending_momentr#  rM  r   s        rJ   point_cflexureBeam.point_cflexure  s    @ '*)s9L9L9N9S9S)s&s# !%,q0@!A,mmDKK.GHut$&	<//	:DMM"#''+F  # 	3s1v=) +S T T 	s   46B, ,
C6CCc           	      b   U R                   nU R                  nU R                  nU R                  S   (       d  [	        U R                  5       U5      $ [        U[        5      (       Ga  U R                  (       Ga	  UR                  nSnSnSn[        [        U5      5       H  nUS:w  a  XHS-
     S   R                  S   n[        R                  * U-  [        U R                  5       XH   S   -  XU45      -  n	U[        U5      S-
  :w  a:  XVU	-   [!        XS5      -  Xi-   [!        XU   S   R                  S   S5      -  -
  -  nOXVU	-   [!        XS5      -  -  nU	R#                  XU   S   R                  S   5      nM     U$ [%        S5      n
[        [        R                  X#-  -  U R                  5       -  U5      * U
-   n/ nU R                  S    H*  u  pUR#                  X5      U-
  nUR'                  U5        M,     [)        [+        X5      5      nUR#                  U
US   S   05      nU$ )al  
Returns a Singularity Function expression which represents
the slope the elastic curve of the Beam object.

Examples
========
There is a beam of length 30 meters. A moment of magnitude 120 Nm is
applied in the clockwise direction at the end of the beam. A pointload
of magnitude 8 N is applied from the top of the beam at the starting
point. There are two simple supports below the beam. One at the end
and another one at a distance of 10 meters from the start. The
deflection is restricted at both the supports.

Using the sign convention of upward forces and clockwise moment
being positive.

>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> R1, R2 = symbols('R1, R2')
>>> b = Beam(30, E, I)
>>> b.apply_load(-8, 0, -1)
>>> b.apply_load(R1, 10, -1)
>>> b.apply_load(R2, 30, -1)
>>> b.apply_load(120, 30, -2)
>>> b.bc_deflection = [(10, 0), (30, 0)]
>>> b.solve_for_reaction_loads(R1, R2)
>>> b.slope()
(-4*SingularityFunction(x, 0, 2) + 3*SingularityFunction(x, 10, 2)
    + 120*SingularityFunction(x, 30, 1) + SingularityFunction(x, 30, 2) + 4000/3)/(E*I)
r-   r   r   r  )r5   r1   r4   r8   r   r,   r2   r   rG   r   r   r   r   Oner   r.   r   r   r   r   r  r   )rH   r(   r   r   r   r-   
prev_slopeprev_endr   slope_valuer  r+  bc_eqsr(  r   r)  	constantss                    rJ   r-   
Beam.slope  s'   @ MM  ((1)1--a##(9(9(966DEJH3t9%6#aCy|003H uufQhy1D1D1Ftwqz1QTUabSc'ddD	A%;68KAYZ8[[#13Fqq'RS*//Z[J\^_3``a aE ;68KAYZ8[[[E(--aa1CD
 & LD\ T-@-@-B!BAFFK#88AOH""1/%7CMM#  B &-.	!&&IaLO'<=rM   c           	         U R                   nU R                  nU R                  nU R                  S   (       Gd  U R                  S   (       Gd  [	        U[
        5      (       GaT  U R                  (       GaB  UR                  nSnSnSnSn[        [        U5      5       GH  n	U	S:w  a  XIS-
     S   R                  S   n[        R                  * U-  [        U R                  5       XI   S   -  XU45      -  n
XZ-   n[        XXq45      nU	[        U5      S-
  :w  a:  XU-   [        XS5      -  Xl-   [        XU	   S   R                  S   S5      -  -
  -  nOXU-   [        XS5      -  -  nU
R                  XU	   S   R                  S   5      nUR                  XU	   S   R                  S   5      nGM     U$ U R                   n[#        US-   5      n[        R                  X#-  -  [        [        U R                  5       U5      * U5      -  US   U-  -   US   -   $ U R                  S   (       d7  U R                   n[#        US-   5      n[        U R%                  5       U5      U-   $ U R                  S   (       GdZ  U R                  S   (       GaE  [	        U[
        5      (       GaT  U R                  (       GaB  UR                  nSnSnSnSn[        [        U5      5       GH  n	U	S:w  a  XIS-
     S   R                  S   n[        R                  * U-  [        U R                  5       XI   S   -  XU45      -  n
XZ-   n[        XXq45      nU	[        U5      S-
  :w  a:  XU-   [        XS5      -  Xl-   [        XU	   S   R                  S   S5      -  -
  -  nOXU-   [        XS5      -  -  nU
R                  XU	   S   R                  S   5      nUR                  XU	   S   R                  S   5      nGM     U$ U R                   n[#        US-   5      u  nn[        U R                  5       U5      * U-   n[        UU5      U-   n/ nU R                  S    H,  u  nnUR                  UU5      U-
  nUR'                  U5        M.     [)        [+        UUU45      5      nUR                  UUS   S   UUS   S   05      n[        R                  X#-  -  U-  $ [	        U[
        5      (       GaS  U R                  (       GaA  UR                  nSnSnSnSn[        [        U5      5       GH  n	U	S:w  a  XIS-
     S   R                  S   n[        R                  U-  [        U R                  5       XI   S   -  XU45      -  n
XZ-   n[        XXq45      nU	[        U5      S-
  :w  a:  XU-   [        XS5      -  Xl-   [        XU	   S   R                  S   S5      -  -
  -  nOXU-   [        XS5      -  -  nU
R                  XU	   S   R                  S   5      nUR                  XU	   S   R                  S   5      nGM     U$ [-        S5      n[        U R%                  5       U5      U-   n/ nU R                  S    H,  u  nnUR                  UU5      U-
  nUR'                  U5        M.     [)        [+        UU5      5      nUR                  UUS   S   05      nU$ )a  
Returns a Singularity Function expression which represents
the elastic curve or deflection of the Beam object.

Examples
========
There is a beam of length 30 meters. A moment of magnitude 120 Nm is
applied in the clockwise direction at the end of the beam. A pointload
of magnitude 8 N is applied from the top of the beam at the starting
point. There are two simple supports below the beam. One at the end
and another one at a distance of 10 meters from the start. The
deflection is restricted at both the supports.

Using the sign convention of upward forces and clockwise moment
being positive.

>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> R1, R2 = symbols('R1, R2')
>>> b = Beam(30, E, I)
>>> b.apply_load(-8, 0, -1)
>>> b.apply_load(R1, 10, -1)
>>> b.apply_load(R2, 30, -1)
>>> b.apply_load(120, 30, -2)
>>> b.bc_deflection = [(10, 0), (30, 0)]
>>> b.solve_for_reaction_loads(R1, R2)
>>> b.deflection()
(4000*x/3 - 4*SingularityFunction(x, 0, 3)/3 + SingularityFunction(x, 10, 3)
    + 60*SingularityFunction(x, 30, 2) + SingularityFunction(x, 30, 3)/3 - 12000)/(E*I)
r,   r-   r   r   z3:54r  )r5   r1   r4   r8   r2   r   rG   r   r   r   r   rl  r   r.   r   r   r7   r   r-   r   r  r   r   )rH   r(   r   r   r   rm  prev_defrn  r,   r   ro  recent_segment_slopedeflection_valuerI   rq  constantr  r  r+  r,  rp  r(  r   r)  s                           rJ   r,   Beam.deflection   s   @ MM  ((66t?X?XY`?a?a!Y''D,=,=,=vv

s4y)AAv#'!9Q<#4#4Q#7#$55&(9T5H5H5J47ST:5UXYefWg+h"hK+5+C('01E8GW'X$CIM)"2B'BDWXYefDg&g':<OPQXYSZ[\S]SbSbcdSegh<ii'j j
 #2B'BDWXYefDg&gg
!,!1!1!!WQZ__Q5G!HJ/44QQ
8JKH * "!I	E 12I55!#;y)D4G4G4I1*M)MqQQT]^_T`abTbbenopeqqq**<8Iy3/HTZZ\1-88**7338Q8QR^8_8_!Y''D,=,=,=vv

s4y)AAv#'!9Q<#4#4Q#7#$55&(9T5H5H5J47ST:5UXYefWg+h"hK+5+C('01E8GW'X$CIM)"2B'BDWXYefDg&g':<OPQXYSZ[\S]SbSbcdSegh<ii'j j
 #2B'BDWXYefDg&gg
!,!1!1!!WQZ__Q5G!HJ/44QQ
8JKH * "!IY./FB$T%8%8%:A>>CK(a82=F#'#<#<\#J%&++Ax85@c" $K Xfr2h78I/44b)A,q/2yYZ|\]5_`55!#;///a##(9(9(966DJHHJ3t9%6#aCy|003HeeAgi0C0C0Edgaj0PST`aRb&cc'1'?$#,-AxCS#T D	A%.>#>@STUab@c"c#68KATUwWXz_`Oacd8ee#f fJ .>#>@STUab@c"ccJ(--aa1CD
+00GAJOOA4FG & D\$TZZ\15:#88FOHe"''84u<CMM#  G &"-.	+00"il1o1FGrM   c                 .   [        [        S5      U R                  S:*  4U R                  5       U R                  U R                  :  4[        S5      S45      n[        UR                  [         5      U R                  [        R                  S9nU R                  5       nU Vs/ s H  oCR                  U R                  U5      PM      nn[        [        [        U5      5      n[        U5      S:w  a   [        U5      nX%R!                  U5         U4$ gs  snf )zZ
Returns point of max deflection and its corresponding deflection value
in a Beam object.
r:  r   Tre  N)r   r@  r5   r-   r0   r   rA  r   rg  r,   r   r  rF  rB  r   rD  rE  )rH   r+  rM  r,  r(   deflectionsmax_defs          rJ   max_deflectionBeam.max_deflection  s      ut}}a/? @t}}T[[89ut$& {**95t}} ww(??,HNO1,,T]]A>O3sK01{q +&G,,W56@@ Ps   "%Dc                 <    U R                  5       U R                  -  $ )zO
Returns an expression representing the Shear Stress
curve of the Beam object.
r/   r~   rY   s    rJ   shear_stressBeam.shear_stress  s    
 !$**,,rM   c           	         U R                  5       nU R                  nU R                  nUc  0 nUR                  [        5       H  nXS:w  d  M
  XQ;  d  M  [        SU-  5      e   XA;   a  X   n[        UR                  U5      USU4SSSSS9$ )a  

Returns a plot of shear stress present in the beam object.

Parameters
==========
subs : dictionary
    Python dictionary containing Symbols as key and their
    corresponding values.

Examples
========
There is a beam of length 8 meters and area of cross section 2 square
meters. A constant distributed load of 10 KN/m is applied from half of
the beam till the end. There are two simple supports below the beam,
one at the starting point and another at the ending point of the beam.
A pointload of magnitude 5 KN is also applied from top of the
beam, at a distance of 4 meters from the starting point.
Take E = 200 GPa and I = 400*(10**-6) meter**4.

Using the sign convention of downwards forces being positive.

.. plot::
    :context: close-figs
    :format: doctest
    :include-source: True

    >>> from sympy.physics.continuum_mechanics.beam import Beam
    >>> from sympy import symbols
    >>> R1, R2 = symbols('R1, R2')
    >>> b = Beam(8, 200*(10**9), 400*(10**-6), 2)
    >>> b.apply_load(5000, 2, -1)
    >>> b.apply_load(R1, 0, -1)
    >>> b.apply_load(R2, 8, -1)
    >>> b.apply_load(10000, 4, 0, end=8)
    >>> b.bc_deflection = [(0, 0), (8, 0)]
    >>> b.solve_for_reaction_loads(R1, R2)
    >>> b.plot_shear_stress()
    Plot object containing:
    [0]: cartesian line: 6875*SingularityFunction(x, 0, 0) - 2500*SingularityFunction(x, 2, 0)
    - 5000*SingularityFunction(x, 4, 1) + 15625*SingularityFunction(x, 8, 0)
    + 5000*SingularityFunction(x, 8, 1) for x over (0.0, 8.0)
zvalue of %s was not passed.r   zShear Stress$\mathrm{x}$z$\tau$rtitlexlabelylabel
line_color)r  r5   r0   atomsr   r   r   r   )rH   r   r  r(   r0   syms         rJ   plot_shear_stressBeam.plot_shear_stress  s    Z ((*MM<D%%f-CxCO !>!CDD . >\F \&&t,q!Vn_Y 	rM   c           	      V   U R                  5       nUc  0 nUR                  [        5       H'  nX0R                  :X  a  M  X1;  d  M  [	        SU-  5      e   U R
                  U;   a  XR
                     nOU R
                  n[        UR                  U5      U R                  SU4SSSSS9$ )a  

Returns a plot for Shear force present in the Beam object.

Parameters
==========
subs : dictionary
    Python dictionary containing Symbols as key and their
    corresponding values.

Examples
========
There is a beam of length 8 meters. A constant distributed load of 10 KN/m
is applied from half of the beam till the end. There are two simple supports
below the beam, one at the starting point and another at the ending point
of the beam. A pointload of magnitude 5 KN is also applied from top of the
beam, at a distance of 4 meters from the starting point.
Take E = 200 GPa and I = 400*(10**-6) meter**4.

Using the sign convention of downwards forces being positive.

.. plot::
    :context: close-figs
    :format: doctest
    :include-source: True

    >>> from sympy.physics.continuum_mechanics.beam import Beam
    >>> from sympy import symbols
    >>> R1, R2 = symbols('R1, R2')
    >>> b = Beam(8, 200*(10**9), 400*(10**-6))
    >>> b.apply_load(5000, 2, -1)
    >>> b.apply_load(R1, 0, -1)
    >>> b.apply_load(R2, 8, -1)
    >>> b.apply_load(10000, 4, 0, end=8)
    >>> b.bc_deflection = [(0, 0), (8, 0)]
    >>> b.solve_for_reaction_loads(R1, R2)
    >>> b.plot_shear_force()
    Plot object containing:
    [0]: cartesian line: 13750*SingularityFunction(x, 0, 0) - 5000*SingularityFunction(x, 2, 0)
    - 10000*SingularityFunction(x, 4, 1) + 31250*SingularityFunction(x, 8, 0)
    + 10000*SingularityFunction(x, 8, 1) for x over (0.0, 8.0)
Value of %s was not passed.r   Shear Forcer  $\mathrm{V}$gr  r/   r  r   r5   r   r0   r   r   )rH   r   r/   r  r0   s        rJ   plot_shear_forceBeam.plot_shear_force  s    V &&(<D$$V,Cmm# !>!CDD	 -
 ;;$++&F[[FK$$T*T]]Av,Fm&3P 	PrM   c           	      V   U R                  5       nUc  0 nUR                  [        5       H'  nX0R                  :X  a  M  X1;  d  M  [	        SU-  5      e   U R
                  U;   a  XR
                     nOU R
                  n[        UR                  U5      U R                  SU4SSSSS9$ )a  

Returns a plot for Bending moment present in the Beam object.

Parameters
==========
subs : dictionary
    Python dictionary containing Symbols as key and their
    corresponding values.

Examples
========
There is a beam of length 8 meters. A constant distributed load of 10 KN/m
is applied from half of the beam till the end. There are two simple supports
below the beam, one at the starting point and another at the ending point
of the beam. A pointload of magnitude 5 KN is also applied from top of the
beam, at a distance of 4 meters from the starting point.
Take E = 200 GPa and I = 400*(10**-6) meter**4.

Using the sign convention of downwards forces being positive.

.. plot::
    :context: close-figs
    :format: doctest
    :include-source: True

    >>> from sympy.physics.continuum_mechanics.beam import Beam
    >>> from sympy import symbols
    >>> R1, R2 = symbols('R1, R2')
    >>> b = Beam(8, 200*(10**9), 400*(10**-6))
    >>> b.apply_load(5000, 2, -1)
    >>> b.apply_load(R1, 0, -1)
    >>> b.apply_load(R2, 8, -1)
    >>> b.apply_load(10000, 4, 0, end=8)
    >>> b.bc_deflection = [(0, 0), (8, 0)]
    >>> b.solve_for_reaction_loads(R1, R2)
    >>> b.plot_bending_moment()
    Plot object containing:
    [0]: cartesian line: 13750*SingularityFunction(x, 0, 1) - 5000*SingularityFunction(x, 2, 1)
    - 5000*SingularityFunction(x, 4, 2) + 31250*SingularityFunction(x, 8, 1)
    + 5000*SingularityFunction(x, 8, 2) for x over (0.0, 8.0)
r  r   Bending Momentr  $\mathrm{M}$br  r.   r  r   r5   r   r0   r   r   )rH   r   r.   r  r0   s        rJ   plot_bending_momentBeam.plot_bending_moment  s    V ,,.<D!''/Cmm# !>!CDD	 0
 ;;$++&F[[FN''-q&/IQa&3P 	PrM   c           	      V   U R                  5       nUc  0 nUR                  [        5       H'  nX0R                  :X  a  M  X1;  d  M  [	        SU-  5      e   U R
                  U;   a  XR
                     nOU R
                  n[        UR                  U5      U R                  SU4SSSSS9$ )a  

Returns a plot for slope of deflection curve of the Beam object.

Parameters
==========
subs : dictionary
    Python dictionary containing Symbols as key and their
    corresponding values.

Examples
========
There is a beam of length 8 meters. A constant distributed load of 10 KN/m
is applied from half of the beam till the end. There are two simple supports
below the beam, one at the starting point and another at the ending point
of the beam. A pointload of magnitude 5 KN is also applied from top of the
beam, at a distance of 4 meters from the starting point.
Take E = 200 GPa and I = 400*(10**-6) meter**4.

Using the sign convention of downwards forces being positive.

.. plot::
    :context: close-figs
    :format: doctest
    :include-source: True

    >>> from sympy.physics.continuum_mechanics.beam import Beam
    >>> from sympy import symbols
    >>> R1, R2 = symbols('R1, R2')
    >>> b = Beam(8, 200*(10**9), 400*(10**-6))
    >>> b.apply_load(5000, 2, -1)
    >>> b.apply_load(R1, 0, -1)
    >>> b.apply_load(R2, 8, -1)
    >>> b.apply_load(10000, 4, 0, end=8)
    >>> b.bc_deflection = [(0, 0), (8, 0)]
    >>> b.solve_for_reaction_loads(R1, R2)
    >>> b.plot_slope()
    Plot object containing:
    [0]: cartesian line: -8.59375e-5*SingularityFunction(x, 0, 2) + 3.125e-5*SingularityFunction(x, 2, 2)
    + 2.08333333333333e-5*SingularityFunction(x, 4, 3) - 0.0001953125*SingularityFunction(x, 8, 2)
    - 2.08333333333333e-5*SingularityFunction(x, 8, 3) + 0.00138541666666667 for x over (0.0, 8.0)
r  r   Sloper  $\theta$mr  r-   r  r   r5   r   r0   r   r   )rH   r   r-   r  r0   s        rJ   
plot_slopeBeam.plot_slopeR  s    V 

<D;;v&Cmm# !>!CDD	 '
 ;;$++&F[[FEJJt$t}}a&@&{sL 	LrM   c           	      V   U R                  5       nUc  0 nUR                  [        5       H'  nX0R                  :X  a  M  X1;  d  M  [	        SU-  5      e   U R
                  U;   a  XR
                     nOU R
                  n[        UR                  U5      U R                  SU4SSSSS9$ )a  

Returns a plot for deflection curve of the Beam object.

Parameters
==========
subs : dictionary
    Python dictionary containing Symbols as key and their
    corresponding values.

Examples
========
There is a beam of length 8 meters. A constant distributed load of 10 KN/m
is applied from half of the beam till the end. There are two simple supports
below the beam, one at the starting point and another at the ending point
of the beam. A pointload of magnitude 5 KN is also applied from top of the
beam, at a distance of 4 meters from the starting point.
Take E = 200 GPa and I = 400*(10**-6) meter**4.

Using the sign convention of downwards forces being positive.

.. plot::
    :context: close-figs
    :format: doctest
    :include-source: True

    >>> from sympy.physics.continuum_mechanics.beam import Beam
    >>> from sympy import symbols
    >>> R1, R2 = symbols('R1, R2')
    >>> b = Beam(8, 200*(10**9), 400*(10**-6))
    >>> b.apply_load(5000, 2, -1)
    >>> b.apply_load(R1, 0, -1)
    >>> b.apply_load(R2, 8, -1)
    >>> b.apply_load(10000, 4, 0, end=8)
    >>> b.bc_deflection = [(0, 0), (8, 0)]
    >>> b.solve_for_reaction_loads(R1, R2)
    >>> b.plot_deflection()
    Plot object containing:
    [0]: cartesian line: 0.00138541666666667*x - 2.86458333333333e-5*SingularityFunction(x, 0, 3)
    + 1.04166666666667e-5*SingularityFunction(x, 2, 3) + 5.20833333333333e-6*SingularityFunction(x, 4, 4)
    - 6.51041666666667e-5*SingularityFunction(x, 8, 3) - 5.20833333333333e-6*SingularityFunction(x, 8, 4)
    for x over (0.0, 8.0)
r  r   
Deflectionr  $\delta$r  r  r,   r  r   r5   r   r0   r   r   )rH   r   r,   r  r0   s        rJ   plot_deflectionBeam.plot_deflection  s    X __&
<D##F+Cmm# !>!CDD	 ,
 ;;$++&F[[FJOOD)DMM1f+E&{"$ 	$rM   c           
      ~   U R                   nU R                  nUc  0 nU R                  5       R                  [        5       H'  nX@R                  :X  a  M  XA;  d  M  [        SU-  5      e   X!;   a  X   n[        U R                  5       R                  U5      USU4SSSSSS9n[        U R                  5       R                  U5      USU4S	SS
SSS9n[        U R                  5       R                  U5      USU4SSSSSS9n[        U R                  5       R                  U5      USU4SSSSSS9n[        SSXVXx5      $ )a  
Returns a subplot of Shear Force, Bending Moment,
Slope and Deflection of the Beam object.

Parameters
==========

subs : dictionary
       Python dictionary containing Symbols as key and their
       corresponding values.

Examples
========

There is a beam of length 8 meters. A constant distributed load of 10 KN/m
is applied from half of the beam till the end. There are two simple supports
below the beam, one at the starting point and another at the ending point
of the beam. A pointload of magnitude 5 KN is also applied from top of the
beam, at a distance of 4 meters from the starting point.
Take E = 200 GPa and I = 400*(10**-6) meter**4.

Using the sign convention of downwards forces being positive.

.. plot::
    :context: close-figs
    :format: doctest
    :include-source: True

    >>> from sympy.physics.continuum_mechanics.beam import Beam
    >>> from sympy import symbols
    >>> R1, R2 = symbols('R1, R2')
    >>> b = Beam(8, 200*(10**9), 400*(10**-6))
    >>> b.apply_load(5000, 2, -1)
    >>> b.apply_load(R1, 0, -1)
    >>> b.apply_load(R2, 8, -1)
    >>> b.apply_load(10000, 4, 0, end=8)
    >>> b.bc_deflection = [(0, 0), (8, 0)]
    >>> b.solve_for_reaction_loads(R1, R2)
    >>> axes = b.plot_loading_results()
r  r   r  r  r  r  Fr  r  r  r  showr  r  r  r  r  r  r  r  r     r   )r0   r5   r,   r  r   r   r   r/   r   r.   r-   r   )	rH   r   r0   r5   r  ax1ax2ax3ax4s	            rJ   plot_loading_resultsBeam.plot_loading_results  sV   R ==<D??$**62Cmm# !>!CDD	 3
 >\F4##%**408Q2G&!/ 4&&(--d3h65J)//!/ 4::<$$T*Xq&,A !/ 4??$))$/(Av1F%ok!/ 1c11rM   c                     U R                   nU R                  nU R                  U[        X#S5      -  -   n[	        XB5      * n[	        XR5      nXV4$ )z

Helper function for I.L.D. It takes the unsubstituted
copy of the load equation and uses it to calculate shear force and bending
moment equations.
r   )r5   r6   r9   r   r   )rH   r   r(   r*   r   r/   r.   s          rJ   _solve_for_ild_equationsBeam._solve_for_ild_equations  sS     MMzzE$7b$AAA ))";2**rM   c           
      d   U R                  U5      u  p4U R                  nU R                  nU R                  n[	        U R
                  5      n[	        U R                  5      n	[        S5      n
[        S5      n[        X5U5      U[        USS5      [        XvS5      -
  -  -
  n[        XEU5      X[        USS5      -  [        USS5      -
  [        XvS5      -   -  -
  n/ n/ n/ n/ nU R                  S    H|  u  nnU R                  5       R                  UU5      U-
  n[        S UR                   5       5      nU[        U* U* S5      [        U* SS5      -
  -  nUU-
  nUR                  U5        M~     U R                  S    H  u  nnU R!                  5       R                  UU5      U-
  n[        S UR                   5       5      nUU[        USS5      -  [        USS5      -
  [        UUS5      -   -  nUU-
  nUR                  U5        M     [#        XE5      U
-   nU R                  S	    HV  u  nnUR                  UU5      U-
  U[        U* SS5      U[        U* SS5      -  -   S
-  -  S
-  -   nUR                  U5        MX     [#        UU5      U-   nU R                  S    HV  u  nnUR                  UU5      U-
  U[        U* SS5      U[        U* SS5      -  -   S-  -  S-  -   nUR                  U5        MX     [%        ['        X/U-   U-   U-   U-   X4U-   U-   U	-   5      R                  S   5      nS
[)        U5      -   nU[)        U5      -   nUS
U nUUU n UUS n![+        [-        UU5      5      U l        [+        [-        UU 5      5      U l        [+        [-        U	U!5      5      U l        g)aZ  

Determines the Influence Line Diagram equations for reaction
forces under the effect of a moving load.

Parameters
==========
value : Integer
    Magnitude of moving load
reactions :
    The reaction forces applied on the beam.

Warning
=======
This method creates equations that can give incorrect results when
substituting a = 0 or a = l, with l the length of the beam.

Examples
========

There is a beam of length 10 meters. There are two simple supports
below the beam, one at the starting point and another at the ending
point of the beam. Calculate the I.L.D. equations for reaction forces
under the effect of a moving load of magnitude 1kN.

Using the sign convention of downwards forces being positive.

.. plot::
    :context: close-figs
    :format: doctest
    :include-source: True

    >>> from sympy import symbols
    >>> from sympy.physics.continuum_mechanics.beam import Beam
    >>> E, I = symbols('E, I')
    >>> R_0, R_10 = symbols('R_0, R_10')
    >>> b = Beam(10, E, I)
    >>> p0 = b.apply_support(0, 'pin')
    >>> p10 = b.apply_support(10, 'roller')
    >>> b.solve_for_ild_reactions(1,R_0,R_10)
    >>> b.ild_reactions
    {R_0: -SingularityFunction(a, 0, 0) + SingularityFunction(a, 0, 1)/10 - SingularityFunction(a, 10, 1)/10,
    R_10: -SingularityFunction(a, 0, 1)/10 + SingularityFunction(a, 10, 0) + SingularityFunction(a, 10, 1)/10}

r  r  r   r   r/   c              3   l   #    U  H*  n[        S  UR                   5       5      (       a  M&  Uv   M,     g7f)c              3   8   #    U  H  oR                   v   M     g 7fry   r	  r  s     rJ   r  9Beam.solve_for_ild_reactions.<locals>.<genexpr>.<genexpr>`       Di`hY\__`hr  Nr  r  s     rJ   r  /Beam.solve_for_ild_reactions.<locals>.<genexpr>`  &     !j#Di`c`h`hDiAi##r  r.   c              3   l   #    U  H*  n[        S  UR                   5       5      (       a  M&  Uv   M,     g7f)c              3   8   #    U  H  oR                   v   M     g 7fry   r	  r  s     rJ   r  r  g  r  r  Nr  r  s     rJ   r  r  g  r  r  r-   r  r,         N)r  r5   r0   r6   r  r>   r?   r   r   r   r8   r/   r   r  r   r   r.   r   r  r   r   r  r   rC   rl   rp   )"rH   r   r!  r/   r.   r(   rz   r*   r^   rb   r  r  r"  r#  r$  r%  r&  r'  r(  rN  r)  eqs_without_inf
shear_sinceqs_with_shear_sincmoment_sinceqs_with_moment_sincr+  r,  r-  r.  r/  r0  r1  r2  s"                                     rJ   solve_for_ild_reactionsBeam.solve_for_ild_reactions  s   \ '+&C&CE&J#MMKKt;;< !<!<=D\D\KA.8KAqRS8TWjklqrWs8s1ttn3eCVWXZ[]^C_?_ATUVXY[\A]@^ATUV[\A]@^ 7_ _ 	!66}EMHc""$))!X6<C!!j!jjO"5cX:q"IL_ab`bdeghLi"ijJ"1J">""#67 F "667GHMHc%%',,Q9C?C!!j!jjO8.A!Q.J#J%8Aq%A$BDWXY[cefDg$h iK#2[#@ %%&:; I  2R7!66w?MHc""1h/#5ATVWUWYZ\]A^ail  BC  AC  EF  HI  mJ  bJ  BJ  MN  AN  9N  QR  9R  RCS! @ %[!4r9!66|DMHc"''84s:UFY[\Z\^_abFcfn  rE  GH  FH  JK  MN  rO  gO  GO  TU  FU  >U  XY  >Y  YC!!#& E ;"="ORd"dgp"p$2#357Hy4H>4Y\l4lnnrnrtuw x S^+'#n*==$Q~6$^NC&~7"3y2C#DE$(^=N)O$P!%)#.>@S*T%U"rM   c                    U R                   (       d  [        S5      eU R                  n/ nUc  0 nU R                    HF  nU R                   U   R                  [        5       H  nXR:w  d  M
  XQ;  d  M  [        SU-  5      e   MH     U R
                  R                  [        5       H  nXR:w  d  M
  XQ;  d  M  [        SU-  5      e   U R                    HX  nUR                  [        U R                   U   R                  U5      USU R
                  R                  U5      4SX$SSS95        MZ     [        [        U5      S/UQ76 $ )	aC  

Plots the Influence Line Diagram of Reaction Forces
under the effect of a moving load. This function
should be called after calling solve_for_ild_reactions().

Parameters
==========

subs : dictionary
       Python dictionary containing Symbols as key and their
       corresponding values.

Warning
=======
The values for a = 0 and a = l, with l the length of the beam, in
the plot can be incorrect.

Examples
========

There is a beam of length 10 meters. A point load of magnitude 5KN
is also applied from top of the beam, at a distance of 4 meters
from the starting point. There are two simple supports below the
beam, located at the starting point and at a distance of 7 meters
from the starting point. Plot the I.L.D. equations for reactions
at both support points under the effect of a moving load
of magnitude 1kN.

Using the sign convention of downwards forces being positive.

.. plot::
    :context: close-figs
    :format: doctest
    :include-source: True

    >>> from sympy import symbols
    >>> from sympy.physics.continuum_mechanics.beam import Beam
    >>> E, I = symbols('E, I')
    >>> R_0, R_7 = symbols('R_0, R_7')
    >>> b = Beam(10, E, I)
    >>> p0 = b.apply_support(0, 'roller')
    >>> p7 = b.apply_support(7, 'roller')
    >>> b.apply_load(5,4,-1)
    >>> b.solve_for_ild_reactions(1,R_0,R_7)
    >>> b.ild_reactions
    {R_0: -SingularityFunction(a, 0, 0) + SingularityFunction(a, 0, 1)/7
    - 3*SingularityFunction(a, 10, 0)/7  - SingularityFunction(a, 10, 1)/7 - 15/7,
    R_7: -SingularityFunction(a, 0, 1)/7 + 10*SingularityFunction(a, 10, 0)/7 + SingularityFunction(a, 10, 1)/7 - 20/7}
    >>> b.plot_ild_reactions()
    PlotGrid object containing:
    Plot[0]:Plot object containing:
    [0]: cartesian line: -SingularityFunction(a, 0, 0) + SingularityFunction(a, 0, 1)/7
    - 3*SingularityFunction(a, 10, 0)/7 - SingularityFunction(a, 10, 1)/7 - 15/7 for a over (0.0, 10.0)
    Plot[1]:Plot object containing:
    [0]: cartesian line: -SingularityFunction(a, 0, 1)/7 + 10*SingularityFunction(a, 10, 0)/7
    + SingularityFunction(a, 10, 1)/7 - 20/7 for a over (0.0, 10.0)

ztI.L.D. reaction equations not found. Please use solve_for_ild_reactions() to generate the I.L.D. reaction equations.r  r   zI.L.D. for ReactionsblueFr  r   )rC   r   r6   r  r   rR   r   r   r   r   r   )rH   r   r*   ildplotsreactionr  s         rJ   plot_ild_reactionsBeam.plot_ild_reactions  s7   x ""  T  U  U<D++H**84::6B8$%BC%GHH C ,
 <<%%f-CxCO !>!CDD . ++HOOD!4!4X!>!C!CD!I4<<$$T*+3I&uF G ,
 Hq4844rM   c                    U R                   nU R                  nU R                  nU R                  U5      u  pxU[	        XtU5      -
  n	[	        XtU5      [	        XtU5      -
  U-
  n
U H?  nU	R                  XR                  U   5      n	U
R                  XR                  U   5      n
MA     XU
-
  [        XaS5      -  -
  U[        U* SS5      -  -
  U[        XeS5      -  -   nXl        g)aG  

Determines the Influence Line Diagram equations for shear at a
specified point under the effect of a moving load.

Parameters
==========
distance : Integer
    Distance of the point from the start of the beam
    for which equations are to be determined
value : Integer
    Magnitude of moving load
reactions :
    The reaction forces applied on the beam.

Warning
=======
This method creates equations that can give incorrect results when
substituting a = 0 or a = l, with l the length of the beam.

Examples
========

There is a beam of length 12 meters. There are two simple supports
below the beam, one at the starting point and another at a distance
of 8 meters. Calculate the I.L.D. equations for Shear at a distance
of 4 meters under the effect of a moving load of magnitude 1kN.

Using the sign convention of downwards forces being positive.

.. plot::
    :context: close-figs
    :format: doctest
    :include-source: True

    >>> from sympy import symbols
    >>> from sympy.physics.continuum_mechanics.beam import Beam
    >>> E, I = symbols('E, I')
    >>> R_0, R_8 = symbols('R_0, R_8')
    >>> b = Beam(12, E, I)
    >>> p0 = b.apply_support(0, 'roller')
    >>> p8 = b.apply_support(8, 'roller')
    >>> b.solve_for_ild_reactions(1, R_0, R_8)
    >>> b.solve_for_ild_shear(4, 1, R_0, R_8)
    >>> b.ild_shear
    -(-SingularityFunction(a, 0, 0) + SingularityFunction(a, 12, 0) + 2)*SingularityFunction(a, 4, 0)
    - SingularityFunction(-a, 0, 0) - SingularityFunction(a, 0, 0) + SingularityFunction(a, 0, 1)/8
    + SingularityFunction(a, 12, 0)/2 - SingularityFunction(a, 12, 1)/8 + 1

r   N)	r5   r0   r6   r  r   r   rC   r   rD   )rH   distancer   r!  r(   rz   r*   r/   _shear_curve1shear_curve2r  shear_eqs                rJ   solve_for_ild_shearBeam.solve_for_ild_shear  s    h MMKK66u=u[X>>ka053RRV[[!H',,X6I6I(6STL',,X6I6I(6STL " !<$?CVWXdeCf#ff11"a;;<>CFYZ[`aFb>bc #rM   c           
         U R                   (       d  [        S5      eU R                  nU R                  nUc  0 nU R                   R	                  [
        5       H  nXC:w  d  M
  XA;  d  M  [        SU-  5      e   U R                  R	                  [
        5       H  nXC:w  d  M
  XA;  d  M  [        SU-  5      e   [        U R                   R                  U5      USU4SSSSSS	9$ )
aA  

Plots the Influence Line Diagram for Shear under the effect
of a moving load. This function should be called after
calling solve_for_ild_shear().

Parameters
==========

subs : dictionary
       Python dictionary containing Symbols as key and their
       corresponding values.

Warning
=======
The values for a = 0 and a = l, with l the length of the beam, in
the plot can be incorrect.

Examples
========

There is a beam of length 12 meters. There are two simple supports
below the beam, one at the starting point and another at a distance
of 8 meters. Plot the I.L.D. for Shear at a distance
of 4 meters under the effect of a moving load of magnitude 1kN.

Using the sign convention of downwards forces being positive.

.. plot::
    :context: close-figs
    :format: doctest
    :include-source: True

    >>> from sympy import symbols
    >>> from sympy.physics.continuum_mechanics.beam import Beam
    >>> E, I = symbols('E, I')
    >>> R_0, R_8 = symbols('R_0, R_8')
    >>> b = Beam(12, E, I)
    >>> p0 = b.apply_support(0, 'roller')
    >>> p8 = b.apply_support(8, 'roller')
    >>> b.solve_for_ild_reactions(1, R_0, R_8)
    >>> b.solve_for_ild_shear(4, 1, R_0, R_8)
    >>> b.ild_shear
    -(-SingularityFunction(a, 0, 0) + SingularityFunction(a, 12, 0) + 2)*SingularityFunction(a, 4, 0)
    - SingularityFunction(-a, 0, 0) - SingularityFunction(a, 0, 0) + SingularityFunction(a, 0, 1)/8
    + SingularityFunction(a, 12, 0)/2 - SingularityFunction(a, 12, 1)/8 + 1
    >>> b.plot_ild_shear()
    Plot object containing:
    [0]: cartesian line: -(-SingularityFunction(a, 0, 0) + SingularityFunction(a, 12, 0) + 2)*SingularityFunction(a, 4, 0)
    - SingularityFunction(-a, 0, 0) - SingularityFunction(a, 0, 0) + SingularityFunction(a, 0, 1)/8
    + SingularityFunction(a, 12, 0)/2 - SingularityFunction(a, 12, 1)/8 + 1 for a over (0.0, 12.0)

ziI.L.D. shear equation not found. Please use solve_for_ild_shear() to generate the I.L.D. shear equations.r  r   zI.L.D. for Shear$\mathrm{a}$r  r  Tr  )rD   r   rR   r6   r  r   r   r   )rH   r   rz   r*   r  s        rJ   plot_ild_shearBeam.plot_ild_shear  s    n   I  J  JLL<D??((0CxCO !>!CDD 1 <<%%f-CxCO !>!CDD . DOO((.Aq	BT%o&VZ\ 	\rM   c                 2   U R                   nU R                  nU R                  nU R                  U5      u  pxX![	        USS5      -  [	        USS5      -
  [	        XaS5      -   -  [        XU5      -
  n	[        XU5      [        XU5      -
  X%[	        USS5      -  [	        USS5      -
  [	        XeS5      -   -  -
  n
U H?  nU	R                  XR                  U   5      n	U
R                  XR                  U   5      n
MA     XU
-
  [	        XaS5      -  -
  nXl        g)aB  

Determines the Influence Line Diagram equations for moment at a
specified point under the effect of a moving load.

Parameters
==========
distance : Integer
    Distance of the point from the start of the beam
    for which equations are to be determined
value : Integer
    Magnitude of moving load
reactions :
    The reaction forces applied on the beam.

Warning
=======
This method creates equations that can give incorrect results when
substituting a = 0 or a = l, with l the length of the beam.

Examples
========

There is a beam of length 12 meters. There are two simple supports
below the beam, one at the starting point and another at a distance
of 8 meters. Calculate the I.L.D. equations for Moment at a distance
of 4 meters under the effect of a moving load of magnitude 1kN.

Using the sign convention of downwards forces being positive.

.. plot::
    :context: close-figs
    :format: doctest
    :include-source: True

    >>> from sympy import symbols
    >>> from sympy.physics.continuum_mechanics.beam import Beam
    >>> E, I = symbols('E, I')
    >>> R_0, R_8 = symbols('R_0, R_8')
    >>> b = Beam(12, E, I)
    >>> p0 = b.apply_support(0, 'roller')
    >>> p8 = b.apply_support(8, 'roller')
    >>> b.solve_for_ild_reactions(1, R_0, R_8)
    >>> b.solve_for_ild_moment(4, 1, R_0, R_8)
    >>> b.ild_moment
    -(4*SingularityFunction(a, 0, 0) - SingularityFunction(a, 0, 1) + SingularityFunction(a, 4, 1))*SingularityFunction(a, 4, 0)
    - SingularityFunction(a, 0, 1)/2 + SingularityFunction(a, 4, 1) - 2*SingularityFunction(a, 12, 0)
    - SingularityFunction(a, 12, 1)/2

r   r   N)	r5   r0   r6   r  r   r   r   rC   rE   )rH   r  r   r!  r(   rz   r*   r  momentmoment_curve1moment_curve2r  	moment_eqs                rJ   solve_for_ild_momentBeam.solve_for_ild_momentj  s?   h MMKK11%8	*=aA*FFI\]^`acdIee!4Q!!D E FHMfYaHbcv!,U6h-GG (;Aq!(D$DGZ[\^_abGc$c&9!&B%C DD "H)..x9L9LX9VWM)..x9L9LX9VWM " "]%BFYZ[ghFi$ii	$rM   c           
         U R                   (       d  [        S5      eU R                  nUc  0 nU R                   R                  [        5       H  nX2:w  d  M
  X1;  d  M  [        SU-  5      e   U R
                  R                  [        5       H  nX2:w  d  M
  X1;  d  M  [        SU-  5      e   [        U R                   R                  U5      USU R
                  4SSSSSS	9$ )
a5  

Plots the Influence Line Diagram for Moment under the effect
of a moving load. This function should be called after
calling solve_for_ild_moment().

Parameters
==========

subs : dictionary
       Python dictionary containing Symbols as key and their
       corresponding values.

Warning
=======
The values for a = 0 and a = l, with l the length of the beam, in
the plot can be incorrect.

Examples
========

There is a beam of length 12 meters. There are two simple supports
below the beam, one at the starting point and another at a distance
of 8 meters. Plot the I.L.D. for Moment at a distance
of 4 meters under the effect of a moving load of magnitude 1kN.

Using the sign convention of downwards forces being positive.

.. plot::
    :context: close-figs
    :format: doctest
    :include-source: True

    >>> from sympy import symbols
    >>> from sympy.physics.continuum_mechanics.beam import Beam
    >>> E, I = symbols('E, I')
    >>> R_0, R_8 = symbols('R_0, R_8')
    >>> b = Beam(12, E, I)
    >>> p0 = b.apply_support(0, 'roller')
    >>> p8 = b.apply_support(8, 'roller')
    >>> b.solve_for_ild_reactions(1, R_0, R_8)
    >>> b.solve_for_ild_moment(4, 1, R_0, R_8)
    >>> b.ild_moment
    -(4*SingularityFunction(a, 0, 0) - SingularityFunction(a, 0, 1) + SingularityFunction(a, 4, 1))*SingularityFunction(a, 4, 0)
    - SingularityFunction(a, 0, 1)/2 + SingularityFunction(a, 4, 1) - 2*SingularityFunction(a, 12, 0)
    - SingularityFunction(a, 12, 1)/2
    >>> b.plot_ild_moment()
    Plot object containing:
    [0]: cartesian line: -(4*SingularityFunction(a, 0, 0) - SingularityFunction(a, 0, 1)
    + SingularityFunction(a, 4, 1))*SingularityFunction(a, 4, 0) - SingularityFunction(a, 0, 1)/2
    + SingularityFunction(a, 4, 1) - 2*SingularityFunction(a, 12, 0) - SingularityFunction(a, 12, 1)/2 for a over (0.0, 12.0)

zlI.L.D. moment equation not found. Please use solve_for_ild_moment() to generate the I.L.D. moment equations.r  r   zI.L.D. for Momentr  r  r  Tr  )rE   r   r6   r  r   rR   r   r   )rH   r   r*   r  s       rJ   plot_ild_momentBeam.plot_ild_moment  s    n   L  M  M<D##))&1CxCO !>!CDD 2 <<%%f-CxCO !>!CDD . D$$))$/!Q1EM`%o&W[] 	]rM   )r    )modulesc                    [         (       d  [        S5      e[        [        U R                  5      [        U R
                  5      -
  5      nU(       d"  [        S U 5       5      (       a  [        S5      eU R                  n[        U R                  [        5      (       aZ  [        U R                  R                  [        5      5      n[        R                  US5      nU R                  R!                  U5      nO0 nU R                  nUS-  n/ nUR#                  SXVSS.5        U R%                  XU5      u  ppnU R'                  XT5      u  pX~-  nX-  n	U R(                   H1  nXR                  -  n[+        U5      U-  nU	U/US-  //S	S
SS./-  n	M3     U R,                   H1  nXR                  -  n[+        U5      U-  nU	U/US-  //SSSS./-  n	M3     U* SU-  4nU(       a}  [/        [/        US   5      [/        S U 5       5      5      n[1        [1        US   5      [1        S U 5       5      5      nUUS   :  d	  UUS   :  a  [3        UU-
  5      S-  nUU-
  UU-   4n[5        Xj-   Xk-   USU4U* XV-   4UXUSUSSS9nU$ )a4
  
Returns a plot object representing the beam diagram of the beam.
In particular, the diagram might include:

* the beam.
* vertical black arrows represent point loads and support reaction
  forces (the latter if they have been added with the ``apply_load``
  method).
* circular arrows represent moments.
* shaded areas represent distributed loads.
* the support, if ``apply_support`` has been executed.
* if a composite beam has been created with the ``join`` method and
  a hinge has been specified, it will be shown with a white disc.

The diagram shows positive loads on the upper side of the beam,
and negative loads on the lower side. If two or more distributed
loads acts along the same direction over the same region, the
function will add them up together.

.. note::
    The user must be careful while entering load values.
    The draw function assumes a sign convention which is used
    for plotting loads.
    Given a right handed coordinate system with XYZ coordinates,
    the beam's length is assumed to be along the positive X axis.
    The draw function recognizes positive loads(with n>-2) as loads
    acting along negative Y direction and positive moments acting
    along positive Z direction.

Parameters
==========

pictorial: Boolean (default=True)
    Setting ``pictorial=True`` would simply create a pictorial (scaled)
    view of the beam diagram. On the other hand, ``pictorial=False``
    would create a beam diagram with the exact dimensions on the plot.

Examples
========

.. plot::
    :context: close-figs
    :format: doctest
    :include-source: True

    >>> from sympy.physics.continuum_mechanics.beam import Beam
    >>> from sympy import symbols
    >>> P1, P2, M = symbols('P1, P2, M')
    >>> E, I = symbols('E, I')
    >>> b = Beam(50, 20, 30)
    >>> b.apply_load(-10, 2, -1)
    >>> b.apply_load(15, 26, -1)
    >>> b.apply_load(P1, 10, -1)
    >>> b.apply_load(-P2, 40, -1)
    >>> b.apply_load(90, 5, 0, 23)
    >>> b.apply_load(10, 30, 1, 50)
    >>> b.apply_load(M, 15, -2)
    >>> b.apply_load(-M, 30, -2)
    >>> p50 = b.apply_support(50, "pin")
    >>> p0, m0 = b.apply_support(0, "fixed")
    >>> p20 = b.apply_support(20, "roller")
    >>> p = b.draw()  # doctest: +SKIP
    >>> p  # doctest: +ELLIPSIS,+SKIP
    Plot object containing:
    [0]: cartesian line: 25*SingularityFunction(x, 5, 0) - 25*SingularityFunction(x, 23, 0)
    + SingularityFunction(x, 30, 1) - 20*SingularityFunction(x, 50, 0)
    - SingularityFunction(x, 50, 1) + 5 for x over (0.0, 50.0)
    [1]: cartesian line: 5 for x over (0.0, 50.0)
    ...
    >>> p.show() # doctest: +SKIP

z-To use this function numpy module is requiredc              3   v   #    U  H/  n[        US    R                  5      S :  =(       a    US   S :  v   M1     g7f)r   r  N)r   free_symbols)r  rz   s     rJ   r  Beam.draw.<locals>.<genexpr>I	  s7     "_Y^TUC!(9(9$:Q$>#OQqTQY#OY^s   79zl`pictorial=False` requires numerical distributed loads. Instead, symbolic loads were found. Cannot continue.
   r   r   brown)xywidthheight	facecolorr  or  whiter   marker
markersizecolor|   g      ?y2c              3   0   #    U  H  oS    S   v   M     g7fr  r   N r  r  s     rJ   r  r  r	       +K
1dGAJ
   y1c              3   0   #    U  H  oS    S   v   M     g7fr  r  r  s     rJ   r  r  s	  r  r   r   r   g?F)	xlimylimannotationsmarkers
rectanglesr  fillaxisr  )r    ImportErrorr  r=  r  r@   r  r   r5   r2   r0   r   r  r   r  fromkeysr   r   
_draw_load_draw_supportsr<   r@  r=   minrD  rB  r   )rH   	pictorialloadsr(   rz   r0   r  r  r  r  load_eqload_eq1r  support_markerssupport_rectanglesr   ratiox_posr  _min_maxoffset	sing_plots                          rJ   draw	Beam.draw  s   T uMNNS++,s43I3I/JJKs"_Y^"___ # $ $ MM dkk4((T[[&&v./Aa$A[[%%a(FA[[F
V]^_7;yZ[7\4g.2.A.A&.L+(
"00C++%E%L6)E%6A:, 7#TU_fghhG 1
 //C++%E%L6)E5'FQJ<!83UWahijjG 0
 f% s4:+K
+K(KLDs4:+K
+K(KLDtAwD47NTD[)C/vtf}5)6+<q!Vn'6?+$#TEC	
 rM   c                     UR                   nUR                  (       d  Ub  U$ UR                  5       R                  5       R                   $ )zTry to determine if a load is negative or positive, using
expansion and doit if necessary.

Returns
=======
True: if the load is negative
False: if the load is positive
None: if it is indeterminate

)r   is_Atomdoitexpand)rH   r   rvs      rJ   _is_load_negativeBeam._is_load_negative	  s:     <<2>Iyy{!!#///rM   c                  
   [        [        U R                  5      [        U R                  5      -
  5      nUS-  nU R                  n/ n/ n/ n	Sn
/ nSn[
        R                  n[
        R                  nS nSnSnU GHt  nU(       a  US   R                  U5      nOUS   nUS   S:X  a}  U R                  US   5      nUc  USUS   < S	US   < S
3-  nU(       a'  UR                  SUS4UUSU-  -
  4SSSSS.S.5        M  UR                  SUU4UUS-  4SSSSS.S.5        M  US   S:X  a  U R                  US   5      nUc  USUS   < S	US   < S
3-  nU R                  US   5      (       a  UR                  U/US-  //SSS.5        GM  UR                  U/US-  //SSS.5        GM6  US   S:  d  GMB  Uu  nnnnU R                  U5      nUc  USU< SU< SU< S
3-  nU(       d  U(       a  US:  a  SSU-
  -  OUS-  nU
U[        UUU5      -  -  n
U(       aq  US:  a  UUU-  -  O
US-  UU-  -  n[        SUS-   5       HE  nU
UR                  UU5      R                  UUU-
  5      [        UUU5      -  [        U5      -  -  n
MG     [        U
[        5      (       a  U
R                   n	OU
4n	[        U	 Vs/ s H  nUR                  U5      PM     sn6 nGMk  U(       a  US:  a  SSU-
  -  OUS-  nU[#        U5      [        UUU5      -  -  nU(       az  US:  a  [#        U5      UU-  -  O
US-  UU-  -  n[        SUS-   5       HE  nUUR                  UU5      R                  UUU-
  5      [        UUU5      -  [        U5      -  -  nMG     [        U[        5      (       a  UR                   nOU4nU Vs/ s H  nUR                  U5      PM     nn[        U6 * U-
  nGMw     [%        U5      S:  a  [&        R(                  " UU-   5        [*        R-                  S[/        U5      S5      n[1        U/X]R3                  [4        5      -   5      " U5      n[1        U/X^R3                  [4        5      -   5      " U5      n[        U[*        R6                  5      (       d  U[*        R9                  U5      -  n[        U[*        R6                  5      (       d  U[*        R9                  U5      -  nUUUSSS.nXxXU4$ s  snf s  snf )Nr  r   zPlease, note that this schematic view might not be in agreement with the sign convention used by the Beam class for load-related computations, because it was not possible to determine the sign (hence, the direction) of the following loads:
 r   r  r   z* Point load z located at 
r  g      ?   black)r  
headlength	headwidthr  )textr  xytext
arrowpropsr   z	* Moment z$\circlearrowright$   )r   r  r  z$\circlearrowleft$z* Distributed load z from z to gMbP?	darkkhaki)r(   r  r  r  zorder)r  r=  r  r@   r5   r   Zeror   r"  r   r   r   r   r   r2   r   r   rB  r   warningswarnr    r"   r@  r   rA  r   ndarray	ones_like)rH   r  r0   rz   r  r  r(   r  r  	load_argsscaled_load
load_args1scaled_load1r  r  r  warning_headwarning_bodyr   posilnr   r   r   r   f2r   xxyy1yy2s                                 rJ   r  Beam._draw_load	  s[   S++,s43I3I/JJKMM	
&&66!
 DAw||A1g Aw"},,T!W5; aRVWXRY$ZZL&&raCQWZ[\bZbQbKc|  PQ  `a  pw  sx  (y  z&&rfRUW]^_W_Q`y|  MN  ]^  mt  pu  (v  waB,,T!W5; T!WdSTg$VVL))$q'22NNSEF1H:+>J`oq#rsNNSEF1H:+>J_np#qraA+/(ueS,,U3; uV[]`$aaL  ! 27QuWq5)<Qu)M#MMK/4zU1e8^vax5?P!&q%!)!4A'BGGAqM,>,>q#+,N,?3,J-KKTUV<-X YK "5 "+s33$/$4$4	 &1N	!y#Ay!AFF1Iy#ABG ! 27QuWq CJ/B1eU/S$SSL49QJSZ50F1HQPUXDU!&q%!)!4A(RWWQ]-?-?3;-O,?3,J.KKTUV<.X YL "5 ",44%1%6%6
 '3_
3=>:aq	:H> #X7HW Z |q MM,56\\!U6]E2sF__Y%??@DsF%5%5i%@@A"E#u}}--5??2&&C#u}}--5??2&&Cs#2/W<<G $B(  ?s   T
Tc           	         [        US-  5      n/ n/ nU R                   H  nU(       a  US   R                  U5      nOUS   nUS   S:X  a  UR                  US//SSSS.5        MH  US   S	:X  a  UR                  Xs* S
-  //SSSS.5        Mo  US   S:X  d  Mz  US:X  a(  UR                  SSU-  4U* S-  SU-  U-   SSS.5        M  UR                  USU-  4US-  SU-  U-   SSS.5        M     XE4$ )Nr  r   r   r   r     r(  r  r   g      @r     r   r      Fz/////)r  r  r  r  hatch)r@  r;   r   r   )rH   r0   rz   r  r  r  supportr<  s           rJ   r  Beam._draw_supports
  sM   vby!--Gqzq)ajqzU"&&aSzATV`g'hix'&&gck]/Cc`bls'tuw&!8&--Q6	NVGTVJabciailrar  |A  KR  /S  T&--VRY4GQWXZQZfghnfnqwfw  AF  PW  /X  Y! .$ 22rM   )!rA   r<   r=   r;   r~   r7   r8   rO   ra   rS   rp   rE   rC   rl   rD   rG   rR   r9   rF   rB   r>   r]   rP   r?   r@   r   r:   r3   r1   r6   r0   r4   r5   r   ry   )T)D__name__
__module____qualname____firstlineno____doc__r   rK   rV   propertyrZ   r^   rb   re   rh   rm   rq   rt   r0   setterr:   r5   r1   r4   r3   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r3  r/   rT  r.   r`  ri  r-   r,   r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r"  r  r  __static_attributes__r  rM   rJ   r%   r%   -   s   [z EK3KZ`adZeqt  DJ  KN  DO G"R
 $ $ $ $ & &   # # ) ) * *       ]]" "   
[[     4 __K K % % + + # # - - # #    
 ) )8 8 8 : : ; ; = = 2 2 __3 3 7 7 8 8@DH2T
(;z4lBHH>I@M@  4 # #6U=n (D0&d 0D4'l0d@D B,-=@8Pt8Pt8Lt:$zA2F+gVRS5jD#LI\VF%PG]R 
+A ,AH0 t=n3rM   r%   c                     ^  \ rS rSrSr\" S5      4U 4S jjr\S 5       r\R                  S 5       r\S 5       r
\
R                  S 5       r
\S	 5       r\R                  S
 5       r\S 5       r\S 5       r\S 5       rS rS0S jrS0S jrS1S jrS rS rS rS rS rS rS rS rS rS rS rS rS2S jrS3S jr S2S  jr!S3S! jr"S2S" jr#S3S# jr$S2S$ jr%S3S% jr&S4S& jr'S2S' jr(S3S( jr)S) r*S* r+S+ r,S, r-\-r.S- r/S. r0S/r1U =r2$ )5Beam3Di!
  am  
This class handles loads applied in any direction of a 3D space along
with unequal values of Second moment along different axes.

.. note::
   A consistent sign convention must be used while solving a beam
   bending problem; the results will
   automatically follow the chosen sign convention.
   This class assumes that any kind of distributed load/moment is
   applied through out the span of a beam.

Examples
========
There is a beam of l meters long. A constant distributed load of magnitude q
is applied along y-axis from start till the end of beam. A constant distributed
moment of magnitude m is also applied along z-axis from start till the end of beam.
Beam is fixed at both of its end. So, deflection of the beam at the both ends
is restricted.

>>> from sympy.physics.continuum_mechanics.beam import Beam3D
>>> from sympy import symbols, simplify, collect, factor
>>> l, E, G, I, A = symbols('l, E, G, I, A')
>>> b = Beam3D(l, E, G, I, A)
>>> x, q, m = symbols('x, q, m')
>>> b.apply_load(q, 0, 0, dir="y")
>>> b.apply_moment_load(m, 0, -1, dir="z")
>>> b.shear_force()
[0, -q*x, 0]
>>> b.bending_moment()
[0, 0, -m*x + q*x**2/2]
>>> b.bc_slope = [(0, [0, 0, 0]), (l, [0, 0, 0])]
>>> b.bc_deflection = [(0, [0, 0, 0]), (l, [0, 0, 0])]
>>> b.solve_slope_deflection()
>>> factor(b.slope())
[0, 0, x*(-l + x)*(-A*G*l**3*q + 2*A*G*l**2*q*x - 12*E*I*l*q
    - 72*E*I*m + 24*E*I*q*x)/(12*E*I*(A*G*l**2 + 12*E*I))]
>>> dx, dy, dz = b.deflection()
>>> dy = collect(simplify(dy), x)
>>> dx == dz == 0
True
>>> dy == (x*(12*E*I*l*(A*G*l**2*q - 2*A*G*l*m + 12*E*I*q)
... + x*(A*G*l*(3*l*(A*G*l**2*q - 2*A*G*l*m + 12*E*I*q) + x*(-2*A*G*l**2*q + 4*A*G*l*m - 24*E*I*q))
... + A*G*(A*G*l**2 + 12*E*I)*(-2*l**2*q + 6*l*m - 4*m*x + q*x**2)
... - 12*E*I*q*(A*G*l**2 + 12*E*I)))/(24*A*E*G*I*(A*G*l**2 + 12*E*I)))
True

References
==========

.. [1] https://homes.civil.aau.dk/jc/FemteSemester/Beams3D.pdf

r(   c                    > [         TU ]  XXF5        X0l        XPl        / SQU l        / SQU l        0 U l        / SQU l        / SQU l        / SQU l	        SU l
        g)a0  Initializes the class.

Parameters
==========
length : Sympifyable
    A Symbol or value representing the Beam's length.
elastic_modulus : Sympifyable
    A SymPy expression representing the Beam's Modulus of Elasticity.
    It is a measure of the stiffness of the Beam material.
shear_modulus : Sympifyable
    A SymPy expression representing the Beam's Modulus of rigidity.
    It is a measure of rigidity of the Beam material.
second_moment : Sympifyable or list
    A list of two elements having SymPy expression representing the
    Beam's Second moment of area. First value represent Second moment
    across y-axis and second across z-axis.
    Single SymPy expression can be passed if both values are same
area : Sympifyable
    A SymPy expression representing the Beam's cross-sectional area
    in a plane perpendicular to length of the Beam.
variable : Symbol, optional
    A Symbol object that will be used as the variable along the beam
    while representing the load, shear, moment, slope and deflection
    curve. By default, it is set to ``Symbol('x')``.
r   r   r   r   N)superrK   shear_modulusr:   _load_vector_moment_load_vector_torsion_moment_load_Singularity_slope_deflection_angular_deflection)rH   r0   r1   rX  r4   r:   r5   	__class__s          rJ   rK   Beam3D.__init__W
  sV    6 	-J*	%#, !!*$#$ rM   c                     U R                   $ r   )_shear_modulusrY   s    rJ   rX  Beam3D.shear_modulus}
  rj   rM   c                 $    [        U5      U l        g ry   )r   rc  r   s     rJ   rX  rd  
  s    %ajrM   c                     U R                   $ r   r   rY   s    rJ   r4   Beam3D.second_moment
  rj   rM   c                     [        U[        5      (       a"  U Vs/ s H  n[        U5      PM     nnXl        g [        U5      U l        g s  snf ry   )r2   r  r   rP   )rH   r   r(   s      rJ   r4   rg  
  s>    a%&'QQA'"#")!*D (s   A	c                     U R                   $ r|   r}   rY   s    rJ   r:   Beam3D.area
  r   rM   c                 $    [        U5      U l        g ry   r   r   s     rJ   r:   rj  
  r   rM   c                     U R                   $ )z<
Returns a three element list representing the load vector.
)rY  rY   s    rJ   load_vectorBeam3D.load_vector
  s    
    rM   c                     U R                   $ )zA
Returns a three element list representing moment loads on Beam.
)rZ  rY   s    rJ   moment_load_vectorBeam3D.moment_load_vector
      
 '''rM   c                     U R                   $ )az  
Returns a dictionary of boundary conditions applied on the beam.
The dictionary has two keywords namely slope and deflection.
The value of each keyword is a list of tuple, where each tuple
contains location and value of a boundary condition in the format
(location, value). Further each value is a list corresponding to
slope or deflection(s) values along three axes at that location.

Examples
========
There is a beam of length 4 meters. The slope at 0 should be 4 along
the x-axis and 0 along others. At the other end of beam, deflection
along all the three axes should be zero.

>>> from sympy.physics.continuum_mechanics.beam import Beam3D
>>> from sympy import symbols
>>> l, E, G, I, A, x = symbols('l, E, G, I, A, x')
>>> b = Beam3D(30, E, G, I, A, x)
>>> b.bc_slope = [(0, (4, 0, 0))]
>>> b.bc_deflection = [(4, [0, 0, 0])]
>>> b.boundary_conditions
{'bending_moment': [], 'deflection': [(4, [0, 0, 0])], 'shear_force': [], 'slope': [(0, (4, 0, 0))]}

Here the deflection of the beam should be ``0`` along all the three axes at ``4``.
Similarly, the slope of the beam should be ``4`` along x-axis and ``0``
along y and z axis at ``0``.
r   rY   s    rJ   r   Beam3D.boundary_conditions
  s    : (((rM   c                 ~    [        U R                  5      (       d  SU R                  -  $ [        U R                  5      $ )ay  
Returns the polar moment of area of the beam
about the X axis with respect to the centroid.

Examples
========

>>> from sympy.physics.continuum_mechanics.beam import Beam3D
>>> from sympy import symbols
>>> l, E, G, I, A = symbols('l, E, G, I, A')
>>> b = Beam3D(l, E, G, I, A)
>>> b.polar_moment()
2*I
>>> I1 = [9, 15]
>>> b = Beam3D(l, E, G, I1, A)
>>> b.polar_moment()
24
r  )r   r4   r  rY   s    rJ   polar_momentBeam3D.polar_moment
  s7    & **++T''''4%%&&rM   c           	          U R                   n[        U5      n[        U5      n[        U5      nUS:X  aB  US:X  d  U R                  S==   U-  ss'   U R                  S==   U[	        XRU5      -  -  ss'   gUS:X  aB  US:X  d  U R                  S==   U-  ss'   U R                  S==   U[	        XRU5      -  -  ss'   gUS:X  d  U R                  S==   U-  ss'   U R                  S==   U[	        XRU5      -  -  ss'   g)a  
This method adds up the force load to a particular beam object.

Parameters
==========
value : Sympifyable
    The magnitude of an applied load.
dir : String
    Axis along which load is applied.
order : Integer
    The order of the applied load.
    - For point loads, order=-1
    - For constant distributed load, order=0
    - For ramp loads, order=1
    - For parabolic ramp loads, order=2
    - ... so on.
r(   r   r   yr   r  N)r5   r   rY  r\  r   rH   r   r   r   dirr(   s         rJ   r   Beam3D.apply_load
  s    $ MM#:B;!!!$-$""1%/B1U/S)SS%CZB;!!!$-$""1%/B1U/S)SS% B;!!!$-$""1%/B1U/S)SS%rM   c           	         U R                   n[        U5      n[        U5      n[        U5      nUS:X  a  US:X  d  U R                  S==   U-  ss'   O?U[        U R                  5      ;   a  U R                  U==   U-  ss'   OXR                  U'   U R
                  S==   U[        XRU5      -  -  ss'   gUS:X  aB  US:X  d  U R                  S==   U-  ss'   U R
                  S==   U[        XRU5      -  -  ss'   gUS:X  d  U R                  S==   U-  ss'   U R
                  S==   U[        XRU5      -  -  ss'   g)a  
This method adds up the moment loads to a particular beam object.

Parameters
==========
value : Sympifyable
    The magnitude of an applied moment.
dir : String
    Axis along which moment is applied.
order : Integer
    The order of the applied load.
    - For point moments, order=-2
    - For constant distributed moment, order=-1
    - For ramp moments, order=0
    - For parabolic ramp moments, order=1
    - ... so on.
r(   r   r   ry  r   r  N)r5   r   rZ  r  r[  r\  r   rz  s         rJ   apply_moment_loadBeam3D.apply_moment_load  s-   $ MM#:B;((+u4+D!5!566((/58/27((/""1%/B1U/S)SS%CZB;((+u4+""1%/B1U/S)SS%B;((+u4+""1%/B1U/S)SS%rM   c                    US;   aE  [        S[        U5      -   5      nX0R                  U'   U R                  R	                  U/ SQ45        g [        S[        U5      -   5      n[        S[        U5      -   5      nX4/U R                  U'   U R                  R	                  U/ SQ45        U R
                  R	                  U/ SQ45        g )Nr   r   rV  r   )r   r   rB   r   r   r   r   s        rJ   r   Beam3D.apply_support/  s    $$"4C=1M2?  /%%sI&67"4C=1M$T#c(]3O3@2RD  /%%sI&67MM  #y!12rM   c                    U R                   nU R                  nU R                  nU Vs/ s H  n[        XR5      PM     nnU Vs/ s H  n[        Xr5      PM     nn[	        S5       H  n	U V
s/ s H7  oU	   R                  U
5      (       d  X   R                  U
5      (       d  M5  U
PM9     nn
[        U5      S:X  a  MX  [        Xi   X#5      n[        X   X#5      n[        [        X/U5      R                  S   5      n[        [        X5      5      nU R                  nU H%  nUU;   d  M  UU   UU   :w  d  M  [        SU-  5      e   U R                  R                  U5        M     gs  snf s  snf s  sn
f )a  
Solves for the reaction forces.

Examples
========
There is a beam of length 30 meters. It it supported by rollers at
of its end. A constant distributed load of magnitude 8 N is applied
from start till its end along y-axis. Another linear load having
slope equal to 9 is applied along z-axis.

>>> from sympy.physics.continuum_mechanics.beam import Beam3D
>>> from sympy import symbols
>>> l, E, G, I, A, x = symbols('l, E, G, I, A, x')
>>> b = Beam3D(30, E, G, I, A, x)
>>> b.apply_load(8, start=0, order=0, dir="y")
>>> b.apply_load(9*x, start=0, order=0, dir="z")
>>> b.bc_deflection = [(0, [0, 0, 0]), (30, [0, 0, 0])]
>>> R1, R2, R3, R4 = symbols('R1, R2, R3, R4')
>>> b.apply_load(R1, start=0, order=-1, dir="y")
>>> b.apply_load(R2, start=30, order=-1, dir="y")
>>> b.apply_load(R3, start=0, order=-1, dir="z")
>>> b.apply_load(R4, start=30, order=-1, dir="z")
>>> b.solve_for_reaction_loads(R1, R2, R3, R4)
>>> b.reaction_loads
{R1: -120, R2: -120, R3: -1350, R4: -2700}
r  r   z2Ambiguous solution for %s in different directions.N)r5   r0   r\  r   r   hasr   r   r  r   r   r  r   rB   r   update)rH   r  r(   rz   qr   shear_curvesshearmoment_curvesr   r  reactr"  r#  solsol_dictrZ   keys                     rJ   r3  Beam3D.solve_for_reaction_loads;  sR   6 MMKK""789qt	$*q9:FG,5,,GqA (`1!_-@-@-C-C}GWG[G[\]G^QE`5zQ6K !118L+!<eDII1MNCCO,H!11N  .(Xc]nS>Q-Q$%Y\_%_``     ''1  :G`s   E(E--4E2%E2c                     U R                   nU R                  n[        US   * U5      [        US   * U5      [        US   * U5      /$ )zu
Returns a list of three expressions which represents the shear force
curve of the Beam object along all three axes.
r   r   r  )r5   rY  r   )rH   r(   r  s      rJ   r/   Beam3D.shear_forcek  sL    
 MM1Q4%#Y!ua%8)QqTE1:MNNrM   c                 (    U R                  5       S   $ )zI
Returns expression of Axial shear force present inside the Beam object.
r   )r/   rY   s    rJ   axial_forceBeam3D.axial_forcet  s     !!$$rM   c                     U R                  5       S   U R                  -  U R                  5       S   U R                  -  U R                  5       S   U R                  -  /$ )zv
Returns a list of three expressions which represents the shear stress
curve of the Beam object along all three axes.
r   r   r  r  rY   s    rJ   r  Beam3D.shear_stressz  s[    
   "1%djj0$2B2B2DQ2G

2RTXTdTdTfghTijnjtjtTtuurM   c                 <    U R                  5       U R                  -  $ )zD
Returns expression of Axial stress present inside the Beam object.
)r  r~   rY   s    rJ   axial_stressBeam3D.axial_stress  s     !$**,,rM   c                     U R                   nU R                  nU R                  5       n[        US   * U5      [        US   * US   -   U5      [        US   * US   -
  U5      /$ )zx
Returns a list of three expressions which represents the bending moment
curve of the Beam object along all three axes.
r   r   r  )r5   rZ  r/   r   )rH   r(   r  r  s       rJ   r.   Beam3D.bending_moment  sq    
 MM$$  "1Q4%#Y!uuQx/?%C1Q4%%(*A.1 	1rM   c                 (    U R                  5       S   $ )zH
Returns expression of Torsional moment present inside the Beam object.
r   )r.   rY   s    rJ   torsional_momentBeam3D.torsional_moment  s     ""$Q''rM   c           
      2   U R                   nSn[        U R                  5       H  nX R                  U   -  nM     [        U R                  5      R                  5         [        U R                  5      n[	        X!US   :*  4SXS   :  45      n[        [        U5      5      SS  H@  nX R                  XFS-
        -  nU[	        SXUS-
     :*  4X!XF   :*  4SXU   :  45      -  nMB     [        U5      nXpR                  U R                  5       -  -  U l
        g)a  
Solves for the angular deflection due to the torsional effects of
moments being applied in the x-direction i.e. out of or into the beam.

Here, a positive torque means the direction of the torque is positive
i.e. out of the beam along the beam-axis. Likewise, a negative torque
signifies a torque into the beam cross-section.

Examples
========

>>> from sympy.physics.continuum_mechanics.beam import Beam3D
>>> from sympy import symbols
>>> l, E, G, I, A, x = symbols('l, E, G, I, A, x')
>>> b = Beam3D(20, E, G, I, A, x)
>>> b.apply_moment_load(4, 4, -2, dir='x')
>>> b.apply_moment_load(4, 8, -2, dir='x')
>>> b.apply_moment_load(4, 8, -2, dir='x')
>>> b.solve_for_torsion()
>>> b.angular_deflection().subs(x, 3)
18/(G*I)
r   r   N)r5   r  r[  r>  r   r   r   r   rX  rv  r_  )rH   r(   sum_momentsrO  
pointsListtorque_diagramr   integrated_torque_diagrams           rJ   solve_for_torsionBeam3D.solve_for_torsion  s%   . MM$../E//66K 0T!!"'')$../
"KJqM1A#BQVW=HXDYZs:'+A//
Q3@@KiA!A#,>(?+R\R_O_A`cdfgtuivfvbwxxN , %.n$=!$=?Q?QRVRcRcRe?e$f rM   c           	      	   U R                   nU R                  nU R                  nU R                  nU R                  n[        U[        5      (       a
  US   US   pvOU=pgU R                  nU R                  n	U R                  n
[        S5      n[        S5      n[        X8-  [        U" U5      U5      -  U5      U	S   -   n[        [        US5      U" U5      5      R                  S   n[        S5      n[        S5      n[        [!        UR#                  US5      UR#                  X5      /UU5      R                  S   5      nUR#                  UUS   UUS   05      nUR%                  U5      nXR&                  S'   UU R(                  S'   [        S5      n[        X7-  [        U" U5      U5      -  U5      [+        U	S   * U5      U-   -   U
S   -   n[        [        US5      5      R                  S   n[        [!        UR#                  US5      UR#                  X5      /UU5      R                  S   5      nUR#                  UUS   UUS   05      nXH-  [        U" U5      U5      -  U	S   U-  -   U-
  XH-  U-  -
  n[        [        US5      U" U5      5      R                  S   n[        [!        UR#                  US5      UR#                  X5      /UU5      R                  S   5      nUR#                  UUS   UUS   05      U R&                  S'   UR#                  UUS   5      U R(                  S'   [        X6-  [        U" U5      U5      -  U5      [+        U	S   U5      U-
  -   U
S   -   n[        [        US5      5      R                  S   n[        [!        UR#                  US5      UR#                  X5      /UU5      R                  S   5      nUR#                  UUS   UUS   05      nXH-  [        U" U5      U5      -  U	S   U-  -   U-
  XH-  U-  -   n[        [        US5      5      R                  S   n[        [!        UR#                  US5      UR#                  X5      /UU5      R                  S   5      nUR#                  UUS   UUS   05      U R&                  S'   UR#                  UUS   5      U R(                  S'   g )	Nr   r   deflthetaC1C2C_ir  )r5   r0   r1   rX  r4   r2   r  r~   rY  rZ  r
   r	   r   r   r   r   r   r   r   r^  r]  r   )rH   r(   rz   r   Gr   I_yI_zr'   r   r  r  r  eqdef_xr  r  rq  slope_xr  eq1slope_zeq2def_yslope_ydef_zs                             rJ   solve_slope_deflectionBeam3D.solve_slope_deflection  s   MMKK  atQqTMCJJ  ))! JtAw22A6a@r"ay$q'*//2D\D\(EJJq!$4ejj6F#GRPUUWXYZ	

By|R	!=>**Q-# A
 Umz%(A66:iaRS>TWZ>Z[^def^ggC$))!, (GLLA$6Q8J#KRQSTYY[\]^	,,9Q<IaLAB c:d1gq)*T!WQY6<qs7{Jr#qz47+003(EJJq!$4ejj6F#GSQVVXYZ[	#jj"Yq\3y|)LM c9Q<8A z%(A66:iQQR>SVY>YZ]cde]ffC$))!,(GLLA$6Q8J#KRQSTYY[\]^	,,9Q<IaLAB c:d1gq)*T!WQY6<qs7{Jr#ay!&&q)(EJJq!$4ejj6F#GSQVVXYZ[	#jj"Yq\3y|)LM c9Q<8ArM   c                     U R                   $ )z_
Returns a three element list representing slope of deflection curve
along all the three axes.
)r]  rY   s    rJ   r-   Beam3D.slope  s    
 {{rM   c                     U R                   $ )zV
Returns a three element list representing deflection curve along all
the three axes.
)r^  rY   s    rJ   r,   Beam3D.deflection  s    
 rM   c                     U R                   $ )zx
Returns a function in x depicting how the angular deflection, due to moments
in the x-axis on the beam, varies with x.
)r_  rY   s    rJ   angular_deflectionBeam3D.angular_deflection  rr  rM   c           
         U R                  5       nUS:X  a  SnSnOUS:X  a  SnSnO
US:X  a  SnS	nUc  0 nUW   R                  [        5       H'  nX`R                  :w  d  M  Xb;  d  M  [	        S
U-  5      e   U R
                  U;   a  X R
                     nOU R
                  n[        X4   R                  U5      U R                  SU4SSU-  SSU-  WS9$ )Nr(   r   r  ry  r   r  zr  r  r  FzShear Force along %c direction$\mathrm{X}$z$\mathrm{V(%c)}$r  r  r  r  r  r  )rH   r{  r   r/   dir_numr  r  r0   s           rJ   _plot_shear_forceBeam3D._plot_shear_force  s    &&(#:GECZGECZGE<Dw'--f5Cmm# !>!CDD 6 ;;$++&F[[FK(--d3dmmQ5OX]  fF  GJ  fJ&/B3/FSXZ 	ZrM   c                    UR                  5       nUS:X  a"  U R                  SU5      nUR                  5       $ US:X  a"  U R                  SU5      nUR                  5       $ US:X  a"  U R                  SU5      nUR                  5       $ U R                  SU5      nU R                  SU5      nU R                  SU5      n[        SSX4U5      $ )a  

Returns a plot for Shear force along all three directions
present in the Beam object.

Parameters
==========
dir : string (default : "all")
    Direction along which shear force plot is required.
    If no direction is specified, all plots are displayed.
subs : dictionary
    Python dictionary containing Symbols as key and their
    corresponding values.

Examples
========
There is a beam of length 20 meters. It is supported by rollers
at both of its ends. A linear load having slope equal to 12 is applied
along y-axis. A constant distributed load of magnitude 15 N is
applied from start till its end along z-axis.

.. plot::
    :context: close-figs
    :format: doctest
    :include-source: True

    >>> from sympy.physics.continuum_mechanics.beam import Beam3D
    >>> from sympy import symbols
    >>> l, E, G, I, A, x = symbols('l, E, G, I, A, x')
    >>> b = Beam3D(20, E, G, I, A, x)
    >>> b.apply_load(15, start=0, order=0, dir="z")
    >>> b.apply_load(12*x, start=0, order=0, dir="y")
    >>> b.bc_deflection = [(0, [0, 0, 0]), (20, [0, 0, 0])]
    >>> R1, R2, R3, R4 = symbols('R1, R2, R3, R4')
    >>> b.apply_load(R1, start=0, order=-1, dir="z")
    >>> b.apply_load(R2, start=20, order=-1, dir="z")
    >>> b.apply_load(R3, start=0, order=-1, dir="y")
    >>> b.apply_load(R4, start=20, order=-1, dir="y")
    >>> b.solve_for_reaction_loads(R1, R2, R3, R4)
    >>> b.plot_shear_force()
    PlotGrid object containing:
    Plot[0]:Plot object containing:
    [0]: cartesian line: 0 for x over (0.0, 20.0)
    Plot[1]:Plot object containing:
    [0]: cartesian line: -6*x**2 for x over (0.0, 20.0)
    Plot[2]:Plot object containing:
    [0]: cartesian line: -15*x for x over (0.0, 20.0)

r(   ry  r  r  r   )lowerr  r  r   rH   r{  r   PxPyPzs         rJ   r  Beam3D.plot_shear_force4  s    h iik#:''T2B779CZ''T2B779CZ''T2B779 ''T2B''T2B''T2BAq""--rM   c           
         U R                  5       nUS:X  a  SnSnOUS:X  a  SnSnO
US:X  a  SnS	nUc  0 nUW   R                  [        5       H'  nX`R                  :w  d  M  Xb;  d  M  [	        S
U-  5      e   U R
                  U;   a  X R
                     nOU R
                  n[        X4   R                  U5      U R                  SU4SSU-  SSU-  WS9$ )Nr(   r   r  ry  r   cr  r  r  r  Fz!Bending Moment along %c directionr  z$\mathrm{M(%c)}$r  r  )rH   r{  r   r.   r  r  r  r0   s           rJ   _plot_bending_momentBeam3D._plot_bending_moment|  s    ,,.#:GECZGECZGE<D!'*008Cmm# !>!CDD 9 ;;$++&F[[FN+00668R[`  iL  MP  iP&/B3/FSXZ 	ZrM   c                    UR                  5       nUS:X  a"  U R                  SU5      nUR                  5       $ US:X  a"  U R                  SU5      nUR                  5       $ US:X  a"  U R                  SU5      nUR                  5       $ U R                  SU5      nU R                  SU5      nU R                  SU5      n[        SSX4U5      $ )a  

Returns a plot for bending moment along all three directions
present in the Beam object.

Parameters
==========
dir : string (default : "all")
    Direction along which bending moment plot is required.
    If no direction is specified, all plots are displayed.
subs : dictionary
    Python dictionary containing Symbols as key and their
    corresponding values.

Examples
========
There is a beam of length 20 meters. It is supported by rollers
at both of its ends. A linear load having slope equal to 12 is applied
along y-axis. A constant distributed load of magnitude 15 N is
applied from start till its end along z-axis.

.. plot::
    :context: close-figs
    :format: doctest
    :include-source: True

    >>> from sympy.physics.continuum_mechanics.beam import Beam3D
    >>> from sympy import symbols
    >>> l, E, G, I, A, x = symbols('l, E, G, I, A, x')
    >>> b = Beam3D(20, E, G, I, A, x)
    >>> b.apply_load(15, start=0, order=0, dir="z")
    >>> b.apply_load(12*x, start=0, order=0, dir="y")
    >>> b.bc_deflection = [(0, [0, 0, 0]), (20, [0, 0, 0])]
    >>> R1, R2, R3, R4 = symbols('R1, R2, R3, R4')
    >>> b.apply_load(R1, start=0, order=-1, dir="z")
    >>> b.apply_load(R2, start=20, order=-1, dir="z")
    >>> b.apply_load(R3, start=0, order=-1, dir="y")
    >>> b.apply_load(R4, start=20, order=-1, dir="y")
    >>> b.solve_for_reaction_loads(R1, R2, R3, R4)
    >>> b.plot_bending_moment()
    PlotGrid object containing:
    Plot[0]:Plot object containing:
    [0]: cartesian line: 0 for x over (0.0, 20.0)
    Plot[1]:Plot object containing:
    [0]: cartesian line: -15*x**2/2 for x over (0.0, 20.0)
    Plot[2]:Plot object containing:
    [0]: cartesian line: 2*x**3 for x over (0.0, 20.0)

r(   ry  r  r  r   )r  r  r  r   r  s         rJ   r  Beam3D.plot_bending_moment  s    h iik#:**35B779CZ**35B779CZ**35B779 **35B**35B**35BAq""--rM   c           
         U R                  5       nUS:X  a  SnSnOUS:X  a  SnSnO
US:X  a  SnS	nUc  0 nUW   R                  [        5       H'  nX`R                  :w  d  M  Xb;  d  M  [	        S
U-  5      e   U R
                  U;   a  X R
                     nOU R
                  n[        X4   R                  U5      U R                  SU4SSU-  SSU-  WS9$ )Nr(   r   r  ry  r   r  r  r  r  r  FzSlope along %c directionr  z$\mathrm{\theta(%c)}$r  r  )rH   r{  r   r-   r  r  r  r0   s           rJ   _plot_slopeBeam3D._plot_slope  s    

#:GECZGECZGE<D>''/Cmm# !>!CDD 0 ;;$++&F[[F EN''-q&/IRW_yz}_}&/G/KX]_ 	_rM   c                    UR                  5       nUS:X  a"  U R                  SU5      nUR                  5       $ US:X  a"  U R                  SU5      nUR                  5       $ US:X  a"  U R                  SU5      nUR                  5       $ U R                  SU5      nU R                  SU5      nU R                  SU5      n[        SSX4U5      $ )a  

Returns a plot for Slope along all three directions
present in the Beam object.

Parameters
==========
dir : string (default : "all")
    Direction along which Slope plot is required.
    If no direction is specified, all plots are displayed.
subs : dictionary
    Python dictionary containing Symbols as keys and their
    corresponding values.

Examples
========
There is a beam of length 20 meters. It is supported by rollers
at both of its ends. A linear load having slope equal to 12 is applied
along y-axis. A constant distributed load of magnitude 15 N is
applied from start till its end along z-axis.

.. plot::
    :context: close-figs
    :format: doctest
    :include-source: True

    >>> from sympy.physics.continuum_mechanics.beam import Beam3D
    >>> from sympy import symbols
    >>> l, E, G, I, A, x = symbols('l, E, G, I, A, x')
    >>> b = Beam3D(20, 40, 21, 100, 25, x)
    >>> b.apply_load(15, start=0, order=0, dir="z")
    >>> b.apply_load(12*x, start=0, order=0, dir="y")
    >>> b.bc_deflection = [(0, [0, 0, 0]), (20, [0, 0, 0])]
    >>> R1, R2, R3, R4 = symbols('R1, R2, R3, R4')
    >>> b.apply_load(R1, start=0, order=-1, dir="z")
    >>> b.apply_load(R2, start=20, order=-1, dir="z")
    >>> b.apply_load(R3, start=0, order=-1, dir="y")
    >>> b.apply_load(R4, start=20, order=-1, dir="y")
    >>> b.solve_for_reaction_loads(R1, R2, R3, R4)
    >>> b.solve_slope_deflection()
    >>> b.plot_slope()
    PlotGrid object containing:
    Plot[0]:Plot object containing:
    [0]: cartesian line: 0 for x over (0.0, 20.0)
    Plot[1]:Plot object containing:
    [0]: cartesian line: -x**3/1600 + 3*x**2/160 - x/8 for x over (0.0, 20.0)
    Plot[2]:Plot object containing:
    [0]: cartesian line: x**4/8000 - 19*x**2/172 + 52*x/43 for x over (0.0, 20.0)

r(   ry  r  r  r   )r  r  r  r   r  s         rJ   r  Beam3D.plot_slope  s    j iik#:!!#t,B779CZ!!#t,B779CZ!!#t,B779 !!#t,B!!#t,B!!#t,BAq""--rM   c           
         U R                  5       nUS:X  a  SnSnOUS:X  a  SnSnO
US:X  a  SnS	nUc  0 nUW   R                  [        5       H'  nX`R                  :w  d  M  Xb;  d  M  [	        S
U-  5      e   U R
                  U;   a  X R
                     nOU R
                  n[        X4   R                  U5      U R                  SU4SSU-  SSU-  WS9$ )Nr(   r   r  ry  r   r  r  r  r  r  FzDeflection along %c directionr  z$\mathrm{\delta(%c)}$r  r  )rH   r{  r   r,   r  r  r  r0   s           rJ   _plot_deflectionBeam3D._plot_deflectionJ  s    __&
#:GECZGECZGE<Dg&,,V4Cmm# !>!CDD 5 ;;$++&F[[FJ',,T2T]]Av4NW\  eD  EH  eH&/G/KX]_ 	_rM   c                    UR                  5       nUS:X  a"  U R                  SU5      nUR                  5       $ US:X  a"  U R                  SU5      nUR                  5       $ US:X  a"  U R                  SU5      nUR                  5       $ U R                  SU5      nU R                  SU5      nU R                  SU5      n[        SSX4U5      $ )a*  

Returns a plot for Deflection along all three directions
present in the Beam object.

Parameters
==========
dir : string (default : "all")
    Direction along which deflection plot is required.
    If no direction is specified, all plots are displayed.
subs : dictionary
    Python dictionary containing Symbols as keys and their
    corresponding values.

Examples
========
There is a beam of length 20 meters. It is supported by rollers
at both of its ends. A linear load having slope equal to 12 is applied
along y-axis. A constant distributed load of magnitude 15 N is
applied from start till its end along z-axis.

.. plot::
    :context: close-figs
    :format: doctest
    :include-source: True

    >>> from sympy.physics.continuum_mechanics.beam import Beam3D
    >>> from sympy import symbols
    >>> l, E, G, I, A, x = symbols('l, E, G, I, A, x')
    >>> b = Beam3D(20, 40, 21, 100, 25, x)
    >>> b.apply_load(15, start=0, order=0, dir="z")
    >>> b.apply_load(12*x, start=0, order=0, dir="y")
    >>> b.bc_deflection = [(0, [0, 0, 0]), (20, [0, 0, 0])]
    >>> R1, R2, R3, R4 = symbols('R1, R2, R3, R4')
    >>> b.apply_load(R1, start=0, order=-1, dir="z")
    >>> b.apply_load(R2, start=20, order=-1, dir="z")
    >>> b.apply_load(R3, start=0, order=-1, dir="y")
    >>> b.apply_load(R4, start=20, order=-1, dir="y")
    >>> b.solve_for_reaction_loads(R1, R2, R3, R4)
    >>> b.solve_slope_deflection()
    >>> b.plot_deflection()
    PlotGrid object containing:
    Plot[0]:Plot object containing:
    [0]: cartesian line: 0 for x over (0.0, 20.0)
    Plot[1]:Plot object containing:
    [0]: cartesian line: x**5/40000 - 4013*x**3/90300 + 26*x**2/43 + 1520*x/903 for x over (0.0, 20.0)
    Plot[2]:Plot object containing:
    [0]: cartesian line: x**4/6400 - x**3/160 + 27*x**2/560 + 2*x/7 for x over (0.0, 20.0)


r(   ry  r  r  r   )r  r  r  r   r  s         rJ   r  Beam3D.plot_deflectionh  s    l iik#:&&sD1B779CZ&&sD1B779CZ&&sD1B779 &&sD1B&&sD1B&&sD1BAq""--rM   c                     UR                  5       nUc  0 nU R                  X5      nU R                  X5      nU R                  X5      nU R	                  X5      n[        SSX4XV5      $ )a  

Returns a subplot of Shear Force, Bending Moment,
Slope and Deflection of the Beam object along the direction specified.

Parameters
==========

dir : string (default : "x")
       Direction along which plots are required.
       If no direction is specified, plots along x-axis are displayed.
subs : dictionary
       Python dictionary containing Symbols as key and their
       corresponding values.

Examples
========
There is a beam of length 20 meters. It is supported by rollers
at both of its ends. A linear load having slope equal to 12 is applied
along y-axis. A constant distributed load of magnitude 15 N is
applied from start till its end along z-axis.

.. plot::
    :context: close-figs
    :format: doctest
    :include-source: True

    >>> from sympy.physics.continuum_mechanics.beam import Beam3D
    >>> from sympy import symbols
    >>> l, E, G, I, A, x = symbols('l, E, G, I, A, x')
    >>> b = Beam3D(20, E, G, I, A, x)
    >>> subs = {E:40, G:21, I:100, A:25}
    >>> b.apply_load(15, start=0, order=0, dir="z")
    >>> b.apply_load(12*x, start=0, order=0, dir="y")
    >>> b.bc_deflection = [(0, [0, 0, 0]), (20, [0, 0, 0])]
    >>> R1, R2, R3, R4 = symbols('R1, R2, R3, R4')
    >>> b.apply_load(R1, start=0, order=-1, dir="z")
    >>> b.apply_load(R2, start=20, order=-1, dir="z")
    >>> b.apply_load(R3, start=0, order=-1, dir="y")
    >>> b.apply_load(R4, start=20, order=-1, dir="y")
    >>> b.solve_for_reaction_loads(R1, R2, R3, R4)
    >>> b.solve_slope_deflection()
    >>> b.plot_loading_results('y',subs)
    PlotGrid object containing:
    Plot[0]:Plot object containing:
    [0]: cartesian line: -6*x**2 for x over (0.0, 20.0)
    Plot[1]:Plot object containing:
    [0]: cartesian line: -15*x**2/2 for x over (0.0, 20.0)
    Plot[2]:Plot object containing:
    [0]: cartesian line: -x**3/1600 + 3*x**2/160 - x/8 for x over (0.0, 20.0)
    Plot[3]:Plot object containing:
    [0]: cartesian line: x**5/40000 - 4013*x**3/90300 + 26*x**2/43 + 1520*x/903 for x over (0.0, 20.0)

r  r   )r  r  r  r  r  r   )rH   r{  r   r  r  r  r  s          rJ   r  Beam3D.plot_loading_results  sk    r iik<D$$S/''2s)##C.1c11rM   c           
         U R                  5       nUS:X  a  SnSnOUS:X  a  SnSnO
US:X  a  SnS	nUc  0 nUW   R                  [        5       H'  nX`R                  :w  d  M  Xb;  d  M  [	        S
U-  5      e   U R
                  U;   a  X R
                     nOU R
                  n[        X4   R                  U5      U R                  SU4SSU-  SSU-  WS9$ )Nr(   r   r  ry  r   r  r  r  r  r  FzShear stress along %c directionr  z
$\tau(%c)$r  )r  r  r   r5   r   r0   r   r   )rH   r{  r   r  r  r  r  r0   s           rJ   _plot_shear_stressBeam3D._plot_shear_stress  s    ((*#:GECZGECZGE<D(..v6Cmm# !>!CDD 7 ;;$++&F[[FL)..t4t}}a6PY^  gH  IL  gL&}S/@UT 	TrM   c                    UR                  5       nUS:X  a"  U R                  SU5      nUR                  5       $ US:X  a"  U R                  SU5      nUR                  5       $ US:X  a"  U R                  SU5      nUR                  5       $ U R                  SU5      nU R                  SU5      nU R                  SU5      n[        SSX4U5      $ )a  

Returns a plot for Shear Stress along all three directions
present in the Beam object.

Parameters
==========
dir : string (default : "all")
    Direction along which shear stress plot is required.
    If no direction is specified, all plots are displayed.
subs : dictionary
    Python dictionary containing Symbols as key and their
    corresponding values.

Examples
========
There is a beam of length 20 meters and area of cross section 2 square
meters. It is supported by rollers at both of its ends. A linear load having
slope equal to 12 is applied along y-axis. A constant distributed load
of magnitude 15 N is applied from start till its end along z-axis.

.. plot::
    :context: close-figs
    :format: doctest
    :include-source: True

    >>> from sympy.physics.continuum_mechanics.beam import Beam3D
    >>> from sympy import symbols
    >>> l, E, G, I, A, x = symbols('l, E, G, I, A, x')
    >>> b = Beam3D(20, E, G, I, 2, x)
    >>> b.apply_load(15, start=0, order=0, dir="z")
    >>> b.apply_load(12*x, start=0, order=0, dir="y")
    >>> b.bc_deflection = [(0, [0, 0, 0]), (20, [0, 0, 0])]
    >>> R1, R2, R3, R4 = symbols('R1, R2, R3, R4')
    >>> b.apply_load(R1, start=0, order=-1, dir="z")
    >>> b.apply_load(R2, start=20, order=-1, dir="z")
    >>> b.apply_load(R3, start=0, order=-1, dir="y")
    >>> b.apply_load(R4, start=20, order=-1, dir="y")
    >>> b.solve_for_reaction_loads(R1, R2, R3, R4)
    >>> b.plot_shear_stress()
    PlotGrid object containing:
    Plot[0]:Plot object containing:
    [0]: cartesian line: 0 for x over (0.0, 20.0)
    Plot[1]:Plot object containing:
    [0]: cartesian line: -3*x**2 for x over (0.0, 20.0)
    Plot[2]:Plot object containing:
    [0]: cartesian line: -15*x/2 for x over (0.0, 20.0)

r(   ry  r  r  r   )r  r  r  r   r  s         rJ   r  Beam3D.plot_shear_stress  s    h iik#:((d3B779CZ((d3B779CZ((d3B779 ((d3B((d3B((d3BAq""--rM   c                    UR                  5       nUS:X  a  SnOUS:X  a  SnOUS:X  a  SnU R                  5       W   (       d  g[        [        S5      U R                  S:*  4U R
                  U   U R                  U R                  :  4[        S5      S	45      n[        UR                  [        5      U R                  [        R                  S
9nUR                  S5        UR                  U R                  5        U R                  5       U   nU Vs/ s H  oeR                  U R                  U5      PM      nn[        [        [        U5      5      n[!        U5      nXGR#                  U5         U4$ s  snf )z(
Helper function for max_shear_force().
r(   r   ry  r   r  r  r  r:  Tre  )r  r/   r   r@  r5   rY  r0   r   rA  r   rg  r   r   r  rF  rB  rD  rE  )	rH   r{  r  
load_curverM  r"  r(   rK  rP  s	            rJ   _max_shear_forceBeam3D._max_shear_force\  sC   
 iik#:GCZGCZG!'*edmmQ.>?""7+T]]4;;-FGut$&
 z)))4dmm ww(adkk"&&(1DJKFq((:FKC\23%	)))45yAA	 Ls   %E3c                     / nUR                  U R                  S5      5        UR                  U R                  S5      5        UR                  U R                  S5      5        U$ )a  
Returns point of max shear force and its corresponding shear value
along all directions in a Beam object as a list.
solve_for_reaction_loads() must be called before using this function.

Examples
========
There is a beam of length 20 meters. It is supported by rollers
at both of its ends. A linear load having slope equal to 12 is applied
along y-axis. A constant distributed load of magnitude 15 N is
applied from start till its end along z-axis.

.. plot::
    :context: close-figs
    :format: doctest
    :include-source: True

    >>> from sympy.physics.continuum_mechanics.beam import Beam3D
    >>> from sympy import symbols
    >>> l, E, G, I, A, x = symbols('l, E, G, I, A, x')
    >>> b = Beam3D(20, 40, 21, 100, 25, x)
    >>> b.apply_load(15, start=0, order=0, dir="z")
    >>> b.apply_load(12*x, start=0, order=0, dir="y")
    >>> b.bc_deflection = [(0, [0, 0, 0]), (20, [0, 0, 0])]
    >>> R1, R2, R3, R4 = symbols('R1, R2, R3, R4')
    >>> b.apply_load(R1, start=0, order=-1, dir="z")
    >>> b.apply_load(R2, start=20, order=-1, dir="z")
    >>> b.apply_load(R3, start=0, order=-1, dir="y")
    >>> b.apply_load(R4, start=20, order=-1, dir="y")
    >>> b.solve_for_reaction_loads(R1, R2, R3, R4)
    >>> b.max_shear_force()
    [(0, 0), (20, 2400), (20, 300)]
r(   ry  r  )r   r  )rH   rP  s     rJ   rT  Beam3D.max_shear_force~  s[    F 	..s34..s34..s34rM   c                    UR                  5       nUS:X  a  SnOUS:X  a  SnOUS:X  a  SnU R                  5       W   (       d  g[        [        S5      U R                  S:*  4U R                  5       U   U R                  U R                  :  4[        S5      S	45      n[        UR                  [        5      U R                  [        R                  S
9nUR                  S5        UR                  U R                  5        U R                  5       U   nU Vs/ s H  oeR                  U R                  U5      PM      nn[        [        [        U5      5      n[!        U5      nXGR#                  U5         U4$ s  snf )z+
Helper function for max_bending_moment().
r(   r   ry  r   r  r  r  r:  Tre  )r  r.   r   r@  r5   r/   r0   r   rA  r   rg  r   r   r  rF  rB  rD  rE  )	rH   r{  r  r"  rM  bending_moment_curver(   bending_momentsmax_bending_moments	            rJ   _max_bending_momentBeam3D._max_bending_moment  sL   
 iik#:GCZGCZG""$W-ut}}a/? @!!#G,dmmDKK.GHut$& {**95t}} ww(adkk"#224W=PVWPV144T]]AFPVWs389 1,,-?@ACUVV	 X   %E7c                     / nUR                  U R                  S5      5        UR                  U R                  S5      5        UR                  U R                  S5      5        U$ )a  
Returns point of max bending moment and its corresponding bending moment value
along all directions in a Beam object as a list.
solve_for_reaction_loads() must be called before using this function.

Examples
========
There is a beam of length 20 meters. It is supported by rollers
at both of its ends. A linear load having slope equal to 12 is applied
along y-axis. A constant distributed load of magnitude 15 N is
applied from start till its end along z-axis.

.. plot::
    :context: close-figs
    :format: doctest
    :include-source: True

    >>> from sympy.physics.continuum_mechanics.beam import Beam3D
    >>> from sympy import symbols
    >>> l, E, G, I, A, x = symbols('l, E, G, I, A, x')
    >>> b = Beam3D(20, 40, 21, 100, 25, x)
    >>> b.apply_load(15, start=0, order=0, dir="z")
    >>> b.apply_load(12*x, start=0, order=0, dir="y")
    >>> b.bc_deflection = [(0, [0, 0, 0]), (20, [0, 0, 0])]
    >>> R1, R2, R3, R4 = symbols('R1, R2, R3, R4')
    >>> b.apply_load(R1, start=0, order=-1, dir="z")
    >>> b.apply_load(R2, start=20, order=-1, dir="z")
    >>> b.apply_load(R3, start=0, order=-1, dir="y")
    >>> b.apply_load(R4, start=20, order=-1, dir="y")
    >>> b.solve_for_reaction_loads(R1, R2, R3, R4)
    >>> b.max_bending_moment()
    [(0, 0), (20, 3000), (20, 16000)]
r(   ry  r  )r   r  )rH   r`  s     rJ   r  Beam3D.max_bending_moment  s[    F 433C89433C89433C89rM   c                    UR                  5       nUS:X  a  SnOUS:X  a  SnOUS:X  a  SnU R                  5       W   (       d  g[        [        S5      U R                  S:*  4U R                  5       U   U R                  U R                  :  4[        S5      S	45      n[        UR                  [        5      U R                  [        R                  S
9nUR                  S5        UR                  U R                  5        U R                  5       U   nU Vs/ s H  oeR                  U R                  U5      PM      nn[        [        [         U5      5      n[#        U5      nXGR%                  U5         U4$ s  snf )z&
Helper function for max_Deflection()
r(   r   ry  r   r  r  r  r:  Tre  )r  r,   r   r@  r5   r-   r0   r   rA  r   rg  r   rR   r   r  rF  rB  rD  rE  )	rH   r{  r  r+  rM  r,  r(   r{  r|  s	            rJ   _max_deflectionBeam3D._max_deflection  s@   
 iik#:GCZGCZG )ut}}a/? @g&dkk(ABut$& {**95t}} ww(adll#??,W5HNO1,,T]]A>O3sK01k"((12G<<	 Pr  c                     / nUR                  U R                  S5      5        UR                  U R                  S5      5        UR                  U R                  S5      5        U$ )a  
Returns point of max deflection and its corresponding deflection value
along all directions in a Beam object as a list.
solve_for_reaction_loads() and solve_slope_deflection() must be called
before using this function.

Examples
========
There is a beam of length 20 meters. It is supported by rollers
at both of its ends. A linear load having slope equal to 12 is applied
along y-axis. A constant distributed load of magnitude 15 N is
applied from start till its end along z-axis.

.. plot::
    :context: close-figs
    :format: doctest
    :include-source: True

    >>> from sympy.physics.continuum_mechanics.beam import Beam3D
    >>> from sympy import symbols
    >>> l, E, G, I, A, x = symbols('l, E, G, I, A, x')
    >>> b = Beam3D(20, 40, 21, 100, 25, x)
    >>> b.apply_load(15, start=0, order=0, dir="z")
    >>> b.apply_load(12*x, start=0, order=0, dir="y")
    >>> b.bc_deflection = [(0, [0, 0, 0]), (20, [0, 0, 0])]
    >>> R1, R2, R3, R4 = symbols('R1, R2, R3, R4')
    >>> b.apply_load(R1, start=0, order=-1, dir="z")
    >>> b.apply_load(R2, start=20, order=-1, dir="z")
    >>> b.apply_load(R3, start=0, order=-1, dir="y")
    >>> b.apply_load(R4, start=20, order=-1, dir="y")
    >>> b.solve_for_reaction_loads(R1, R2, R3, R4)
    >>> b.solve_slope_deflection()
    >>> b.max_deflection()
    [(0, 0), (10, 495/14), (-10 + 10*sqrt(10793)/43, (10 - 10*sqrt(10793)/43)**3/160 - 20/7 + (10 - 10*sqrt(10793)/43)**4/6400 + 20*sqrt(10793)/301 + 27*(10 - 10*sqrt(10793)/43)**2/560)]
r(   ry  r  )r   r  )rH   r|  s     rJ   r}  Beam3D.max_deflection  sT    J t++C01t++C01t++C01rM   )r_  r~   r^  r\  rY  rZ  rP   rc  r]  r[  r:   rX  )ry  rJ  ry   )allN)r(   N)3rK  rL  rM  rN  rO  r   rK   rP  rX  rQ  r4   r:   rm  rp  r   rv  r   r~  r   r3  r/   r  r  r  r.   r  r  r  r-   r,   r  r  r  r  r  r  r  r  r  r  r  r  r  rT  r  r  r`  r  r}  rR  __classcell__)r`  s   @rJ   rT  rT  !
  s   3l !'s$%L # # ) ) # # - -   
[[    ! ! ( ( ) )<'.$TL'TR
3.2`O%v-
1("gHB9H (Z<F.PZ<F.P_>G.R_<H.TB2HT<F.P BD'R WD'R %K =D) )rM   rT  )7rO  
sympy.corer   r   r   r   sympy.core.addr   sympy.core.exprr   sympy.core.functionr	   r
   sympy.core.mulr   sympy.core.relationalr   sympy.core.sympifyr   sympy.solversr   sympy.solvers.ode.oder   sympy.solvers.solversr   sympy.printingr   sympy.functionsr   r   r   sympy.integralsr   sympy.seriesr   sympy.plottingr   r   sympy.geometry.entityr   sympy.externalr   sympy.sets.setsr   sympy.utilities.lambdifyr   sympy.utilities.decoratorr   sympy.utilities.iterablesr   r2  __doctest_requires__r    r%   rT  r  rM   rJ   <module>r     s   
 0 /    6  $ & " ( '  E E %  ) 0 ( $ - 8 .  '	  	gj(-DEq'3 q'3hO^T ^rM   