From b9587903789182001f5a09616da2caa8f23722d3 Mon Sep 17 00:00:00 2001 From: Oscar Suescun Elizalde Date: Mon, 7 Apr 2025 13:22:22 +0200 Subject: [PATCH] actualizacion --- src/funcionesSim.py | 47 +++++++++++----------- src/simulador/modelo_transitorio_1.op.raw | Bin 1436 -> 1436 bytes src/simulador/modelo_transitorio_1.raw | Bin 409686 -> 409686 bytes 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/funcionesSim.py b/src/funcionesSim.py index 88058ea..a38f9f0 100644 --- a/src/funcionesSim.py +++ b/src/funcionesSim.py @@ -63,25 +63,30 @@ def simular(tensionCap, Rtotal, Lbobina, Ctotal, lts_path, tSim = 100e-3, toff_s simulador.run(netlist) - for raw_path, log_path in simulador: - raw = RawRead(raw_path) + raw_path, log_path = next(iter(simulador)) # Obtener el único resultado + raw = RawRead(raw_path) + + try: + return { + 'tiempo': np.array(raw.get_trace('time')), + 'vCap': np.array(raw.get_trace('V(condensador)')), + 'vBob': np.array(raw.get_trace('V(v1)')) - np.array(raw.get_trace('V(v2)')), + 'iBob': np.array(raw.get_trace('I(L1)')) + } + except KeyError as e: + print(f'Error al leer señal del archivo .raw: {e}') + return None - try: - return{ - 'tiempo' : np.array(raw.get_trace('time')), - 'vCap' : np.array(raw.get_trace('V(condensador)')), - 'vBob' : np.array(raw.get_trace('V(V1)')) - np.array(raw.get_trace('V(V2)')), - 'iBob' : np.array(raw.get_trace('I(L1)')) - } - - except KeyError as e: - print(f'Error: {e}') - return None +def dibujar(resultado): + plt.figure() + plt.plot(resultado['tiempo'], resultado['vCap'], label='Tension Cap [V]') + plt.plot(resultado['tiempo'], resultado['vBob'], label='Tension Bobina [V]') + plt.plot(resultado['tiempo'], resultado['iBob'], label='Corriente Bobina [A]') + plt.grid() + plt.legend() + plt.show() - - - if __name__ == '__main__': lts_path = "C:/Users/osuescuneli/AppData/Local/Programs/ADI/LTspice/LTspice.exe" @@ -105,11 +110,5 @@ if __name__ == '__main__': toff_sw = tiempoSwitch, ton_mos = tiempoMos) - - plt.figure() - plt.plot(resultado['tiempo'], resultado['vCap'], label='Tension Cap [V]') - plt.plot(resultado['tiempo'], resultado['vBob'], label='Tension Bobina [V]') - plt.plot(resultado['tiempo'], resultado['iBob'], label='Corriente Bobina [A]') - plt.grid() - plt.legend() - plt.show() \ No newline at end of file + dibujar(resultado) + \ No newline at end of file diff --git a/src/simulador/modelo_transitorio_1.op.raw b/src/simulador/modelo_transitorio_1.op.raw index 38d465ab49e9af5fd7a49a5475802dad7f16a33b..957afab60124ac4f3fb061993143c5efb618820b 100644 GIT binary patch delta 24 ccmbQkJ%@Y330`9cD+VJ5LojK+@#=9F08hjQcmMzZ delta 24 dcmbQkJ%@Y330@-xD+Ut=5NX65B-V+Jb*BL+h-Y2J9X^(tfQRi@Uf%&k{hTCcKhy~@^T4**t`5H0`! delta 44 ycmccCAbG7pa>5B-BL*u569y1z#9-QZwe>1v>s6-KtIVxeSz52MZoSIZXb%8ZpAaqp