Пример #1
0
def test_nyquist_basic(ss_siso):
    """Test nyquist plot call (Very basic)"""
    # TODO: proper test
    tf_siso = tf(ss_siso)
    nyquist_plot(ss_siso)
    nyquist_plot(tf_siso)
    count, contour = nyquist_plot(tf_siso,
                                  plot=False,
                                  return_contour=True,
                                  omega_num=20)
    assert len(contour) == 20

    with pytest.warns(UserWarning, match="encirclements was a non-integer"):
        count, contour = nyquist_plot(tf_siso,
                                      plot=False,
                                      omega_limits=(1, 100),
                                      return_contour=True)
    assert_allclose(contour[0], 1j)
    assert_allclose(contour[-1], 100j)

    count, contour = nyquist_plot(tf_siso,
                                  plot=False,
                                  omega=np.logspace(-1, 1, 10),
                                  return_contour=True)
    assert len(contour) == 10
Пример #2
0
def lima_nyquist(sys, freq, gain_range, lim_x=None):

    warnings.filterwarnings("ignore")
    plt.figure(1)
    plt.grid()
    leg = []
    for gain in gain_range:
        nyquist_plot(gain * sys,
                     freq,
                     arrowhead_width=0.005,
                     arrowhead_length=0.008)
        leg.extend(['K = ' + str(gain), '_', '_'])

    plt.axvline(x=0, color='k', lw=1)

    if (lim_x):
        plt.xlim(lim_x)
    plt.legend(leg)
    warnings.filterwarnings("default")
    plt.xlabel('Real')
    plt.ylabel('Imaginário')
    plt.title('Diagrama de Nyquist')
Пример #3
0
def test_nyquist_basic(ss_siso):
    """Test nyquist plot call (Very basic)"""
    # TODO: proper test
    tf_siso = tf(ss_siso)
    nyquist_plot(ss_siso)
    nyquist_plot(tf_siso)
    assert len(nyquist_plot(tf_siso, plot=False, omega_num=20)[0] == 20)
    omega = nyquist_plot(tf_siso, plot=False, omega_limits=(1, 100))[2]
    assert_allclose(omega[0], 1)
    assert_allclose(omega[-1], 100)
    assert len(
        nyquist_plot(tf_siso, plot=False, omega=np.logspace(-1, 1,
                                                            10))[0]) == 10
Пример #4
0
def test_nyquist_basic(ss_siso):
    """Test nyquist plot call (Very basic)"""
    # TODO: proper test
    tf_siso = tf(ss_siso)
    nyquist_plot(ss_siso)
    nyquist_plot(tf_siso)
    count, contour = nyquist_plot(tf_siso,
                                  plot=False,
                                  return_contour=True,
                                  omega_num=20)
    assert len(contour) == 20

    count, contour = nyquist_plot(tf_siso,
                                  plot=False,
                                  omega_limits=(1, 100),
                                  return_contour=True)
    assert_allclose(contour[0], 1j)
    assert_allclose(contour[-1], 100j)

    count, contour = nyquist_plot(tf_siso,
                                  plot=False,
                                  omega=np.logspace(-1, 1, 10),
                                  return_contour=True)
    assert len(contour) == 10
Пример #5
0
# Importe os parâmetros do sistemas de maneira mais geral para plot e para
# o tratamento de variáveis complexas.
import matplotlib
import matplotlib.pyplot as plt
import numpy as o
import cmath

# Importe para algo mais específico que faz a simulação do Matlab para trata-
# mento de variáveis similares ao que acontece naquela plataforma.
import control
from control.matlab import TransferFunction
from control.freqplot import bode_plot
from control.freqplot import nyquist_plot

num = 10
den = [1, 10]

sys = TransferFunction(num, den)

w = o.linspace(1, 100, 1000)
bode_plot(sys)
plt.figure()
nyquist_plot(sys)
plt.grid()