o
    ohQ                    @   sb  d Z ddlmZmZmZmZ ddlmZ ddlm	Z	 ddl
mZmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZmZmZ ddlm Z  ddl!m"Z" ddl#m$Z$m%Z% ddl&m'Z' ddl(m)Z) ddl*m+Z+ ddl,m-Z- ddl.m/Z/ ddl0m1Z1 ddl2Z2ddgiZ3e)dddgidZ4G dd dZ5G d d! d!e5Z6dS )"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)	Beam.drawBeam.plot_bending_momentBeam.plot_deflectionBeam.plot_ild_momentBeam.plot_ild_shearBeam.plot_shear_forceBeam.plot_shear_stressBeam.plot_slope
matplotlibnumpyfromlistarange)import_kwargsc                   @   s  e Zd ZdZededdfddZdd Zed	d
 Zedd Z	edd Z
edd Zedd Zejdd Zedd Zejdd Zedd Zejdd Zedd Zejdd Zedd Zejdd Zed d! Zejd"d! Zed#d$ Zed%d& Zejd'd& Zed(d) Zejd*d) Zdvd,d-Zdvd.d/Zdwd1d2Zdwd3d4Zd5d6 Zed7d8 Zed9d: Zd;d< Zd=d> Zd?d@ ZdAdB Z dCdD Z!dEdF Z"dGdH Z#dIdJ Z$dKdL Z%dMdN Z&dOdP Z'dwdQdRZ(dwdSdTZ)dwdUdVZ*dwdWdXZ+dwdYdZZ,dwd[d\Z-d]d^ Z.d_d` Z/dwdadbZ0dcdd Z1dwdedfZ2dgdh Z3dwdidjZ4e5dkdldxdndoZ6dpdq Z7drds Z8dtdu Z9d0S )yBeamaO  
    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
    {'deflection': [(0, 0), (4, 0)], '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Cc                 C   s   || _ || _t|tr|| _nd| _|| _|| _|| _g g d| _d| _	|| _
g | _g | _g | _i | _i | _d| _d| _d| _d| _d| _dS )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.
        N)
deflectionsloper   )lengthelastic_modulus
isinstancer   cross_sectionsecond_momentvariable
_base_char_boundary_conditions_loadarea_applied_supports_support_as_loads_applied_loads_reaction_loads_ild_reactions
_ild_shear_ild_moment_original_load_composite_type_hinge_position)selfr3   r4   r7   r<   r8   	base_char rI   z/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/sympy/physics/continuum_mechanics/beam.py__init__   s*   '

zBeam.__init__c                 C   s4   | j r| j n| j}dt| jt| jt|}|S )NzBeam({}, {}, {}))_cross_section_second_momentformatr   _length_elastic_modulus)rG   shape_descriptionstr_solrI   rI   rJ   __str__   s   zBeam.__str__c                 C      | j S )z- Returns the reaction forces in a dictionary.)r@   rG   rI   rI   rJ   reaction_loads      zBeam.reaction_loadsc                 C   rT   )z# Returns the I.L.D. shear equation.)rB   rU   rI   rI   rJ   	ild_shear   rW   zBeam.ild_shearc                 C   rT   )z4 Returns the I.L.D. reaction forces in a dictionary.)rA   rU   rI   rI   rJ   ild_reactions   rW   zBeam.ild_reactionsc                 C   rT   )z$ Returns the I.L.D. moment equation.)rC   rU   rI   rI   rJ   
ild_moment   rW   zBeam.ild_momentc                 C   rT   )zLength of the Beam.)rO   rU   rI   rI   rJ   r3      rW   zBeam.lengthc                 C      t || _d S N)r   rO   )rG   lrI   rI   rJ   r3         c                 C   rT   z"Cross-sectional area of the Beam. _arearU   rI   rI   rJ   r<      rW   z	Beam.areac                 C   r[   r\   r   ra   rG   arI   rI   rJ   r<      r^   c                 C   rT   )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
        )	_variablerU   rI   rI   rJ   r8         zBeam.variablec                 C   s   t |tr
|| _d S td)Nz'The variable should be a Symbol object.)r5   r   re   	TypeError)rG   vrI   rI   rJ   r8     s   

c                 C   rT   zYoung's Modulus of the Beam. )rP   rU   rI   rI   rJ   r4     rW   zBeam.elastic_modulusc                 C   r[   r\   )r   rP   rG   erI   rI   rJ   r4     r^   c                 C   rT   z#Second moment of area of the Beam. rM   rU   rI   rI   rJ   r7   !  rW   zBeam.second_momentc                 C   s&   d | _ t|trtdt|| _d S )Nz>To update cross-section geometry use `cross_section` attribute)rL   r5   r   
ValueErrorr   rM   rG   irI   rI   rJ   r7   &  s   
c                 C   rT   )zCross-section of the beam)rL   rU   rI   rI   rJ   r6   .  rW   zBeam.cross_sectionc                 C   s   |r	|  d | _|| _d S )Nr   )second_moment_of_arearM   rL   )rG   srI   rI   rJ   r6   3  s   
c                 C   rT   )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
        {'deflection': [(0, 2)], '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``.
        r:   rU   rI   rI   rJ   boundary_conditions9  s   zBeam.boundary_conditionsc                 C   
   | j d S Nr2   rs   rU   rI   rI   rJ   bc_slopeV     
zBeam.bc_slopec                 C      || j d< d S rv   rs   )rG   s_bcsrI   rI   rJ   rw   Z  r^   c                 C   ru   Nr1   rs   rU   rI   rI   rJ   bc_deflection^  rx   zBeam.bc_deflectionc                 C   ry   r{   rs   )rG   d_bcsrI   rI   rJ   r|   b  r^   fixedc                 C   s   | j }| j}| j|j }| j|jkr#t| j|| jkf|j||kf}n| j}|dkr6t||||}d|_|S |dkrJt||||}d|_| j|_|S dS )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 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)
        r~   hingeN)r8   r4   r3   r7   r   r-   rE   rF   )rG   beamviar/   E
