How to plot Shockley diode current in Python using UliEngineering

You can easily plot the Shockley diode current in both linear and logarithmic form using the UliEngineering Python library.

plot_shockley_diode_current.py
from UliEngineering.Electronics.Diode import shockley_diode_current
import matplotlib.pyplot as plt
import numpy as np

plt.style.use('ggplot')

voltages = np.linspace(0, 0.8, 400)
current = shockley_diode_current(voltages, "1pA")

# Linear plot
plt.figure(figsize=(6, 4))
plt.plot(voltages, current)
plt.title('Shockley diode current (linear)')
plt.xlabel('Voltage (V)')
plt.ylabel('Current (A)')
plt.grid(True, which='both', linestyle='--', linewidth=0.5)
plt.tight_layout()
plt.savefig('shockley_diode_current_linear.svg')
plt.close()

# Log plot
plt.figure(figsize=(6, 4))
plt.plot(voltages, np.maximum(current, 1e-20))
plt.title('Shockley diode current (log)')
plt.xlabel('Voltage (V)')
plt.ylabel('Current (A)')
plt.yscale('log')
plt.grid(True, which='both', linestyle='--', linewidth=0.5)
plt.tight_layout()
plt.savefig('shockley_diode_current_log.svg')

shockley diode current linear.svg

shockley diode current log.svg


Check out similar posts by category: Electronics, Python