OncomIA Claude Opus 5.5 commited on
Commit ·
f5f5765
1
Parent(s): 77ba96d
Corrige dos casos del diseño por asignación de polos
Browse files- Ecuación de igualación de coeficientes que se reduce a 0 = 0.
- Planta bipropia con ganancia negativa: se explica en vez de fallar.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- nucleo.py +2 -0
- paneles.py +10 -1
nucleo.py
CHANGED
|
@@ -1031,6 +1031,8 @@ def lin_tex(e):
|
|
| 1031 |
def poly_sym_tex(P, var="s"):
|
| 1032 |
"""Polinomio en s con coeficientes que dependen de las incógnitas, por potencias."""
|
| 1033 |
P = sp.Poly(sp.expand(P), s)
|
|
|
|
|
|
|
| 1034 |
out = ""
|
| 1035 |
for k in range(P.degree(), -1, -1):
|
| 1036 |
c = P.coeff_monomial(s ** k)
|
|
|
|
| 1031 |
def poly_sym_tex(P, var="s"):
|
| 1032 |
"""Polinomio en s con coeficientes que dependen de las incógnitas, por potencias."""
|
| 1033 |
P = sp.Poly(sp.expand(P), s)
|
| 1034 |
+
if P.is_zero:
|
| 1035 |
+
return "0"
|
| 1036 |
out = ""
|
| 1037 |
for k in range(P.degree(), -1, -1):
|
| 1038 |
c = P.coeff_monomial(s ** k)
|
paneles.py
CHANGED
|
@@ -1021,9 +1021,18 @@ def disenar(planta, tipo, Mp, ts, banda, r_extra, N_sim):
|
|
| 1021 |
if est != "estable":
|
| 1022 |
return "\n\n".join(md), gf.figura_error("Lazo cerrado no estable."), gf.figura_error("—"), (kp, ki, kd)
|
| 1023 |
T_hor = max(2.5 * ts, horizonte(T.polos_np()))
|
| 1024 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1025 |
yinf = float(T.N.eval(0) / T.D.eval(0))
|
| 1026 |
met = metricas_escalon(sim["t"], sim["y"], yinf)
|
|
|
|
|
|
|
|
|
|
| 1027 |
cumpleM = met["Mp"] <= Mp * 1.02 + 0.2
|
| 1028 |
cumpleT = met["ts2" if banda == 2 else "ts5"] <= ts * 1.02
|
| 1029 |
md.append(f"| | Especificación | Obtenido en simulación | |\n|:--|:--:|:--:|:--:|\n"
|
|
|
|
| 1021 |
if est != "estable":
|
| 1022 |
return "\n\n".join(md), gf.figura_error("Lazo cerrado no estable."), gf.figura_error("—"), (kp, ki, kd)
|
| 1023 |
T_hor = max(2.5 * ts, horizonte(T.polos_np()))
|
| 1024 |
+
try:
|
| 1025 |
+
sim = simula_pid(G, kp, ki, kd, N=N_sim, t_end=T_hor)
|
| 1026 |
+
except (ValueError, RuntimeError) as e:
|
| 1027 |
+
md.append(caja("aviso", "No se puede simular este diseño",
|
| 1028 |
+
f"{e} Con una planta bipropia, una ganancia negativa puede dejar el lazo sin sentido físico: "
|
| 1029 |
+
"revise las especificaciones o el tipo de controlador."))
|
| 1030 |
+
return "\n\n".join(md), gf.figura_error("Diseño no simulable."), gf.figura_error("—"), (kp, ki, kd)
|
| 1031 |
yinf = float(T.N.eval(0) / T.D.eval(0))
|
| 1032 |
met = metricas_escalon(sim["t"], sim["y"], yinf)
|
| 1033 |
+
if not met:
|
| 1034 |
+
md.append("No se han podido medir las especificaciones sobre la respuesta simulada.")
|
| 1035 |
+
return "\n\n".join(md), gf.figura_error("Sin valor final medible."), gf.figura_error("—"), (kp, ki, kd)
|
| 1036 |
cumpleM = met["Mp"] <= Mp * 1.02 + 0.2
|
| 1037 |
cumpleT = met["ts2" if banda == 2 else "ts5"] <= ts * 1.02
|
| 1038 |
md.append(f"| | Especificación | Obtenido en simulación | |\n|:--|:--:|:--:|:--:|\n"
|