libICEpost

@author: F. Ramognino <federico.ramognino@polimi.it> Last update: 9/03/2023

Package with useful classes and executables and function for pre/post processing of data in the context of internal combustion engines and CFD simulations”

-> Processing of experimental measurements on ICEs -> Processing of results of CFD simulations -> Computation of mixture compositions (external/internal EGR, thermophysical properties) -> Processing of laminar flame speed correlations and OpenFOAM tabulations -> Handling, reading/writing, and assessment of OpenFOAM tabulations

Content of the package: TODO: Add description

Submodules

Attributes

database

Classes

BaseClass

Class wrapping useful methods for base virtual classes (e.g. run-time selector)

Dictionary

Ordered dictionary embedding some useful OpenFOAM-like methods.

Package Contents

libICEpost.database
class libICEpost.BaseClass[source]

Bases: libICEpost.src.base.Utilities.Utilities

Class wrapping useful methods for base virtual classes (e.g. run-time selector)

classmethod selectionTable() SelectionTable[source]

The run-time selection table associated to this class.

classmethod selector(typeName: str, dictionary: dict) BaseClassType[source]

Construct an instance of a subclass of this that was added to the selection table.

Parameters:
  • typeName (str) – Name of the subclass to instantiate

  • dictionary (dict) – Dictionary containing the data to construct the class.

Returns:

Instance of the specific class.

Return type:

BaseClassType

classmethod hasSelectionTable() bool[source]

Check if selection table was defined for this class.

classmethod fromDictionary(dictionary: dict) BaseClassType[source]
Abstractmethod:

Construct an instance of this class from a dictionary. To be overwritten by derived class.

Parameters:

dictionary (dict) – Dictionary containing the data to construct the class.

Returns:

Instance of the specific class.

Return type:

BaseClassType

classmethod addToRuntimeSelectionTable(childClass: BaseClassType, *, overwrite: bool = True) None[source]

Add the subclass to the database of available subclasses for runtime selection.

Parameters:
  • childClass (BaseClassType) – Subclass to add to the selection table

  • overwrite (bool, optional) – Overwrite if present? Defaults to True.

classmethod createRuntimeSelectionTable() None[source]

Create the runtime selection table, initializing the property ‘selectionTable’ of the class.

classmethod showRuntimeSelectionTable() None[source]

Prints a list of the available classes in the selection table and if they are instantiable.

Example

Available classes in selection table:

ClassA (Abstract class) ClassB ClassC

class libICEpost.Dictionary(*args, _fileName: str = None, **argv)[source]

Bases: collections.OrderedDict, libICEpost.src.base.Utilities.Utilities

Ordered dictionary embedding some useful OpenFOAM-like methods.

path: str | None
file: str | None
classmethod fromFile(fileName: str)[source]

Read the variables stored in a python file (Runs the code in the file and retrieves the local variables)

Parameters:

fileName (str) – Path of the file

Returns:

A Dictionary object containing the variables defined in the file.

Return type:

Dictionary

lookup(entryName: str, *, varType: T | Iterable[type] = None, **kwargs) T | Any[source]

Same as __getitem__ but embeds error handling and type checking.

Parameters:
  • entryName (str) – Name of the entry to look for

  • varType (type|Iterable[type], optional) – Type of the variable to lookup for. Performes type-checking if it is given. Defaults to None.

  • **kwargs (dict[str,object]) – Additional arguments to pass to the checkType function in case of type checking.

Raises:
  • KeyError – If the entry is not found

  • TypeError – If the type is not consistent with varType

Returns:

self[entryName]

Return type:

varType|Any

pop(entryName: str)[source]
entryName: str

Name of the entry to look for

Same as dictionary.pop but custom error message

lookupOrDefault(entryName: str, default: T, fatal: bool = True, **kwargs) T[source]

Lookup of give a default value if not found

Parameters:
  • entryName (str) – Name of the entry to look for

  • default (T) – Instance to return in case the value is not found. It is also used for typeChecking

  • fatal (bool, optional) – If the type is not consistent rise a TypeError. Defaults to True.

  • **kwargs (dict[str,object]) – Additional arguments to pass to the checkType function in case of type checking.

Returns:

self[entryName] if entryName is found, else default

Return type:

T

_correctSubdicts()[source]

Convert recursively every subdictionary into Dictionary classes.

__setitem__(*args, **argv)[source]

Set self[key] to value.

update(/, dictionary=None, **kwargs)[source]

Performs like dict.update() method but recursively updates sub-dictionaries. Accepts both a dictionary and keyword arguments.

Parameters:

dictionary (dict, optional) – Dictionary to update with. Defaults to None.