bird.utilities package

Submodules

bird.utilities.mathtools module

bird.utilities.mathtools.conditional_average(x: ndarray, y: ndarray, nbins: int = 32) tuple[ndarray, ndarray]

Compute a 1D conditional average of y with respect to x The conditional average is distributed to neighbors of the binned array when needed

Parameters:
  • x (np.ndarray) – 1D array with respect to which conditional averaged is performed

  • y (np.ndarray) – 1D array conditioned

  • nbins (int) – Number of bins through x

Returns:

  • x_cond (np.ndarray) – The binned array of values conditioned againsts

  • y_cond (np.ndarray) – The conditional averages at each bin

bird.utilities.ofio module

bird.utilities.ofio.get_case_times(case_folder: str, remove_zero: bool = False) tuple[list[float], list[str]]

Get list of all time folders from an OpenFOAM case

Parameters:
  • case_folder (str) – Path to case folder

  • remove_zero (bool) – Whether to remove zero from the time folder list

Returns:

  • time_float_sorted (list[float]) – List of time folder values in ascending order

  • time_str_sorted (list[str]) – List of time folder names in ascending order

bird.utilities.ofio.get_species_name(case_folder: str, phase: str = 'gas') list[str]

Get list of species name in a phase

Parameters:
  • case_folder (str) – Path to OpenFOAM case

  • phase (str) – Name of phase where to find the species

Returns:

species_name – List of species name in the phase

Return type:

list[str]

bird.utilities.ofio.readSizeGroups(file)
bird.utilities.ofio.read_bubble_diameter(case_folder: str, time_folder: str | None = None, n_cells: int | None = None, field_dict: dict | None = None) tuple[ndarray | float, dict]

Read bubble diameter at a given time and store it in dictionary for later reuse. A specific function is constructed so that if d.gas is not available, the bubble diameter is read from phaseProperties.

Parameters:
  • case_folder (str) – Path to case folder

  • time_folder (str | None) – Name of time folder to analyze. If None, it will be found automatically

  • n_cells (int | None) – Number of cells in the domain. If None, it will deduced from the field reading

  • field_dict (dict | None) – Dictionary of fields used to avoid rereading the same fields to calculate different quantities

Returns:

  • cell_volumes (np.ndarray | float) – Field of cell volumes

  • field_dict (dict) – Dictionary of fields read

bird.utilities.ofio.read_cell_centers(case_folder: str, cell_centers_file: str | None = None, field_dict: dict | None = None) tuple[ndarray, dict]

Read field of cell centers and store it in dictionary for later reuse

Parameters:
  • case_folder (str) – Path to case folder

  • cell_centers_file (str) – Filename of cell center data If None, find the cell center file automoatically

  • field_dict (dict | None) – Dictionary of fields used to avoid rereading the same fields to calculate different quantities

Returns:

  • cell_centers (np.ndarray) – cell centers read from file

  • field_dict (dict) – Dictionary of fields read

bird.utilities.ofio.read_cell_volumes(case_folder: str, time_folder: str | None = None, n_cells: int | None = None, field_dict: dict | None = None) tuple[ndarray | float, dict]

Read volume at a given time and store it in dictionary for later reuse

Parameters:
  • case_folder (str) – Path to case folder

  • time_folder (str | None) – Name of time folder to analyze. If None, it will be found automatically

  • n_cells (int | None) – Number of cells in the domain. If None, it will deduced from the field reading

  • field_dict (dict | None) – Dictionary of fields used to avoid rereading the same fields to calculate different quantities

Returns:

  • cell_volumes (np.ndarray | float) – Field of cell volumes

  • field_dict (dict) – Dictionary of fields read

bird.utilities.ofio.read_field(case_folder: str, time_folder: str, field_name: str, n_cells: int | None = None, field_dict: dict | None = None) tuple[ndarray | float, dict]

Read field at a given time and store it in dictionary for later reuse

Parameters:
  • case_folder (str) – Path to case folder

  • time_folder (str) – Name of time folder to analyze

  • field_name (str) – Name of the field file to read

  • n_cells (int | None) – Number of cells in the domain. If None, it will deduced from the field reading

  • field_dict (dict | None) – Dictionary of fields used to avoid rereading the same fields to calculate different quantities

Returns:

  • field (np.ndarray | float) – Field read

  • field_dict (dict) – Dictionary of fields read

bird.utilities.ofio.read_global_vars(case_folder: str | None = None, filename: str | None = None, cross_ref: bool = True) dict

Read globalVars into a python dictionary

Parameters:
  • case_folder (str | None) – Path to case folder If None, using filename

  • filename (str | None) – Path to the globalVars file If None, using case_folder

  • cross_ref (bool) – Do cross referencing or no If True, all the #calc values from the python dict are replaced by their numeral values If False, all the #calc values are stored as string

Returns:

globalVars_dict – Dictionary that contains the globals vars variable values

Return type:

dict

bird.utilities.ofio.read_mu_liquid(case_folder: str, time_folder: str | None = None, n_cells: int | None = None, field_dict: dict | None = None) tuple[ndarray | float, dict]

Read liquid viscosity at a given time and store it in dictionary for later reuse. A specific function is constructed so that if thermo:mu.liquid is not available, the liquid viscosity is read from globalVars

Parameters:
  • case_folder (str) – Path to case folder

  • time_folder (str | None) – Name of time folder to analyze. If None, it will be found automatically

  • n_cells (int | None) – Number of cells in the domain. If None, it will deduced from the field reading

  • field_dict (dict | None) – Dictionary of fields used to avoid rereading the same fields to calculate different quantities

Returns:

  • cell_volumes (np.ndarray | float) – Field of cell volumes

  • field_dict (dict) – Dictionary of fields read

bird.utilities.ofio.read_openfoam_dict(filename: str) dict

Parse OpenFOAM dictionary into a python dictionary

Parameters:

filename (str) – OpenFOAM dictionary filename

Returns:

dict_of – A Python dictionary representing the structure of the OpenFOAM dictionary.

Return type:

dict

bird.utilities.ofio.species_name_to_mw(case_folder: str, species_name: str) float

Get molecular weight in \(kg/mol\) from the species name. In order of availability, the molecular weight is read from the thermophysicalProperties.XXX, and globalVars. If nothing is found in globalVars (last resort) an error is raised. This function is primarily useful to compute concentrations

Parameters:
  • case_folder (str) – Path to case folder

  • species_name (str) – The name of the species for which molecular weight is desired

Returns:

mw – The species molecular weight

Return type:

float

bird.utilities.ofio.write_openfoam_dict(data: dict, filename: str, indent: int = 0) None

Save a Python dictionary back to an OpenFOAM-style file.

Parameters:
  • d (dict) – Python dictionary to save

  • filename (str) – The file that will contain the saved dictionary

  • indent (int) – Number of indentation space

bird.utilities.parser module

bird.utilities.parser.parse_json(file_path: str) dict

Parse a json file into a dictionary

Parameters:

file_path (str) – path to json file

Returns:

inpt – Dictionary that contains the json file content

Return type:

dict

bird.utilities.parser.parse_yaml(file_path: str) dict

Parse a yaml file into a dictionary

Parameters:

file_path (str) – path to yaml file

Returns:

inpt – Dictionary that contains the yaml file content

Return type:

dict

bird.utilities.stl_plotting module

bird.utilities.stl_plotting.plotSTL(stl_file)