convertPtclComponentsCartToCylX.py

Sometimes we perform simulations with natural cylindrical symmetry in Cartesian coordinates to avoid issues arising from the small timestep caused by small cells near the axis. It is helpful to interpret the results in cylindrical coordinates, rather than the Cartesian coordinates of the simulation mesh. This analyzer performs the conversion of the particle coordinates and the particle velocity. New _r, _phi, _vr, _vphi columns are added to the particle file’s coordinates. If one is wishing to restart, these columns will need removing before proceeding. This assumes the x-axis in the Cartesian simulation would correspond to z’, the coordinate along r = 0 in the cylindrical coordinate system. z and vz in the transformed frame is not written, as this is simply the same as x and vx in the original system, which are already present in the dataset.

-s <simname>, --simulationName=<simname>

(string, required)

<simname> is the name of the simulation to be analyzed. The file extension should NOT be included in this text field.

-S <spname>, --speciesName=<spname>

(string, required)

<spname> is the name of the species from which you want to read Cartesian coordinates.

-o <outspname>, --outputSpeciesName=<outspname>

(string, optional)

<outspname> is the name of the species into which you want to write cylindrical coordinates. If unset, will add these to the species from which it read the Cartesian output. This will limit your ability to restart the simulation unless you manually remove these columns from the dataset before restarting.

-w, --overwrite

(flag)

Whether a dataset or group should be overwritten if it already exists.

Output

This analysis script updates the species datafile, adding _r and _phi components for both position and velocity. As \(x \rightarrow z'\), there is no new component required for z.

If you are running this analyzer from the UI, and the output dataset file already exists, then it will be overwritten each time the analyzer is run, unless you uncheck the Overwrite Existing Files box near the bottom of the Analysis Results pane.

If you are running the analyzer from the command line, the dataset will not be overwritten unless the -w, or --overwrite flag is specified on the command line.

The results of your analyzer may not be written into the output file if you have not specified the overwrite option to be True.

Example usage

This analysis script may be useful for interpreting the klystron and helix TWT examples in VSim for Microwave Devices, which naturally have particles traveling down a cylindrical beampipe oriented along x.