<jupyter_start><jupyter_text>Compare Theoretical Waveguide Loss to HFSS<jupyter_code>import numpy as np 
import matplotlib.pyplot as plt 
import scipy.constants as sc
import skrf as rf

from waveguide import conductor_loss, dielectric_loss

plt.style.use(["science", "notebook"])<jupyter_output><empty_output><jupyter_text>ParametersThese parameters match the HFSS simulation<jupyter_code># Waveguide dimensions
a, b, d = 224.65*sc.mil, 112.35*sc.mil, 4.0045*sc.inch
# Waveguide walls (gold)
cond = 4.1e7  # conductivity, S/m

# Dielectric filling (HDPE)
er_mag = 2.3  # relative permittivity (magnitude)
tand = 1e-4   # loss tangent
er = er_mag * (1 - 1j * tand)
# Frequency sweep
f = np.linspace(26.8, 43.5, 17001) * 1e9<jupyter_output><empty_output><jupyter_text>Theory<jupyter_code># Empty waveguide
alphac1_theory = conductor_loss(f, cond, a, b, er=1, ur=1)
alpha1_theory = alphac1_theory.copy()

# Dielectric filled waveguide
alphac2_theory = conductor_loss(f, cond, a, b, er=er, ur=1)
alphad2_theory = dielectric_loss(f, a, b, er=er, ur=1, m=1, n=0)
alpha2_theory = alphac2_theory + alphad2_theory<jupyter_output><empty_output><jupyter_text>HFSS<jupyter_code>hfss1 = rf.Network("hfss/WR22-4inch.s2p")       # empty waveguide
hfss2 = rf.Network("hfss/WR22-4inch-hdpe.s2p")  # HDPE-filled waveguide<jupyter_output><empty_output><jupyter_text>Compare<jupyter_code>fig, ax = plt.subplots()
hfss1.plot_s_db(1, 0, ax=ax, label="HFSS")
ax.plot(f, -alpha1_theory * d * 8.686, 'r--', label="Theory")
ax.legend();
fig, ax = plt.subplots()
hfss2.plot_s_db(1, 0, ax=ax, label="HFSS")
ax.plot(f, -alpha2_theory * d * 8.686, 'r--', label="Theory")
ax.legend();<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14319667260843733, 'fraction_numerical': 0.0457516339869281, 'mean_word_length': 6.227467811158799, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '55800', 'license': 'MIT', 'n_tokens_mistral': 772, 'n_tokens_neox': 691, 'n_words': 138, 'path': 'examples/compare-loss-to-hfss.ipynb', 'repo_name': 'garrettj403/Waveguide', 'size': '1683'}