Basic unit
-
class CBaseUnit
Basic class for dynamic and steady-state models.
It describes a mathematical model. A somewhat misleading name of the class is kept for compatibility reasons.
Public Functions
-
void ConfigureUnitStructures(const CBaseUnit *_other)
Sets pointers and values of all required internal data.
- Parameters
_other – Pointer to an existing unit.
-
std::string GetUnitName() const
Returns the name of the unit.
Basic unit information
- Returns
Name of the unit.
-
std::string GetAuthorName() const
Returns the name of unit’s author.
- Returns
Name of unit’s author.
-
size_t GetVersion() const
Returns the version of the unit.
- Returns
Version of the unit.
-
std::string GetUniqueID() const
Returns the unique identifier of the unit.
- Returns
Unique identifier of the unit.
-
std::string GetHelpLink() const
Returns the help link of the unit.
- Returns
Help link of the unit.
-
void SetUnitName(const std::string &_name)
Sets the name of the unit.
Should be used in CBaseUnit::CreateBasicInfo() function only.
- Parameters
_name – Name of the unit.
-
void SetAuthorName(const std::string &_author)
Sets the name of unit’s author.
Should be used in CBaseUnit::CreateBasicInfo() function only.
- Parameters
_author – Author’s name
-
void SetVersion(size_t _version)
Sets the version of the unit.
Should be used in CBaseUnit::CreateBasicInfo() function only.
- Parameters
_version – Unit’s version.
-
void SetUniqueID(const std::string &_id)
Sets the unique identifier of the unit.
Should be used in CBaseUnit::CreateBasicInfo() function only.
- Parameters
_id – Identifier of the unit. Must be unique among all units in the library.
-
void SetHelpLink(const std::string &_helpLink)
Sets the help link of the unit.
- Parameters
_helpLink – Help link of the unit.
-
const CPortsManager &GetPortsManager() const
Returns a const reference to ports manager.
Can be used for centralized access to ports.
- Returns
Const reference to ports manager.
-
CUnitPort *AddPort(const std::string &_portName, EUnitPort _type)
Adds a port to the unit.
Should be used in CBaseUnit::CreateBasicInfo() function only. If the unit already has a port with the same name, a logic_error exception is thrown.
- Parameters
_portName – Name of the port. Must be unique within the unit.
_type – Type of the port.
- Returns
Pointer to the created port.
-
const CUnitPort *GetPort(const std::string &_portName) const
Returns a const pointer to the specified port of the unit.
If no such port exists, a logic_error exception is thrown.
- Parameters
_portName – Name of the port.
- Returns
Const pointer to the port.
-
CUnitPort *GetPort(const std::string &_portName)
Returns a pointer to the specified port of the unit.
If no such port exists, a logic_error exception is thrown.
- Parameters
_portName – Name of the port.
- Returns
Pointer to the port.
-
CStream *GetPortStream(const std::string &_portName) const
Returns a pointer to the stream connected to this port.
If such port does not exist or empty, a logic_error exception is thrown.
- Parameters
_portName – Name of the port.
- Returns
Pointer to the connected stream.
-
CStream *AddFeed(const std::string &_name)
Adds a new feed to the unit.
Adds a new feed with the specified name to the unit. The structure of the feed will be the same as the global streams structure (MD dimensions, phases, grids, compounds etc.). Name should be unique within the unit. If a feed with the given name already exists in the unit, a logic_error exception is thrown. Should be used in the CBaseUnit::CreateStructure() function; then the feed will be automatically handled by the simulation system (saved and loaded during the simulation, cleared and removed after use). However, it is allowed to add feed outside CBaseUnit::CreateStructure() for temporal purposes, but you have to save, load (in the functions CBaseUnit::SaveState(), CBaseUnit::LoadState()) and remove this feed (by calling CBaseUnit::RemoveFeed()) manually. Otherwise, all such feeds will be removed at the end of the simulation. This function returns the pointer to a created feed. This pointer should not be used inside the CBaseUnit::CreateStructure() function, since all changes of the feed made through this pointer will be discarded during the initialization of the unit.
- Parameters
_name – Name of the feed.
- Returns
Pointer to the added feed.
-
const CStream *GetFeed(const std::string &_name) const
Returns a const pointer to the feed with the specified name.
If such feed does not exist, a logic_error exception is thrown. The returned pointer should not be used inside the CBaseUnit::CreateStructure() function, since all changes of the feed made through this pointer will be discarded during the initialization of the unit.
- Parameters
_name – Name of the feed.
- Returns
Const pointer to the feed.
-
CStream *GetFeed(const std::string &_name)
Returns a pointer to the feed with the specified name.
If such feed does not exist, a logic_error exception is thrown. The returned pointer should not be used inside the CBaseUnit::CreateStructure() function, since all changes of the feed made through this pointer will be discarded during the initialization of the unit.
- Parameters
_name – Name of the feed.
- Returns
Pointer to the feed.
-
void RemoveFeed(const std::string &_name)
Removes the feed with the specified name from the unit.
If such feed does not exist, a logic_error exception is thrown. Should be used only for those feeds, which have been added to the unit outside the CBaseUnit::CreateStructure().
- Parameters
_name – Name of the feed.
-
CHoldup *AddHoldup(const std::string &_name)
Adds a new holdup to the unit.
Adds a new holdup with the specified name to the unit. The structure of the holdup will be the same as the global streams structure (MD dimensions, phases, grids, compounds etc.). Name should be unique within the unit. If a holdup with the given name already exists in the unit, a logic_error exception is thrown. Should be used in the CBaseUnit::CreateStructure() function; then the holdup will be automatically handled by the simulation system (saved and loaded during the simulation, cleared and removed after use). However, it is allowed to add holdup outside CBaseUnit::CreateStructure() for temporal purposes, but you have to save, load (in the functions CBaseUnit::SaveState(), CBaseUnit::LoadState()) and remove this holdup (by calling CBaseUnit::RemoveFeed()) manually. Otherwise, all such holdups will be removed at the end of the simulation. This function returns the pointer to a created holdup. This pointer should not be used inside the CBaseUnit::CreateStructure() function, since all changes of the holdup made through this pointer will be discarded during the initialization of the unit.
- Parameters
_name – Name of the holdup.
- Returns
Pointer to the added holdup.
-
const CHoldup *GetHoldup(const std::string &_name) const
Returns a const pointer to the holdup with the specified name.
If such holdup does not exist, a logic_error exception is thrown. The returned pointer should not be used inside the CBaseUnit::CreateStructure() function, since all changes of the holdup made through this pointer will be discarded during the initialization of the unit.
- Parameters
_name – Name of the holdup.
- Returns
Const pointer to the holdup.
-
CHoldup *GetHoldup(const std::string &_name)
Returns a pointer to the holdup with the specified name.
If such holdup does not exist, a logic_error exception is thrown. The returned pointer should not be used inside the CBaseUnit::CreateStructure() function, since all changes of the holdup made through this pointer will be discarded during the initialization of the unit.
- Parameters
_name – Name of the holdup.
- Returns
Pointer to the holdup.
-
void RemoveHoldup(const std::string &_name)
Removes the holdup with the specified name from the unit.
If such holdup does not exist, a logic_error exception is thrown. Should be used only for those holdups, which have been added to the unit outside the CBaseUnit::CreateStructure().
- Parameters
_name – Name of the holdup.
-
CStream *AddStream(const std::string &_name)
Adds a new stream to the unit.
Adds a new stream with the specified name to the unit. The structure of the stream will be the same as the global streams structure (MD dimensions, phases, grids, compounds etc.). Name should be unique within the unit. If a stream with the given name already exists in the unit, a logic_error exception is thrown. Should be used in the CBaseUnit::CreateStructure() function; then the stream will be automatically handled by the simulation system (saved and loaded during the simulation, cleared and removed after use). However, it is allowed to add stream outside CBaseUnit::CreateStructure() for temporal purposes, but you have to save, load (in the functions CBaseUnit::SaveState(), CBaseUnit::LoadState()) and remove this stream (by calling CBaseUnit::RemoveFeed()) manually. Otherwise, all such streams will be removed at the end of the simulation. This function returns the pointer to a created stream. This pointer should not be used inside the CBaseUnit::CreateStructure() function, since all changes of the stream made through this pointer will be discarded during the initialization of the unit.
- Parameters
_name – Name of the stream.
- Returns
Pointer to the added stream.
-
const CStream *GetStream(const std::string &_name) const
Returns a const pointer to the stream with the specified name.
If such stream does not exist, a logic_error exception is thrown. The returned pointer should not be used inside the CBaseUnit::CreateStructure() function, since all changes of the stream made through this pointer will be discarded during the initialization of the unit.
- Parameters
_name – Name of the stream.
- Returns
Const pointer to the stream.
-
CStream *GetStream(const std::string &_name)
Returns a pointer to the stream with the specified name.
If such stream does not exist, a logic_error exception is thrown. The returned pointer should not be used inside the CBaseUnit::CreateStructure() function, since all changes of the stream made through this pointer will be discarded during the initialization of the unit.
- Parameters
_name – Name of the stream.
- Returns
Pointer to the stream.
-
void RemoveStream(const std::string &_name)
Removes the stream with the specified name from the unit.
If such stream does not exist, a logic_error exception is thrown. Should be used only for those streams, which have been added to the unit outside the CBaseUnit::CreateStructure().
- Parameters
_name – Name of the stream.
-
const CUnitParametersManager &GetUnitParametersManager() const
Returns a const reference to unit parameters manager.
Can be used for centralized access to unit parameters.
- Returns
Const reference to unit parameters manager.
-
CConstRealUnitParameter *AddConstRealParameter(const std::string &_name, double _initValue, const std::string &_units, const std::string &_description, double _minValue = std::numeric_limits<double>::lowest(), double _maxValue = std::numeric_limits<double>::max())
Adds a new real constant unit parameter to the unit.
Should be used in the CBaseUnit::CreateStructure() function. Adds the possibility to specify one real value as a parameter. The name of the parameter should be unique within the unit. If the unit already has a parameter with the same name, logic_error exception is thrown. Boundary values are only a recommendation to the user, and going beyond them will only result in a warning to the user. Boundary values are optional; if they are not specified, the limits do not apply.
- Parameters
_name – Name of the unit parameter.
_initValue – Initial value.
_units – Units of measurement.
_description – Extended parameter description.
_minValue – Minimum boundary value of the parameter.
_maxValue – Maximum boundary value of the parameter.
- Returns
Pointer to the added unit parameter.
-
CConstIntUnitParameter *AddConstIntParameter(const std::string &_name, int64_t _initValue, const std::string &_units, const std::string &_description, int64_t _minValue = std::numeric_limits<int64_t>::lowest(), int64_t _maxValue = std::numeric_limits<int64_t>::max())
Adds a new signed integer constant unit parameter to the unit.
Should be used in the CBaseUnit::CreateStructure() function. Adds the possibility to specify one signed integer value as a parameter. The name of the parameter should be unique within the unit. If the unit already has a parameter with the same name, logic_error exception is thrown. Boundary values are only a recommendation to the user, and going beyond them will only result in a warning to the user. Boundary values are optional; if they are not specified, the limits do not apply.
- Parameters
_name – Name of the unit parameter.
_initValue – Initial value.
_units – Units of measurement.
_description – Extended parameter description.
_minValue – Minimum boundary value of the parameter.
_maxValue – Maximum boundary value of the parameter.
- Returns
Pointer to the added unit parameter.
-
CConstUIntUnitParameter *AddConstUIntParameter(const std::string &_name, uint64_t _initValue, const std::string &_units, const std::string &_description, uint64_t _minValue = std::numeric_limits<uint64_t>::lowest(), uint64_t _maxValue = std::numeric_limits<uint64_t>::max())
Adds a new unsigned integer constant unit parameter to the unit.
Should be used in the CBaseUnit::CreateStructure() function. Adds the possibility to specify one unsigned integer value as a parameter. The name of the parameter should be unique within the unit. If the unit already has a parameter with the same name, logic_error exception is thrown. Boundary values are only a recommendation to the user, and going beyond them will only result in a warning to the user. Boundary values are optional; if they are not specified, the limits do not apply.
- Parameters
_name – Name of the unit parameter.
_initValue – Initial value.
_units – Units of measurement.
_description – Extended parameter description.
_minValue – Minimum boundary value of the parameter.
_maxValue – Maximum boundary value of the parameter.
- Returns
Pointer to the added unit parameter.
-
CDependentUnitParameter *AddDependentParameter(const std::string &_valueName, double _valueInit, const std::string &_valueUnits, const std::string &_paramName, double _paramInit, const std::string &_paramUnits, const std::string &_description, double _valueMin = std::numeric_limits<double>::lowest(), double _valueMax = std::numeric_limits<double>::max(), double _paramMin = std::numeric_limits<double>::lowest(), double _paramMax = std::numeric_limits<double>::max())
Adds a new dependent unit parameter to the unit.
Should be used in the CBaseUnit::CreateStructure() function. Adds the possibility to specify dependency between two values. The name of the parameter should be unique within the unit. If the unit already has a parameter with the same name, logic_error exception is thrown. Boundary values are only a recommendation to the user, and going beyond them will only result in a warning to the user. Boundary values are optional; if they are not specified, the limits do not apply.
- Parameters
_valueName – Name of the value and the unit parameter.
_valueInit – Initial value.
_valueUnits – Units of measurement of values.
_paramName – Name of the parameter.
_paramInit – Initial value of the parameter.
_paramUnits – Units of measurement of parameters.
_description – Extended parameter description.
_valueMin – Minimum boundary of the value.
_valueMax – Maximum boundary of the value.
_paramMin – Minimum boundary of the parameter.
_paramMax – Maximum boundary of the parameter.
- Returns
Pointer to the added unit parameter.
-
CTDUnitParameter *AddTDParameter(const std::string &_name, double _initValue, const std::string &_units, const std::string &_description, double _minValue = std::numeric_limits<double>::lowest(), double _maxValue = std::numeric_limits<double>::max())
Adds a new real time-dependent unit parameter to the unit.
Should be used in the CBaseUnit::CreateStructure() function. Adds the possibility to specify multiple values at different time points as a parameter. The name of the parameter should be unique within the unit. If the unit already has a parameter with the same name, logic_error exception is thrown. Boundary values are only a recommendation to the user, and going beyond them will only result in a warning to the user. Boundary values are optional; if they are not specified, the limits do not apply.
- Parameters
_name – Name of the unit parameter.
_initValue – Initial value.
_units – Units of measurement.
_description – Extended parameter description.
_minValue – Minimum boundary value of the parameter.
_maxValue – Maximum boundary value of the parameter.
- Returns
Pointer to the added unit parameter.
-
CStringUnitParameter *AddStringParameter(const std::string &_name, const std::string &_initValue, const std::string &_description)
Adds a new string unit parameter to the unit.
Should be used in the CBaseUnit::CreateStructure() function. Adds the possibility to specify one string value as a parameter. The name of the parameter should be unique within the unit. If the unit already has a parameter with the same name, logic_error exception is thrown.
- Parameters
_name – Name of the unit parameter.
_initValue – Initial value.
_description – Extended parameter description.
- Returns
Pointer to the added unit parameter.
-
CCheckBoxUnitParameter *AddCheckBoxParameter(const std::string &_name, bool _initValue, const std::string &_description)
Adds a new two-positional checkbox unit parameter to the unit.
Should be used in the CBaseUnit::CreateStructure() function. Adds the possibility to specify one two-positional (yes/no) parameter. The name of the parameter should be unique within the unit. If the unit already has a parameter with the same name, logic_error exception is thrown.
- Parameters
_name – Name of the unit parameter.
_initValue – Initial value.
_description – Extended parameter description.
- Returns
Pointer to the added unit parameter.
-
CComboUnitParameter *AddComboParameter(const std::string &_name, size_t _initValue, const std::vector<size_t> &_items, const std::vector<std::string> &_itemsNames, const std::string &_description)
Adds a new combobox unit parameter to the unit.
Should be used in the CBaseUnit::CreateStructure() function. Adds the possibility to select a single value from the list. The name of the parameter should be unique within the unit. If the unit already has a parameter with the same name, logic_error exception is thrown.
- Parameters
_name – Name of the unit parameter.
_initValue – Initial value.
_items – List of selectable items.
_itemsNames – List of names for each selectable item.
_description – Extended parameter description.
- Returns
Pointer to the added unit parameter.
-
template<typename T, typename = std::enable_if_t<std::is_enum_v<T>>>
CComboUnitParameter *AddComboParameter(const std::string &_name, T _initValue, const std::vector<T> &_items, const std::vector<std::string> &_itemsNames, const std::string &_description) Adds a new combobox unit parameter to the unit.
Should be used in the CBaseUnit::CreateStructure() function. Adds the possibility to select a single value from the list. The name of the parameter should be unique within the unit. If the unit already has a parameter with the same name, logic_error exception is thrown.
- Parameters
_name – Name of the unit parameter.
_initValue – Initial value.
_items – List of selectable items.
_itemsNames – List of names for each selectable item.
_description – Extended parameter description.
- Returns
Pointer to the added unit parameter.
-
CCompoundUnitParameter *AddCompoundParameter(const std::string &_name, const std::string &_description)
Adds a new compound combobox unit parameter to the unit.
Should be used in the CBaseUnit::CreateStructure() function. Adds the possibility to select a single compound from the list of active compounds. The name of the parameter should be unique within the unit. If the unit already has a parameter with the same name, logic_error exception is thrown.
- Parameters
_name – Name of the unit parameter.
_description – Extended parameter description.
- Returns
Pointer to the added unit parameter.
-
CMDBCompoundUnitParameter *AddMDBCompoundParameter(const std::string &_name, const std::string &_description)
Adds a new MDB compound combobox unit parameter to the unit.
Should be used in the CBaseUnit::CreateStructure() function. Adds the possibility to select a single compound from the materials database. The name of the parameter should be unique within the unit. If the unit already has a parameter with the same name, logic_error exception is thrown.
- Parameters
_name – Name of the unit parameter.
_description – Extended parameter description.
- Returns
Pointer to the added unit parameter.
-
CReactionUnitParameter *AddReactionParameter(const std::string &_name, const std::string &_description)
Adds a new reaction unit parameter to the unit.
Should be used in the CBaseUnit::CreateStructure() function. Adds the possibility to specify one or several reactions. The name of the parameter should be unique within the unit. If the unit already has a parameter with the same name, logic_error exception is thrown.
- Parameters
_name – Name of the unit parameter.
_description – Extended parameter description.
- Returns
Pointer to the added unit parameter.
-
CListRealUnitParameter *AddListRealParameter(const std::string &_name, double _initValue, const std::string &_units, const std::string &_description, double _minValue = std::numeric_limits<double>::lowest(), double _maxValue = std::numeric_limits<double>::max())
Adds a new real list unit parameter to the unit.
Should be used in the CBaseUnit::CreateStructure() function. Adds the possibility to specify multiple real values as a parameter. The name of the parameter should be unique within the unit. If the unit already has a parameter with the same name, logic_error exception is thrown. Boundary values are only a recommendation to the user, and going beyond them will only result in a warning to the user. Boundary values are optional; if they are not specified, the limits do not apply.
- Parameters
_name – Name of the unit parameter.
_initValue – Initial value.
_units – Units of measurement.
_description – Extended parameter description.
_minValue – Minimum boundary value of the parameter.
_maxValue – Maximum boundary value of the parameter.
- Returns
Pointer to the added unit parameter.
-
CListIntUnitParameter *AddListIntParameter(const std::string &_name, int64_t _initValue, const std::string &_units, const std::string &_description, int64_t _minValue = std::numeric_limits<int64_t>::lowest(), int64_t _maxValue = std::numeric_limits<int64_t>::max())
Adds a new signed integer list unit parameter to the unit.
Should be used in the CBaseUnit::CreateStructure() function. Adds the possibility to specify multiple signed integer values as a parameter. The name of the parameter should be unique within the unit. If the unit already has a parameter with the same name, logic_error exception is thrown. Boundary values are only a recommendation to the user, and going beyond them will only result in a warning to the user. Boundary values are optional; if they are not specified, the limits do not apply.
- Parameters
_name – Name of the unit parameter.
_initValue – Initial value.
_units – Units of measurement.
_description – Extended parameter description.
_minValue – Minimum boundary value of the parameter.
_maxValue – Maximum boundary value of the parameter.
- Returns
Pointer to the added unit parameter.
-
CListUIntUnitParameter *AddListUIntParameter(const std::string &_name, uint64_t _initValue, const std::string &_units, const std::string &_description, uint64_t _minValue = std::numeric_limits<uint64_t>::lowest(), uint64_t _maxValue = std::numeric_limits<uint64_t>::max())
Adds a new unsigned integer list unit parameter to the unit.
Should be used in the CBaseUnit::CreateStructure() function. Adds the possibility to specify multiple unsigned integer values as a parameter. The name of the parameter should be unique within the unit. If the unit already has a parameter with the same name, logic_error exception is thrown. Boundary values are only a recommendation to the user, and going beyond them will only result in a warning to the user. Boundary values are optional; if they are not specified, the limits do not apply.
- Parameters
_name – Name of the unit parameter.
_initValue – Initial value.
_units – Units of measurement.
_description – Extended parameter description.
_minValue – Minimum boundary value of the parameter.
_maxValue – Maximum boundary value of the parameter.
- Returns
Pointer to the added unit parameter.
-
CSolverUnitParameter *AddSolverAgglomeration(const std::string &_name, const std::string &_description)
Adds a new agglomeration solver unit parameter to the unit.
Should be used in the CBaseUnit::CreateStructure() function. Adds the possibility to choose one of the available agglomeration solvers of this type. The name of the parameter should be unique within the unit. If the unit already has a parameter with the same name, logic_error exception is thrown. Boundary values are only a recommendation to the user, and going beyond them will only result in a warning to the user. Boundary values are optional; if they are not specified, the limits do not apply.
- Parameters
_name – Name of the unit parameter.
_description – Extended parameter description.
- Returns
Pointer to the added unit parameter.
-
void AddParametersToGroup(const std::string &_unitParamNameSelector, const std::string &_unitParamSelectedValueName, const std::vector<std::string> &_groupedParamNames)
Groups the specified unit parameters.
Allows to hide some parameters depending on the selected value of a combobox unit parameter. The parameter, its value and all the adding parameters must already exist. If something does not exist, logic_error exception is thrown.
- Parameters
_unitParamNameSelector – Name of the target combobox unit parameter.
_unitParamSelectedValueName – Selected value of the target combobox unit parameter.
_groupedParamNames – Names of other unit parameters that will be shown if
_unitParamSelectedValueName
is selected.
-
void AddParametersToGroup(const CComboUnitParameter *_selector, size_t _selectedValue, const std::vector<CBaseUnitParameter*> &_groupedParams)
Groups the specified unit parameters.
Allows to hide some parameters depending on the selected value of a combobox unit parameter. The parameter, its value and all the adding parameters must already exist. If something does not exist, logic_error exception is thrown.
- Parameters
_selector – Pointer to the target combobox unit parameter.
_selectedValue – Selected value of the target combobox unit parameter.
_groupedParams – Other unit parameters that will be shown if
_selectedValue
is selected.
-
template<typename T, typename = std::enable_if_t<std::is_enum_v<T>>>
void AddParametersToGroup(const CComboUnitParameter *_selector, T _selectedValue, const std::vector<CBaseUnitParameter*> &_groupedParams) Groups the specified unit parameters.
Allows to hide some parameters depending on the selected value of a combobox unit parameter. The parameter, its value and all the adding parameters must already exist. If something does not exist, logic_error exception is thrown.
- Parameters
_selector – Pointer to the target combobox unit parameter.
_selectedValue – Selected value of the target combobox unit parameter.
_groupedParams – Other unit parameters that will be shown if
_selectedValue
is selected.
-
double GetConstRealParameterValue(const std::string &_name) const
Returns value of the real constant unit parameter.
Throws logic_error exception if a unit parameter with the given name and type does not exist.
- Parameters
_name – Name of the unit parameter.
- Returns
Current value of the unit parameter.
-
int64_t GetConstIntParameterValue(const std::string &_name) const
Returns value of the signed integer constant unit parameter.
Throws logic_error exception if a unit parameter with the given name and type does not exist.
- Parameters
_name – Name of the unit parameter.
- Returns
Current value of the unit parameter.
-
uint64_t GetConstUIntParameterValue(const std::string &_name) const
Returns value of the unsigned integer constant unit parameter.
Throws logic_error exception if a unit parameter with the given name and type does not exist.
- Parameters
_name – Name of the unit parameter.
- Returns
Current value of the unit parameter.
-
double GetDependentParameterValue(const std::string &_name, double _param) const
Returns value of the dependent unit parameter at the given value of the parameter.
If the selected parameter value has not been defined, linear interpolation or nearest-neighbor extrapolation will be performed. Throws logic_error exception if a unit parameter with the given name and type does not exist.
- Parameters
_name – Name of the unit parameter.
_param – Target parameter value.
- Returns
Current value of the unit parameter at the given parameter value.
-
double GetTDParameterValue(const std::string &_name, double _time) const
Returns value of the real time-dependent unit parameter at the given time point.
If the selected time point has not been defined, linear interpolation or nearest-neighbor extrapolation will be performed. Throws logic_error exception if a unit parameter with the given name and type does not exist.
- Parameters
_name – Name of the unit parameter.
_time – Target time point.
- Returns
Current value of the unit parameter at the given time point.
-
std::string GetStringParameterValue(const std::string &_name) const
Returns value of the string unit parameter.
Throws logic_error exception if a unit parameter with the given name and type does not exist.
- Parameters
_name – Name of the unit parameter.
- Returns
Current value of the unit parameter.
-
bool GetCheckboxParameterValue(const std::string &_name) const
Returns value of the checkbox unit parameter.
Throws logic_error exception if a unit parameter with the given name and type does not exist.
- Parameters
_name – Name of the unit parameter.
- Returns
Current value of the unit parameter.
-
size_t GetComboParameterValue(const std::string &_name) const
Returns value of the combobox unit parameter.
Throws logic_error exception if a unit parameter with the given name and type does not exist.
- Parameters
_name – Name of the unit parameter.
- Returns
Current value of the unit parameter.
-
std::string GetCompoundParameterValue(const std::string &_name) const
Returns value of the compound combobox unit parameter.
Throws logic_error exception if a unit parameter with the given name and type does not exist.
- Parameters
_name – Name of the unit parameter.
- Returns
Unique key of the selected compound.
-
std::string GetMDBCompoundParameterValue(const std::string &_name) const
Returns value of the MDB compound combobox unit parameter.
Throws logic_error exception if a unit parameter with the given name and type does not exist.
- Parameters
_name – Name of the unit parameter.
- Returns
Unique key of the selected compound.
-
std::vector<CChemicalReaction> GetReactionParameterValue(const std::string &_name) const
Returns value of the reaction unit parameter.
Throws logic_error exception if a unit parameter with the given name and type does not exist.
- Parameters
_name – Name of the unit parameter.
- Returns
List of defined reactions.
-
double GetListRealParameterValue(const std::string &_name, size_t _index) const
Returns value of the real list unit parameter at the given index.
If the selected index has not been defined, 0 is returned. Throws logic_error exception if a unit parameter with the given name and type does not exist.
- Parameters
_name – Name of the unit parameter.
_index – Target index.
- Returns
Current value of the unit parameter at the given time point.
-
int64_t GetListIntParameterValue(const std::string &_name, size_t _index) const
Returns value of the signed integer list unit parameter at the given index.
If the selected index has not been defined, 0 is returned. Throws logic_error exception if a unit parameter with the given name and type does not exist.
- Parameters
_name – Name of the unit parameter.
_index – Target index.
- Returns
Current value of the unit parameter at the given time point.
-
uint64_t GetListUIntParameterValue(const std::string &_name, size_t _index) const
Returns value of the unsigned integer list unit parameter at the given index.
If the selected index has not been defined, 0 is returned. Throws logic_error exception if a unit parameter with the given name and type does not exist.
- Parameters
_name – Name of the unit parameter.
_index – Target index.
- Returns
Current value of the unit parameter at the given time point.
-
CAgglomerationSolver *GetSolverAgglomeration(const std::string &_name) const
Returns value of the agglomeration solver unit parameter.
Throws logic_error exception if a unit parameter with the given name and type does not exist.
- Parameters
_name – Name of the unit parameter.
- Returns
Pointer to the selected agglomeration solver.
-
CAgglomerationSolver *GetSolverAgglomeration(const CSolverUnitParameter *_param) const
Returns value of the agglomeration solver unit parameter.
Throws logic_error exception if the provided pointer to the unit parameter is of the wrong type.
- Parameters
_param – Pointer to the agglomeration solver unit parameter.
- Returns
Pointer to the selected agglomeration solver.
-
const CStateVariablesManager &GetStateVariablesManager() const
Returns a const reference to state variables manager.
Can be used for centralized access to state variables.
- Returns
Const reference to state variables manager.
-
CStateVariable *AddStateVariable(const std::string &_name, double _initValue)
Adds a new state variable.
Can be used to handle state-dependent values: all variables added with this function will be automatically saved and restored during the simulation. Can also store the history of changes during the simulation for further post-processing. The name must by unique within the unit. If the unit already has a state variable with the same name, logic_error exception is thrown. Should be used in the CBaseUnit::CreateStructure() function.
- Parameters
_name – Name of the variable.
_initValue – Initial value of the variable.
- Returns
Pointer to the added state variable.
-
double GetStateVariable(const std::string &_name) const
Returns current value of the state variable.
If a state variable with the given name does not exist in this unit, logic_error exception is thrown.
- Parameters
_name – Name of the variable.
- Returns
Current value of the state variable.
-
void SetStateVariable(const std::string &_name, double _value)
Sets a new value of the state variable.
If a state variable with the given name does not exist in this unit, logic_error exception is thrown.
- Parameters
_name – Name of the variable.
_value – Name value of the variable.
-
void SetStateVariable(const std::string &_name, double _value, double _time)
Sets a new value of the state variable and adds its value to the history.
If a state variable with the given name does not exist in this unit, logic_error exception is thrown.
- Parameters
_name – Name of the variable.
_value – Name value of the variable.
_time – Time point for which new value is added to the history.
-
CPlot *AddPlot(const std::string &_plotName, const std::string &_labelX, const std::string &_labelY)
Adds a new 2-dimensional plot to the unit.
Adds a plot with the specified name and axes labels to the unit and returns a pointer to it. If the unit already has a plot with the same name, logic_error exception is thrown.
- Parameters
_plotName – Name of the plot.
_labelX – Text label of the X-axis.
_labelY – Text label of the Y-axis.
- Returns
Pointer to the added plot.
-
CPlot *AddPlot(const std::string &_plotName, const std::string &_labelX, const std::string &_labelY, const std::string &_labelZ)
Adds a new 3-dimensional plot to the unit.
Adds a plot with the specified name and axes labels to the unit and returns a pointer to it. If the unit already has a plot with the same name, logic_error exception is thrown.
- Parameters
_plotName – Name of the plot.
_labelX – Text label of the X-axis.
_labelY – Text label of the Y-axis.
_labelZ – Text label of the Z-axis.
- Returns
Pointer to the added plot.
-
CCurve *AddCurveOnPlot(const std::string &_plotName, const std::string &_curveName)
Adds a new curve to a 2-dimensional plot.
Adds a new curve with the specified name to the 2-dimensional plot with the given name and returns a pointer to it. If a plot with this name does not exist or it already contains a curve with the given name, logic_error exception is thrown.
- Parameters
_plotName – Name of the plot.
_curveName – Name of the new curve.
- Returns
Pointer to the added curve.
-
CCurve *AddCurveOnPlot(const std::string &_plotName, double _valueZ)
Adds a new curve to a 3-dimensional plot.
Adds a new curve with the specified Z-value to the 3-dimensional plot with the given name and returns a pointer to it. If a plot with this name does not exist or it already contains a curve with the given Z-value, logic_error exception is thrown.
- Parameters
_plotName – Name of the plot.
_valueZ – Z-value of the new curve.
- Returns
Pointer to the added curve.
-
void AddPointOnCurve(const std::string &_plotName, const std::string &_curveName, double _x, double _y)
Adds a new point to the curve on the 2-dimensional plot.
Adds a new point to the specified curve on the 2-dimensional plot. If a plot or a curve with these names do not exist, logic_error exception is thrown.
- Parameters
_plotName – Name of the plot.
_curveName – Name of the curve on plot.
_x – X-value of the new point.
_y – Y-value of the new point.
-
void AddPointOnCurve(const std::string &_plotName, double _valueZ, double _x, double _y)
Adds a new point to the curve on the 3-dimensional plot.
Adds a new point to the specified curve on the 2-dimensional plot. If a plot with this name or a curve with this Z-value do not exist, logic_error exception is thrown.
- Parameters
_plotName – Name of the plot.
_valueZ – Z-value of the curve.
_x – X-value of the new point.
_y – Y-value of the new point.
-
void AddPointsOnCurve(const std::string &_plotName, const std::string &_curveName, const std::vector<double> &_x, const std::vector<double> &_y)
Adds new points to the curve on the 2-dimensional plot.
Adds new points to the specified curve on the 2-dimensional plot. If a plot or a curve with these names do not exist, logic_error exception is thrown.
- Parameters
_plotName – Name of the plot.
_curveName – Name of the curve on plot.
_x – X-values of the new points.
_y – Y-values of the new points.
-
void AddPointsOnCurve(const std::string &_plotName, double _valueZ, const std::vector<double> &_x, const std::vector<double> &_y)
Adds new points to the curve on the 3-dimensional plot.
Adds new points to the specified curve on the 2-dimensional plot. If a plot with this name or a curve with this Z-value do not exist, logic_error exception is thrown.
- Parameters
_plotName – Name of the plot.
_valueZ – Z-value of the curve.
_x – X-values of the new points.
_y – Y-values of the new points.
-
void CopyStreamToPort(double _time, const CStream *_stream, CUnitPort *_port) const
Copies all stream data from the given stream to the stream connected to the selected output port at the given time point.
All data after the time point are removed from the destination stream. Throws logic_error exception on error.
- Parameters
_time – Time point to copy.
_stream – Source stream.
_port – Destination port.
-
void CopyStreamToPort(double _time, const CStream *_stream, const std::string &_portName)
Copies all stream data from the given stream to the stream connected to the selected output port at the given time point.
All data after the time point are removed from the destination stream. Throws logic_error exception on error.
- Parameters
_time – Time point to copy.
_stream – Source stream.
_portName – Name of the destination port.
-
void CopyStreamToPort(double _timeBeg, double _timeEnd, const CStream *_stream, CUnitPort *_port) const
Copies all stream data from the given stream to the stream connected to the selected output port at the given time interval.
All data after the end time point are removed from the destination stream. Throws logic_error exception on error.
- Parameters
_timeBeg – Begin of the time interval to copy.
_timeEnd – End of the time interval to copy.
_stream – Source stream.
_port – Destination port.
-
void CopyStreamToPort(double _timeBeg, double _timeEnd, const CStream *_stream, const std::string &_portName)
Copies all stream data from the given stream to the stream connected to the selected output port at the given time interval.
All data after the end time point are removed from the destination stream. Throws logic_error exception on error.
- Parameters
_timeBeg – Begin of the time interval to copy.
_timeEnd – End of the time interval to copy.
_stream – Source stream.
_portName – Name of the destination port.
-
void CopyPortToStream(double _time, const CUnitPort *_port, CStream *_stream) const
Copies all stream data from the stream connected to the selected input port to the given stream at the given time point.
All data after the time point are removed from the destination stream. Throws logic_error exception on error.
- Parameters
_time – Time point to copy.
_port – Source port.
_stream – Destination stream.
-
void CopyPortToStream(double _time, const std::string &_portName, CStream *_stream)
Copies all stream data from the stream connected to the selected input port to the given stream at the given time point.
All data after the time point are removed from the destination stream. Throws logic_error exception on error.
- Parameters
_time – Time point to copy.
_portName – Name of the source port.
_stream – Destination stream.
-
void CopyPortToStream(double _timeBeg, double _timeEnd, const CUnitPort *_port, CStream *_stream) const
Copies all stream data from the stream connected to the selected input port to the given stream at the given time interval.
All data after the end time point are removed from the destination stream. Throws logic_error exception on error.
- Parameters
_timeBeg – Begin of the time interval to copy.
_timeEnd – End of the time interval to copy.
_port – Source port.
_stream – Destination stream.
-
void CopyPortToStream(double _timeBeg, double _timeEnd, const std::string &_portName, CStream *_stream)
Copies all stream data from the stream connected to the selected input port to the given stream at the given time interval.
All data after the end time point are removed from the destination stream. Throws logic_error exception on error.
- Parameters
_timeBeg – Begin of the time interval to copy.
_timeEnd – End of the time interval to copy.
_portName – Name of the source port.
_stream – Destination stream.
-
std::vector<double> GetAllTimePoints() const
Returns all time points at which input streams and time-dependent parameters are defined.
- Returns
Sorted vector of time points.
-
std::vector<double> GetAllTimePoints(double _timeBeg, double _timeEnd) const
Returns all time points in the specified time interval at which input streams and time-dependent parameters are defined.
- Parameters
_timeBeg – Begin of the time interval.
_timeEnd – End of the time interval.
- Returns
Sorted vector of time points.
-
std::vector<double> GetAllTimePointsClosed(double _timeBeg, double _timeEnd) const
Returns all time points in the specified time interval at which input streams and time-dependent parameters are defined.
Boundary time points are unconditionally included into result.
- Parameters
_timeBeg – Begin of the time interval.
_timeEnd – End of the time interval.
- Returns
Sorted vector of time points.
-
std::vector<double> GetInputTimePoints() const
Returns all time points at which input streams are defined.
- Returns
Sorted vector of time points.
-
std::vector<double> GetInputTimePoints(double _timeBeg, double _timeEnd) const
Returns all time points in the specified time interval at which input streams are defined.
- Parameters
_timeBeg – Begin of the time interval.
_timeEnd – End of the time interval.
- Returns
Sorted vector of time points.
-
std::vector<double> GetInputTimePointsClosed(double _timeBeg, double _timeEnd) const
Returns all time points in the specified time interval at which input streams are defined.
Boundary time points are unconditionally included into result.
- Parameters
_timeBeg – Begin of the time interval.
_timeEnd – End of the time interval.
- Returns
Sorted vector of time points.
-
std::vector<double> GetStreamsTimePoints(const std::vector<CStream*> &_streams) const
Returns all time points at which given streams are defined.
- Parameters
_streams – List of streams.
- Returns
Sorted vector of time points.
-
std::vector<double> GetStreamsTimePoints(double _timeBeg, double _timeEnd, const std::vector<CStream*> &_streams) const
Returns all time points in the specified time interval at which given streams are defined.
- Parameters
_timeBeg – Begin of the time interval.
_timeEnd – End of the time interval.
_streams – List of streams.
- Returns
Sorted vector of time points.
-
std::vector<double> GetStreamsTimePointsClosed(double _timeBeg, double _timeEnd, const std::vector<CStream*> &_streams) const
Returns all time points in the specified time interval at which given streams are defined.
Boundary time points are unconditionally included into result.
- Parameters
_timeBeg – Begin of the time interval.
_timeEnd – End of the time interval.
_streams – List of streams.
- Returns
Sorted vector of time points.
-
std::string GetCompoundName(const std::string &_compoundKey) const
Returns the name of the compound with the specified unique key.
Returns empty string if such compound does not exist in the list of active compounds.
- Parameters
_compoundKey – Unique key of the compound.
- Returns
Name of the compound.
-
std::string GetCompoundName(size_t _index) const
Returns the name of the compound with the specified index.
Indexing is done in the list of active compounds. Returns empty string if such compound does not exist.
- Parameters
_index – Index of the compound in the list of active compounds.
- Returns
Name of the compound.
-
std::string GetCompoundKey(const std::string &_compoundName) const
Returns the unique key of the compound with the specified name.
Returns empty string if such compound does not exist in the list of active compounds.
- Parameters
_compoundName – Name of the compound.
- Returns
Unique key of the compound.
-
std::string GetCompoundKey(size_t _index) const
Returns the unique key of the compound with the specified index.
Returns empty string if such compound does not exist in the list of active compounds.
- Parameters
_index – Index of the compound in the list of active compounds.
- Returns
Unique key of the compound.
-
size_t GetCompoundIndex(const std::string &_compoundKey) const
Returns index of the compound with the specified key.
Returns -1 if such compound does not exist in the list of active compounds.
- Parameters
_compoundKey – Unique key of the compound.
- Returns
Index of the compound in the list of active compounds.
-
size_t GetCompoundIndexByName(const std::string &_compoundName) const
Returns index of the compound with the specified name.
Returns -1 if such compound does not exist in the list of active compounds.
- Parameters
_compoundName – Name of the compound.
- Returns
Index of the compound in the list of active compounds.
-
std::vector<std::string> GetAllCompounds() const
Returns unique keys of all active compounds.
- Returns
Unique keys of all active compounds.
-
std::vector<std::string> GetAllCompoundsNames() const
Returns names of all active compounds.
- Returns
Unique keys of all active compounds.
-
size_t GetCompoundsNumber() const
Returns the number of active compounds.
- Returns
Number of active compounds.
-
bool IsCompoundDefined(const std::string &_compoundKey) const
Checks if a compound with the specified unique key is defined.
- Parameters
_compoundKey – Unique key of the compound.
- Returns
Whether a compound with the specified unique key is defined.
-
bool IsCompoundNameDefined(const std::string &_compoundName) const
Checks if a compound with the specified name is defined.
- Parameters
_compoundName – Name of the compound.
- Returns
Whether a compound with the specified unique name is defined.
-
std::string GetPhaseName(EPhase _phase) const
Returns the name of the specified phase.
Returns empty string if such phase does not exist in the list of active phases.
- Parameters
_phase – Phase type.
- Returns
Name of the phase.
-
EPhase GetPhaseType(size_t _index) const
Returns the type of the phase with the specified index.
Returns EPhase::UNDEFINED if the phase with the given index does not exist.
- Parameters
_index – Index of the phase in the list of active phases.
- Returns
Phase type.
-
std::vector<EPhase> GetAllPhases() const
Returns types of all active phases.
- Returns
Types of all active phases.
-
size_t GetPhasesNumber() const
Returns the number of active phases.
- Returns
Number of active phases.
-
bool IsPhaseDefined(EPhase _phase) const
Checks if a phase of the specified type is in the list of active phases.
- Returns
Whether a phase of the specified type is defined.
-
size_t GetDistributionsNumber() const
Returns number of defined distributed properties of the solid phase.
- Returns
Number of distributed properties.
-
std::vector<EDistrTypes> GetDistributionsTypes() const
Returns types of all defined distributed properties of the solid phase.
- Returns
Types of all distributed properties.
-
std::vector<size_t> GetDistributionsClasses() const
Returns numbers of classes of all defined distributed properties of the solid phase.
- Returns
Number of classes of all distributed properties.
-
EGridEntry GetDistributionGridType(EDistrTypes _distribution) const
Returns type of grid entries of the given distributed property of the solid phase.
Returns EGridEntry::GRID_UNDEFINED if the given distributed property is not defined.
- Parameters
_distribution – Type of the distributed property.
- Returns
Type of the grid entries.
-
size_t GetClassesNumber(EDistrTypes _distribution) const
Returns number of classes defined for the specified distributed property of the solid phase.
Returns 0 if the given distributed property is not defined.
- Parameters
_distribution – Type of the distributed property.
- Returns
Number of classes.
-
std::vector<double> GetNumericGrid(EDistrTypes _distribution) const
Returns a numeric grid defined for the specified distributed property of the solid phase.
Returns an empty vector if the distribution is not of numeric type.
- Parameters
_distribution – Type of the distributed property.
- Returns
Numeric grid.
-
std::vector<std::string> GetSymbolicGrid(EDistrTypes _distribution) const
Returns a symbolic grid defined for the specified distributed property of the solid phase.
Returns empty vector if the distribution is not of symbolic type.
- Parameters
_distribution – Type of the distributed property.
- Returns
Symbolic grid.
-
std::vector<double> GetClassesSizes(EDistrTypes _distribution) const
Returns the sizes of classes defined in the grid of the specified distributed property of the solid phase.
Returns an empty vector if the distribution is not of numeric type.
- Parameters
_distribution – Type of the distributed property.
- Returns
Sizes of classes.
-
std::vector<double> GetClassesMeans(EDistrTypes _distribution) const
Returns the mean values of classes defined in the grid of the specified distributed property of the solid phase.
Returns an empty vector if the distribution is not of numeric type.
- Parameters
_distribution – Type of the distributed property.
- Returns
Mean values of classes.
-
std::vector<double> GetPSDGridDiameters() const
Returns a grid defined for the particle size distribution in terms of particle diameters.
Returns an empty vector if DISTR_SIZE distribution has not been defined.
- Returns
Particle size grid as diameters.
-
std::vector<double> GetPSDGridSurfaces() const
Returns a grid defined for the particle size distribution in terms of particle surfaces.
Returns an empty vector if DISTR_SIZE distribution has not been defined.
- Returns
Particle size grid as surfaces.
-
std::vector<double> GetPSDGridVolumes() const
Returns a grid defined for the particle size distribution in terms of particle volumes.
Returns an empty vector if DISTR_SIZE distribution has not been defined.
- Returns
Particle size grid as volumes.
-
std::vector<double> GetPSDMeanDiameters() const
Returns mean values of classes defined for the particle size distribution in terms of particle diameters.
Returns an empty vector if DISTR_SIZE distribution has not been defined.
- Returns
Particle mean diameters.
-
std::vector<double> GetPSDMeanSurfaces() const
Returns mean values of classes defined for the particle size distribution in terms of particle surfaces.
Returns an empty vector if DISTR_SIZE distribution has not been defined.
- Returns
Particle mean surfaces.
-
std::vector<double> GetPSDMeanVolumes() const
Returns mean values of classes defined for the particle size distribution in terms of particle volumes.
Returns an empty vector if DISTR_SIZE distribution has not been defined.
- Returns
Particle mean volumes.
-
bool IsDistributionDefined(EDistrTypes _distribution) const
Checks if the specified distributed property is defined.
- Parameters
_distribution – Type of the distributed property.
- Returns
Whether the distributed property is defined.
-
double GetAbsTolerance() const
Returns global absolute tolerance.
See also: Convergence methods
- Returns
Absolute tolerance.
-
double GetRelTolerance() const
Returns global relative tolerance.
See also: Convergence methods
- Returns
Relative tolerance.
-
double GetCompoundProperty(const std::string &_compoundKey, ECompoundConstProperties _property) const
Returns the value of the constant physical property of the specified compound.
Gets data directly from the materials database. See also: Constant parameters
- Parameters
_compoundKey – Unique key of the compound.
_property – Identifier of the constant material property.
- Returns
Property value.
-
double GetCompoundProperty(const std::string &_compoundKey, ECompoundTPProperties _property, double _temperature = STANDARD_CONDITION_T, double _pressure = STANDARD_CONDITION_P) const
Returns the value of the temperature/pressure-dependent physical property of the specified compound.
Gets data directly from the materials database and calculates them for the given temperature [K] and pressure [Pa]. See also: Dependent parameters
- Parameters
_compoundKey – Unique key of the compound.
_property – Identifier of the temperature/pressure-dependent material property.
_temperature – Temperature [K] for which the property should be calculated.
_pressure – Pressure [Pa] for which the property should be calculated.
- Returns
Property value.
-
double GetCompoundProperty(const std::string &_compoundKey1, const std::string &_compoundKey2, EInteractionProperties _property, double _temperature = STANDARD_CONDITION_T, double _pressure = STANDARD_CONDITION_P) const
Returns the value of the interaction physical property between the specified compounds.
Gets data directly from the materials database and calculates them for the given temperature [K] and pressure [Pa]. See also: Interaction properties
- Parameters
_compoundKey1 – Unique key of the first compound.
_compoundKey2 – Unique key of the second compound.
_property – Identifier of the temperature/pressure-dependent material property.
_temperature – Temperature [K] for which the property should be calculated.
_pressure – Pressure [Pa] for which the property should be calculated.
- Returns
Property value.
-
bool IsPropertyDefined(ECompoundConstProperties _property) const
Checks if a constant physical property with the specified key is present in the materials database.
- Parameters
_property – Identifier of the constant material property.
- Returns
Whether the property is defined.
-
bool IsPropertyDefined(ECompoundTPProperties _property) const
Checks if a temperature/pressure-dependent physical property with the specified key is present in the materials database.
- Parameters
_property – Identifier of the temperature/pressure-dependent material property.
- Returns
Whether the property is defined.
-
bool IsPropertyDefined(EInteractionProperties _property) const
Checks if an interaction physical property with the specified key is present in the materials database.
- Parameters
_property – Identifier of the temperature/pressure-dependent material property.
- Returns
Whether the property is defined.
-
CMixtureEnthalpyLookup *GetEnthalpyCalculator() const
Returns a pointer to a unit-specific enthalpy calculator.
- Returns
Pointer to an enthalpy calculator.
-
double CalculateEnthalpyFromTemperature(double _temperature, const std::vector<double> &_fractions) const
Calculates enthalpy of the mixture for the given temperature.
Calculates enthalpy of the mixture of all defined compounds for the given temperature and compound fractions using a lookup table. Uses the values of enthalpy defined in the materials database.
- Parameters
_temperature – Temperature [K].
_fractions – Mass fraction of all defined compounds.
- Returns
Enthalpy [J/kg].
-
double CalculateTemperatureFromEnthalpy(double _enthalpy, const std::vector<double> &_fractions) const
Calculates temperature of the mixture for the given enthalpy.
Calculates temperature of the mixture of all defined compounds for the given enthalpy and compound fractions using a lookup table. Uses the values of enthalpy defined in the materials database.
- Parameters
_enthalpy – Enthalpy [J/kg].
_fractions – Mass fraction of all defined compounds.
- Returns
Temperature [K].
-
void HeatExchange(double _time, CBaseStream *_stream1, CBaseStream *_stream2, double _efficiency) const
Performs a heat exchange between two streams.
Performs a heat exchange between two streams at the specified time point with a specified efficiency.
- Parameters
_time – Time point for which heat exchange is done.
_stream1 – Pointer to the first stream.
_stream2 – Pointer to the second stream.
_efficiency – Heat exchange efficiency (0..1].
-
void RaiseError(const std::string &_message = "")
Sets an error state of the unit, prints the message to the simulation log, and requests to stop simulation.
- Parameters
_message – Message to show in the simulation log.
-
void RaiseWarning(const std::string &_message = "")
Sets a warning state of the unit, and prints the message to the simulation log.
- Parameters
_message – Message to show in the simulation log.
-
void ShowInfo(const std::string &_message)
Prints the message to the simulation log.
- Parameters
_message – Message to show in the simulation log.
-
bool HasError() const
Checks if an error state is requested.
- Returns
Whether an error has occurred.
-
bool HasWarning() const
Checks if a warning state is requested.
- Returns
Whether a warning has occurred.
-
bool HasInfo() const
Checks if an info output is requested.
- Returns
Whether an info output is requested.
-
std::string GetErrorMessage() const
Returns a textual description of the last error.
- Returns
Actual error message.
-
std::string GetWarningMessage() const
Returns a textual description of the last warning.
- Returns
Actual warning message.
-
std::string GetInfoMessage() const
Returns a textual description of the last info.
- Returns
Actual info message.
-
virtual void CreateBasicInfo() = 0
Setup basic parameters of the unit (name, author, key, version).
This function must be defined in each unit. No information on the flowsheet structure and connected streams is available at this point.
-
virtual void CreateStructure() = 0
Setup the structure of the unit (ports, unit parameters, holdups, internal streams).
This function must be defined in each unit. Here, all GUI-relevant parts of the unit are described. No information on the flowsheet structure and connected streams is available at this point.
-
inline virtual void Initialize(double _time)
Initialize unit for at time point 0 before starting the simulation.
This function can be defined in each unit. It is called once for each simulation. Here, some additional objects can be initialized (for example holdups, material streams or state variables).
-
inline virtual void Simulate(double _time)
Calculate the unit on the given time point.
This function must be defined in each steady-state unit. Is called by the simulator iteratively for all time points for which this unit should be calculated. Should implement all main calculations of the model.
- Parameters
_time – Time point for which the model is calculated.
-
inline virtual void Simulate(double _timeBeg, double _timeEnd)
Calculate the unit on the given time interval.
This function must be defined in each dynamic unit. Is called by the simulator iteratively for all time points for which this unit should be calculated. Should implement all main calculations of the model.
- Parameters
_timeBeg – Start of the time interval for which the model is calculated.
_timeEnd – End of the time interval for which the model is calculated.
-
inline virtual void Finalize()
Finalize the unit after the calculation finishes.
This function can be defined in each unit. It is called once at the end of the simulation. Here, closing and cleaning operations can be performed.
-
inline virtual void SaveState()
Save the current state of the unit.
This function can be defined in each unit. Save the current state of all time-dependent parameters for a possible restart of the simulation from this time point. For flowsheets with recycled streams, it is called when the convergence on the current time window is reached.
-
inline virtual void LoadState()
Load the stored state of the unit.
This function can be defined in each unit. Load the current state of all time-dependent parameters before a restart of the simulation from that time point. For flowsheets with recycled streams, it is called each time before the Simulate() function
Public Static Functions
-
static void CopyStreamToStream(double _time, const CStream *_srcStream, CStream *_dstStream)
Copies all stream data from one stream to another at the given time point.
All data after the time point are removed from the destination stream.
- Parameters
_time – Time point to copy.
_srcStream – Source stream.
_dstStream – Destination stream.
-
static void CopyStreamToStream(double _timeBeg, double _timeEnd, const CStream *_srcStream, CStream *_dstStream)
Copies all stream data from one stream to another at the given time interval.
All data after the end time point are removed from the destination stream.
- Parameters
_timeBeg – Begin of the time interval to copy.
_timeEnd – End of the time interval to copy.
_srcStream – Source stream.
_dstStream – Destination stream.
-
static void CalculateTM(EDistrTypes _distribution, const std::vector<double> &_inValue, const std::vector<double> &_outValue, CTransformMatrix &_matrix)
Calculates a transformation matrix needed to obtain the output distribution from the input one.
Calculates a transformation matrix for one-dimensional distribution according to input and output distributions. Obtained matrix can be applied to the stream instead of direct setting of distribution to retain secondary dimensions in multidimensional distribution. Following algorithm is applied to setup transformation matrix:
Go through the classes of source and target distributions from left to right.
The most left not empty class of the input distribution proceeds to the most left not empty class of the output distribution.
Transition to the next class of the input distribution is performed if the current class is completely transferred to the output distribution.
Transition to the next class of the output distribution is performed if the current class is already full.
- Parameters
_distribution – Type of the distributed property.
_inValue – Input distribution.
_outValue – Output distribution.
_matrix – Resulting transformation matrix.
-
void ConfigureUnitStructures(const CBaseUnit *_other)