Ejemplo n.º 1
0
    def calcular(self, n, norm=False, k_factor=1):
        # Atencion: Norm = calcular normalizada

        if n % 2 == 1:
            k = int((n - 1) / 2)
            arr = []
            for i in range(k + 1):
                arr.append(get_a(i, n))

            poly = legendre.leg2poly(legendre.legint(legendre.legmul(arr,
                                                                     arr)))
        else:
            k = int((n - 2) / 2)
            arr = []
            for i in range(k + 1):
                arr.append(get_a(i, n))

            leg_b = legendre.legmul(legendre.legmul(arr, arr),
                                    legendre.poly2leg([1, 1]))

            poly = legendre.leg2poly(legendre.legint(leg_b))

        exp = 0
        wn, sn, s, sa = sp.symbols("wn sn sa s")

        for i in range(len(poly)):
            exp += poly[i] * ((2 * (wn**2) - 1)**i)
            exp -= poly[i] * ((-1)**i)

        if n % 2 == 1:
            exp = exp * 1 / (2 * (k + 1)**2)
        else:
            exp = exp * 1 / ((k + 1) * (k + 2))

        exp = 1 / (1 + self.getXi(0, n)**2 * exp)
        exp = exp.subs(wn, sn / 1j)

        roots = algebra.getRoots(exp, sn)
        roots[1] = algebra.filterRealNegativeRoots(roots[1])

        poles = []
        for i in roots[1]:
            poles.append({"value": i})

        exp = algebra.armarPolinomino(poles, [], sn, 1)
        self.tf_normalized = algebra.conseguir_tf(exp, sn, poles)

        if not norm:
            exp = self.plantilla.denormalizarFrecuencias(exp, sa, sn)
            self.getGainPoints()

            factor = (self.k1 - self.k2) * norm / 100 + self.k2

            exp = self.plantilla.denormalizarAmplitud(exp, s, sa, factor)

            self.tf = algebra.conseguir_tf(exp, s, [])

            return self.tf
        else:
            return self.tf_normalized
Ejemplo n.º 2
0
    def calcularDadoGamma(self, n_value, k=1, norm=-1, gamma=1):
        sn, s = sp.symbols("sn s")

        #print(num)
        den = 0
        fact = 1
        cnt = -1

        for i in range(1, n_value + 1):
            fact *= i
            den += (gamma**i) * ((s / sp.I)**(2 * i)) / fact
        #print(den)

        exp = 1 / (1 + den)
        #exp = self.plantilla.denormalizarFrecuencias(exp, s, sn)
        #print(exp)

        roots = algebra.getRoots(exp, s)
        roots[1] = algebra.filterRealNegativeRoots(roots[1])

        poles = []
        for i in roots[1]:
            poles.append({"value": i})

        exp = algebra.armarPolinomino(poles, [], s, 1)
        self.tf = algebra.conseguir_tf(exp, s, [])

        return self.tf
Ejemplo n.º 3
0
    def calcular(
        self,
        n_value,
        norm,
        k=1
    ):  # calcular mediante N la funcion transferencia de la aproximacion
        poles = self.getPoles(n_value, self.getXi(norm, n_value))
        zeroes = self.getZeroes(n_value, self.getXi(norm, n_value))
        sn, sa, s = sp.symbols("sn sa s")
        pol = armarPolinomino(poles, zeroes, sn, self.getZeroGain(n_value))
        self.tf_normalized = conseguir_tf(pol, sn, poles)
        self.getGainPoints()
        factor = (self.k1 - self.k2) * norm / 100 + self.k2

        pol = self.plantilla.denormalizarAmplitud(pol, sa, sn, factor)

        #pol = self.plantilla.denormalizarAmplitud(pol, sa, sn, n_value, 1, 0)
        pol = self.plantilla.denormalizarFrecuencias(pol, s, sa)
        #print(pol)

        self.tf = conseguir_tf(pol, s, poles)
        self.updateEtapas()
        return self.tf
Ejemplo n.º 4
0
    def calcular(self, n_value, k=1, norm = -1):
        sn, s = sp.symbols("sn s")
        self.var = s

        num = computeBesselPoly(n_value, sn).evalf(subs={sn: 0})

        #print(num)
        den = computeBesselPoly(n_value, sn)
        #print(den)

        exp = num / den
        exp = self.plantilla.denormalizarFrecuencias(exp, s, sn)
        self.exp = exp
        self.coef = algebra.conseguir_coef(exp, s)

        self.tf = algebra.conseguir_tf(exp, s, [])
        return self.tf
Ejemplo n.º 5
0
    def computarMinMaxGain(
        self, min_freq, max_freq
    ):  # conseguir minima y maxima ganancia de la etapa dado un rango de frecuencias
        self.tf = conseguir_tf(self.transfer_expression, self.var)

        w, mag, pha = signal.bode(
            self.tf, logspace(log10(min_freq), log10(max_freq), 10000))
        self.w = w
        self.mag = mag

        minGain = 1e8
        maxGain = -1e8

        for m in self.mag:
            minGain = min(minGain, m)
            maxGain = max(maxGain, m)

        self.minGain = minGain
        self.maxGain = maxGain

        if config.debug:
            print("Ganancia mínima:", minGain)
            print("Ganancia máxima:", maxGain)
