summaryrefslogtreecommitdiff
path: root/MIL_testing/reading_output.py
diff options
context:
space:
mode:
authorYour Name <[email protected]>2026-07-14 12:20:20 -0700
committerYour Name <[email protected]>2026-07-14 21:04:43 -0700
commit99c240a1c69da19813c50f167cd51456208479d2 (patch)
tree958d1d99fa8ab24d84f42de4fe18021e7dff1a4d /MIL_testing/reading_output.py
parent4f36a1654ff6560c915a39e1f9999e0efc4a9680 (diff)
backup before big change
Diffstat (limited to 'MIL_testing/reading_output.py')
-rw-r--r--MIL_testing/reading_output.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/MIL_testing/reading_output.py b/MIL_testing/reading_output.py
new file mode 100644
index 0000000..3e37dfe
--- /dev/null
+++ b/MIL_testing/reading_output.py
@@ -0,0 +1,36 @@
+from spicelib import RawRead
+import matplotlib.pyplot as plt
+
+raw = RawRead("simulation.raw")
+print(raw.get_trace_names())
+
+time = raw.get_trace("time").get_wave()
+current = raw.get_trace("i(v.xmem.v_emem)").get_wave()
+voltage = raw.get_trace("v(in)").get_wave()
+state_variable = raw.get_trace("v(xmem.x)").get_wave()
+
+print(f"final current: {current[-1]}")
+
+print(f"state variable : {state_variable[-1]}")
+
+# Create a figure with two stacked subplots
+fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(10, 8), sharex=True)
+
+# 1. Plot Current vs Time
+ax1.plot(time, current, color='blue', linewidth=2, label='Memristor Current')
+ax1.set_ylabel('Current (A)')
+ax1.set_title('Memristor Simulation Results')
+ax1.grid(True, linestyle='--', alpha=0.7)
+ax1.legend()
+
+# 2. Plot Voltage vs Time
+ax2.plot(time, voltage, color='red', linewidth=2, label='Input Voltage v(in)')
+ax2.set_xlabel('Time (s)')
+ax2.set_ylabel('Voltage (V)')
+ax2.grid(True, linestyle='--', alpha=0.7)
+ax2.legend()
+
+# Adjust layout to prevent overlap and display the plot
+plt.tight_layout()
+plt.savefig("memristor_waveforms.png", dpi=300, bbox_inches='tight')
+print("Saved waveforms to memristor_waveforms.png")