o
    jgO€  ã                   @   s~  d dl mZ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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 g d¢ZedddgiefdZedƒZer`ejZerdeZdd„ Z dd„ Z!			d<dd„Z"	 	d=dd„Z#	 	d>d"d#„Z$	 	d=d$d%„Z%	 	d>d&d'„Z&		d?d)d*„Z'	 	d@d+d,„Z(dAd0d1„Z)	.	/dBd2d3„Z*dCd5d6„Z+	.	dDd7d8„Z,	.	dEd9d:„Z-d;S )Fé    )ÚIÚpi)ÚexpÚlog)Úapart)ÚDummy)Úimport_module)ÚargÚAbs)Ú_fast_inverse_laplace)ÚSISOLinearTimeInvariant)ÚLineOver1DRangeSeries)ÚPoly)Úlatex)Úpole_zero_numerical_dataÚpole_zero_plotÚstep_response_numerical_dataÚstep_response_plotÚimpulse_response_numerical_dataÚimpulse_response_plotÚramp_response_numerical_dataÚramp_response_plotÚbode_magnitude_numerical_dataÚbode_phase_numerical_dataÚbode_magnitude_plotÚbode_phase_plotÚ	bode_plotÚ
matplotlibÚfromlistÚpyplot)Úimport_kwargsÚcatchÚnumpyc                 C   sJ   t | tƒs	tdƒ‚|  ¡ }t|jƒ}|dkrtdƒ‚| t¡r#tdƒ‚dS )zYFunction to check whether the dynamical system passed for plots is
    compatible or not.z.Only SISO LTI systems are currently supported.é   zExtra degree of freedom found. Make sure that there are no free symbols in the dynamical system other than the variable of Laplace transform.z#Time delay terms are not supported.N)	Ú
isinstancer   ÚNotImplementedErrorÚto_exprÚlenÚfree_symbolsÚ
ValueErrorÚhasr   )ÚsystemÚsysÚlen_free_symbols© r.   ú[/var/www/html/zoom/venv/lib/python3.10/site-packages/sympy/physics/control/control_plots.pyÚ_check_system!   s   


ýr0   c                 C   sp   t | ƒ |  ¡ } t| j| jƒ ¡ }t| j| jƒ ¡ }tj|tj	d}tj|tj	d}t 
|¡}t 
|¡}||fS )a£  
    Returns the numerical data of poles and zeros of the system.
    It is internally used by ``pole_zero_plot`` to get the data
    for plotting poles and zeros. Users can use this data to further
    analyse the dynamics of the system or plot using a different
    backend/plotting-module.

    Parameters
    ==========

    system : SISOLinearTimeInvariant
        The system for which the pole-zero data is to be computed.

    Returns
    =======

    tuple : (zeros, poles)
        zeros = Zeros of the system. NumPy array of complex numbers.
        poles = Poles of the system. NumPy array of complex numbers.

    Raises
    ======

    NotImplementedError
        When a SISO LTI system is not passed.

        When time delay terms are present in the system.

    ValueError
        When more than one free symbol is present in the system.
        The only variable in the transfer function should be
        the variable of the Laplace transform.

    Examples
    ========

    >>> from sympy.abc import s
    >>> from sympy.physics.control.lti import TransferFunction
    >>> from sympy.physics.control.control_plots import pole_zero_numerical_data
    >>> tf1 = TransferFunction(s**2 + 1, s**4 + 4*s**3 + 6*s**2 + 5*s + 2, s)
    >>> pole_zero_numerical_data(tf1)   # doctest: +SKIP
    ([-0.+1.j  0.-1.j], [-2. +0.j        -0.5+0.8660254j -0.5-0.8660254j -1. +0.j       ])

    See Also
    ========

    pole_zero_plot

    )Údtype)r0   Údoitr   ÚnumÚvarÚ
all_coeffsÚdenÚnpÚarrayÚ
complex128Úroots)r+   Únum_polyÚden_polyÚzerosÚpolesr.   r.   r/   r   2   s   2

r   Úblueé
   Úorangeé   Tc                 K   sÌ   t | ƒ\}	}
t |	¡}t |	¡}t |
¡}t |
¡}tj||dd||d tj||d||d t d¡ t d¡ tjdt	| ƒ› d	d
d |rLt 
¡  |r\tjddd tjddd |rdt ¡  dS tS )a“  
    Returns the Pole-Zero plot (also known as PZ Plot or PZ Map) of a system.

    A Pole-Zero plot is a graphical representation of a system's poles and
    zeros. It is plotted on a complex plane, with circular markers representing
    the system's zeros and 'x' shaped markers representing the system's poles.

    Parameters
    ==========

    system : SISOLinearTimeInvariant type systems
        The system for which the pole-zero plot is to be computed.
    pole_color : str, tuple, optional
        The color of the pole points on the plot. Default color
        is blue. The color can be provided as a matplotlib color string,
        or a 3-tuple of floats each in the 0-1 range.
    pole_markersize : Number, optional
        The size of the markers used to mark the poles in the plot.
        Default pole markersize is 10.
    zero_color : str, tuple, optional
        The color of the zero points on the plot. Default color
        is orange. The color can be provided as a matplotlib color string,
        or a 3-tuple of floats each in the 0-1 range.
    zero_markersize : Number, optional
        The size of the markers used to mark the zeros in the plot.
        Default zero markersize is 7.
    grid : boolean, optional
        If ``True``, the plot will have a grid. Defaults to True.
    show_axes : boolean, optional
        If ``True``, the coordinate axes will be shown. Defaults to False.
    show : boolean, optional
        If ``True``, the plot will be displayed otherwise
        the equivalent matplotlib ``plot`` object will be returned.
        Defaults to True.

    Examples
    ========

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

        >>> from sympy.abc import s
        >>> from sympy.physics.control.lti import TransferFunction
        >>> from sympy.physics.control.control_plots import pole_zero_plot
        >>> tf1 = TransferFunction(s**2 + 1, s**4 + 4*s**3 + 6*s**2 + 5*s + 2, s)
        >>> pole_zero_plot(tf1)   # doctest: +SKIP

    See Also
    ========

    pole_zero_numerical_data

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Pole%E2%80%93zero_plot

    ÚxÚnone)ÚmfcÚ
markersizeÚcolorÚo)rF   rG   z	Real AxiszImaginary AxiszPoles and Zeros of $ú$é   ©Úpadr   Úblack©rG   N)r   r7   ÚrealÚimagÚpltÚplotÚxlabelÚylabelÚtitler   ÚgridÚaxhlineÚaxvlineÚshow)r+   Ú
pole_colorÚpole_markersizeÚ
zero_colorÚzero_markersizerV   Ú	show_axesrY   Úkwargsr=   r>   Ú	zero_realÚ	zero_imagÚ	pole_realÚ	pole_imagr.   r.   r/   r   s   s.   ?



ÿÿ

r   é   c                 K   sn   |dk rt dƒ‚t| ƒ tdƒ}|  ¡ | j }t|| jdd}t|| j|ƒ |¡}t||||ffi |¤Ž 	¡ S )a°  
    Returns the numerical values of the points in the step response plot
    of a SISO continuous-time system. By default, adaptive sampling
    is used. If the user wants to instead get an uniformly
    sampled response, then ``adaptive`` kwarg should be passed ``False``
    and ``n`` must be passed as additional kwargs.
    Refer to the parameters of class :class:`sympy.plotting.series.LineOver1DRangeSeries`
    for more details.

    Parameters
    ==========

    system : SISOLinearTimeInvariant
        The system for which the unit step response data is to be computed.
    prec : int, optional
        The decimal point precision for the point coordinate values.
        Defaults to 8.
    lower_limit : Number, optional
        The lower limit of the plot range. Defaults to 0.
    upper_limit : Number, optional
        The upper limit of the plot range. Defaults to 10.
    kwargs :
        Additional keyword arguments are passed to the underlying
        :class:`sympy.plotting.series.LineOver1DRangeSeries` class.

    Returns
    =======

    tuple : (x, y)
        x = Time-axis values of the points in the step response. NumPy array.
        y = Amplitude-axis values of the points in the step response. NumPy array.

    Raises
    ======

    NotImplementedError
        When a SISO LTI system is not passed.

        When time delay terms are present in the system.

    ValueError
        When more than one free symbol is present in the system.
        The only variable in the transfer function should be
        the variable of the Laplace transform.

        When ``lower_limit`` parameter is less than 0.

    Examples
    ========

    >>> from sympy.abc import s
    >>> from sympy.physics.control.lti import TransferFunction
    >>> from sympy.physics.control.control_plots import step_response_numerical_data
    >>> tf1 = TransferFunction(s, s**2 + 5*s + 8, s)
    >>> step_response_numerical_data(tf1)   # doctest: +SKIP
    ([0.0, 0.025413462339411542, 0.0484508722725343, ... , 9.670250533855183, 9.844291913708725, 10.0],
    [0.0, 0.023844582399907256, 0.042894276802320226, ..., 6.828770759094287e-12, 6.456457160755703e-12])

    See Also
    ========

    step_response_plot

    r   ú:Lower limit of time must be greater than or equal to zero.rC   T©Úfull©
r)   r0   r   r&   r4   r   r   Úevalfr   Ú
get_points©r+   ÚprecÚlower_limitÚupper_limitr_   Ú_xÚexprÚ_yr.   r.   r/   r   Î   s   Bÿÿr   ÚbFc                 K   óš   t | f|||dœ|¤Ž\}	}
tj|	|
|d t d¡ t d¡ tjdt| ƒ› ddd |r3t ¡  |rCtjd	d
d tj	d	d
d |rKt 
¡  dS tS )a›  
    Returns the unit step response of a continuous-time system. It is
    the response of the system when the input signal is a step function.

    Parameters
    ==========

    system : SISOLinearTimeInvariant type
        The LTI SISO system for which the Step Response is to be computed.
    color : str, tuple, optional
        The color of the line. Default is Blue.
    show : boolean, optional
        If ``True``, the plot will be displayed otherwise
        the equivalent matplotlib ``plot`` object will be returned.
        Defaults to True.
    lower_limit : Number, optional
        The lower limit of the plot range. Defaults to 0.
    upper_limit : Number, optional
        The upper limit of the plot range. Defaults to 10.
    prec : int, optional
        The decimal point precision for the point coordinate values.
        Defaults to 8.
    show_axes : boolean, optional
        If ``True``, the coordinate axes will be shown. Defaults to False.
    grid : boolean, optional
        If ``True``, the plot will have a grid. Defaults to True.

    Examples
    ========

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

        >>> from sympy.abc import s
        >>> from sympy.physics.control.lti import TransferFunction
        >>> from sympy.physics.control.control_plots import step_response_plot
        >>> tf1 = TransferFunction(8*s**2 + 18*s + 32, s**3 + 6*s**2 + 14*s + 24, s)
        >>> step_response_plot(tf1)   # doctest: +SKIP

    See Also
    ========

    impulse_response_plot, ramp_response_plot

    References
    ==========

    .. [1] https://www.mathworks.com/help/control/ref/lti.step.html

    ©rl   rm   rn   rN   úTime (s)Ú	AmplitudezUnit Step Response of $rI   rJ   rK   r   rM   N)r   rQ   rR   rS   rT   rU   r   rV   rW   rX   rY   ©r+   rG   rl   rm   rn   r^   rV   rY   r_   rC   Úyr.   r.   r/   r     ó$   6ÿ
ÿ

r   c                 K   sh   |dk rt dƒ‚t| ƒ tdƒ}|  ¡ }t|| jdd}t|| j|ƒ |¡}t||||ffi |¤Ž 	¡ S )aŽ  
    Returns the numerical values of the points in the impulse response plot
    of a SISO continuous-time system. By default, adaptive sampling
    is used. If the user wants to instead get an uniformly
    sampled response, then ``adaptive`` kwarg should be passed ``False``
    and ``n`` must be passed as additional kwargs.
    Refer to the parameters of class :class:`sympy.plotting.series.LineOver1DRangeSeries`
    for more details.

    Parameters
    ==========

    system : SISOLinearTimeInvariant
        The system for which the impulse response data is to be computed.
    prec : int, optional
        The decimal point precision for the point coordinate values.
        Defaults to 8.
    lower_limit : Number, optional
        The lower limit of the plot range. Defaults to 0.
    upper_limit : Number, optional
        The upper limit of the plot range. Defaults to 10.
    kwargs :
        Additional keyword arguments are passed to the underlying
        :class:`sympy.plotting.series.LineOver1DRangeSeries` class.

    Returns
    =======

    tuple : (x, y)
        x = Time-axis values of the points in the impulse response. NumPy array.
        y = Amplitude-axis values of the points in the impulse response. NumPy array.

    Raises
    ======

    NotImplementedError
        When a SISO LTI system is not passed.

        When time delay terms are present in the system.

    ValueError
        When more than one free symbol is present in the system.
        The only variable in the transfer function should be
        the variable of the Laplace transform.

        When ``lower_limit`` parameter is less than 0.

    Examples
    ========

    >>> from sympy.abc import s
    >>> from sympy.physics.control.lti import TransferFunction
    >>> from sympy.physics.control.control_plots import impulse_response_numerical_data
    >>> tf1 = TransferFunction(s, s**2 + 5*s + 8, s)
    >>> impulse_response_numerical_data(tf1)   # doctest: +SKIP
    ([0.0, 0.06616480200395854,... , 9.854500743565858, 10.0],
    [0.9999999799999999, 0.7042848373025861,...,7.170748906965121e-13, -5.1901263495547205e-12])

    See Also
    ========

    impulse_response_plot

    r   re   rC   Trf   )
r)   r0   r   r&   r   r4   r   ri   r   rj   rk   r.   r.   r/   r   e  s   Bÿÿr   c                 K   rs   )aŠ  
    Returns the unit impulse response (Input is the Dirac-Delta Function) of a
    continuous-time system.

    Parameters
    ==========

    system : SISOLinearTimeInvariant type
        The LTI SISO system for which the Impulse Response is to be computed.
    color : str, tuple, optional
        The color of the line. Default is Blue.
    show : boolean, optional
        If ``True``, the plot will be displayed otherwise
        the equivalent matplotlib ``plot`` object will be returned.
        Defaults to True.
    lower_limit : Number, optional
        The lower limit of the plot range. Defaults to 0.
    upper_limit : Number, optional
        The upper limit of the plot range. Defaults to 10.
    prec : int, optional
        The decimal point precision for the point coordinate values.
        Defaults to 8.
    show_axes : boolean, optional
        If ``True``, the coordinate axes will be shown. Defaults to False.
    grid : boolean, optional
        If ``True``, the plot will have a grid. Defaults to True.

    Examples
    ========

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

        >>> from sympy.abc import s
        >>> from sympy.physics.control.lti import TransferFunction
        >>> from sympy.physics.control.control_plots import impulse_response_plot
        >>> tf1 = TransferFunction(8*s**2 + 18*s + 32, s**3 + 6*s**2 + 14*s + 24, s)
        >>> impulse_response_plot(tf1)   # doctest: +SKIP

    See Also
    ========

    step_response_plot, ramp_response_plot

    References
    ==========

    .. [1] https://www.mathworks.com/help/control/ref/dynamicsystem.impulse.html

    rt   rN   ru   rv   zImpulse Response of $rI   rJ   rK   r   rM   N)r   rQ   rR   rS   rT   rU   r   rV   rW   rX   rY   rw   r.   r.   r/   r   ³  ry   r   r#   c           	      K   s†   |dk rt dƒ‚|dk rt dƒ‚t| ƒ tdƒ}||  ¡  | jd  }t|| jdd}t|| j|ƒ |¡}t||||ffi |¤Ž 	¡ S )a	  
    Returns the numerical values of the points in the ramp response plot
    of a SISO continuous-time system. By default, adaptive sampling
    is used. If the user wants to instead get an uniformly
    sampled response, then ``adaptive`` kwarg should be passed ``False``
    and ``n`` must be passed as additional kwargs.
    Refer to the parameters of class :class:`sympy.plotting.series.LineOver1DRangeSeries`
    for more details.

    Parameters
    ==========

    system : SISOLinearTimeInvariant
        The system for which the ramp response data is to be computed.
    slope : Number, optional
        The slope of the input ramp function. Defaults to 1.
    prec : int, optional
        The decimal point precision for the point coordinate values.
        Defaults to 8.
    lower_limit : Number, optional
        The lower limit of the plot range. Defaults to 0.
    upper_limit : Number, optional
        The upper limit of the plot range. Defaults to 10.
    kwargs :
        Additional keyword arguments are passed to the underlying
        :class:`sympy.plotting.series.LineOver1DRangeSeries` class.

    Returns
    =======

    tuple : (x, y)
        x = Time-axis values of the points in the ramp response plot. NumPy array.
        y = Amplitude-axis values of the points in the ramp response plot. NumPy array.

    Raises
    ======

    NotImplementedError
        When a SISO LTI system is not passed.

        When time delay terms are present in the system.

    ValueError
        When more than one free symbol is present in the system.
        The only variable in the transfer function should be
        the variable of the Laplace transform.

        When ``lower_limit`` parameter is less than 0.

        When ``slope`` is negative.

    Examples
    ========

    >>> from sympy.abc import s
    >>> from sympy.physics.control.lti import TransferFunction
    >>> from sympy.physics.control.control_plots import ramp_response_numerical_data
    >>> tf1 = TransferFunction(s, s**2 + 5*s + 8, s)
    >>> ramp_response_numerical_data(tf1)   # doctest: +SKIP
    (([0.0, 0.12166980856813935,..., 9.861246379582118, 10.0],
    [1.4504508011325967e-09, 0.006046440489058766,..., 0.12499999999568202, 0.12499999999661349]))

    See Also
    ========

    ramp_response_plot

    r   z,Slope must be greater than or equal to zero.re   rC   é   Trf   rh   )	r+   Úsloperl   rm   rn   r_   ro   rp   rq   r.   r.   r/   r   ü  s   Fÿÿr   c	                 K   s¢   t | f||||dœ|	¤Ž\}
}tj|
||d t d¡ t d¡ tjdt| ƒ› d|› ddd	 |r7t ¡  |rGtjd
dd tj	d
dd |rOt 
¡  dS tS )a>  
    Returns the ramp response of a continuous-time system.

    Ramp function is defined as the straight line
    passing through origin ($f(x) = mx$). The slope of
    the ramp function can be varied by the user and
    the default value is 1.

    Parameters
    ==========

    system : SISOLinearTimeInvariant type
        The LTI SISO system for which the Ramp Response is to be computed.
    slope : Number, optional
        The slope of the input ramp function. Defaults to 1.
    color : str, tuple, optional
        The color of the line. Default is Blue.
    show : boolean, optional
        If ``True``, the plot will be displayed otherwise
        the equivalent matplotlib ``plot`` object will be returned.
        Defaults to True.
    lower_limit : Number, optional
        The lower limit of the plot range. Defaults to 0.
    upper_limit : Number, optional
        The upper limit of the plot range. Defaults to 10.
    prec : int, optional
        The decimal point precision for the point coordinate values.
        Defaults to 8.
    show_axes : boolean, optional
        If ``True``, the coordinate axes will be shown. Defaults to False.
    grid : boolean, optional
        If ``True``, the plot will have a grid. Defaults to True.

    Examples
    ========

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

        >>> from sympy.abc import s
        >>> from sympy.physics.control.lti import TransferFunction
        >>> from sympy.physics.control.control_plots import ramp_response_plot
        >>> tf1 = TransferFunction(s, (s+4)*(s+8), s)
        >>> ramp_response_plot(tf1, upper_limit=2)   # doctest: +SKIP

    See Also
    ========

    step_response_plot, impulse_response_plot

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Ramp_function

    )r{   rl   rm   rn   rN   ru   rv   zRamp Response of $z$ [Slope = ú]rJ   rK   r   rM   N)r   rQ   rR   rS   rT   rU   r   rV   rW   rX   rY   )r+   r{   rG   rl   rm   rn   r^   rV   rY   r_   rC   rx   r.   r.   r/   r   Q  s$   
<ÿ
ÿ

 r   éûÿÿÿé   úrad/secc                 K   s¨   t | ƒ |  ¡ }d}||vrtdƒ‚tddd}|dkr%t| d t }nt| }| | j|i¡}	dtt	|	ƒd	ƒ }
t
|
|d	| d	| ffd
di|¤Ž ¡ \}}||fS )aŒ  
    Returns the numerical data of the Bode magnitude plot of the system.
    It is internally used by ``bode_magnitude_plot`` to get the data
    for plotting Bode magnitude plot. Users can use this data to further
    analyse the dynamics of the system or plot using a different
    backend/plotting-module.

    Parameters
    ==========

    system : SISOLinearTimeInvariant
        The system for which the data is to be computed.
    initial_exp : Number, optional
        The initial exponent of 10 of the semilog plot. Defaults to -5.
    final_exp : Number, optional
        The final exponent of 10 of the semilog plot. Defaults to 5.
    freq_unit : string, optional
        User can choose between ``'rad/sec'`` (radians/second) and ``'Hz'`` (Hertz) as frequency units.

    Returns
    =======

    tuple : (x, y)
        x = x-axis values of the Bode magnitude plot.
        y = y-axis values of the Bode magnitude plot.

    Raises
    ======

    NotImplementedError
        When a SISO LTI system is not passed.

        When time delay terms are present in the system.

    ValueError
        When more than one free symbol is present in the system.
        The only variable in the transfer function should be
        the variable of the Laplace transform.

        When incorrect frequency units are given as input.

    Examples
    ========

    >>> from sympy.abc import s
    >>> from sympy.physics.control.lti import TransferFunction
    >>> from sympy.physics.control.control_plots import bode_magnitude_numerical_data
    >>> tf1 = TransferFunction(s**2 + 1, s**4 + 4*s**3 + 6*s**2 + 5*s + 2, s)
    >>> bode_magnitude_numerical_data(tf1)   # doctest: +SKIP
    ([1e-05, 1.5148378120533502e-05,..., 68437.36188804005, 100000.0],
    [-6.020599914256786, -6.0205999155219505,..., -193.4117304087953, -200.00000000260573])

    See Also
    ========

    bode_magnitude_plot, bode_phase_numerical_data

    ©r   ÚHzú5Only "rad/sec" and "Hz" are accepted frequency units.ÚwT©rO   r   rz   rJ   r@   Úxscaler   )r0   r&   r)   r   r   r   Úsubsr4   r   r
   r   rj   )r+   Úinitial_expÚ	final_expÚ	freq_unitr_   rp   Ú
freq_unitsÚ_wÚreplÚw_exprÚmagrC   rx   r.   r.   r/   r      s*   ;ÿÿÿÿr   c                 K   sª   t | |||d\}	}
tj|	|
fd|i|¤Ž t d¡ t d| ¡ t d¡ tjdt| ƒ› ddd	 |r;t d
¡ |rKtj	ddd tj
ddd |rSt ¡  dS tS )zu
    Returns the Bode magnitude plot of a continuous-time system.

    See ``bode_plot`` for all the parameters.
    )r‡   rˆ   r‰   rG   r   úFrequency (%s) [Log Scale]zMagnitude (dB)zBode Plot (Magnitude) of $rI   rJ   rK   Tr   rM   rN   N)r   rQ   rR   r…   rS   rT   rU   r   rV   rW   rX   rY   )r+   r‡   rˆ   rG   r^   rV   rY   r‰   r_   rC   rx   r.   r.   r/   r   ð  s"   
ÿ


r   Úradc                 K   sV  t | ƒ |  ¡ }d}d}	||vrtdƒ‚||	vrtdƒ‚tddd}
|dkr/t|
 d	 t }nt|
 }| | j|i¡}|d
krHt|ƒd t }nt|ƒ}t	||
d| d| ffddi|¤Ž 
¡ \}}d}|rs|dkrmt}n|d
krsd}|r§d	| }tdt|ƒƒD ]&}|| ||d   }||kr™|| | ||< q€|| k r¦|| | ||< q€||fS )a‹  
    Returns the numerical data of the Bode phase plot of the system.
    It is internally used by ``bode_phase_plot`` to get the data
    for plotting Bode phase plot. Users can use this data to further
    analyse the dynamics of the system or plot using a different
    backend/plotting-module.

    Parameters
    ==========

    system : SISOLinearTimeInvariant
        The system for which the Bode phase plot data is to be computed.
    initial_exp : Number, optional
        The initial exponent of 10 of the semilog plot. Defaults to -5.
    final_exp : Number, optional
        The final exponent of 10 of the semilog plot. Defaults to 5.
    freq_unit : string, optional
        User can choose between ``'rad/sec'`` (radians/second) and '``'Hz'`` (Hertz) as frequency units.
    phase_unit : string, optional
        User can choose between ``'rad'`` (radians) and ``'deg'`` (degree) as phase units.
    phase_unwrap : bool, optional
        Set to ``True`` by default.

    Returns
    =======

    tuple : (x, y)
        x = x-axis values of the Bode phase plot.
        y = y-axis values of the Bode phase plot.

    Raises
    ======

    NotImplementedError
        When a SISO LTI system is not passed.

        When time delay terms are present in the system.

    ValueError
        When more than one free symbol is present in the system.
        The only variable in the transfer function should be
        the variable of the Laplace transform.

        When incorrect frequency or phase units are given as input.

    Examples
    ========

    >>> from sympy.abc import s
    >>> from sympy.physics.control.lti import TransferFunction
    >>> from sympy.physics.control.control_plots import bode_phase_numerical_data
    >>> tf1 = TransferFunction(s**2 + 1, s**4 + 4*s**3 + 6*s**2 + 5*s + 2, s)
    >>> bode_phase_numerical_data(tf1)   # doctest: +SKIP
    ([1e-05, 1.4472354033813751e-05, 2.035581932165858e-05,..., 47577.3248186011, 67884.09326036123, 100000.0],
    [-2.5000000000291665e-05, -3.6180885085e-05, -5.08895483066e-05,...,-3.1415085799262523, -3.14155265358979])

    See Also
    ========

    bode_magnitude_plot, bode_phase_numerical_data

    r€   )r   Údegr‚   z.Only "rad" and "deg" are accepted phase units.rƒ   Tr„   r   rz   r‘   é´   r@   r…   r   Nr   r#   )r0   r&   r)   r   r   r   r†   r4   r	   r   rj   Úranger'   )r+   r‡   rˆ   r‰   Ú
phase_unitÚphase_unwrapr_   rp   rŠ   Úphase_unitsr‹   rŒ   r   ÚphaserC   rx   ÚhalfÚunitÚiÚdiffr.   r.   r/   r     sR   ?ÿÿÿÿ
€r   c
                 K   s²   t | |||||	d\}}tj||fd|i|
¤Ž t d¡ t d| ¡ t d| ¡ tjdt| ƒ› ddd	 |r?t d
¡ |rOtj	ddd tj
ddd |rWt ¡  dS tS )zq
    Returns the Bode phase plot of a continuous-time system.

    See ``bode_plot`` for all the parameters.
    )r‡   rˆ   r‰   r”   r•   rG   r   r   z
Phase (%s)zBode Plot (Phase) of $rI   rJ   rK   Tr   rM   rN   N)r   rQ   rR   r…   rS   rT   rU   r   rV   rW   rX   rY   )r+   r‡   rˆ   rG   r^   rV   rY   r‰   r”   r•   r_   rC   rx   r.   r.   r/   r   v  s"   
ÿ

r   c	                 K   s’   t  d¡ t| f||d|||dœ|	¤Ž}
|
jdt| ƒ› ddd |
 d¡ t  d	¡ t| f||d|||||d
œ|	¤Ž d¡ |rGt  ¡  dS t S )aÈ  
    Returns the Bode phase and magnitude plots of a continuous-time system.

    Parameters
    ==========

    system : SISOLinearTimeInvariant type
        The LTI SISO system for which the Bode Plot is to be computed.
    initial_exp : Number, optional
        The initial exponent of 10 of the semilog plot. Defaults to -5.
    final_exp : Number, optional
        The final exponent of 10 of the semilog plot. Defaults to 5.
    show : boolean, optional
        If ``True``, the plot will be displayed otherwise
        the equivalent matplotlib ``plot`` object will be returned.
        Defaults to True.
    prec : int, optional
        The decimal point precision for the point coordinate values.
        Defaults to 8.
    grid : boolean, optional
        If ``True``, the plot will have a grid. Defaults to True.
    show_axes : boolean, optional
        If ``True``, the coordinate axes will be shown. Defaults to False.
    freq_unit : string, optional
        User can choose between ``'rad/sec'`` (radians/second) and ``'Hz'`` (Hertz) as frequency units.
    phase_unit : string, optional
        User can choose between ``'rad'`` (radians) and ``'deg'`` (degree) as phase units.

    Examples
    ========

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

        >>> from sympy.abc import s
        >>> from sympy.physics.control.lti import TransferFunction
        >>> from sympy.physics.control.control_plots import bode_plot
        >>> tf1 = TransferFunction(1*s**2 + 0.1*s + 7.5, 1*s**4 + 0.12*s**3 + 9*s**2, s)
        >>> bode_plot(tf1, initial_exp=0.2, final_exp=0.7)   # doctest: +SKIP

    See Also
    ========

    bode_magnitude_plot, bode_phase_plot

    éÓ   F)r‡   rˆ   rY   rV   r^   r‰   zBode Plot of $rI   rJ   rK   NéÔ   )r‡   rˆ   rY   rV   r^   r‰   r”   r•   )rQ   Úsubplotr   rU   r   rS   r   rY   )r+   r‡   rˆ   rV   r^   rY   r‰   r”   r•   r_   rŽ   r.   r.   r/   r   ’  s(   
2
þþ


ÿÿr   N)r?   r@   rA   rB   TTT)rd   r   r@   )rr   rd   r   r@   FTT)r#   rd   r   r@   )r#   rr   rd   r   r@   FTT)r}   r~   r   )r}   r~   rr   FTTr   )r}   r~   r   r   T)	r}   r~   rr   FTTr   r   T)r}   r~   TFTr   r   T).Úsympy.core.numbersr   r   Ú&sympy.functions.elementary.exponentialr   r   Úsympy.polys.partfracr   Úsympy.core.symbolr   Úsympy.externalr   Úsympy.functionsr	   r
   Úsympy.integrals.laplacer   Úsympy.physics.control.ltir   Úsympy.plotting.seriesr   Úsympy.polys.polytoolsr   Úsympy.printing.latexr   Ú__all__ÚRuntimeErrorr   r"   r   rQ   r7   r0   r   r   r   r   r   r   r   r   r   r   r   r   r   r.   r.   r.   r/   Ú<module>   sp    
þA
þ[
ÿN
ÿI
ÿN
ÿI
ÿU
ÿ
OP
ÿ
i
ÿÿ