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 38d465a..957afab 100644 Binary files a/src/simulador/modelo_transitorio_1.op.raw and b/src/simulador/modelo_transitorio_1.op.raw differ diff --git a/src/simulador/modelo_transitorio_1.raw b/src/simulador/modelo_transitorio_1.raw index cab0baf..62b4646 100644 Binary files a/src/simulador/modelo_transitorio_1.raw and b/src/simulador/modelo_transitorio_1.raw differ