Syntax
parameter Integer
idx
= getIDXfromCAS
( CAS, gasType, modelName,assertionLevel);
Description
Within a gas mixture the properties of that substance, which is specified by the given CAS,
can be addressed by its idx.
Currently, CAS is not the actual CAS number but a string that specifies the components name.
For example, the partial pressure is then p_i[idx]
. As an example for hydrogen, oxygen and water one could write
parameter Integer idx_H2 = getIDXfromCAS(TIL3_AddOn_HydrogenEnergySystems.Internals.Substances.H2.name, gasType, modelName);
parameter Integer idx_O2 = getIDXfromCAS(TIL3_AddOn_HydrogenEnergySystems.Internals.Substances.O2.name, gasType, modelName);
parameter Integer idx_H2O = getIDXfromCAS(TIL3_AddOn_HydrogenEnergySystems.Internals.Substances.H2O.name, gasType, modelName);
Error Handling
If the gasType does not contain the required substance different ways of error handling can be chosen via the input assertionLevel:
assertionLevel = error: |
an error message is written to the Logs-window pointing the user to the model specified by modelName. It is convenient to use the built-in function getInstanceName() to set the modelName. |
|
assertionLevel = warning: |
a warning message is written to the Logs-window and the value -1 is return as result of the function. |
|
assertionLevel = nomessage: |
(disabled option) no warning is given. -1 is returned as result. Not recommended, since accessing concentration array with index -1 crashes the simulation. |
function getIDXfromCAS input String CAS "CAS Number of the substance (as String)"; input TILMedia.GasTypes.BaseGas gasType; input String modelName; input TILMedia.Internals.GetIDXfromCAS.assertionLevel assertionLevel = TILMedia.Internals.GetIDXfromCAS.assertionLevel.warning "given warning level, if component not exists: warning and noMessage results in output = -1"; output Integer idx; end getIDXfromCAS;