
    \hz                         S r SSKJr  SSKJrJr  SSKJrJrJ	r	J
r
JrJrJrJr  SSKJr  SSKJr  SSKJr  SSKJr   " S	 S
5      rg)zA
This module can be used to solve problems related
to 2D Cables.
    )sympify)Symbolsymbols)sincospiatandiff	Piecewisesolverad)sqrt)linsolve)Matrix)plotc                       \ rS rSrSrS r\S 5       r\S 5       r\S 5       r	\S 5       r
\S 5       r\S	 5       r\S
 5       r\S 5       rS rS rS rS rS rS rS rS rS rS rS rSrg)Cable   a  
Cables are structures in engineering that support
the applied transverse loads through the tensile
resistance developed in its members.

Cables are widely used in suspension bridges, tension
leg offshore platforms, transmission lines, and find
use in several other engineering applications.

Examples
========
A cable is supported at (0, 10) and (10, 10). Two point loads
acting vertically downwards act on the cable, one with magnitude 3 kN
and acting 2 meters from the left support and 3 meters below it, while
the other with magnitude 2 kN is 6 meters from the left support and
6 meters below it.

>>> from sympy.physics.continuum_mechanics.cable import Cable
>>> c = Cable(('A', 0, 10), ('B', 10, 10))
>>> c.apply_load(-1, ('P', 2, 7, 3, 270))
>>> c.apply_load(-1, ('Q', 6, 4, 2, 270))
>>> c.loads
{'distributed': {}, 'point_load': {'P': [3, 270], 'Q': [2, 270]}}
>>> c.loads_position
{'P': [2, 7], 'Q': [6, 4]}
c                 T   / U l         / U l        0 U l        / U l        0 0 S.U l        0 U l        SU l        0 U l        0 U l        [        S5      U l
        [        S5      U l        SU l        SU l        US   US   :X  a  [        S5      eUS   US   :X  a  [        S5      e[        US   5      n[        US   5      nX4/U R                  US   '   [        US   5      n[        US   5      nXV/U R                  US   '   US   US   :  a  U R                   R                  U5        U R                   R                  U5        U R                  R                  U5        U R                  R                  U5        U R                  R                  US   5        U R                  R                  US   5        OU R                   R                  U5        U R                   R                  U5        U R                  R                  U5        U R                  R                  U5        U R                  R                  US   5        U R                  R                  US   5        U R                   H?  nSU R                  [!        SU-   S	-   5      '   SU R                  [!        SU-   S
-   5      '   MA     g)a5  
Initializes the class.

Parameters
==========

support_1 and support_2 are tuples of the form
(label, x, y), where

label : String or symbol
    The label of the support

x : Sympifyable
    The x coordinate of the position of the support

y : Sympifyable
    The y coordinate of the position of the support
)distributed
point_loadr   Nz$Supports can not have the same label   z(Supports can not be at the same location   R__x_y)_left_support_right_support	_supports_support_labels_loads_loads_position_length_reaction_loads_tensionr   _lowest_x_global_lowest_y_global
_cable_eqn_tension_func
ValueErrorappendr   )self	support_1	support_2x1y1x2y2is           _/var/www/auris/envauris/lib/python3.13/site-packages/sympy/physics/continuum_mechanics/cable.py__init__Cable.__init__)   sh   &   !&(;!! '
 '
!Q<9Q<'CDDq\Yq\)GHHYq\"Yq\"(*xy|$Yq\"Yq\"(*xy|$Q<)A,&%%b)%%b)&&r*&&r*  ''	!5  ''	!5 %%b)%%b)&&r*&&r*  ''	!5  ''	!5%%A:;D  a!67:;D  a!67 &    c                     U R                   $ )z?
Returns the supports of the cable along with their
positions.
)r   r,   s    r4   supportsCable.supportsk   s     ~~r7   c                     U R                   $ )z+
Returns the position of the left support.
)r   r9   s    r4   left_supportCable.left_supports   s    
 !!!r7   c                     U R                   $ )z,
Returns the position of the right support.
)r   r9   s    r4   right_supportCable.right_supportz   s    
 """r7   c                     U R                   $ )zG
Returns the magnitude and direction of the loads
acting on the cable.
)r!   r9   s    r4   loadsCable.loads   s     {{r7   c                     U R                   $ )z>
Returns the position of the point loads acting on the
cable.
)r"   r9   s    r4   loads_positionCable.loads_position        ###r7   c                     U R                   $ )z"
Returns the length of the cable.
)r#   r9   s    r4   lengthCable.length   s    
 ||r7   c                     U R                   $ )zJ
Returns the reaction forces at the supports, which are
initialized to 0.
)r$   r9   s    r4   reaction_loadsCable.reaction_loads   rH   r7   c                     U R                   $ )zF
Returns the tension developed in the cable due to the loads
applied.
)r%   r9   s    r4   tensionCable.tension   s     }}r7   c                 $   SU R                   R                  5       ;  a  [        S5      eXR                  S   :  d  XR                  S   :  a  [        S5      eU R                   S   n[        S5      nUR                  X1U R                  -
  05      $ )zN
Returns the tension at a given value of x developed due to
distributed load.
r   z4No distributed load added or solve method not calledr   z1The value of x should be between the two supportsX)r%   keysr*   r   r   r   subsr&   )r,   xArS   s       r4   
tension_atCable.tension_at   s    
  2 2 44STT""1%%-?-?-B)BPQQMM-(3KvvqD111344r7   c                     U R                   S   U R                  S   -
  S-  U R                   S   U R                  S   -
  S-  -
  S-  nX:  a  [        S5      eXl        g)a  
This method specifies the length of the cable

Parameters
==========

length : Sympifyable
    The length of the cable

Examples
========

>>> from sympy.physics.continuum_mechanics.cable import Cable
>>> c = Cable(('A', 0, 10), ('B', 10, 10))
>>> c.apply_length(20)
>>> c.length
20
r   r   r         ?z@length should not be less than the distance between the supportsN)r   r   r*   r#   )r,   rJ   dists      r4   apply_lengthCable.apply_length   ss    & ##A&)<)<Q)??!C%%a(4+>+>q+AAAEFILN =_``r7   c                    XR                   ;  a  [        S5      eU R                  R                  U5      nU R                  US-   S-     nU R                   U   S   nU R                   U   S   n[	        US   5      n[	        US   5      nU R
                   H2  n	U	S   [        Xu5      :  d  U	S   [        Xu5      ::  d  M)  [        S5      e   U R                   R                  U5        U R                  R                  5         U R                  R                  5         U R                  R                  5         U R                  R                  U5        Xx/U R                   US   '   XW:  a  U R                  R                  U5        U R                  R                  U5        U R                  R                  U5        U R                  R                  U5        U R                  R                  US   5        OU R                  R                  U5        U R                  R                  U5        U R                  R                  U5        U R                  R                  U5        U R                  R                  SUS   5        U R                   H?  nSU R                  [!        SU-   S-   5      '   SU R                  [!        SU-   S-   5      '   MA     g	)
a  
This method changes the mentioned support with a new support.

Parameters
==========
label: String or symbol
    The label of the support to be changed

new_support: Tuple of the form (new_label, x, y)
    new_label: String or symbol
        The label of the new support

    x: Sympifyable
        The x-coordinate of the position of the new support.

    y: Sympifyable
        The y-coordinate of the position of the new support.

Examples
========

>>> from sympy.physics.continuum_mechanics.cable import Cable
>>> c = Cable(('A', 0, 10), ('B', 10, 10))
>>> c.supports
{'A': [0, 10], 'B': [10, 10]}
>>> c.change_support('B', ('C', 5, 6))
>>> c.supports
{'A': [0, 10], 'C': [5, 6]}
z&No support exists with the given labelr   r   r   z>The change in support will throw an existing load out of ranger   r   r   N)r   r*   r    indexr   r"   maxminpopr   clearr   r$   remover+   insertr   )
r,   labelnew_supportr3   	rem_labelr/   r0   rV   yls
             r4   change_supportCable.change_support   sZ   < &EFF  &&u-((!A#q1	^^I&q)^^I&q)KN#KN#%%Ats1z!QqTSZ%7 !abb & 	5!  "!!#""$##E**+{1~&6%%b)%%b)&&q)&&q)  ''A7 %%a(%%a(&&r*&&r*  '';q>:%%A:;D  a!67:;D  a!67 &r7   c                    US:X  a  [        U R                  S   5      S:w  a  [        S5      eUS   nX0R                  S   ;   a  [        S5      e[        US   5      n[        US   5      nX@R                  S   :  d  X@R
                  S   :  a  [        S	5      e[        US
   5      n[        US   5      nXg/U R                  S   U'   XE/U R                  U'   gUS:X  af  [        U R                  5      S:w  a  [        S5      eUS   nX0R                  S   ;   a  [        S5      e[        US   5      nX`R                  S   U'   g[        S5      e)aV  
This method adds load to the cable.

Parameters
==========

order : Integer
    The order of the applied load.

        - For point loads, order = -1
        - For distributed load, order = 0

load : tuple

    * For point loads, load is of the form (label, x, y, magnitude, direction), where:

    label : String or symbol
        The label of the load

    x : Sympifyable
        The x coordinate of the position of the load

    y : Sympifyable
        The y coordinate of the position of the load

    magnitude : Sympifyable
        The magnitude of the load. It must always be positive

    direction : Sympifyable
        The angle, in degrees, that the load vector makes with the horizontal
        in the counter-clockwise direction. It takes the values 0 to 360,
        inclusive.


    * For uniformly distributed load, load is of the form (label, magnitude)

    label : String or symbol
        The label of the load

    magnitude : Sympifyable
        The magnitude of the load. It must always be positive

Examples
========

For a point load of magnitude 12 units inclined at 30 degrees with the horizontal:

>>> from sympy.physics.continuum_mechanics.cable import Cable
>>> c = Cable(('A', 0, 10), ('B', 10, 10))
>>> c.apply_load(-1, ('Z', 5, 5, 12, 30))
>>> c.loads
{'distributed': {}, 'point_load': {'Z': [12, 30]}}
>>> c.loads_position
{'Z': [5, 5]}


For a uniformly distributed load of magnitude 9 units:

>>> from sympy.physics.continuum_mechanics.cable import Cable
>>> c = Cable(('A', 0, 10), ('B', 10, 10))
>>> c.apply_load(0, ('X', 9))
>>> c.loads
{'distributed': {'X': 9}, 'point_load': {}}
r   r   zDistributed load already existsr   zLabel already existsr   r   z2The load should be positioned between the supports      zPoint load(s) already existzOrder should be either -1 or 0N)lenr!   r*   r   r   r   r"   )r,   orderloadrg   rV   rj   	magnitude	directions           r4   
apply_loadCable.apply_load  sV   B B;4;;}-.!3 !BCCGEL11 !788Q AQ A&&q))Q1C1CA1F-F !UVVQ(IQ(I09/EDKK%e,+,&D  'aZ4''(A- !>??GEM22 !788Q(I09KK&u- =>>r7   c                    U H  n[        U R                  5      S:X  aC  X R                  S   ;  a  [        SU-   S-   5      eU R                  S   R	                  U5        M_  X R                  S   ;  a  [        SU-   S-   5      eU R                  S   R	                  U5        U R                  R	                  U5        M     g)a  
This methods removes the specified loads.

Parameters
==========
This input takes multiple label(s) as input
label(s): String or symbol
    The label(s) of the loads to be removed.

Examples
========

>>> from sympy.physics.continuum_mechanics.cable import Cable
>>> c = Cable(('A', 0, 10), ('B', 10, 10))
>>> c.apply_load(-1, ('Z', 5, 5, 12, 30))
>>> c.loads
{'distributed': {}, 'point_load': {'Z': [12, 30]}}
>>> c.remove_loads('Z')
>>> c.loads
{'distributed': {}, 'point_load': {}}
r   r   zError removing load z: no such load existsdisrtibutedr   N)rr   r"   r!   r*   rc   )r,   argsr3   s      r4   remove_loadsCable.remove_loads~  s    , A4''(A-KK66$%;a%?BY%YZZ KK.2215 KK55$%;a%?BY%YZZ KK-11!4((,,Q/ r7   c           
      d   [        U R                  5      S:w  Ga1  [        U R                  R                  5       S S9nUR	                  U R
                  S   5        UR                  SU R
                  S   5        U R                  R                  5         SnSnSnSnSU l	        / n[        S5      n[        S[        U5      S-
  5       GHn  n	U	S:X  ar  U =R                  [        U R                  S   U R                  X)   S      S   -
  S-  U R                  S   U R                  X)   S      S   -
  S-  -   5      -  sl	        OU =R                  [        U R                  X)S-
     S      S   U R                  X)   S      S   -
  S-  U R                  X)S-
     S      S   U R                  X)   S      S   -
  S-  -   5      -  sl	        U	[        U5      S-
  :X  aq  U =R                  [        U R                  S   U R                  X)   S      S   -
  S-  U R                  S   U R                  X)   S      S   -
  S-  -   5      -  sl	        X0R                  S   X)   S      S   [!        ["        U R                  S   X)   S      S   -  S-  5      -  [%        U R                  S   U R                  X)   S      S   -
  5      -  -  nX0R                  S   X)   S      S   ['        ["        U R                  S   X)   S      S   -  S-  5      -  [%        U R                  S   U R                  X)   S      S   -
  5      -  -  nXPR                  S   X)   S      S   [!        ["        U R                  S   X)   S      S   -  S-  5      -  -  nX`R                  S   X)   S      S   ['        ["        U R                  S   X)   S      S   -  S-  5      -  -  n[)        X)   S   S	-   X)S-      S   -   5      n
U R                  X)   S      S   nU R                  X)   S      S   nSnSnU	[        U5      S-
  :X  a  U R                  S   nU R                  S   nO4U R                  X)S-      S      S   nU R                  X)S-      S      S   n[+        X-
  X-
  -  5      nU* [%        U R                  S   U R                  X)   S      S   -
  5      [!        U5      -  [%        U R                  S   U R                  X)   S      S   -
  5      ['        U5      -  -   -  nUU R                  U
'   UR	                  UX:*  45        X@R                  S   X)   S      S   [!        ["        U R                  S   X)   S      S   -  S-  5      -  [%        U R                  S   U R                  X)   S      S   -
  5      -  -  nX@R                  S   X)   S      S   ['        ["        U R                  S   X)   S      S   -  S-  5      -  [%        U R                  S   U R                  X)   S      S   -
  5      -  -  nGMq     [)        US   S   S	-   US   S   -   5      n
U R                  US   S      S   nU R                  US   S      S   nU R                  S   nU R                  S   n[+        X-
  X-
  -  5      * nU* [%        U R                  S   U R                  US   S      S   -
  5      [!        U5      -  [%        U R                  S   U R                  US   S      S   -
  5      ['        U5      -  -   -  nUU R                  U
'   UR                  SUX:*  45        [-        U6 U l        ["        S-  U-
  nU R
                  S   n
['        U5      * U-  U R0                  [)        S
U
-   S-   5      '   U['        U5      * U-  -  n[!        U5      U-  U R0                  [)        S
U
-   S-   5      '   U[!        U5      U-  -  nU R
                  S   n
U* U R0                  [)        S
U
-   S-   5      '   U* U R0                  [)        S
U
-   S-   5      '   g[        U R                  S   5      S:w  Ga  [        U5      S:X  a  [3        S5      e[5        US   5      nUU l        [)        SSS9n[)        S5      n[9        U R                  S   U-
  S-  SU R                  S   /U R                  S   U-
  S-  SU R                  S   //5      n[;        [=        UUU45      5      n[        U5      S:X  d  US   S   S:X  a  [3        S5      eUS   S   nUS   S   US   S   US-  -  -   nSUS   S   -  U-  nUS   S   U l        U R>                  n[)        S5      n[)        S5      nUUU-   S-  -  UUU-   -  -   U-   U-
  n[;        U R                  S   RA                  5       5      nUS   nUU R                  S   U-
  S-  -  SU R                  S   U-
  -  -  nU R                  R                  5         [C        UU5      nU[!        [+        U5      5      -  U R                  S'   U R
                  S   n
U RE                  U R                  S   5      [!        [+        URG                  UU R                  S   U-
  5      5      5      -  U R0                  [)        S
U
-   S-   5      '   U RE                  U R                  S   5      ['        [+        URG                  UU R                  S   U-
  5      5      5      -  U R0                  [)        S
U
-   S-   5      '   U R
                  S   n
U RE                  U R                  S   5      [!        [+        URG                  UU R                  S   U-
  5      5      5      -  U R0                  [)        S
U
-   S-   5      '   U RE                  U R                  S   5      ['        [+        URG                  UU R                  S   U-
  5      5      5      -  U R0                  [)        S
U
-   S-   5      '   gg)a  
This method solves for the reaction forces at the supports, the tension developed in
the cable, and updates the length of the cable.

Parameters
==========
This method requires no input when solving for point loads
For distributed load, the x and y coordinates of the lowest point of the cable are
required as

x: Sympifyable
    The x coordinate of the lowest point

y: Sympifyable
    The y coordinate of the lowest point

Examples
========
For point loads,

>>> from sympy.physics.continuum_mechanics.cable import Cable
>>> c = Cable(("A", 0, 10), ("B", 10, 10))
>>> c.apply_load(-1, ('Z', 2, 7.26, 3, 270))
>>> c.apply_load(-1, ('X', 4, 6, 8, 270))
>>> c.solve()
>>> c.tension
{A_Z: 8.91403453669861, X_B: 19*sqrt(13)/10, Z_X: 4.79150773600774}
>>> c.reaction_loads
{R_A_x: -5.25547445255474, R_A_y: 7.2, R_B_x: 5.25547445255474, R_B_y: 3.8}
>>> c.length
5.7560958484519 + 2*sqrt(13)

For distributed load,

>>> from sympy.physics.continuum_mechanics.cable import Cable
>>> c=Cable(("A", 0, 40),("B", 100, 20))
>>> c.apply_load(0, ("X", 850))
>>> c.solve(58.58)
>>> c.tension
{'distributed': 36465.0*sqrt(0.00054335718671383*X**2 + 1)}
>>> c.tension_at(0)
61717.4130533677
>>> c.reaction_loads
{R_A_x: 36465.0, R_A_y: -49793.0, R_B_x: 44399.9537590861, R_B_y: 42868.2071025955}
r   c                     U S   S   $ Nr   r    items    r4   <lambda>Cable.solve.<locals>.<lambda>      W[\]W^_`War7   keyr   rV   r   r      _r   r   r   r   z%Provide the lowest point of the cableaT)positivecz2The lowest point is inconsistent with the supportsrS   YN)$rr   r"   sorteditemsr+   r    rf   r%   rd   r#   r   ranger   r   r   r!   r   r   absr   r   r	   r   r)   r$   r*   r   r&   r   listr   r'   valuesr
   rX   rU   ) r,   r{   sorted_positionmoment_sum_from_left_supportmoment_sum_from_right_supportF_xF_ytension_funcrV   r3   rg   r2   r1   r0   r/   angle_with_horizontalrP   lowest_xr   r   Mcoefficient_solutionrW   CBlowest_yrS   r   	temp_listapplied_forcehorizontal_force_constanttangent_slope_to_curves                                    r4   r   Cable.solve  s8   ^ t##$)$T%9%9%?%?%AIabO""4#7#7#:;""1d&:&:1&=>MM!+,(,-)CCDLLA1c/21456LL$(:(:1(=@T@TUdUghiUj@klm@n(nqr'rvz  wI  wI  JK  wL  OS  Oc  Oc  ds  dv  wx  dy  Oz  {|  O}  w}  @A  vA  (A  #B  BL LL$(<(<_qS=QRS=T(UVW(X[_[o[op  qC  DE  qF  \G  HI  \J  )J  MN  (N  RV  Rf  Rf  gv  yz  wz  g{  |}  g~  R  @A  RB  EI  EY  EY  Zi  Zl  mn  Zo  Ep  qr  Es  Rs  vw  Qw  (w  #x  xLO,Q..LL$(;(;A(>AUAUVeVhijVkAlmnAo(ors'sw{  xK  xK  LM  xN  QU  Qe  Qe  fu  fx  yz  f{  Q|  }~  Q  x  BC  wC  (C  #D  DL,L0I/J\]^J_0`ab0cfijlosozoz  |H  pI  JY  J\  ]^  J_  p`  ab  pc  kc  fi  ki  gj  1j  mp  qu  qC  qC  DE  qF  IM  I]  I]  ^m  ^p  qr  ^s  It  uv  Iw  qw  mx  1x  x,,L0I/J\]^J_0`ab0cfijlosozoz  |H  pI  JY  J\  ]^  J_  p`  ab  pc  kc  fi  ki  gj  1j  mp  qu  qC  qC  DE  qF  IM  I]  I]  ^m  ^p  qr  ^s  It  uv  Iw  qw  mx  1x  x,{{<01CA1FGJSQSVZVaVabnVop  qC  DE  qF  WG  HI  WJ  RJ  MP  RP  NQ  Q  Q{{<01CA1FGJSQSVZVaVabnVop  qC  DE  qF  WG  HI  WJ  RJ  MP  RP  NQ  Q  Q1!4S819Ma9PPQ))/*<Q*?@C))/*<Q*?@CO,Q..,,Q/B,,Q/B --oc.B1.EFqIB--oc.B1.EFqIB(,bg-@(A%893t?Q?QRS?TW[WkWkl{l~  @A  mB  XC  DE  XF  @F  <G  HK  La  Hb  <b  eh  im  i{  i{  |}  i~  AE  AU  AU  Ve  Vh  ij  Vk  Al  mn  Ao  io  ep  qt  uJ  qK  eK  <K  L'.e$##Wae$45-\1J?K]^_K`1abc1dgjkmptp{p{  }I  qJ  KZ  K]  ^_  K`  qa  bc  qd  ld  gj  lj  hk  2k  nq  rv  rE  rE  FG  rH  KO  K_  K_  `o  `r  st  `u  Kv  wx  Ky  ry  nz  2z  z--\1J?K]^_K`1abc1dgjkmptp{p{  }I  qJ  KZ  K]  ^_  K`  qa  bc  qd  ld  gj  lj  hk  2k  nq  rv  rE  rE  FG  rH  KO  K_  K_  `o  `r  st  `u  Kv  wx  Ky  ry  nz  2z  z-I 6L ?1-a04_Q5G5JJKE%%oa&8&;<Q?B%%oa&8&;<Q?B##A&B##A&B%)27RW*=%>$>!56D<O<OPQ<RUYUiUijyz{j|}~j  VA  BC  VD  =D  9E  FI  J_  F`  9`  cf  gk  gz  gz  {|  g}  @D  @T  @T  Ud  ef  Ug  hi  Uj  @k  lm  @n  gn  co  ps  tI  pJ  cJ  9J  KG#*DMM% 7AE"23!*L!9D$&qD+@$@!((+E=@AV=W<WZa<aD  U
4!89C-..88C<?@U<VY`<`D  U
4!893,-77C((+E=@DD  U
4!89=@DD  U
4!89]+,14yA~ !HIItAw'H$,D!sT*AsA %%a(1A5q$:L:LQ:OP%%a(1A5q$:M:Ma:PQA
 $(QF(;#< '(1,0DQ0G0JQ0N !UVV$Q'*A$Q'*-A!-DQ-GRS-SSA'*1--h6A$8$;A$>D!,,H sAsA1x<!##aX&66:XEAT[[7>>@AI%aLM)6$:M:Ma:PS[:[^_9_)_deimi|i|}~i  CK  jK  eL  )M%MM!%)!QZ"+DDQgLhHi+jDMM-(((+E<@OODL^L^_`La<behim  oE  oJ  oJ  KL  NR  N`  N`  ab  Nc  fn  Nn  oo  jp  fq  =qD  U
4!89<@OODL^L^_`La<behim  oE  oJ  oJ  KL  NR  N`  N`  ab  Nc  fn  Nn  oo  jp  fq  =qD  U
4!89((+E<@OODL^L^_`La<behim  oE  oJ  oJ  KL  NR  Na  Na  bc  Nd  go  No  op  jq  fr  =rD  U
4!89<@OODL^L^_`La<behim  oE  oJ  oJ  KL  NR  Na  Na  bc  Nd  go  No  op  jq  fr  =rD  U
4!89a 2r7   c           
         [        S5      n/ nU R                  5       n[        U R                  S   U R                  5      n[        U R                  S   [        U R                  S   U R                  S   5      5      nXT-
  n[        U R                  5      S:w  a*  U R                  S5      U l
        X R                  S5      -  nOE[        U R                  S   5      S:w  a)  U R                  S5      U l
        X R                  S5      -  nU R                  (       d  [        S5      e[        / U R                  QXR                  S   U R                  S   4P7USU-  -
  USU-  -   4USU-  -
  USU-  -   4USUSS	.6nU$ )
a  
This method is used to obtain a plot for the specified cable with its supports,
shape and loads.

Examples
========

For point loads,

>>> from sympy.physics.continuum_mechanics.cable import Cable
>>> c = Cable(("A", 0, 10), ("B", 10, 10))
>>> c.apply_load(-1, ('Z', 2, 7.26, 3, 270))
>>> c.apply_load(-1, ('X', 4, 6, 8, 270))
>>> c.solve()
>>> p = c.draw()
>>> p  # doctest: +ELLIPSIS
Plot object containing:
[0]: cartesian line: Piecewise((10 - 1.37*x, x <= 2), (8.52 - 0.63*x, x <= 4), (2*x/3 + 10/3, x <= 10)) for x over (0.0, 10.0)
...
>>> p.show()

For uniformly distributed loads,

>>> from sympy.physics.continuum_mechanics.cable import Cable
>>> c=Cable(("A", 0, 40),("B", 100, 20))
>>> c.apply_load(0, ("X", 850))
>>> c.solve(58.58)
>>> p = c.draw()
>>> p # doctest: +ELLIPSIS
Plot object containing:
[0]: cartesian line: 0.0116550116550117*(x - 58.58)**2 + 0.00447086247086247 for x over (0.0, 100.0)
[1]: cartesian line: -7.49552913752915 for x over (0.0, 100.0)
...
>>> p.show()
rV   r   r   ro   r   zRsolve method not called and/or values provided for loads and supports not adequater[   F)xlimylim
rectanglesshowannotationsaxis)r   _draw_supportsrb   r   r'   ra   r   rr   r"   _draw_cabler(   _draw_loadsr!   r*   r   )r,   rV   r   support_rectanglesxy_minxy_maxmax_diffcab_plots           r4   draw
Cable.drawP  s   H 3K!002T''*4+@+@AT((+S1D1DQ1GHZHZ[\H]-^_?t##$)"..r2DO++B//K]+,1"..q1DO++A..Kqrr g g!,>,>q,A$BUBUVWBX)Y g$S\1&X2EF$S\1&X2EF#5Ek`eg
 r7   c                    / n[        U R                  S   U R                  5      n[        U R                  S   [        U R                  S   U R                  S   5      5      nX2-
  nSU-  nUR                  U R                  S   U-
  U R                  S   4UUSSS.5        UR                  U R                  S   U R                  S   4UUSSS.5        U$ )Nr   r   333333?brownF)xywidthheightcolorfill)rb   r   r'   ra   r   r+   )r,   member_rectanglesr   r   r   
supp_widths         r4   r   Cable._draw_supports  s    T''*4+@+@AT((+S1D1DQ1GHZHZ[\H]-^_?8^
  ))!,Z78J8J18MN##	
 	  **1-d.A.A!.DE##	
 ! r7   c           	         [        U R                  S   U R                  5      n[        U R                  S   [        U R                  S   U R                  S   5      5      nX2-
  nUS:X  Ga  [        S5      u  pV/ n[        U R                  R                  5       S S9n[        [        U5      5       H  n	U	S:X  aX  X   S   S   U R                  S   -
  XPR                  S   -
  -  X   S   S   U R                  S   -
  -  U R                  S   -   nOPX   S   S   XS-
     S   S   -
  XXU	S-
     S   S   -
  -  X   S   S   XS-
     S   S   -
  -  XS-
     S   S   -   nUR                  XeX   S   S   :*  45        M     U[        U5      S-
     S   S   U R                  S   -
  XPR                  S   -
  -  UW	   S   S   U R                  S   -
  -  U R                  S   -   nUR                  XeU R                  S   :*  45        [        U6 /$ US:X  a  U R                  n
US-  n[        S5      u  ppVXU
-
  S	-  -  U-   U-
  nU R                  S   U R                  S   4U R                  S   U R                  S   4/n/ nU H*  u  nnUR                  UR                  UUUU05      5        M,     [        UX45      nUU   XZ-
  S	-  -  UU   -   nXR                  U-
  /$ g )
Nr   r   ro   zx yc                     U S   S   $ r   r   r   s    r4   r   #Cable._draw_cable.<locals>.<lambda>  r   r7   r   r   za c x yr   )rb   r   r'   ra   r   r   r   r"   r   r   rr   r+   r   r&   rU   r   )r,   rs   r   r   r   rV   rj   	line_funcr   r3   x0diff_force_heightr   r   parabola_eqnpoints	equationspxpysolutions                       r4   r   Cable._draw_cable  sd   T''*4+@+@AT((+S1D1DQ1GHZHZ[\H]-^_?B;%.CAI$T%9%9%?%?%AIabO3/0a4),Q/2T5G5G5JJQOaOabcOdMdehwhz{|h}~  iA  CG  CU  CU  VW  CX  iX  Y  \`  \n  \n  op  \q  qA),Q/2_qS5I!5LQ5OOSTefghehUijkUlmnUoSop  tC  tF  GH  tI  JK  tL  N]  `a  ^a  Nb  cd  Ne  fg  Nh  th  i  l{  ~  |  l@  AB  lC  DE  lF  FA  !'9!'<Q'?$?!@A 1 "#o"6q"89!<Q?$BUBUVWBXX[\]p]pqr]s[st  xG  HI  xJ  KL  xM  NO  xP  RV  Re  Re  fg  Rh  xh  i  lp  l  l  @A  lB  BAa4#6#6q#9 9:;y)**aZ&&B (i(GAdQY;?Q.L))!,T-?-?-BCTEXEXYZE[\`\o\opq\rDstFI B  !2!2Ar1b>!BC !Y/H#A;qy08A;>L "7"7:K"KLL r7   c                 V   [        U R                  S   U R                  5      n[        U R                  S   [        U R                  S   U R                  S   5      5      nX2-
  nUS:X  Ga  US-  n/ nU R
                  S    GHc  nUR                  SU R                  U   S   U[        [        U R
                  S   U   S   5      5      -  -   U R                  U   S   U[        [        U R
                  S   U   S   5      5      -  -   4U R                  U   S   U R                  U   S   4SSSSS	.S
.5        U R
                  S   U   S   nUR                  U S3U R                  U   S   US-  [        [        U R
                  S   U   S   5      5      -  -   U R                  U   S   US-  [        [        U R
                  S   U   S   5      5      -  -   4S.5        GMf     U$ US:X  Ga2  [        S5      n	/ n[        SS5       V
s/ s H7  oR                  S   U R                  S   U R                  S   -
  S-  U
-  -   PM9     nn
U HZ  n
UR                  SU
U R                  S   R                  X5      4U
U R                  S   R                  X5      4SSSSS	.S.5        M\     SnU R
                  S    H  nXR
                  S   U   -  nM     UR                  U S3U R                  S   U R                  S   -   S-  U R                  US-  -
  4S.5        U$ g s  sn
f )Nr   r   ro   g?r    rp   black)r   
headlength	headwidth	facecolor)textr   xytext
arrowpropsNg?)r   r   rV   
   g      @)r   r   r   r   r   z N/mr   g333333?)rb   r   r'   ra   r   r!   r+   r"   r   r   r   r   r   r(   rU   )r,   rs   r   r   r   arrow_lengthforce_arrowsr   magrV   r3   x_vals               r4   r   Cable._draw_loads  s   T''*4+@+@AT((+S1D1DQ1GHZHZ[\H]-^_?"9#C<LL{{<0## ""2237:<CPTP[P[\hPijmPnopPqLrHs;ss"2237:\#cRVR]R]^jRkloRpqrRsNtJu=uuw#'#7#7#<Q#?@T@TUX@YZ[@\"]01q`g&j kk,/4Q7##"%ay#33C8;L<LSQTUYU`U`amUnorUstuUvQwMx<xx#33C8;l3>NsSVW[WbWbcoWpqtWuvwWxSyOz>zz| 1$  qjALlqrstvlwxlwgh''*t/B/B1/EdFXFXYZF[/[]_._ab-bblwEx##! OOA.33A8"
  OOA.33A8 /0cs`g%h  C{{=1{{=1#66 2 !U$<--a01D1DQ1GGJ4K`K`cklpcpKpq  ;  ys   >L&c                 2   [        U R                  5      S:w  a>  [        S5      n[        U R                  XR
                  S   U R                  S   4SS9nU$ [        S5      n[        U R                  S   X0R
                  S   U R                  S   4SS9nU$ )an  
Returns the diagram/plot of the tension generated in the cable at various points.

Examples
========

For point loads,

>>> from sympy.physics.continuum_mechanics.cable import Cable
>>> c = Cable(("A", 0, 10), ("B", 10, 10))
>>> c.apply_load(-1, ('Z', 2, 7.26, 3, 270))
>>> c.apply_load(-1, ('X', 4, 6, 8, 270))
>>> c.solve()
>>> p = c.plot_tension()
>>> p
Plot object containing:
[0]: cartesian line: Piecewise((8.91403453669861, x <= 2), (4.79150773600774, x <= 4), (19*sqrt(13)/10, x <= 10)) for x over (0.0, 10.0)
>>> p.show()

For uniformly distributed loads,

>>> from sympy.physics.continuum_mechanics.cable import Cable
>>> c=Cable(("A", 0, 40),("B", 100, 20))
>>> c.apply_load(0, ("X", 850))
>>> c.solve(58.58)
>>> p = c.plot_tension()
>>> p
Plot object containing:
[0]: cartesian line: 36465.0*sqrt(0.00054335718671383*X**2 + 1) for X over (0.0, 100.0)
>>> p.show()

r   rV   F)r   rS   r   )rr   r"   r   r   r)   r   r   r%   )r,   rV   tension_plotrS   s       r4   plot_tensionCable.plot_tension  s    B t##$)A !3!3a8J8J18MdNaNabcNd5elqrL  A }!=BTBTUVBWX\XkXklmXn?ov{|Lr7   )r(   r   r#   r!   r"   r&   r'   r$   r   r    r   r%   r)   N)__name__
__module____qualname____firstlineno____doc__r5   propertyr:   r=   r@   rC   rF   rJ   rM   rP   rX   r]   rl   rw   r|   r   r   r   r   r   r   __static_attributes__r   r7   r4   r   r      s    4@<D   " " # #   $ $   $ $  5 6E<Nb?H$0LjrX;z!<!MF8 t'r7   r   N)r   sympy.core.sympifyr   sympy.core.symbolr   r   sympyr   r   r   r	   r
   r   r   r   (sympy.functions.elementary.miscellaneousr   sympy.solvers.solvesetr   sympy.matricesr   sympy.plottingr   r   r   r7   r4   <module>r      s3   
 ' , A A A 9 + ! a ar7   