Skip to content

Interface - Flat chamber impedance

Eskil Vik requested to merge feature/interface-flatchamber into master

The first MR in a series that will implement a new interface for IW2D, to be used by pywit and other users of the package.

Overview

This MR implements two main features:

  1. Input dataclasses
  2. Impedance calculation using the new interface

Additionally, unit tests for the added code is added, and some parts of the underlying C++ code was changed to prevent name conflicts.


Input dataclasses

The input dataclasses IW2DLayer, RoundIW2DInput and FlatIW2DInput will be the main interface with IW2D. Except for frequencies, which is supplied separately, the input dataclasses contain all parameters needed for impedance calculations.

The IW2DLayer class contains information about a layer in the wall of the chamber, namely the layer thickness and material properties. The material properties are used by two methods of the class, eps1(frequency) and mu1(frequency), to return the relative complex permittivity and permeability. Several calculation modes are available for both. Upon instantiation, the newly created object verifies that it has received a valid set of input parameters. Additionally, the method b() returns the layer thickness.

While the IW2DLayer class is designed to be versatile, all calculations are designed to work with any abstract Layer class as long as it implements the methods eps1(frequency), mu1(frequency) and b().

The RoundIW2DInput and FlatIW2DInput classes contain tuples of these layers, as well as other parameters (e.g. relativistic gamma), and are what is passed to the functions performing the impedance (and later wake field) computations. Unlike the IW2DLayer class, these are not intended to be interchangable with any abstract class with some common properties - Here the user should use these specific classes.

Both of these classes implement a method for hashing them, allowing users to recognize inputs they have previously used and use caching to skip calculations.


Flat impedance calculations

The impedance calculations are fairly straightforward. A function is made that takes a single frequency and a FlatIW2DInput object as inputs, retrieves various values from the input object, and calculates the impedances (longitudinal, constant y, dipolar x y, quadrupolar x y) for that frequency. A separate function takes in either a single frequency or an iterable of frequencies and makes a pandas.DataFrame with the impedances for this/these frequencies.


Other changes of note:

  • Rename clog, cexp and csqrt from IW2D/cpp/multiprecision.cc to clogMP, cexpMP and csqrtMP, respectively, in order to avoid name conflicts.
  • Move functions related to loading and including code with cppyy to IW2D/loading.py, and change inclusion strategy to include everything in IW2D/__init__.py rather than in the file it is needed. The reason for this change is that spreading these inclusing over multiple files can make it hard to keep track of and control the order in which the files are included, something cppyy can be very sensitive to.

Merge request reports

Loading