analysis_modules.eigenmode.customEig package

Submodules

analysis_modules.eigenmode.customEig.compute_QoIs module

analysis_modules.eigenmode.customEig.run_field_solver module

class analysis_modules.eigenmode.customEig.run_field_solver.Model(folder, name, parent_dir=None)[source]

Bases: object

Methods

calculate_U(EE, HH, zz, rr)

Calculates the energy \(U_n\) of eigenmode \(n\) from either electric or magnetic field.

calculate_bpk(Hpk, Eacc)

Calculates the peak surface magnetic field to accelerating field ratio

calculate_disspated_power(H_surf, z_surf, r_surf)

Calculates the dissipated power from the cavity walls

calculate_epk(Epk, Eacc)

Calculates the peak surface electric field to accelerating field ratio

calculate_fields()

Calculate the fields from the eigenvectors

calculate_g()

Calculates the geometry or form factor for the cavity

calculate_loss_factor(R_Q)

Calculates fundamental mode loss factor

calculate_rq(Vacc, U)

Calculates the \(R/Q_\parallel\) of the accelerating mode.

calculate_surface_resistance_copper()

Calculates the surface resistance for Copper with conductivity

calculate_vacc(z, E_z_axis)

Calculates the accelerating voltage of the accelerating mode

calculate_volume(EE, zz, rr)

Calculates the volume of the volume of revolution of the cavity profile

create_inputs()

Create required inputs

define_geometry(n_cells, mid_cell[, ...])

Define geometry

eigen(n_modes, freq, req_mode_num, search)

Perform eigenmode simulation

generate_mesh([gridcons, epsr, plot])

Generate mesh

get_surface_field(field_array, zz, rr)

Get the surface field values.

plot_cavity_fields(ptype)

Plots the computed fields on the input geometry

plot_mesh()

Plot generated mesh

save_fields(wall, job)

Save mode fields

save_qois()

Save the quantities of interest

calculate_QoI

calculate_q

eee

find_resonance

inttri

normalize_u

peak_cavity_field

plot_FEM_fields

run

run_field_solver

search

calculate_QoI()[source]
static calculate_U(EE, HH, zz, rr)[source]

Calculates the energy \(U_n\) of eigenmode \(n\) from either electric or magnetic field.

\[ \begin{align}\begin{aligned}U_n = \frac{1}{2} \int_{z_\min}^{z_\max} \int_{r_\min}^{r_\max} \int_{0}^{2\pi} D_n \cdot E_n \mathrm{d}V = \frac{1}{2}\int_{z_\min}^{z_\max} \int_{r_\min}^{r_\max} \int_{0}^{2\pi} B_n \cdot H_n \mathrm{d}V\\D_n \cdot E_n = \epsilon_0 E^2; ~B_n \cdot H_n = \mu_0 H^2\end{aligned}\end{align} \]
Parameters
  • EE (2D array) – Array of electric field magnitude in 2D space

  • HH – Array of magnetic field magnitude in 2D space

  • zz (2D array) – Grid points z coordinate

  • rr (2D array) – Grid points r coordinate

Returns

U – Energy over the shape volume

Return type

float

static calculate_bpk(Hpk, Eacc)[source]

Calculates the peak surface magnetic field to accelerating field ratio

Parameters
  • Hpk (float) – Peak wall surface magnetic field

  • Eacc (float) – Accelerating electric field

Returns

Bpk/Eacc

Return type

float

calculate_disspated_power(H_surf, z_surf, r_surf)[source]

Calculates the dissipated power from the cavity walls

\[P_\mathrm{ds} = \frac{1}{2} R_\mathrm{s} \int_{z_\min}^{z_\max} \int_{0}^{2\pi} |H_\theta|^2 \mathrm{d}s\]
Parameters
  • H_surf

  • z_surf

  • r_surf

static calculate_epk(Epk, Eacc)[source]

Calculates the peak surface electric field to accelerating field ratio

Parameters
  • Epk (float) – Peak electric field

  • Eacc (float) – Accelerating electric field

Returns

Epk/Eacc

Return type

float

calculate_fields()[source]

Calculate the fields from the eigenvectors

calculate_g()[source]

Calculates the geometry or form factor for the cavity

