Skip to content

Commit 4ed52f6

Browse files
author
John Garrett
committed
readme: add example showing cutoff frequencies
1 parent 342f9f5 commit 4ed52f6

File tree

1 file changed

+69
-17
lines changed

1 file changed

+69
-17
lines changed

README.md

Lines changed: 69 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
Waveguide
22
=========
33

4-
*Calculate the properties of rectangular waveguides*
4+
*Calculate the various properties of rectangular waveguides*
55

6-
Example: Simple Waveguide
7-
-------------------------
6+
For example:
7+
- Cutoff frequency
8+
- Phase constant
9+
- Attenuation constant due to conductor and/or dielectric loss
10+
11+
Example 1: Properties of a WR-90 Waveguide
12+
------------------------------------------
813

914
WR-90 waveguide:
1015
```python
1116
import numpy as np
1217
import scipy.constants as sc
1318
import matplotlib.pyplot as plt
14-
import waveguide as wg
19+
from waveguide import phase_constant, attenuation_constant
1520

16-
# WR-90
17-
a, b = 0.9*sc.inch, 0.45*sc.inch
21+
# WR-90 waveguide dimensions
22+
a, b = 0.9 * sc.inch, 0.45 * sc.inch
1823

19-
# Conductivity, S/m
24+
# Conductivity of waveguide walls, S/m
2025
cond = 2e7
2126

2227
# Frequency sweep
@@ -25,7 +30,7 @@ freq = np.linspace(7, 13, 100) * sc.giga
2530

2631
Phase constant:
2732
```python
28-
beta = wg.phase_constant(freq, a, b, cond=cond)
33+
beta = phase_constant(freq, a, b, cond=cond)
2934

3035
plt.figure()
3136
plt.plot(freq/1e9, beta)
@@ -34,36 +39,81 @@ plt.xlabel("Frequency (GHz)")
3439
plt.xlim([7, 13])
3540
```
3641

42+
<p align="center">
3743
<img src="https://raw.githubusercontent.com/garrettj403/Waveguide/main/examples/results/simple-waveguide-phase-constant.png" width="500">
44+
</p>
3845

3946
Attenuation constant:
4047
```python
41-
alpha = wg.attenuation_constant(freq, a, b, cond=cond)
48+
alpha = attenuation_constant(freq, a, b, cond=cond)
4249

4350
plt.figure()
4451
plt.plot(freq/1e9, alpha)
45-
plt.ylabel(r"Attenuation constant, $\beta$ (Np/m)")
52+
plt.ylabel(r"Attenuation constant, $\alpha$ (Np/m)")
4653
plt.xlabel("Frequency (GHz)")
4754
plt.xlim([7, 13])
4855
```
4956

57+
<p align="center">
5058
<img src="https://raw.githubusercontent.com/garrettj403/Waveguide/main/examples/results/simple-waveguide-attenuation-constant.png" width="500">
59+
</p>
60+
61+
Example 2: Cutoff Frequencies
62+
-----------------------------
63+
64+
```python
65+
import numpy as np
66+
import scipy.constants as sc
67+
from waveguide import cutoff_frequency
68+
69+
# Waveguide sizes to analyze (EIA designations)
70+
wr_sizes = np.array([28, 22.4, 18.8, 14.8, 12.2, 10, 6.5, 5.1, 4.3, 3.4, 2.8])
71+
72+
# Calculate cutoff frequencies
73+
f_center = np.empty_like(wr_sizes)
74+
f1 = np.empty_like(wr_sizes)
75+
f2 = np.empty_like(wr_sizes)
76+
for i, _wr in np.ndenumerate(wr_sizes):
77+
a = _wr * 10 * sc.mil # waveguide width
78+
f1[i] = cutoff_frequency(a, a/2, m=1, n=0) * 1.25 # TE10
79+
f2[i] = cutoff_frequency(a, a/2, m=2, n=0) * 0.95 # TE20
80+
f_center[i] = (f1[i] + f2[i]) / 2
81+
82+
# Plot
83+
fig, ax = plt.subplots(figsize=(12,12))
84+
ax.loglog(wr_sizes, f_center/1e9, 'ko')
85+
ax.errorbar(wr_sizes, f_center/1e9, yerr=[(f_center-f1)/1e9, -(f_center-f2)/1e9], c='k', fmt='o', ls='--', capsize=5, capthick=2)
86+
ax.set_xlabel("\nEIA waveguide designation (\"WR-\")")
87+
ax.set_ylabel("Frequency range (GHz)")
88+
ax.set_ylim([20, 500])
89+
ax.grid(which='both')
90+
plt.yticks(ticks=[20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500],
91+
labels=[20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500])
92+
ax.set_xticks(ticks=wr_sizes, minor=False)
93+
ax.set_xticks(ticks=[], minor=True)
94+
plt.xticks(ticks=wr_sizes, labels=wr_sizes, rotation=90)
95+
96+
```
97+
98+
<p align="center">
99+
<img src="https://raw.githubusercontent.com/garrettj403/Waveguide/main/examples/results/waveguide-loss-cutoff-frequency.png" width="500">
100+
</p>
51101

52-
Example: Alumina-Filled Waveguide
53-
---------------------------------
102+
Example 3: Alumina-Filled WR-28 Waveguide
103+
-----------------------------------------
54104

55-
WR-28 waveguide filled with 1 inch alumina slug
105+
WR-28 waveguide filled with 1 inch long alumina slug:
56106
```python
57107
import numpy as np
58108
import scipy.constants as sc
59109
import matplotlib.pyplot as plt
60110

61111
import waveguide as wg
62112

63-
# WR-28
64-
a, b = 0.28*sc.inch, 0.14*sc.inch
113+
# WR-28 waveguide dimensions
114+
a, b = 0.28 * sc.inch, 0.14 * sc.inch
65115

66-
# Conductivity
116+
# Conductivity of waveguide walls, S/m
67117
cond = 1.8e7
68118

69119
# Frequency sweep
@@ -72,7 +122,7 @@ freq = np.linspace(22, 42, 401) * sc.giga
72122
# Relativity permittivity
73123
er = 9.3
74124

75-
# Alumina length
125+
# Alumina length, m
76126
length = 1 * sc.inch
77127

78128
# Section lengths
@@ -91,4 +141,6 @@ plt.xlabel("Frequency (GHz)")
91141
plt.xlim([22, 42])
92142
```
93143

144+
<p align="center">
94145
<img src="https://raw.githubusercontent.com/garrettj403/Waveguide/main/examples/results/alumina-filled-waveguide-sparam.png" width="500">
146+
</p>

0 commit comments

Comments
 (0)