libICEpost.src.engineModel.functionObjects ========================================== .. py:module:: libICEpost.src.engineModel.functionObjects .. autoapi-nested-parse:: @author: F. Ramognino 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 ------- .. autoapisummary:: libICEpost.src.engineModel.functionObjects.FunctionObject libICEpost.src.engineModel.functionObjects.CodedFunctionObject libICEpost.src.engineModel.functionObjects.ZoneFunctionObject libICEpost.src.engineModel.functionObjects.SaveMixtureComposition libICEpost.src.engineModel.functionObjects.EstimateBurntUnburntProperties libICEpost.src.engineModel.functionObjects.SaveMixtureProperties Module Contents --------------- .. py:class:: FunctionObject Bases: :py:obj:`libICEpost.src.base.BaseClass.BaseClass` Base class for implementing function objects. .. py:method:: __call__(model: libICEpost.src.engineModel.EngineModel.EngineModel.EngineModel) -> tuple[float, int] :abstractmethod: A function object must implement a __call__ method taking an EngineModel as input and returning None. :param model: The input model to apply the FO. :type model: EngineModel :returns: current CA and corresponding index in the database of the engineModel instance. :rtype: tuple[float,index] .. py:class:: CodedFunctionObject(*, function: types.FunctionType) Bases: :py:obj:`FunctionObject` A 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. .. py:attribute:: function :type: types.FunctionType The function to execute at every __call__. .. py:method:: fromDictionary(dictionary: dict) :classmethod: Construct from dictionary. :param dictionary: Dictionary containing: function (FunctionType): the function to call at every __call__ :type dictionary: dict :returns: Instance of this class :rtype: CodedFunctionObject .. py:method:: __call__(model: libICEpost.src.engineModel.EngineModel.EngineModel.EngineModel) Evaluate the function object. :param model: Input model :type model: EngineModel .. py:class:: ZoneFunctionObject(*, zone: str = 'cylinder') Bases: :py:obj:`FunctionObject` Function objects constructed for a specific zone. Variables saved for a zone are saved as: _ Where: var: The variable to save zone: The zone name. By convention, properties of the cylinder zone have no '_' postfix. .. py:attribute:: zone :type: str The zone for which saving the composition .. py:attribute:: postfix :type: str The postfix corresponding to the zone .. py:method:: fromDictionary(dictionary: dict) -> libICEpost.Dictionary :classmethod: :abstractmethod: Construct from dictionary. :param dictionary: Dictionary containing: zone (str, optional): zone for which saving. Defaults to 'cylinder'. :type dictionary: dict :returns: Update the dictionary with the zone in case not found. :rtype: Dictionary .. py:method:: __call__(model: libICEpost.src.engineModel.EngineModel.EngineModel.EngineModel) -> tuple[float, int, libICEpost.src.thermophysicalModels.thermoModels.ThermoModel.ThermoModel] :abstractmethod: Check that zone exists :returns: current CA and corresponding index in the database of the engineModel instance, and the ThermoModel associated to the zone. :rtype: tuple[float, int, ThermoModel] .. py:class:: SaveMixtureComposition(*, fracType: Literal['mass', 'mole', 'both'], **kwargs) Bases: :py:obj:`ZoneFunctionObject` Store the mixture composition in terms of either mole and/or mass fractionsfor a zone at each time-step. Mixture composition is saved as: __ 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 '_' postfix. .. py:attribute:: fracType :type: str Which kind of fraction to save .. py:method:: fromDictionary(dictionary: dict) :classmethod: Construct from dictionary. :param dictionary: Dictionary containing: zone (str): zone for which saving fracType(str): type of composition fraction (mass, mole, both) :type dictionary: dict :returns: Instance of this class :rtype: SaveMixtureComposition .. py:method:: __call__(model: libICEpost.src.engineModel.EngineModel.EngineModel.EngineModel) Evaluate the function object for a model. :param model: Input model :type model: EngineModel .. py:class:: EstimateBurntUnburntProperties(*, mechanism: str = None, densityRatio: float = None, **kwargs) Bases: :py:obj:`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: _ 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 '_' postfix. zone: The zone name. By convention, properties of the cylinder zone have no '_' postfix. .. py:attribute:: densityRatio :type: float Density ratio rhou/rhob .. py:attribute:: reactor :type: cantera.Solution The cantera reactor to compute properties at adiabati flame temperature at start of combustion .. py:attribute:: unburnt :type: libICEpost.src.thermophysicalModels.thermoModels.ThermoModel.ThermoModel The unburnt mixture .. py:attribute:: burnt :type: libICEpost.src.thermophysicalModels.thermoModels.ThermoModel.ThermoModel The burnt mixture .. py:method:: fromDictionary(dictionary: dict) :classmethod: Construct from dictionary. :param dictionary: 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 :type dictionary: dict :returns: Instance of this class :rtype: EstimateBurntUnburntProperties .. py:method:: __call__(model: libICEpost.src.engineModel.EngineModel.EngineModel.EngineModel) Evaluate the function object for a model. yb is computed as: yb = (1 + (1/densityRatio)*(1/xb - 1))^-1 :param model: Input model :type model: EngineModel .. py:class:: 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) Bases: :py:obj:`ZoneFunctionObject` Store the mixture thermophysical properties for a zone at each time-step as: _ Where: property: The property Where: zone: The zone name. By convention, properties of the cylinder zone have no '_' postfix. .. py:attribute:: cp :type: bool save cp? .. py:attribute:: cv :type: bool save cv? .. py:attribute:: gamma :type: bool save gamma? .. py:attribute:: ha :type: bool save ha? .. py:attribute:: ua :type: bool save ua? .. py:attribute:: hs :type: bool save hs? .. py:attribute:: us :type: bool save us? .. py:attribute:: hf :type: bool save hf? .. py:attribute:: Z :type: bool save Z? .. py:attribute:: MM :type: bool save MM? .. py:method:: fromDictionary(dictionary: dict) :classmethod: Construct from dictionary. :param dictionary: 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? :type dictionary: dict :returns: Instance of this class :rtype: SaveMixtureProperties .. py:method:: __call__(model: libICEpost.src.engineModel.EngineModel.EngineModel.EngineModel) Evaluate the function object for a model. :param model: Input model :type model: EngineModel