new_lengthnew_second_momentnew_beamrI   rI   rJ   joinf  s$   +z	Beam.joinc                 C   s   t |}| j||f |dv r(tdt| }| ||d | j|df n8tdt| }tdt| }| ||d | ||d | j|df | j|df | j||ddf | j||ddf |dv rp|S ||fS )a  
        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|   rw   r>   rG   loctypereaction_loadreaction_momentrI   rI   rJ   apply_support  s"   3zBeam.apply_supportNc                 C   s   | j }t|}t|}t|}| j||||f |  j|t||| 7  _|  j|t||| 7  _|rB| j|||||dd dS dS )a  
        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)r8   r   r?   r   r;   r   rD   _handle_end)rG   valuestartorderendr/   rI   rI   rJ   r     s   7zBeam.apply_loadc                 C   s   | j }t|}t|}t|}||||f| jv r=|  j|t||| 8  _|  j|t||| 8  _| j||||f nd}t||rR| j|||||dd dS dS )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)	r8   r   r?   r;   r   rD   r   rn   r   )rG   r   r   r   r   r/   msgrI   rI   rJ   remove_load2  s   /zBeam.remove_loadc           
      C   s:  |j r	d}t||||  }|dkrUtd|d D ]8}	|  j|||	||| t|||	 t|	 8  _|  j|||	||| t|||	 t|	 8  _qdS |dkrtd|d D ]:}	|  j|||	||| t|||	 t|	 7  _|  j|||	||| t|||	 t|	 7  _q`dS dS )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   N)	is_negativern   ranger;   r   subsr   r   rD   )
rG   r/   r   r   r   r   r   r   frp   rI   rI   rJ   r   r  s>   





zBeam._handle_endc                 C   rT   )a  
        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)
        )r;   rU   rI   rI   rJ   load  rf   z	Beam.loadc                 C   rT   )a  
        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)]
        )r?   rU   rI   rI   rJ   applied_loads  s   zBeam.applied_loadsc           !      G   s  | j }| j}| j}| j}t|tr |jd d }|jd d }n| }}d}d}	| jD ]}
|
d |k r}||
d t||
d |
d  7 }|
d dkrZ||
d t||
d |
d  8 }q+|
d dkr|||
d t||
d |
d  |
d t||
d d  8 }q+|
d |kr||
d t||
d |
d  7 }|	|
d t||
d | |
d  7 }	q+|
d |kr|	|
d t||
d | |
d  7 }	|
d dkr|	|
d t||
d | |
d  8 }	q+|
d dkr|	|
d t||
d | |
d  |
d t||
d | d  8 }	q+t	d}||t||d 7 }|	|t|dd 8 }	g }t
||}t|||}|| t
||}t|||}|| t
|	|}t||| j| }|| t
||}t||| j| }|| t	d}t	d}t	d	}t	d
}tj||  t
|||  }tj||  t
|| | |||  |  }tj||  t
t
t
|	||||  }tj||  t
|| | ||  }| jD ]$\}}||k r|||||  q||||| |  q| jD ]$\}}||k r|||||  q||||| |  q||||||d  tt||||||g|R  }t|d dd } tt|| | _| j| j| _|||d d ||d d i| j}|||d d ||d d ||d d i| j}|||| ||d d ||d d i| j}|||| ||d d ||d d ||d d i| j}|t|dd |t||d  |t||d  | _|t|dd |t||d  |t||d  | _dS )a5  Method to find integration constants and reactional variables in a
        composite beam connected via hinge.
        This method resolves the composite Beam into its sub-beams and then
        equations of shear force, bending moment, slope and deflection are
        evaluated for both of them separately. These equations are then solved
        for unknown reactions and integration constants using the boundary
        conditions applied on the Beam. Equal deflection of both sub-beams
        at the hinge joint gives us another equation to solve the system.

        Examples
        ========
        A combined beam, with constant fkexural rigidity E*I, is formed by joining
        a Beam of length 2*l to the right of another Beam of length l. The whole beam
        is fixed at both of its both end. A point load of magnitude P is also applied
        from the top at a distance of 2*l from starting point.

        >>> from sympy.physics.continuum_mechanics.beam import Beam
        >>> from sympy import symbols
        >>> E, I = symbols('E, I')
        >>> l=symbols('l', positive=True)
        >>> b1=Beam(l, E, I)
        >>> b2=Beam(2*l, E, I)
        >>> b=b1.join(b2,"hinge")
        >>> M1, A1, M2, A2, P = symbols('M1 A1 M2 A2 P')
        >>> b.apply_load(A1,0,-1)
        >>> b.apply_load(M1,0,-2)
        >>> b.apply_load(P,2*l,-1)
        >>> b.apply_load(A2,3*l,-1)
        >>> b.apply_load(M2,3*l,-2)
        >>> b.bc_slope=[(0,0), (3*l, 0)]
        >>> b.bc_deflection=[(0,0), (3*l, 0)]
        >>> b.solve_for_reaction_loads(M1, A1, M2, A2)
        >>> b.reaction_loads
        {A1: -5*P/18, A2: -13*P/18, M1: 5*P*l/18, M2: -4*P*l/9}
        >>> b.slope()
        (5*P*l*SingularityFunction(x, 0, 1)/18 - 5*P*SingularityFunction(x, 0, 2)/36 + 5*P*SingularityFunction(x, l, 2)/36)*SingularityFunction(x, 0, 0)/(E*I)
        - (5*P*l*SingularityFunction(x, 0, 1)/18 - 5*P*SingularityFunction(x, 0, 2)/36 + 5*P*SingularityFunction(x, l, 2)/36)*SingularityFunction(x, l, 0)/(E*I)
        + (P*l**2/18 - 4*P*l*SingularityFunction(-l + x, 2*l, 1)/9 - 5*P*SingularityFunction(-l + x, 0, 2)/36 + P*SingularityFunction(-l + x, l, 2)/2
        - 13*P*SingularityFunction(-l + x, 2*l, 2)/36)*SingularityFunction(x, l, 0)/(E*I)
        >>> b.deflection()
        (5*P*l*SingularityFunction(x, 0, 2)/36 - 5*P*SingularityFunction(x, 0, 3)/108 + 5*P*SingularityFunction(x, l, 3)/108)*SingularityFunction(x, 0, 0)/(E*I)
        - (5*P*l*SingularityFunction(x, 0, 2)/36 - 5*P*SingularityFunction(x, 0, 3)/108 + 5*P*SingularityFunction(x, l, 3)/108)*SingularityFunction(x, l, 0)/(E*I)
        + (5*P*l**3/54 + P*l**2*(-l + x)/18 - 2*P*l*SingularityFunction(-l + x, 2*l, 2)/9 - 5*P*SingularityFunction(-l + x, 0, 3)/108 + P*SingularityFunction(-l + x, l, 3)/6
        - 13*P*SingularityFunction(-l + x, 2*l, 3)/108)*SingularityFunction(x, l, 0)/(E*I)
        r   r         hr   C1C2C3C4   N   )r8   rF   rP   rM   r5   r   argsr   r   r   r   r   r   r3   r   Onerw   r   r|   listr   dictzipr@   r;   _hinge_beam_slope_hinge_beam_deflection)!rG   	reactionsr/   r]   r   II1I2load_1load_2r   r   eqshear_1shear_curve_1	bending_1moment_curve_1shear_2shear_curve_2	bending_2moment_curve_2r   r   r   r   slope_1def_1slope_2def_2positionr   	constantsreaction_valuesrI   rI   rJ   _solve_hinge_beams  s   .

 "8 &$&@







,($

*62>26zBeam._solve_hinge_beamsc                 G   s,  | j dkr
| j| S | j}| j}td}td}t|  ||}t|  ||}g }g }	t|  || }
| j	d D ]\}}|

||| }|| q:t|
|| }| j	d D ]\}}|
||| }|	| qXtt||g| |	 ||f| jd }|dd }tt||| _| j
| j| _dS )	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)
        r   r   r   r2   r1   r   r   N)rE   r   r8   r3   r   r   shear_forcebending_momentr   r:   r   r   r   r   r   r   r   r@   r;   )rG   r   r/   r]   r   r   shear_curvemoment_curve	slope_eqsdeflection_eqsslope_curver   r   eqsdeflection_curvesolutionrI   rI   rJ   solve_for_reaction_loadsP  s8   
$

zBeam.solve_for_reaction_loadsc                 C   s   | j }t| j| S )a)  
        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)
        )r8   r   r   rG   r/   rI   rI   rJ   r        zBeam.shear_forcec              
   C   s0  |   }| j}|j}g }|D ]}t|tr|jd }||jd  qtt|}|  g }g }t	|D ]\}}	|	dkr>q5zkt
td|||d  kf| jt
||	k ftddf}
t|
|}g }|D ]}|t||| qd|||d  |	g |tt||||d  dtt|||	dg7 }t|}|| ||||  W q5 ty   t||||d  d}t|||	d}||||d  |	 d || d kr||kr|||g |||d  |	g n|| |t||d  |	 Y q5w ttt|}t|}||| }||fS 	zJReturns maximum Shear force and its coordinate
        in the Beam object.r   r   r   nanT+-r   )r   r8   r   r5   r
   r   r   setsort	enumerater   floatr;   rewriter   absr   extendr   maxindexNotImplementedErrorr   map)rG   r   r/   termssingularityterm	intervalsshear_valuesrp   rr   shear_slopepointsvalpoint	max_shearinitial_shearfinal_shearmaximum_shearrI   rI   rJ   max_shear_force  sP   

8
0
0
zBeam.max_shear_forcec                 C   s   | j }t|  |S )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)
        )r8   r   r   r   rI   rI   rJ   r     r   zBeam.bending_momentc              
   C   s2  |   }| j}|j}g }|D ]}t|tr|jd }||jd  qtt|}|  g }g }t	|D ]\}}	|	dkr>q5zlt
td|||d  kf|  t
||	k ftddf}
t|
|}g }|D ]}|t||| qe|||d  |	g |tt||||d  dtt|||	dg7 }t|}|| ||||  W q5 ty   t||||d  d}t|||	d}||||d  |	 d || d kr||kr|||g |||d  |	g n|| |t||d  |	 Y q5w ttt|}t|}||| }||fS r   )r   r8   r   r5   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )rG   bending_curver/   r   r   r   r   moment_valuesrp   rr   moment_sloper   r   r   
max_momentinitial_momentfinal_momentmaximum_momentrI   rI   rJ   max_bmoment	  sX   



0
0
zBeam.max_bmomentc                 C   sN   t td| jdkf|  | j| jk ftddf}t|t | jtjd}|S )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]
        r   r   Tdomain)	r   r   r8   r   r3   r   r   r   Reals)rG   r   r   rI   rI   rJ   point_cflexure?  s   !
zBeam.point_cflexurec                 C   s  | j }| j}| j}| jdkr| jS | jd st|  |S t|t	r| jdkr|j
}d}d}d}tt|D ]f}|dkrG||d  d j
d }tj | t|  || d  |||f }	|t|d kr|||	 t||d ||	 t||| d j
d d  7 }n|||	 t||d 7 }|	||| d j
d }q6|S td}
ttj||  |   | |
 }g }| jd D ]\}}|||| }|| qtt||
}||
|d d i}|S )aD  
        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   r2   r~   r   r   r   )r8   r4   r7   rE   r   r:   r   r1   r5   r   r   r   lenr   r   r   r   r   r   r   r   r   r   )rG   r/   r   r   r   r2   
prev_slopeprev_endrp   slope_valuer   r   bc_eqsr   r   r   r   rI   rI   rJ   r2   h  s@    

, "z
Beam.slopec                 C   s  | j }| j}| j}| jdkr| jS | jd s| jd st|tr| jdkr|j}d}d}d}d}t	t
|D ]}	|	dkrG||	d  d jd }tj | t|  ||	 d  |||f }
||
 }t||||f}|	t
|d kr||| t||d || t|||	 d jd d  7 }n||| t||d 7 }|
|||	 d jd }||||	 d jd }q6|S | j}t|d }tj||  tt|  | | |d |  |d  S | jd s| j}t|d }t|  || S | jd s| jd rt|tr| jdkr|j}d}d}d}d}t	t
|D ]}	|	dkr/||	d  d jd }tj | t|  ||	 d  |||f }
||
 }t||||f}|	t
|d krx||| t||d || t|||	 d jd d  7 }n||| t||d 7 }|
|||	 d jd }||||	 d jd }q|S | j}t|d \}}t|  | | }t||| }g }| jd D ]\}}|||| }|| qtt|||f}|||d d ||d d i}tj||  | S t|tr| jdkr|j}d}d}d}d}t	t
|D ]}	|	dkr*||	d  d jd }tj| t|  ||	 d  |||f }
||
 }t||||f}|	t
|d krr||| t||d || t|||	 d jd d  7 }n||| t||d 7 }|
|||	 d jd }||||	 d jd }q|S td	}t|  || }g }| jd D ]\}}|||| }|| qtt||}|||d d i}|S )
aW  
        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   r1   r2   r~   r   r   z3:54r   )r8   r4   r7   rE   r   r:   r5   r   r   r   r  r   r   r   r   r   r   r9   r   r2   r   r   r   r   )rG   r/   r   r   r   r  prev_defr  r1   rp   r  recent_segment_slopedeflection_valuerH   r   constantr   r   r   r   r	  r   r   r   rI   rI   rJ   r1     s    
, 8

, "
* zBeam.deflectionc                    s   t tdjdkf jjk ftddf}t|t jtjd}	   fdd|D }t
tt|}t|dkrMt|}||| |fS dS )zr
        Returns point of max deflection and its corresponding deflection value
        in a Beam object.
        r   r   Tr  c                       g | ]	}  j|qS rI   r   r8   .0r/   r   rG   rI   rJ   
<listcomp>=      z'Beam.max_deflection.<locals>.<listcomp>N)r   r   r8   r2   r3   r   r   r   r  r1   r   r   r   r  r   r   )rG   r   r   deflectionsmax_defrI   r  rJ   max_deflection/  s   
zBeam.max_deflectionc                 C      |   | j S )zg
        Returns an expression representing the Shear Stress
        curve of the Beam object.
        r   ra   rU   rI   rI   rJ   shear_stressE  s   zBeam.shear_stressc                 C   s|   |   }| j}| j}|du ri }|tD ]}||kr%||vr%td| q||v r.|| }t|||d|fdddddS )	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)
        Nzvalue of %s was not passed.r   zShear Stress$\mathrm{x}$z$\tau$rtitlexlabelylabel
line_color)r  r8   r3   atomsr   rn   r   r   )rG   r   r  r/   r3   symrI   rI   rJ   plot_shear_stressL  s   -r&   c                 C      |   }|du r
i }|tD ]}|| jkrq||vr!td| q| j|v r-|| j }n| j}t||| jd|fdddddS )	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)
        NValue of %s was not passed.r   Shear Forcer  $\mathrm{V}$gr  r   r#  r   r8   rn   r3   r   r   )rG   r   r   r$  r3   rI   rI   rJ   plot_shear_force     +

r%   c                 C   r&  )	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)
        Nr'  r   Bending Momentr  $\mathrm{M}$br  r   r#  r   r8   rn   r3   r   r   )rG   r   r   r$  r3   rI   rI   rJ   plot_bending_moment  r-  r!   c                 C   r&  )	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)
        Nr'  r   Sloper  $\theta$mr  r2   r#  r   r8   rn   r3   r   r   )rG   r   r2   r$  r3   rI   rI   rJ   
plot_slope   r-  r'   c                 C   r&  )	a0  

        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)
        Nr'  r   
Deflectionr  $\delta$r  r  r1   r#  r   r8   rn   r3   r   r   )rG   r   r1   r$  r3   rI   rI   rJ   plot_deflection:  s    ,

r"   c           	   	   C   s  | j }| j}|du ri }|  tD ]}|| jkrq||vr%td| q||v r.|| }t|  ||d|fdddddd	}t| 	 ||d|fd
ddddd	}t| 
 ||d|fdddddd	}t|  ||d|fdddddd	}tdd||||S )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()
        Nr'  r   r(  r  r)  r*  Fr  r   r!  r"  showr.  r/  r0  r3  r4  r5  r8  r9  r  r   r   )r3   r8   r1   r#  r   rn   r   r   r   r   r2   r   )	rG   r   r3   r8   r$  ax1ax2ax3ax4rI   rI   rJ   plot_loading_resultsw  s:   )
zBeam.plot_loading_resultsc                 C   s&   | j }t| j| }t||}||fS )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.
        )r8   r   rD   )rG   r/   r   r   rI   rI   rJ   _solve_for_ild_equations  s   
zBeam._solve_for_ild_equationsc                 G   s  |   \}}| j}| j}td}td}t|||| }	t||||||   }
g }g }t||| }| jd D ]\}}|||| }|| q8t||| }| jd D ]\}}|||| }|| qVt	t
|	|
g| | ||f| jd }|dd }tt||| _dS )a  

        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.

        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, 'roller')
            >>> p10 = b.apply_support(10, 'roller')
            >>> b.solve_for_ild_reactions(1,R_0,R_10)
            >>> b.ild_reactions
            {R_0: x/10 - 1, R_10: -x/10}

        r   r   r2   r1   r   r   N)rC  r8   r3   r   r   r   r:   r   r   r   r   r   r   r   rA   )rG   r   r   r   r   r/   r]   r   r   r   r   r   r   r   r   r   r   r   rI   rI   rJ   solve_for_ild_reactions  s4   (
zBeam.solve_for_ild_reactionsc                 C   s   | j std| j}g }|du ri }| j D ]}| j | tD ]}||kr/||vr/td| qq| jtD ]}||krG||vrGtd| q7| j D ]}|t| j | ||d| j|fd||ddd qKt	t
|d	g|R  S )
a>  

        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.

        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: x/7 - 22/7, R_7: -x/7 - 20/7}
            >>> b.plot_ild_reactions()
            PlotGrid object containing:
            Plot[0]:Plot object containing:
            [0]: cartesian line: x/7 - 22/7 for x over (0.0, 10.0)
            Plot[1]:Plot object containing:
            [0]: cartesian line: -x/7 - 20/7 for x 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.Nr'  r   zI.L.D. for ReactionsblueFr<  r   )rA   rn   r8   r#  r   rO   r   r   r   r   r  )rG   r   r/   ildplotsreactionr$  rI   rI   rJ   plot_ild_reactions  s,   3


zBeam.plot_ild_reactionsc                 G   s   | j }| j}|  \}}|t||| }t|||t||| | }	|D ]}
||
| j|
 }|	|
| j|
 }	q$t|||k f|	||kf}|| _dS )a  

        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.

        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
            Piecewise((x/8, x < 4), (x/8 - 1, x > 4))

        N)r8   r3   rC  r   r   rA   r   rB   )rG   distancer   r   r/   r]   r   _shear_curve1shear_curve2rG  shear_eqrI   rI   rJ   solve_for_ild_shearY  s   -
zBeam.solve_for_ild_shearc              	   C   s   | j std| j}| j}|du ri }| j tD ]}||kr)||vr)td| q| jtD ]}||kr@||vr@td| q0t| j ||d|fddddd	d
S )a  

        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.

        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
            Piecewise((x/8, x < 4), (x/8 - 1, x > 4))
            >>> b.plot_ild_shear()
            Plot object containing:
            [0]: cartesian line: Piecewise((x/8, x < 4), (x/8 - 1, x > 4)) for x 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.Nr'  r   zI.L.D. for Shear$\mathrm{X}$r)  rE  Tr<  )rB   rn   r8   rO   r#  r   r   r   )rG   r   r/   r]   r$  rI   rI   rJ   plot_ild_shear  s"   .r$   c                 G   s   | j }| j}|  \}}|||  t||| }t|||t||| |||   }	|D ]}
||
| j|
 }|	|
| j|
 }	q,t|||k f|	||kf}|| _dS )a  

        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.

        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
            Piecewise((-x/2, x < 4), (x/2 - 4, x > 4))

        N)r8   r3   rC  r   r   rA   r   rC   )rG   rI  r   r   r/   r]   rJ  momentmoment_curve1moment_curve2rG  	moment_eqrI   rI   rJ   solve_for_ild_moment  s   -$
zBeam.solve_for_ild_momentc              	   C   s   | j std| j}|du ri }| j tD ]}||kr&||vr&td| q| jtD ]}||kr=||vr=td| q-t| j ||d| jfddddd	d
S )a  

        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.

        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
            Piecewise((-x/2, x < 4), (x/2 - 4, x > 4))
            >>> b.plot_ild_moment()
            Plot object containing:
            [0]: cartesian line: Piecewise((-x/2, x < 4), (x/2 - 4, x > 4)) for x 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.Nr'  r   zI.L.D. for MomentrO  r/  rE  Tr<  )rC   rn   r8   r#  r   rO   r   r   )rG   r   r/   r$  rI   rI   rJ   plot_ild_moment  s    .r#   )r)   )modulesTc                 C   s  t stdtt| jt| j }|s!tdd |D r!td| j}t	| j
tr?t| j
t}t|d}| j
|}ni }| j
}|d }g }|d||dd | |||\}}	}
}}| ||\}}||7 }|	|7 }	| jd	kr| j| j
 }t|| }|	|g|d
 ggddddg7 }	| d| f}|rtt|d tdd |D }tt|d tdd |D }||d k s||d krt|| d }|| || f}t||
 || |d|f| || f|||	|d|ddd}|S )a$  
        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                 s   s.    | ]}t |d  jd ko|d d kV  qdS )r   r   N)r  free_symbols)r  r]   rI   rI   rJ   	<genexpr>  s   , zBeam.draw.<locals>.<genexpr>zl`pictorial=False` requires numerical distributed loads. Instead, symbolic loads were found. Cannot continue.
   r   r   brown)xywidthheight	facecolorr   r   o   whiter   marker
markersizecolorg      ?y2c                 s       | ]	}|d  d V  qdS r]  r   NrI   r  r  rI   rI   rJ   rY        y1c                 s   ri  rj  rI   rk  rI   rI   rJ   rY    rl  r   r   g?F)	xlimylimannotationsmarkers
rectanglesr"  fillaxisr=  )r)   ImportErrorr   r   r   r>   anyrn   r8   r5   r3   r   r#  r   r   fromkeysr   r   
_draw_load_draw_supportsrE   rF   r   minr   r   r   )rG   	pictorialloadsr/   r]   r3   r_  rr  rp  rq  load_eqload_eq1rs  support_markerssupport_rectanglesratiox_posro  _min_maxoffset	sing_plotrI   rI   rJ   drawT  sH   J
   r    c                 C   s&   |j }|js
|dur|S |  j S )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

        N)r   is_Atomdoitexpand)rG   r   rvrI   rI   rJ   _is_load_negative  s   zBeam._is_load_negativec                    sb  t t| jt| j }|d }| j}g }g }g }	d}
g }d}tj}tj}d }d}d}|D ]} r:|d  }n|d }|d dkr| |d }|d u r[|d|d |d f 7 }|ru|	d|df||d	|  fd
ddddd q-|	d||f||d	 fd
d	d	ddd q-|d dkr| |d }|d u r|d|d |d f 7 }| |d r|	|g|d ggddd q-|	|g|d ggddd q-|d dkr|\}}}}| |}|d u r|d|||f 7 }|s^|r|dkrdd|  n|d }|
|t
||| 7 }
|rE|dkr|||  n|d ||  }td|d D ]}|
|||||| t
||| t| 8 }
q)t|
trO|
j}	n|
f}	t fdd|	D  }q-|rp|dkrldd|  n|d }|t|t
||| 7 }|r|dkrt|||  n|d ||  }td|d D ]}||||||| t
||| t| 8 }qt|tr|j}n|f} fdd|D }t|  | }q-t|dkrt||  tdt|d}t|g||t |}t|g||t |}t|tjs|t|9 }t|tjs"|t|9 }|||ddd}|||||fS )NrZ  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 %s located at %s
r   g      ?r   black)r^  
headlength	headwidthr`  )textr]  xytext
arrowpropsr   z* Moment %s located at %s
z$\circlearrowright$   )r   re  rf  z$\circlearrowleft$z$* Distributed load %s from %s to %s
c                       g | ]}|  qS rI   r   r  rp   r]   rI   rJ   r  6	      z#Beam._draw_load.<locals>.<listcomp>c                    r  rI   r  r  r  rI   rJ   r  J	  r  gMbP?	darkkhaki)r/   rm  rh  rg  zorder)r   r   r   r>   r8   r   Zeror   r  r   r   r   r   r   r5   r   r   r   r  warningswarnr)   r+   r   r   r   r   ndarray	ones_like)rG   r{  r3   r]   r|  r_  r/   rp  rq  	load_argsscaled_load
load_args1scaled_load1r}  r~  rs  warning_headwarning_bodyr   posilnr   r   r   r   f2rp   xxyy1yy2rI   r  rJ   rx    s   
0,  
&

