Uncertainty quantification of non-elliptical cavities¶
A uq_config works on every shape, with the shape’s own names for its dimensions. This
guide puts a manufacturing tolerance on a control point of a spline cavity and on a wall
of an RF gun, and reads the spread of the frequency and R/Q that follows. The
uncertainty quantification guide describes every setting.
import os
import tempfile
import numpy as np
import matplotlib.pyplot as plt
from cavsim2d import Study, SplineCavity, RFGun
from cavsim2d.utils.style import apply_style
apply_style()
1. A spline cavity: a tolerance on a control point¶
A spline’s dimensions are its control-point coordinates. Here p3_r, the radius of the
equator control point p3, varies by up to 0.5 mm either side of its nominal value:
with the Stroud3 rule, delta is the half-width of a uniform spread, in the shape’s
own unit, millimetres for a spline.
geom = {'p0': [0, 35], 'p1': [0, 70], 'p2': [30, 103],
'p3': [85, 103], 'p4': [115, 70], 'p5': [115, 35]}
cavs = Study(os.path.join(tempfile.mkdtemp(), 'spline_uq'))
cavs.add_cavity([SplineCavity({'geometry': dict(geom)}, kind='Bezier')], ['SPLINE'])
cavs.run_eigenmode({
'boundary_conditions': 'mm',
'uq_config': {
'variables': ['p3_r'],
'delta': [0.5], # mm
'method': ['Quadrature', 'Stroud3'],
'objectives': ['monopole:freq [MHz]', 'monopole:R/Q [Ohm]'],
},
})
cavs['SPLINE'].eigenmode.uq_df[['nominal', 'mean', 'std']].round(4)
| nominal | mean | std | |
|---|---|---|---|
| objective | |||
| monopole:freq [MHz] | 1534.0576 | 1534.0586 | 1.4452 |
| monopole:R/Q [Ohm] | 103.4250 | 103.4248 | 0.0146 |
2. An RF gun: a tolerance on a wall¶
The same call on an RF gun, with a tolerance of up to 0.5 mm on L3, the long straight
wall from the cathode nose outward, which sets the gun’s frequency more than any other
dimension. A gun’s dimensions are in metres, so the tolerance is written 5e-4.
gun = {'geometry': {'y1': 1.5e-2, 'R2': 3e-2, 'T2': np.deg2rad(45), 'L3': 24e-2,
'R4': 5e-2, 'L5': 11e-2, 'R6': 6e-2, 'L7': 19e-2, 'R8': 4e-2,
'T9': np.deg2rad(8), 'R10': 3e-2, 'T10': np.deg2rad(40),
'L11': 5e-2, 'R12': 3e-2, 'L13': 3e-2, 'R14': 3e-2, 'x': 1e-2}}
cavs_g = Study(os.path.join(tempfile.mkdtemp(), 'gun_uq'))
cavs_g.add_cavity([RFGun(gun)], ['GUN'])
cavs_g.run_eigenmode({
'boundary_conditions': 'mm',
'uq_config': {
'variables': ['L3'],
'delta': [5e-4], # m
'method': ['Quadrature', 'Stroud3'],
'objectives': ['monopole:freq [MHz]', 'monopole:R/Q [Ohm]'],
},
})
cavs_g['GUN'].eigenmode.uq_df[['nominal', 'mean', 'std']].round(4)
| nominal | mean | std | |
|---|---|---|---|
| objective | |||
| monopole:freq [MHz] | 213.0660 | 213.0650 | 0.1966 |
| monopole:R/Q [Ohm] | 133.5339 | 133.6572 | 0.3359 |
A tolerance of up to 0.5 mm on the spline’s equator control point spreads its frequency
by 1.4452 MHz, one standard deviation, around a mean of 1534.0586 MHz, while R/Q hardly
moves, by 0.0146 Ohm. The same tolerance on the gun’s L3 spreads its frequency by
0.1966 MHz around 213.0650 MHz, and its R/Q by 0.3359 Ohm. Relative to the frequency,
the two spreads are about the same, 0.09 % in both.
3. The spread, at a glance¶
plot_fm_scatter(uq=True) draws each figure of merit’s mean with a bar of one standard
deviation either side, beside the nominal design, and writes the mean and the
standard deviation in the corner of each panel (show_stats=False leaves them out).
cavs.eigenmode.plot_fm_scatter(uq=True, qois=['freq', 'R/Q']);
See also: the shape how-to guides for spline cavities and RF guns, robust tuning and robust optimisation.