\[G = Q_0 \cdot R_\mathrm{s} = \frac{\omega U_n}{P_\mathrm{ds}}\]
calculate_loss_factor(R_Q)[source]

Calculates fundamental mode loss factor

\[k_{\parallel, n} = \frac{|V_{\parallel, n}(0, 0)|^2}{4 U_n} = \frac{\omega_n}{4} \frac{R}{Q}_n\]
Parameters

R_Q (float) – R/Q of cavity geometry

Returns

k_loss – Mode loss factor

Return type

float

calculate_q()[source]
calculate_rq(Vacc, U)[source]

Calculates the \(R/Q_\parallel\) of the accelerating mode.

\[R/Q = \frac{|V_{\parallel, n(0, z)}|^2}{\omega_n U_n}\]
Parameters
  • Vacc (float) – Accelerating voltage.

  • U (float) – Stored energy

calculate_surface_resistance_copper()[source]

Calculates the surface resistance for Copper with conductivity

of \(\sigma = 5.96 \times 10^7 \mathrm{S/m}\) at eigen frequency

\[R_\mathrm{s} = \sqrt{\frac{\mu \omega}{2 \sigma}}\]
Returns

Rs – Surface resistance of copper at operating frequency.

Return type

float

calculate_vacc(z, E_z_axis)[source]

Calculates the accelerating voltage of the accelerating mode

\[V_\mathrm{cav} = \vert \int_{z_\min}^{z_\max} E_z(r=0, z) \mathrm{e}^{jk_0 z}\vert \mathrm{d}z\]
Parameters
  • E_z_axis (array) – \(z\) component of electric field on axis \(r=0\)

  • z (array) – \(z\) coordinate points along axis \(r=0\)

Returns

Vacc – Accelerating voltage along axis \(r=0\)

Return type

float

calculate_volume(EE, zz, rr)[source]

Calculates the volume of the volume of revolution of the cavity profile

Parameters
  • EE (array like) – Electric field array

  • zz (array like) – z coordinates on grid

  • rr (array like) – r coordinates on grid

Returns

V – Volume of revolution of cavity profile

Return type

float

create_inputs()[source]

Create required inputs

define_geometry(n_cells, mid_cell, end_cell_left=None, end_cell_right=None, beampipe='none', plot=False)[source]

Define geometry

Parameters
  • n_cells (int) – Number of cavity cells

  • mid_cell (array like) – Mid cell cell geometric parameters

  • end_cell_left (array like) – Left end cell cell geometric parameters

  • end_cell_right (array like) – Right end cell cell geometric parameters

  • beampipe ({"none", "both", "left", "right"}) – Which sides to include beampipes

  • plot (bool) – Show geometry after definition or not

eee(offset, maara, show)[source]
eigen(n_modes, freq, req_mode_num, search)[source]

Perform eigenmode simulation

Parameters
  • n_modes (int) – Number of modes

  • freq (float) – Frequency to find eigenvalues around

  • req_mode_num (int) – Required mode number

  • search (null) – Redundant for now

find_resonance(freq)[source]
generate_mesh(gridcons=0.005, epsr=1, plot=False)[source]

Generate mesh

Parameters
  • gridcons (float) – Maximum element width

  • epsr – Relative permittivity

  • plot – Show mesh after generation or not

get_surface_field(field_array, zz, rr)[source]

Get the surface field values. Works by looping through the 2D field array and returning the first and last non-zero elements in each row

Parameters
  • rr (2D array) – r coordinates

  • zz (2D array) – z coordinates

  • field_array (array) – Field values on grid

static inttri(p)[source]
normalize_u(wall=0)[source]
peak_cavity_field()[source]
plot_FEM_fields(ptype)[source]
plot_cavity_fields(ptype)[source]

Plots the computed fields on the input geometry

Parameters

ptype ({'contour', 'arrow'}) – Plot type

plot_mesh()[source]

Plot generated mesh

run(n_cells, mid_cell, end_cell_left, end_cell_right=None, beampipe=None, req_mode_num=None, plot=False)[source]
run_field_solver(n_modes=None, freq=None, req_mode_num=None, show_plots=True, search=True)[source]
save_fields(wall, job)[source]

Save mode fields

Parameters
  • wall

  • job

save_qois()[source]

Save the quantities of interest

search(korig, maara, ind, raja)[source]

Module contents