*

zBeam._draw_loadc              	   C   s  t |d }g }g }| jD ]q}|r|d |}n|d }|d dkr1||dggdddd q|d d	krH||| d
 ggdddd q|d dkr~|dkri|dd| f| d d| | ddd q||d| f|d d| | ddd q||fS )NrZ  r   r   r   rb     r  rd  r   g      @ra     r~      Fz/////)r]  r^  r_  rs  hatch)r   r=   r   r   )rG   r3   r]   r_  r  r  supportr  rI   rI   rJ   ry  \	  s"   
".*zBeam._draw_supportsr~   r\   )T):__name__
__module____qualname____doc__r   rK   rS   propertyrV   rX   rY   rZ   r3   setterr<   r8   r4   r7   r6   rt   rw   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r2   r1   r  r  r%  r,  r2  r7  r;  rB  rC  rD  rH  rN  rP  rU  rV  r   r  r  rx  ry  rI   rI   rI   rJ   r-   -   s    ]@






















?
I
D@ 

 C"2"6)D 

@
:
:
:
=C
EL
=B
<@ wr-   c                       s  e Zd ZdZedf fdd	Zedd Zejdd Zedd	 Z	e	jd
d	 Z	edd Z
e
jdd Z
edd Zedd Zedd Zdd ZdZddZdZddZd[ddZdd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd4d5 Zd\d7d8Zd]d:d;Zd\d<d=Z d]d>d?Z!d\d@dAZ"d]dBdCZ#d\dDdEZ$d]dFdGZ%d^dHdIZ&d\dJdKZ'd]dLdMZ(dNdO Z)dPdQ Z*dRdS Z+dTdU Z,e,Z-dVdW Z.dXdY Z/  Z0S )_Beam3Da!  
    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                    s`   t  |||| || _|| _g d| _g d| _i | _g d| _g d| _g d| _	d| _
dS )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.
        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)rG   r3   r4   r  r7   r<   r8   	__class__rI   rJ   rK   	  s   





zBeam3D.__init__c                 C   rT   ri   )_shear_modulusrU   rI   rI   rJ   r  	  rW   zBeam3D.shear_modulusc                 C   r[   r\   )r   r  rj   rI   rI   rJ   r  	  r^   c                 C   rT   rl   rm   rU   rI   rI   rJ   r7   	  rW   zBeam3D.second_momentc                 C   s0   t |trdd |D }|| _d S t|| _d S )Nc                 S   s   g | ]}t |qS rI   r   r  rI   rI   rJ   r  	  s    z(Beam3D.second_moment.<locals>.<listcomp>)r5   r   rM   r   ro   rI   rI   rJ   r7   	  s   

c                 C   rT   r_   r`   rU   rI   rI   rJ   r<   	  rW   zBeam3D.areac                 C   r[   r\   rb   rc   rI   rI   rJ   r<   	  r^   c                 C   rT   )zL
        Returns a three element list representing the load vector.
        )r  rU   rI   rI   rJ   load_vector	     zBeam3D.load_vectorc                 C   rT   )zQ
        Returns a three element list representing moment loads on Beam.
        )r  rU   rI   rI   rJ   moment_load_vector	  r  zBeam3D.moment_load_vectorc                 C   rT   )a	  
        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
        {'deflection': [(4, [0, 0, 0])], '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``.
        rs   rU   rI   rI   rJ   rt   	  s   zBeam3D.boundary_conditionsc                 C   s   t | js
d| j S t| jS )a  
        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   r7   sumrU   rI   rI   rJ   polar_moment
  s   


