Skip to content

Instantly share code, notes, and snippets.

@rezamarzban
Created November 7, 2025 05:29
Show Gist options
  • Select an option

  • Save rezamarzban/5d2a2a77d65f08eee87e143c88ebc187 to your computer and use it in GitHub Desktop.

Select an option

Save rezamarzban/5d2a2a77d65f08eee87e143c88ebc187 to your computer and use it in GitHub Desktop.
Hull split-anode design, Pulse width: 0.56 μs (time to reach $V_{bd}$). Off time: 50 μs. Duty cycle: 1.1%, 1 mm glass coating, conservative thermal limits
import math
import numpy as np
import matplotlib.pyplot as plt
# Constants
epsilon_0 = 8.85e-12 # F/m (vacuum permittivity)
mu_0 = 4 * math.pi * 1e-7 # H/m (vacuum permeability)
k_glass = 1.0 # W/m·K (thermal conductivity of glass)
epsilon_r = 5.0 # relative permittivity of glass
delta_T_max = 50.0 # Maximum temperature rise (°C)
eta = 0.2 # Efficiency
V_d_over_V_c = 0.1 # Dielectric volume fraction
d_coating = 0.001 # m (coating thickness)
d_gap = 0.0025 # m (anode-cathode gap)
wire_r = 0.0005 # m (wire radius for inductance)
r_a = 0.005 # m (anode radius)
h = 0.02 # m (anode height)
r_c = r_a / 2 # m (cathode radius, assumed half)
m_e = 9.1093837e-31 # kg (electron mass)
e = 1.60217662e-19 # C (electron charge)
V_bd = 10000 # V (breakdown voltage)
tau_leak = 0.001 # s (leakage time constant)
I_a_peak = 0.01 # A (peak anode current during pulse)
N_pulses = 20 # Number of pulses
off_time = 50e-6 # s (off time per cycle)
arc_duration = 1e-6 # s (arc duration, increased for visibility in plot)
P_out_peak = 10 # W (assumed peak RF power during arc)
# Step 1: Thermal calculations
A_thermal = 2 * math.pi * r_a * h # Anode surface area (m²)
P_heat_max = (k_glass * A_thermal * delta_T_max) / d_coating # Max heat loss (W)
P_in_avg = P_heat_max / (1 - eta) # Average input power (W)
P_out_avg = eta * P_in_avg # Average output RF power (W)
# Step 2: LC circuit for original resonant frequency
A_cap = math.pi * r_a * h / 2 # Capacitive area between segments (m²)
C = epsilon_0 * A_cap / d_gap # Capacitance (F)
l_loop = 2 * math.pi * r_a # Loop length for inductance (m)
L = mu_0 * (l_loop / (2 * math.pi)) * math.log(2 * l_loop / wire_r) # Inductance (H)
f_original = 1 / (2 * math.pi * math.sqrt(L * C)) / 1e6 # Original frequency (MHz)
# Step 3: Detuned frequency due to coating
delta_f_over_f = -((epsilon_r - 1) * V_d_over_V_c) / 2 # Relative shift
f_new = f_original * (1 + delta_f_over_f) # Detuned frequency (MHz)
# Step 4: Magnetic field B (Hartree condition approximation for split-anode)
omega_RF = 2 * math.pi * (f_new * 1e6) # RF angular frequency (rad/s)
omega_s = omega_RF # Spoke angular velocity (for basic split-anode mode)
B = (2 * m_e * omega_s) / e # Required magnetic field (T)
# Step 5: Magnetic flux Φ through interaction space
area_interaction = math.pi * (r_a**2 - r_c**2) # Cross-sectional area (m²)
Phi = B * area_interaction * h # Total flux (Wb)
# Step 6: Hartree threshold voltage V_T
V_T = 0.5 * omega_s * B * (r_a**2 - r_c**2) - (m_e / (2 * e)) * omega_s**2 * r_a**2 # Anode voltage (V)
# Step 7: Pulse width calculation
pulse_width = V_bd * C / I_a_peak # Time to reach V_bd (s)
# Step 8: Simulation of Vs(t), RF power(t), and I_a(t)
dt = 0.1e-6 # Time step (s)
total_time = N_pulses * (pulse_width + off_time) # Total simulation time (s)
time = np.arange(0, total_time, dt)
Vs = np.zeros_like(time)
RF_power = np.zeros_like(time) # Instantaneous RF power
I_a = np.zeros_like(time) # Instantaneous anode current
for i in range(len(time)):
t = time[i]
cycle_num = int(t / (pulse_width + off_time))
t_in_cycle = t % (pulse_width + off_time)
if t_in_cycle < pulse_width:
# Charging phase
Vs[i] = min(V_bd, I_a_peak * t_in_cycle / C)
I_a[i] = I_a_peak # Constant current during charging
RF_power[i] = 0 # No RF until breakdown
else:
# Decay phase
time_since_breakdown = t_in_cycle - pulse_width
Vs[i] = V_bd * np.exp(-time_since_breakdown / tau_leak)
I_a[i] = 0 # Off during decay
RF_power[i] = 0
# Add RF power and higher current during arc after breakdown (short window for visibility)
arc_start = pulse_width
arc_end = pulse_width + arc_duration
if arc_start <= t_in_cycle < arc_end:
RF_power[i] = P_out_peak
I_a[i] = I_a_peak * 5 # Higher current during breakdown arc
# Step 9: Plotting
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(10, 12))
# Plot Vs vs time
ax1.plot(time * 1e6, Vs / 1000, 'b-', label='Vs(t)')
ax1.set_xlabel('Time (μs)')
ax1.set_ylabel('Surface Voltage Vs (kV)')
ax1.set_title('Surface Voltage Vs vs Time')
ax1.grid(True)
ax1.legend()
# Plot RF power vs time
ax2.plot(time * 1e6, RF_power, 'r-', label='RF Power')
ax2.set_xlabel('Time (μs)')
ax2.set_ylabel('RF Power (W)')
ax2.set_title('RF Radiation Power vs Time')
ax2.grid(True)
ax2.legend()
# Plot anode current vs time
ax3.plot(time * 1e6, I_a * 1000, 'g-', label='I_a(t)')
ax3.set_xlabel('Time (μs)')
ax3.set_ylabel('Anode Current I_a (mA)')
ax3.set_title('Anode Current vs Time')
ax3.grid(True)
ax3.legend()
plt.tight_layout()
plt.show()
# Output results
print("=== Magnetron Calculation Results ===")
print(f"Anode Surface Area (A_thermal): {A_thermal:.6f} m²")
print(f"Maximum Heat Loss (P_heat_max): {P_heat_max:.2f} W")
print(f"Average Input Power (P_in_avg): {P_in_avg:.2f} W")
print(f"Average RF Output Power (P_out_avg): {P_out_avg:.2f} W")
print(f"Capacitance (C): {C:.2e} F")
print(f"Inductance (L): {L:.2e} H")
print(f"Original Resonant Frequency (f_original): {f_original:.1f} MHz")
print(f"Detuned RF Frequency (f_new): {f_new:.1f} MHz")
print(f"Required Magnetic Field (B): {B:.4f} T")
print(f"Magnetic Flux (Φ): {Phi:.2e} Wb")
print(f"Needed Anode Voltage (V_T): {V_T:.0f} V")
print(f"Pulse Width: {pulse_width * 1e6:.2f} μs")
print(f"Duty Cycle Approx: { (pulse_width / (pulse_width + off_time)) * 100 :.1f}%")
print("Plots displayed.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment