Preprocessing Package Documentation

Simulation Run Configuration Generation

IDSimPy.preprocessing.run_configuration_preprocessing.generate_run_configurations_from_template(template_filename, parameter_values, result_basename)[source]

Generates simulation input files from a simple template file, a vector of parameter values and a basename for the resulting input files

A template file is a simple text file, which contains replacement tokens of the form %%-0-%% with a running index

Parameter values are a list of parameter value lists, with one parameter value vector per resulting file

Example:

parameters = (
    (result_file_1_parameter_1, result_file_1_parameter_2),
    (result_file_2_parameter_1, result_file_2_parameter_2),
    (result_file_2_parameter_1, result_file_2_parameter_2)
)
Parameters:
  • template_filename – Name of the template file

  • parameter_values – list List of parameter values

  • result_basename – Basename of the resulting generated input files

Field Generation

IDSimPy.preprocessing.field_generation.plot_3d_grid(meshgrid, field_dat, Xi)[source]

Plots a field imported from a comsol 3d csv file.

Parameters:
  • meshgrid (numpy.Array) – the meshgrid (as defined by numpy meshgrid) for the 3d field

  • field_dat (numpy.Array) – the scalar field to plot

  • Xi (int) – the index of the slice in x direction to plot

IDSimPy.preprocessing.field_generation.transform_2d_axial_to_3d(R_axi, Z_axi, V_axi, radial_component=False)[source]

Transforms 2d axial symmetric data into 3d cartesian data. The symmetry axis which is used for the rotation is the y axis in cartesian coordinates.

Note: The data is expected to be given as meshgrid in ij indexing.

IDSimPy.preprocessing.field_generation.write_3d_scalar_fields_as_vtk_point_data(dat, result_filename, scale_factor=1.0)[source]
IDSimPy.preprocessing.field_generation.write_3d_scalar_fields_to_hdf5(dat, result_filename, scale_factor=1.0)[source]
IDSimPy.preprocessing.field_generation.write_3d_vector_fields_as_vtk_point_data(dat, result_filename, scale_factor=1.0)[source]
IDSimPy.preprocessing.field_generation.write_3d_vector_fields_to_hdf5(dat, result_filename, scale_factor=1.0)[source]

Ion Cloud Generation

ion_cloud_generation: Generation of ion cloud initialization files

IDSimPy.preprocessing.ion_cloud_generation.add_thermalized_kinetic_energy(ion_cloud, ke)[source]
IDSimPy.preprocessing.ion_cloud_generation.define_cylinder_x_dir(n_ions, r, x, charge, mass)[source]

Defines a cylinder with the cylinder axis parallel to the x-axis and the center of one face of the cylinder on the origin of the coordinate system filled with random ions

The cylinder cross section, a disk, must be filled uniformly with ions, see http://mathworld.wolfram.com/DiskPointPicking.html for details and argument how to do this.

Parameters:
  • n_ions (int) – The number of ions in the cylinder

  • r (float) – the radius of the cylinder

  • x (float) – length (“radius”) in x direction

  • charge (float) – Charge of the ions in the generated cylinder

  • mass (float) – Mass of the ions in the generated cylinder

Returns:

Array with parameters of the particles in the defined cylinder. Columns are: [x,y,z, vx, vy, vz, charge, mass, time of birth]

IDSimPy.preprocessing.ion_cloud_generation.define_cylinder_z_dir(n_ions, r, z, charge, mass)[source]

Defines a cylinder with the cylinder axis parallel to the z-axis and the center of one face of the cylinder on the origin of the coordinate system filled with random ions.

The cylinder cross section, a disk, must be filled uniformly with ions, see http://mathworld.wolfram.com/DiskPointPicking.html for details and argument how to do this.

Parameters:
  • n_ions (int) – The number of ions in the cylinder

  • r (float) – Radius of the cylinder

  • z (float) – Height of the cylinder

  • charge (float) – Charge of the ions in the generated cylinder

  • mass (float) – Mass of the ions in the generated cylinder

Returns:

Array with parameters of the particles in the defined cylinder. Columns are: [x,y,z, vx, vy, vz, charge, mass, time of birth]

IDSimPy.preprocessing.ion_cloud_generation.define_origin_centered_block(n_ions, w_x, w_y, w_z, mass)[source]

Defines a block of random ions around the coordinate system origin

Parameters:
  • n_ions (int) – the number of ions in the block

  • w_x (float) – the width in x direction

  • w_y (float) – the width in y direction

  • w_z (float) – the width in z direction

  • mass (float) – the mass of the ions (in amu)

Returns:

the ion cloud in an np.array with the structure as expected by write_cloud_file

IDSimPy.preprocessing.ion_cloud_generation.define_xy_grid(n_x, n_y, w_x, w_y, o_x, o_y, mass)[source]

Defines a grid in the x-y direction (z=0) (grid is from -width to width)

Parameters:
  • n_x (int) – ions in x direction

  • n_y (int) – ions in y direction

  • w_x (float) – width in x direction

  • w_y (float) – width in y direction

  • o_x (float) – offset in x direction

  • o_y (float) – offset in y direction

  • mass (float) – the mass of the ions in the grid

Returns:

the ion cloud in an np.array with the structure as expected by write_cloud_file

IDSimPy.preprocessing.ion_cloud_generation.random_sphere(radius, n_samples)[source]
IDSimPy.preprocessing.ion_cloud_generation.set_kinetic_energy_in_z_dir(ion_cloud, ke)[source]
IDSimPy.preprocessing.ion_cloud_generation.velo_from_kinetic_energy(ke_eV, mass_amu)[source]
IDSimPy.preprocessing.ion_cloud_generation.write_cloud_file(ion_cloud, filename)[source]

Writes an ion cloud to an ion cloud file

Parameters:
  • ion_cloud (numpy.Array) – an np.array with the columns: [x pos, y pos, z pos, x velo, y velo, z velo, charge (in elem. charges), mass (in amu)]

  • filename (str) – name of the file in which the tabular ion cloud data is written to

Comsol Import

IDSimPy.preprocessing.comsol_import.import_comsol_3d_csv_grid(filename)[source]

Imports a csv file with multiple 3d scalar fields exported from comsol.

Result dictionary contains:

  • grid_points: Array of vectors with the positions of the grid points in the x,y,z directions

  • meshgrid: Array of meshgrid matrices as defined by numpy meshgrid

  • fields: Array of scalar fields, which are dictionaries with a name and the scalar data in ‘data’

Parameters:

filename (str) – the file name to import

Returns:

Result dictionary as defined above

IDSimPy.preprocessing.comsol_import.parse_comsol_csv_data_chunk(raw_chunk, dims)[source]

Parses a raw data chunk (given as string) and returns a numpy array with the data values.

Parameters:
  • raw_chunk (str) – The string containing the data chunk

  • dims (tuple or numpy.Array) – 3 dim array with the number of points in the spatial (x,y,z) dimensions

Returns:

Dictionary with the field_name and the data of the field

IDSimPy.preprocessing.comsol_import.parse_grid_vector(vec_str, delimiter=',')[source]

Parses a vector with spatial grid positions from a grid vector line from a comsol csv header.

Parameters:
  • vec_str (str) – A string containing the header line

  • delimiter (str) – the delimiter in the vector line

Returns:

numpy array with the vector values

IDSimPy.preprocessing.comsol_import.parse_spatial_dimensions(header)[source]

Parses and returns the spatial dimensions of a comsol csv field file from the header of the comsol csv file.

Parameters:

header (str) – The header (given as string)

Returns:

Tuple of three vectors with the spatial point grid positions in x,y,z direction