zBeam3D.polar_momentyc                 C   s   | j }t|}t|}t|}|dkr1|dks | jd  |7  < | jd  |t||| 7  < dS |dkrS|dksB| jd  |7  < | jd  |t||| 7  < dS |dks`| jd  |7  < | jd  |t||| 7  < dS )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   r  r   r   N)r8   r   r  r  r   rG   r   r   r   dirr/   rI   rI   rJ   r   5
  s   """zBeam3D.apply_loadc                 C   s  | j }t|}t|}t|}|dkrH|dks!| jd  |7  < n|t| jv r2| j|  |7  < n|| j|< | jd  |t||| 7  < dS |dkrj|dksY| jd  |7  < | jd  |t||| 7  < dS |dksw| jd  |7  < | jd  |t||| 7  < dS )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   r  r   r   N)r8   r   r  r   r  r  r   r  rI   rI   rJ   apply_moment_load[
  s$   
"""zBeam3D.apply_moment_loadr~   c                 C   s   |dv rt dt| }|| j|< | j|g df d S t dt| }t dt| }||g| j|< | j|g df | j|g df d S )Nr   r   r  r   )r   r   r@   r|   r   rw   r   rI   rI   rJ   r   
  s   
zBeam3D.apply_supportc                    s   | j | j}| j}fdd|D fddD tdD ]W  fdd|D }t|dkr3qt  |}t  |}tt||g|jd }t	t
||}| j}	|D ]}
|
|	v ro||
 |	|
 krotd|
 q[| j| qdS )	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}
        c                       g | ]}t | qS rI   r   )r  r   r/   rI   rJ   r  
  r  z3Beam3D.solve_for_reaction_loads.<locals>.<listcomp>c                    r  rI   r   )r  shearr  rI   rJ   r  
  r  r   c                    s,   g | ]}   |s   |r|qS rI   )hasrk  )rp   moment_curvesshear_curvesrI   rJ   r  
  s   , r   z2Ambiguous solution for %s in different directions.N)r8   r3   r  r   r  r   r   r   r   r   r   r@   rn   update)rG   rG  r]   qreactr   r   solsol_dictrV   keyrI   )rp   r  r  r/   rJ   r   
  s(   zBeam3D.solve_for_reaction_loadsc                 C   s:   | j }| j}t|d  |t|d  |t|d  |gS )z
        Returns a list of three expressions which represents the shear force
        curve of the Beam object along all three axes.
        r   r   r   )r8   r  r   )rG   r/   r  rI   rI   rJ   r   
  s   .zBeam3D.shear_forcec                 C      |   d S )zY
        Returns expression of Axial shear force present inside the Beam object.
        r   )r   rU   rI   rI   rJ   axial_force
     zBeam3D.axial_forcec                 C   s4   |   d | j |   d | j |   d | j gS )z
        Returns a list of three expressions which represents the shear stress
        curve of the Beam object along all three axes.
        r   r   r   r  rU   rI   rI   rJ   r  
  s   4zBeam3D.shear_stressc                 C   r  )zT
        Returns expression of Axial stress present inside the Beam object.
        )r  ra   rU   rI   rI   rJ   axial_stress
  s   zBeam3D.axial_stressc                 C   sR   | j }| j}|  }t|d  |t|d  |d  |t|d  |d  |gS )z
        Returns a list of three expressions which represents the bending moment
        curve of the Beam object along all three axes.
        r   r   r   )r8   r  r   r   )rG   r/   r5  r  rI   rI   rJ   r   
  s   $zBeam3D.bending_momentc                 C   r  )zX
        Returns expression of Torsional moment present inside the Beam object.
        r   )r   rU   rI   rI   rJ   torsional_moment
  r  zBeam3D.torsional_momentc              	   C   s   | j }d}t| jD ]	}|| j| 7 }q
t| j  t| j}t|||d kfd||d kf}tt|dd D ])}|| j||d   8 }|td|||d  kf|||| kfd||| kf7 }q;t|}|| j| 	   | _
dS )af  
        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)r8   r   r  r   r   r   r  r   r  r  r  )rG   r/   sum_momentsr   
pointsListtorque_diagramrp   integrated_torque_diagramrI   rI   rJ   solve_for_torsion
  s   
":zBeam3D.solve_for_torsionc                 C   s  | j }| j}| j}| j}| j}t|tr|d |d }}n| }}| j}| j}	| j	}
t
d}t
d}t|| t||| ||	d  }tt|d||jd }td}td}tt||d|||g||jd }|||d ||d i}||}|| jd< || jd< td}t|| t||| |t|	d  ||  |
d  }tt|djd }tt||d|||g||jd }|||d ||d i}|| t||| |	d |  | || |  }tt|d||jd }tt||d|||g||jd }|||d ||d i| jd< |||d | jd< t|| t||| |t|	d ||  |
d  }tt|djd }tt||d|||g||jd }|||d ||d i}|| t||| |	d |  | || |  }tt|djd }tt||d|||g||jd }|||d ||d i| jd< |||d | jd< d S )	Nr   r   deflthetar   r   C_ir   )r8   r3   r4   r  r7   r5   r   ra   r  r  r	   r   r   r   r   r   r   r   r   r  r  r   )rG   r/   r]   r   Gr   I_yI_zr.   r   rQ  r  r  r   def_xr   r   r   slope_xr  eq1slope_zeq2def_yslope_ydef_zrI   rI   rJ   solve_slope_deflection  sR   
$*


8*2* 6*2* zBeam3D.solve_slope_deflectionc                 C   rT   )zw
        Returns a three element list representing slope of deflection curve
        along all the three axes.
        )r  rU   rI   rI   rJ   r2   V  r  zBeam3D.slopec                 C   rT   )zn
        Returns a three element list representing deflection curve along all
        the three axes.
        )r  rU   rI   rI   rJ   r1   ]  r  zBeam3D.deflectionc                 C   rT   )z
        Returns a function in x depicting how the angular deflection, due to moments
        in the x-axis on the beam, varies with x.
        )r  rU   rI   rI   rJ   angular_deflectiond  r  zBeam3D.angular_deflectionNc              	   C      |   }|dkrd}d}n|dkrd}d}n|dkrd}d	}|d u r$i }|| tD ]}|| jkr<||vr<td
| q+| j|v rH|| j }n| j}t|| || jd|fdd| dd| |dS )Nr/   r   r  r  r   r*  zr   r0  r'  FzShear Force along %c directionrO  z$\mathrm{V(%c)}$r=  r  r   r!  r"  r+  )rG   r  r   r   dir_numrg  r$  r3   rI   rI   rJ   _plot_shear_forcek  ,   
 
zBeam3D._plot_shear_forceallc                 C      |  }|dkr| d|}| S |dkr | d|}| S |dkr.| d|}| S | d|}| d|}| d|}tdd|||S )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/   r  r  r   r   )lowerr  r=  r   rG   r  r   PxPyPzrI   rI   rJ   r,       4zBeam3D.plot_shear_forcec              	   C   r  )Nr/   r   r*  r  r   cr  r   r5  r'  Fz!Bending Moment along %c directionrO  z$\mathrm{M(%c)}$r  r1  )rG   r  r   r   r  rg  r$  r3   rI   rI   rJ   _plot_bending_moment  r  zBeam3D._plot_bending_momentc                 C   r  )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/   r  r  r   r   )r  r  r=  r   r   rI   rI   rJ   r2    r  zBeam3D.plot_bending_momentc              	   C   r  )Nr/   r   r0  r  r   r5  r  r   r*  r'  FzSlope along %c directionrO  z$\mathrm{\theta(%c)}$r  r6  )rG   r  r   r2   r  rg  r$  r3   rI   rI   rJ   _plot_slope7  s,   
 
zBeam3D._plot_slopec                 C   r  )aP  

        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/   r  r  r   r   )r  r  r=  r   r   rI   rI   rJ   r7  V  s   5zBeam3D.plot_slopec              	   C   r  )Nr/   r   r5  r  r   r  r  r   r  r'  FzDeflection along %c directionrO  z$\mathrm{\delta(%c)}$r  r:  )rG   r  r   r1   r  rg  r$  r3   rI   rI   rJ   _plot_deflection  r  zBeam3D._plot_deflectionc                 C   r  )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/   r  r  r   r   )r  r  r=  r   r   rI   rI   rJ   r;    s   6zBeam3D.plot_deflectionc                 C   sV   |  }|du r
i }| ||}| ||}| ||}| ||}tdd||||S )aP	  

        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)

        Nr   r   )r  r  r  r  r  r   )rG   r  r   r>  r?  r@  rA  rI   rI   rJ   rB    s   9zBeam3D.plot_loading_resultsc              	   C   r  )Nr/   r   r  r  r   r*  r  r   r0  r'  FzShear stress along %c directionrO  z
$\tau(%c)$r  )r  r#  r   r8   rn   r3   r   r   )rG   r  r   r  r  rg  r$  r3   rI   rI   rJ   _plot_shear_stressK  r  zBeam3D._plot_shear_stressc                 C   r  )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/   r  r  r   r   )r  r	  r=  r   r   rI   rI   rJ   r%  i  r  zBeam3D.plot_shear_stressc                    s   |  }|dkrd}n|dkrd}n|dkrd}  | s dS ttd jdkf j|  j jk ftdd	f}t|t jt	j
d
}|d | j   |  fdd|D }ttt|}t|}||| |fS )z8
        Helper function for max_shear_force().
        r/   r   r  r   r  r   r[  r   Tr  c                    s   g | ]	}  j|qS rI   r  r  rG   r   rI   rJ   r    r  z+Beam3D._max_shear_force.<locals>.<listcomp>)r  r   r   r   r8   r  r3   r   r   r   r  r   r   r   r   r   r   )rG   r  r  
load_curver   r   r   rI   r
  rJ   _max_shear_force  s.   

zBeam3D._max_shear_forcec                 C   8   g }| | d | | d | | d |S )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/   r  r  )r   r  )rG   r   rI   rI   rJ   r     
   #zBeam3D.max_shear_forcec                    s   |  }|dkrd}n|dkrd}n|dkrd} | s dS ttdjdkf | jjk ftdd	f}t|tjt	j
d
}|d |j  |   fdd|D }ttt|}t|}||| |fS )z;
        Helper function for max_bending_moment().
        r/   r   r  r   r  r   r[  r   Tr  c                    r  rI   r  r  bending_moment_curverG   rI   rJ   r    r  z.Beam3D._max_bending_moment.<locals>.<listcomp>)r  r   r   r   r8   r   r3   r   r   r   r  r   r   r   r   r   r   )rG   r  r  r   r   bending_momentsmax_bending_momentrI   r  rJ   _max_bending_moment  .   

zBeam3D._max_bending_momentc                 C   r  )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/   r  r  )r   r  )rG   r   rI   rI   rJ   r    r  zBeam3D.max_bending_momentc                    s   |  }|dkrd}n|dkrd}n|dkrd} | s dS ttdjdkf | jjk ftdd	f}t|tjt	j
d
}|d |j  |   fdd|D }ttt|}t|}||| |fS )z6
        Helper function for max_Deflection()
        r/   r   r  r   r  r   r[  r   Tr  c                    r  rI   r  r  r  rI   rJ   r  e  r  z*Beam3D._max_deflection.<locals>.<listcomp>)r  r1   r   r   r8   r2   r3   r   r   r   r  r   rO   r   r   r   r   r   )rG   r  r  r   r   r  r  rI   r  rJ   _max_deflectionI  r  zBeam3D._max_deflectionc                 C   r  )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/   r  r  )r   r  )rG   r  rI   rI   rJ   r  k  s
   %zBeam3D.max_deflection)r  r  r\   )r  N)r/   N)1r  r  r  r  r   rK   r  r  r  r7   r<   r  r  rt   r  r   r  r   r   r   r  r  r  r   r  r  r  r2   r1   r  r  r,  r  r2  r  r7  r  r;  rB  r	  r%  r  r   r  r  r   r  r  __classcell__rI   rI   r  rJ   r  v	  sp    6&










&
)0	$D


H

H

I

J
D
H")")"r  )7r  
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   r  __doctest_requires__r)   r-   r  rI   rI   rI   rJ   <module>   s^                      [