Ejemplo n.º 6
0
s = sp.symbols('s')

Wo1 = 2 * pi * 12948.60
Q1 = 11.58
Wo2 = 2 * pi * 13850.42
Q2 = 3.65
Wo3 = 2 * pi * 15845.49
Q3 = 1.96
Wo4 = 2 * pi * 19525.55
Q4 = 1.19
Wo5 = 2 * pi * 25958.29
Q5 = 0.76
Wo6 = 2 * pi * 34110.10
Q6 = 0.53

H1 = veces(-0.10074052126957483) * s**2 / (s**2 + s * Wo1 / Q1 + Wo1**2)
H2 = veces(-0.10947355039605151) * s**2 / (s**2 + s * Wo2 / Q2 + Wo2**2)
H3 = veces(-0.12928908650773577) * s**2 / (s**2 + s * Wo3 / Q3 + Wo3**2)
H4 = veces(-0.1434825614451729) * s**2 / (s**2 + s * Wo4 / Q4 + Wo4**2)
H5 = veces(-0.035653959985164595) * s**2 / (s**2 + s * Wo5 / Q5 + Wo5**2)
H6 = veces(0.5186397040040062) * s**2 / (s**2 + s * Wo6 / Q6 + Wo6**2)

H = [H1, H2, H3, H4, H5, H6]

for i in range(len(H)):
    if i != 0:
        H[i] = H[i - 1] * H[i]
for i in range(len(H)):
    H[i] = algebra.conseguir_tf(H[i], s)
Ejemplo n.º 7
0
Q4 = 1.19
Wo5 = 2 * pi * 25958.29
Q5 = 0.76
Wo6 = 2 * pi * 34110.10
Q6 = 0.53

H1 = s**2 / (s**2 + s * Wo1 / Q1 + Wo1**2)
H2 = s**2 / (s**2 + s * Wo2 / Q2 + Wo2**2)
H3 = s**2 / (s**2 + s * Wo3 / Q3 + Wo3**2)
H4 = s**2 / (s**2 + s * Wo4 / Q4 + Wo4**2)
H5 = s**2 / (s**2 + s * Wo5 / Q5 + Wo5**2)
H6 = s**2 / (s**2 + s * Wo6 / Q6 + Wo6**2)

conjunto = H1 * H2 * H3 * H4 * H5 * H6

w, mag, pha = signal.bode(algebra.conseguir_tf(conjunto, s), [1e7 * 2 * pi])
total_gain = -mag[0]

#
# print("total_gain = ", total_gain)
# conjunto = H1 * H2 * H3 * H4 * H5 * total_gain
#
# mag, pha, w = signal.bode(algebra.conseguir_tf(conjunto, s),1e6)
# total_gain = -mag[0]
print("total_gain = ", total_gain)
#
#
transf = [H1, H2, H3, H4, H5, H6]

transf = [etapas.EtapaEA(i, s) for i in transf]
transf[0].name = "1"
Ejemplo n.º 8
0
 def __init__(self, expr, var):
     self.tf = conseguir_tf(expr, var)
     self.gain = 0
Ejemplo n.º 9
0
K = 0.162
C = 680e-12
a = 0.033
R2 = 20.5e3


H1 = (1/(1-K))*(a*s/(C*R1))/((s**2) + s*(2/(C*R2))*(1-(R2*K/(2*R1*(1-K)))) + (1/((C**2)*R1*R2)))

R1 = 1.39e3
K = 0.165
C = 1e-9
a = 0.033
R2 = 12.6e3

H2 = (1/(1-K))*(a*s/(C*R1))/((s**2) + s*(2/(C*R2))*(1-(R2*K/(2*R1*(1-K)))) + (1/((C**2)*R1*R2)))


H = H1*H2

#print(coef)

K = 0.162
C = 470e-12
R2 = 29.7e3

Zin = 100000/(1 - H1*(((1-K)/(s*C*R2)) + K))

tf = algebra.conseguir_tf(H, s)

tfZin = algebra.conseguir_tf(Zin, s)
Ejemplo n.º 10
0
R1 = 1.5e3
RA = 2.2e3
RB = 2e3
K = 1 + (RB / RA)
C = 100e-9
R2 = 1.5e3
a = 1.5 / 2.2

H2 = (a * K / (R1 * R2 * (C**2))) / ((s)**2 + s * (((1 / R1) +
                                                    ((2 - K) / R2)) / (C)) +
                                     (1 / (R1 * R2 * (C**2))))

Cf = 100e-9
Rf = 1.8e3
Rr = 2.9e3

H3 = Rf / (Rr * (s * Cf * Rf + 1))

bH = algebra.conseguir_tf(-H1 * H2 * H3, s)

R1 = 172e3
RA = 10e3
RB = 2.2e3
K = 1 + (RB / RA)
C = 1e-9
R2 = 172e3
a = 1

bZin = algebra.conseguir_tf(
    R1 / (a * (1 - (H1 * RA * (s * C * R2 + 1) / (RA + RB)))), s)