rizer.misc.simulation#

Helper functions for running simulations.

Functions#

parse_convert_yaml(→ dict[str, Any])

Parse and convert YAML file. Also perform minimal validation.

create_case_folder(→ pathlib.Path)

Create a folder for the case.

get_momentum_transfer_collision_frequencies_list(...)

Get a list of momentum transfer collision frequency models for the given species.

get_generator_from_input(...)

Get a generator object from the input dictionary.

get_cable_from_input(...)

Create an IdealCable object from the input dictionary.

save_result(→ None)

Export the simulation results to CSV and YAML files.

Module Contents#

rizer.misc.simulation.parse_convert_yaml(path: str | pathlib.Path, expected_sections: list[str] | None = None) dict[str, Any]#

Parse and convert YAML file. Also perform minimal validation.

Parameters:
  • path (str or pathlib.Path) – Path to the YAML file containing the parameters.

  • expected_sections (list of str or None, optional) – List of expected top-level sections in the YAML file. If provided, the function will check that these sections are present in the YAML file. Default is None, which means no validation of sections will be performed.

Returns:

A dictionary containing the parsed parameters from the YAML file.

Return type:

dict of str to Any

rizer.misc.simulation.create_case_folder(base_folder: str, case_name: str) pathlib.Path#

Create a folder for the case.

Parameters:
  • base_folder (str) – The base folder where the case folder will be created.

  • case_name (str) – The name of the case. If “auto”, the function will automatically find the next available case number.

Returns:

The path to the created case folder.

Return type:

pathlib.Path

rizer.misc.simulation.get_momentum_transfer_collision_frequencies_list(species_names: list[str], collision_frequency_model: dict[str, dict[str, str | float]]) list[rizer.plasma.collision_frequency.MomentumTransferCollisionFrequencyModel]#

Get a list of momentum transfer collision frequency models for the given species.

Parameters:
  • species_names (list of str) – List of species names for which to get the momentum transfer collision frequency models.

  • collision_frequency_model (dict of str to dict of str to str or float) –

    A dictionary containing the collision frequency model information for each species. The keys are the species names and the values are dictionaries containing the model information. The expected keys in the inner dictionaries are:

    • ”model”: The type of collision frequency model to use. Supported values are “tabulated” and “hard-sphere”.

    • For “tabulated” model:

      • ”database”: The name of the database to use for the tabulated cross section. This should correspond to a file in the data/cross_section folder.

    • For “hard-sphere” model:

      • ”radius”: The effective radius of the species in meters to use for the hard-sphere cross section.

Returns:

A list of momentum transfer collision frequency models corresponding to the given species names and the specified collision frequency models in the input dictionary.

Return type:

list of MomentumTransferCollisionFrequencyModel

Raises:
  • ValueError – If the collision frequency model specified for a species is unknown or if required parameters are missing for the specified model.

  • ValueError – If the database name for a tabulated model is not a string.

rizer.misc.simulation.get_generator_from_input(generator_input: dict[str, str | float]) rizer.electric_circuit.generator.FromMeasurementGenerator | rizer.electric_circuit.generator.GaussianGenerator | rizer.electric_circuit.generator.TrapezoidalGenerator#

Get a generator object from the input dictionary.

Parameters:

generator_input (dict of str and str or float) –

A dictionary containing the parameters of the generator. Expected keys are:

  • ”type”: Type of the generator. Supported types are “from_measurement”, “gaussian”, “trapezoidal”.

  • ”R_g”: Internal resistance of the generator in Ohms.

  • For “gaussian” type:
    • ”height”: Height of the Gaussian pulse in Volts.

    • ”mean”: Mean of the Gaussian pulse in seconds.

    • ”FWHM”: Full width at half maximum of the Gaussian pulse in seconds.

  • For “trapezoidal” type:
    • ”U_off”: Voltage level when the generator is off, in Volts.

    • ”U_on”: Voltage level when the generator is on, in Volts.

    • ”t_rise”: Rise time of the trapezoidal pulse in seconds.

    • ”t_on”: Duration for which the generator is on (at U_on) in seconds.

    • ”t_fall”: Fall time of the trapezoidal pulse in seconds.

  • For “from_measurement” type:
    • Not implemented yet.

Returns:

An instance of the generator class corresponding to the specified type, initialized with the parameters from the input dictionary.

Return type:

FromMeasurementGenerator or GaussianGenerator or TrapezoidalGenerator

Raises:
  • NotImplementedError – If the generator type is “from_measurement”, which is not implemented yet.

  • ValueError – If the generator type is unknown or if required parameters are missing for the specified type.

rizer.misc.simulation.get_cable_from_input(cable_input: dict[str, str | float]) rizer.electric_circuit.cable.IdealCable#

Create an IdealCable object from the input dictionary.

Parameters:

cable_input (dict) –

A dictionary containing the parameters of the cable. Expected keys are:

  • ”length”: Length of the cable in meters.

  • ”impedance”: Characteristic impedance of the cable in Ohms.

  • ”wave_propagation_speed”: Wave propagation speed in the cable in m/s.

Returns:

An instance of the IdealCable class initialized with the parameters from the input dictionary.

Return type:

IdealCable

rizer.misc.simulation.save_result(states: cantera.SolutionArray, case_path: pathlib.Path, overwrite: bool = False) None#

Export the simulation results to CSV and YAML files.

Parameters:
  • states (cantera.SolutionArray) – The Cantera SolutionArray containing the simulation results.

  • case_path (pathlib.Path) – The path to the case folder where the results will be saved.

  • overwrite (bool, optional) – If True, overwrite existing files. If False, raise an error if the files already exist