libICEpost.src.engineModel.functionObjects
@author: F. Ramognino <federico.ramognino@polimi.it> Last update: 16/12/25
Function objects to perform additional computations in an EngineModel class at each iteration of the processing loop. A function-object should be a function taking only the EngineModel as an argument and is called at the end of each time loop to perform additional operations (tipically to store some variables which are updated at every time-step).
Classes
Base class for implementing function objects. |
|
A user-defined function object. The used must define the function f(model:EngineModel) |
|
Function objects constructed for a specific zone. |
|
Store the mixture composition in terms of either mole and/or |
|
Estimate the burnt volume fraction from xb and density ratio for a zone at each time-step as: |
|
Store the mixture thermophysical properties for a zone at each time-step as: |
Module Contents
- class libICEpost.src.engineModel.functionObjects.FunctionObject[source]
Bases:
libICEpost.src.base.BaseClass.BaseClassBase class for implementing function objects.
- abstractmethod __call__(model: libICEpost.src.engineModel.EngineModel.EngineModel.EngineModel) tuple[float, int][source]
A function object must implement a __call__ method taking an EngineModel as input and returning None.
- Parameters:
model (EngineModel) – The input model to apply the FO.
- Returns:
current CA and corresponding index in the database of the engineModel instance.
- Return type:
tuple[float,index]
- class libICEpost.src.engineModel.functionObjects.CodedFunctionObject(*, function: types.FunctionType)[source]
Bases:
FunctionObjectA user-defined function object. The used must define the function f(model:EngineModel) that is executed at every call of __call__ method.
The user can refer to some other sub-classes of FunctionObject class for reference.
- function: types.FunctionType
The function to execute at every __call__.
- classmethod fromDictionary(dictionary: dict)[source]
Construct from dictionary.
- Parameters:
dictionary (dict) – Dictionary containing: function (FunctionType): the function to call at every __call__
- Returns:
Instance of this class
- Return type:
- __call__(model: libICEpost.src.engineModel.EngineModel.EngineModel.EngineModel)[source]
Evaluate the function object.
- Parameters:
model (EngineModel) – Input model
- class libICEpost.src.engineModel.functionObjects.ZoneFunctionObject(*, zone: str = 'cylinder')[source]
Bases:
FunctionObjectFunction objects constructed for a specific zone. Variables saved for a zone are saved as:
<var>_<zone>
- Where:
var: The variable to save zone: The zone name. By convention, properties of the cylinder zone have no ‘_<zone>’ postfix.
- zone: str
The zone for which saving the composition
- postfix: str
The postfix corresponding to the zone
- classmethod fromDictionary(dictionary: dict) libICEpost.Dictionary[source]
- Abstractmethod:
Construct from dictionary.
- Parameters:
dictionary (dict) – Dictionary containing: zone (str, optional): zone for which saving. Defaults to ‘cylinder’.
- Returns:
Update the dictionary with the zone in case not found.
- Return type:
- abstractmethod __call__(model: libICEpost.src.engineModel.EngineModel.EngineModel.EngineModel) tuple[float, int, libICEpost.src.thermophysicalModels.thermoModels.ThermoModel.ThermoModel][source]
Check that zone exists
- Returns:
current CA and corresponding index in the database of the engineModel instance, and the ThermoModel associated to the zone.
- Return type:
tuple[float, int, ThermoModel]
- class libICEpost.src.engineModel.functionObjects.SaveMixtureComposition(*, fracType: Literal['mass', 'mole', 'both'], **kwargs)[source]
Bases:
ZoneFunctionObjectStore the mixture composition in terms of either mole and/or mass fractionsfor a zone at each time-step. Mixture composition is saved as:
<specie>_<x/y>_<zone>
- Where:
specie: The specie name x/y: Wether mole or mass fraction zone: The zone name. By convention, properties of the cylinder zone have no ‘_<zone>’ postfix.
- fracType: str
Which kind of fraction to save
- classmethod fromDictionary(dictionary: dict)[source]
Construct from dictionary.
- Parameters:
dictionary (dict) – Dictionary containing: zone (str): zone for which saving fracType(str): type of composition fraction (mass, mole, both)
- Returns:
Instance of this class
- Return type:
- __call__(model: libICEpost.src.engineModel.EngineModel.EngineModel.EngineModel)[source]
Evaluate the function object for a model.
- Parameters:
model (EngineModel) – Input model
- class libICEpost.src.engineModel.functionObjects.EstimateBurntUnburntProperties(*, mechanism: str = None, densityRatio: float = None, **kwargs)[source]
Bases:
ZoneFunctionObject- Estimate the burnt volume fraction from xb and density ratio for a zone at each time-step as:
yb = (1 + (1/densityRatio)*(1/xb - 1))^-1
Using a constant density ratio rhou/rhob computed at start of combustion at the adiabatic flame temperature. Hence, estimate properties of burnt and unburnt mixtures from the volume fractions:
<property><u/b>_<zone>
- Where:
property: The property saved. u/b: Whether of burnt or unburnt mixture. zone: The zone name. By convention, properties of the cylinder zone have no ‘_<zone>’ postfix. zone: The zone name. By convention, properties of the cylinder zone have no ‘_<zone>’ postfix.
- densityRatio: float
Density ratio rhou/rhob
- reactor: cantera.composite.Solution
The cantera reactor to compute properties at adiabati flame temperature at start of combustion
- unburnt: libICEpost.src.thermophysicalModels.thermoModels.ThermoModel.ThermoModel
The unburnt mixture
- burnt: libICEpost.src.thermophysicalModels.thermoModels.ThermoModel.ThermoModel
The burnt mixture
- classmethod fromDictionary(dictionary: dict)[source]
Construct from dictionary.
- Parameters:
dictionary (dict) –
Dictionary containing: zone (str): zone for which saving mechanism (str, optional): The path of the chemical mechanism to compute chemical
composition at adiabati flame temperature (used to compute rhou/rhob).
densityRatio (float, optional): The density ratio to use
- Returns:
Instance of this class
- Return type:
- __call__(model: libICEpost.src.engineModel.EngineModel.EngineModel.EngineModel)[source]
- Evaluate the function object for a model. yb is computed as:
yb = (1 + (1/densityRatio)*(1/xb - 1))^-1
- Parameters:
model (EngineModel) – Input model
- class libICEpost.src.engineModel.functionObjects.SaveMixtureProperties(*, cp: bool = True, cv: bool = True, gamma: bool = True, MM: bool = False, ha: bool = False, ua: bool = False, hs: bool = False, us: bool = False, hf: bool = False, Z: bool = False, **kwargs)[source]
Bases:
ZoneFunctionObject- Store the mixture thermophysical properties for a zone at each time-step as:
<property>_<zone>
- Where:
property: The property
- Where:
zone: The zone name. By convention, properties of the cylinder zone have no ‘_<zone>’ postfix.
- cp: bool
save cp?
- cv: bool
save cv?
- gamma: bool
save gamma?
- ha: bool
save ha?
- ua: bool
save ua?
- hs: bool
save hs?
- us: bool
save us?
- hf: bool
save hf?
- Z: bool
save Z?
- MM: bool
save MM?
- classmethod fromDictionary(dictionary: dict)[source]
Construct from dictionary.
- Parameters:
dictionary (dict) – Dictionary containing: zone (str): zone for which saving cp (bool): Save cp? cv (bool): Save cv? gamma (bool): Save gamma? ha (bool): Save ha? ua (bool): Save ua? hs (bool): Save hs? us (bool): Save us? hf (bool): Save hf? Z (bool): Save Z? MM (bool): Save MM?
- Returns:
Instance of this class
- Return type:
- __call__(model: libICEpost.src.engineModel.EngineModel.EngineModel.EngineModel)[source]
Evaluate the function object for a model.
- Parameters:
model (EngineModel) – Input model