actualizacion

This commit is contained in:
Oscar Suescun Elizalde 2025-04-07 13:22:22 +02:00
parent 8a19683b30
commit b958790378
3 changed files with 23 additions and 24 deletions

View File

@ -63,25 +63,30 @@ def simular(tensionCap, Rtotal, Lbobina, Ctotal, lts_path, tSim = 100e-3, toff_s
simulador.run(netlist) simulador.run(netlist)
for raw_path, log_path in simulador: raw_path, log_path = next(iter(simulador)) # Obtener el único resultado
raw = RawRead(raw_path) 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: def dibujar(resultado):
return{ plt.figure()
'tiempo' : np.array(raw.get_trace('time')), plt.plot(resultado['tiempo'], resultado['vCap'], label='Tension Cap [V]')
'vCap' : np.array(raw.get_trace('V(condensador)')), plt.plot(resultado['tiempo'], resultado['vBob'], label='Tension Bobina [V]')
'vBob' : np.array(raw.get_trace('V(V1)')) - np.array(raw.get_trace('V(V2)')), plt.plot(resultado['tiempo'], resultado['iBob'], label='Corriente Bobina [A]')
'iBob' : np.array(raw.get_trace('I(L1)')) plt.grid()
} plt.legend()
plt.show()
except KeyError as e:
print(f'Error: {e}')
return None
if __name__ == '__main__': if __name__ == '__main__':
lts_path = "C:/Users/osuescuneli/AppData/Local/Programs/ADI/LTspice/LTspice.exe" lts_path = "C:/Users/osuescuneli/AppData/Local/Programs/ADI/LTspice/LTspice.exe"
@ -105,11 +110,5 @@ if __name__ == '__main__':
toff_sw = tiempoSwitch, toff_sw = tiempoSwitch,
ton_mos = tiempoMos) ton_mos = tiempoMos)
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()