Professional Documents
Culture Documents
KULI Manual Eng Advanced
KULI Manual Eng Advanced
2021)
Table of Contents
1 advanced COM .............................................................................................. 5
1.1 The COM interface............................................................................................................5
1.2 Defining the interface in KULI..........................................................................................5
1.2.1 Defining sensor values to be read from external applications ............................................................... 6
1.2.2 Defining actuator values to be set from external applications............................................................... 7
2 advanced optimize...................................................................................... 74
2.1 Statistical Analysis .........................................................................................................74
2.2 Optimization and parameter variation possibilities in KULI .......................................77
2.3 Optimization ..................................................................................................................79
2.3.1 Optimization target................................................................................................................................. 79
2.3.2 Optimization parameter ......................................................................................................................... 82
2.3.3 How the optimization works .................................................................................................................. 83
2.3.4 Applications............................................................................................................................................. 84
To get further information about connectors of a specific component visit the Component
connector overview.
advanced COM 5
1.2.1 Defining sensor values to be read from external applications
Suppose that you want to read the exit temperature of the radiator's coolant from your external
application. Therefore, open your KULI model, change to the page Circuits / Air Path, select your
radiator and choose Show connection attributes in the component's context menu.
Select the sensor that you want to make available to other programs. In our example check in
the column S the sensor Exit temperature IM. Finally, close the dialog by pressing on the button
Ok.
Icon Description
Next you have to create a COM object. Click on the toolbar button Insert COM
controller and place the new symbol on the page Circuits / Air Path. Connect your
sensor to the COM object. Then double-click on the icon of your COM object in the
graphics network. As a result you will see the following dialog.
Dialog COM
Specify a descriptive name in the field COM-ID. This name will later be used to identify your COM
object. For your object the radio button Output is selected. This means that the value will be an
advanced COM 6
output of KULI, available for your external application. Finally, be sure to choose the desired unit
in which the value should be given to your application.
In the same way you can add as many COM objects for further sensor values as you like.
The Export connector is used to define the COM object as connector of a public interface (e.g.
FMU).
Icon Description
Next, you have to create another COM object. Click on the toolbar button Insert
COM controller and place the symbol somewhere on the page Circuits / Air Path.
You can not connect the COM object to your actuator right away, since both have
a green In-port. Hence, double-click on the icon of your COM object and change its
type to Input, which means that this value is an input value for the KULI model.
In the dialog you have to set a descriptive name for the COM-ID and select the correct unit. After
closing the window the connector will change to a red Out-port, thus, you can now connect it to
the actuator. You might want to rotate the COM object twice to make the graphics look better.
advanced COM 7
Dialog COM - Input
In the same way you can add COM objects for as many actuator values as you like. With the
activation of "Default value" it is possible to define a default value, which is used for the
simulation directly over the KULI GUI. In the case of the use over an interface (e.g. EXCEL - KULI)
the default value is used when no value is set by KULI.SetCOMValueByID. The Export connector is
used to define the COM object as connector of a public interface (e.g. FMU).
advanced COM 8
Dialog COM - Input with Default value
advanced COM 9
1.3.1 Initializing KULI
Tip
When the interface of KULI and Excel does not work, it is always a good idea to check, if
the correct version of the KULI type library is selected in the menu Tools/References.
Also, if you run older Excel files that have been built using previous KULI versions, it
might be necessary to change to the current version. But selecting the appropriate
version of the type library also gives you the possibility to work with different KULI
versions at the same time.
Next you have to create a variable that gives the link to the library. This should be done on the
top of your script using the command
Public WithEvents KULI As KuliAnalysisCtr2
(You can also use any other name you like instead of 'KULI'). To initialize this variable use the
following command:
Set KULI = New KuliAnalysisCtr2
Be sure to release this variable at the end of your script using the command
Set KULI = Nothing
advanced COM 10
myfig = figure('pos',[100 200 200 200]);
KULI = ...
actxcontrol('KuliAnalysisServer.KuliAnalysisCtr2.13',...
[0 0 200 200], myfig, ...
{'OnError','KULIEvents'; 'OnMessage','KULIEvents'});
% your source code here...
delete(KULI);
close(myfig);
In this case the file KULIEvents.m includes the source code for event handling.
In addition, a KULI/Simulink-Toolbox is offered for Matlab Simulink. This provides a graphical
way to integrate KULI in your Simulink model without having to write a line of code.
KuliAnalysisServer
KULI versions older than 13 used the "KuliAnalysis2" library. In order for scripts
to use KULI version 13, references to "KuliAnalysis2" should be changed to
"KuliAnalysisServer".
advanced COM 11
Public WithEvents KULI As KuliAnalysisCtr2
Cells(3, 3) = "done."
End Sub
KULI = ...
actxcontrol('KuliAnalysisServer.KuliAnalysisCtr2.13',...
[0 0 200 200], myfig, ...
{'OnError','KULIEvents'; 'OnMessage','KULIEvents'});
set(KULI, 'KuliFileName','D:\mykuli\ExTRUCK_COM.scs');
tempvector = [];
result = invoke(KULI,'Initialize');
for i = 1:5
newrpm = double(i*1000);
result = invoke(KULI,'SetCOMValueByID','RPM',newrpm);
result = invoke(KULI,'SimulateOperatingPoint',int8(1));
watertemp = invoke(KULI,'GetCOMValueByID','temp');
tempvector = [tempvector watertemp];
end
invoke(KULI,'CleanUp');
delete(KULI);
close(myfig);
advanced COM 12
The example given here assumes that the KULI model ExTRUCK_COM.scs has two COM objects.
One with COM-ID 'RPM' is attached to an actuator for the input speed of a mechanical fan, and
the other one with COM-ID 'temp' is attached to a sensor for one inlet or outlet temperature of a
radiator.
In real world applications the fan rpm might come from some sophisticated Matlab engine
models, but you can also set more than just one parameter for KULI. This enables KULI to be just
a part of a complete simulation package, whose master is e.g. Matlab and where KULI only
computes the heat-related parts.
Attention
Be careful when setting parameters within KULI iterations. If parameters are changed
considerably for each iteration, then you might end up with a non-converging system.
The script provided here can be used to watch the convergence process within KULI. It starts
KULI, chooses the KULI model, initializes the computation, and within each iteration it reads the
current temperature and puts it into a cell of your Excel sheet.
advanced COM 13
Note that within the loop you could also set some parameters. However, KULI prevents setting
certain parameter within the iteration process. For instance, you cannot set the dimensions of
components within a loop, because this does not make much sense. Moreover, it would require
a complete reinitialization of the cooling system, which would make it necessary to start the
iteration process all over. Other parameters, like fan rpm or the opening percentage of a valve,
can be set. This allows the modeling of e.g. thermostatically controlled valves. (Although you
could do this within KULI, too.)
In order for the custom result file name to be effective, the ResultFileName property
must be set after setting the KuliFileName property. This is because KuliFileName also
sets ResultFileName, overwriting any other filename that may have been set before.
The file path can be defined absolute or relativ. If the file name does not have a suffix or a
suffix, which is not *.hdmb, the suffix *.hdmb will be added automatically.
advanced COM 14
In order for the custom media path to be effective, the MediaPath property must be set
before initializing the simulation model (RunAnalysis, SimulateOperatingPoint and
StartAnalysis includes the initizalisation call), preferably directly after setting the
KuliFileName property. Otherwise a warning message is generated ("System already
initialized. New media path ignored.")
Application.DisplayAlerts = False
Please note, this command disables all Excel alert. Use solution 3 to hide exactly the
message in this context.
advanced COM 15
'''Declare function at the beginning of the VBA script
Private Declare Function _
CoRegisterMessageFilter Lib "OLE32.DLL" _
(ByVal lFilterIn As Long, _
ByRef lPreviousFilter) As Long
...
Available properties
• BatchMode
• EnableEvents
• KuliFileName
• MediaPath
• ResultFileName
• SensitiveAnalysis
• WriteResults
Using properties
The KuliAnalysisServer.exe also has some properties. These variables are set or can be retrieved
in Visual Basic by simply using the = sign, i.e.,
advanced COM 16
VBA example
KULI.propertyname = newpropertyvalue
getpropertyvalue = KULI.propertyname
Matlab example
BatchMode
Deprecated Property
This property will be removed in future versions of KULI. Contact KULI Support for
batch calculation examples.
boolean BatchMode
This Boolean variable specifies if KULI should use the batch mode. If so, then all files in the
list of files for the batch mode are computed.
advanced COM 17
EnableEvents
Deprecated Property
This property will be removed in future versions of KULI. Setting this value does not
influence the simulation anymore.
boolean EnableEvents
This Boolean variable specifies, whether the KULI events should be active.
KuliFileName
string KuliFileName
This string variable specifies the name (including the directory path) of the KULI model that
should be used.
Setting this property also sets the ResultFileName property with same name automatically,
overwriting any previously set value.
advanced COM 18
MediaPath
string MediaPath
This string variable specifies the user defined media path except the vendor name (e.g. "C:
\Program Files (x86)\ECS\KULI_132000\System" for the default installation)
All neccessary media files are in the specified directory, no media splitting is
allowed.
The subfolders for the used media types a mandatory (e.g. Coolant, Air, Oil,
Refrigerant,...)
ResultFileName
string ResultFileName
This string variable specifies the user-defined name (including the directory path) of
the simulation result file that was generated. If this property is not set, the name of the
input KULI file name is used as the default output file name.
When setting this property make sure it is done after setting KULIFileName and before the Initialize
command. See Setting the output file name.
advanced COM 19
SensitiveAnalysis
boolean SensitiveAnalysis
WriteResults
boolean WriteResults
This Boolean variable specifies if KULI should write the results into the *.hdmb-files. If not
specified the default value is the same as that set in the KULI settings dialog.
This property must be set before the command Initialize is called. If the variable
WriteResults is set to false before the command Initialize, then no *.hdmb-file will be
generated at all, if it is set to false after Initialize but before e.g. SimulateOperatingPoint,
then the *.hdmb-file will have some initial contents, but will not grow during the
computation.
Methods
• AddToBatchList
• Cancel
• CleanUp
• GetCOMCodes
• GetComponentConnectorUnit
advanced COM 20
• GetComponentDescription
• GetCOMValueByID
• GetCOMValueByIDAsStr
• GetCOMValueByIDAsStr2
• GetErrorInfo
• GetInputCOMUnitByID
• GetOutputCOMUnitByID
• GetValue
• GetValueAsStr
• GetValueUnit
• GetValueUnitAsStr
• GetVersionID
• GetVersionStr
• GetWarningInfo
• Initialize
• IsFinished
• IsNextTimeStep
• ListComponents
• ListComponentTypes
• ListConnectors
• NextKULIIteration
• ObjectExists
• ResetCurrentSimulationStep
• RunAnalysis
• RunMonteCarlo
• RunOptimization
• RunParameterVariation
• SetCOMValueByID
• SetCOMValueByIDAsStr
• SetCOMValueByIDAsStr2
• SetValue
• SetValueAsStr
• SetValueUnit
• SetValueUnitAsStr
• SimulateCFD
• SimulateOperatingPoint
• StartAnalysis
advanced COM 21
Instructions for usage
In Visual Basic all methods are called in the format
returnvalue = invoke(KULI,'methodname',arguments)
Note that in Matlab you must force integer values to integer format, e.g.
returnvalue = invoke(KULI,'SimulateOperatingPoint',int8(2))
advanced COM 22
Attention
If an actuator is already used (over a constant or a signal path) the value can't be set by
direct access.
For further information about the KULI connectors (sensor or actuator name), component types
and units please refer to the chapter List of sensors and actuators.
AddToBatchList
Deprecated method
This command adds a file to the list of KULI models that are executed by a batch mode
computation.
Input Parameters: a string with the complete name of the KULI model, including the path
Return value: none
Example:
KULI.BatchMode = true
KULI.AddToBatchList('C:\KULIModels\supermodel.scs')
KULI.RunAnalysis()
Cancel
void Cancel()
Cancels the current computation. Cancel() can only be called within the CheckForCancel event.
Input Parameters: none
Return value: none
Example:
advanced COM 23
Private Sub KULI_OnCheckForCancel()
Dim cond As Boolean
If (cond) Then
KULI.Cancel
End If
End Sub
CleanUp
bool CleanUp()
Performs several memory clean-ups. In particular this function also finalizes the generation of
the output file (hdmb file). Call this function before deleting your KuliAnalysisCtr2 variable. It is
not necessary to call this function if you use RunAnalysis() since that already includes the clean-
up.
Input parameters: none
Return value: a Boolean variable that indicates if clean-up was successful.
Example:
cleanOK = KULI.CleanUp()
GetCOMCodes
advanced COM 24
Dim codesInput, codesoutput As String
Dim codeArrayInput() As String
Dim codeArrayOutput() As String
GetComponentConnectorUnit
Error cases:
An error is raised if the connector is not found with the message "Invalid actuator/
sensor". In this case the unit remains empty.
Example:
advanced COM 25
'Define variables
Dim component, connector, connectorUnit As String
component = "Rad"
connector = "EntryPressOM"
For further information about the KULI connectors (sensor or actuator name) and units please
refer to the file KULI_COM_Reference.xls in the program folder.
Return value:
• a string containing the SI-Unit of a sensor or actuator ([Pa], [1/min], ..),
• in case of an undefined unit (e.g. - ) an empty string
GetComponentDescription
advanced COM 26
'Define variables
Dim fileKULI, compType, compDescr As String
GetCOMValueByID
Attention
This command must not be called after RunAnalysis() is called, since RunAnalysis() also
performs a clean-up at the end such that no information about the current values of the
objects in the KULI model is available any more.
advanced COM 27
GetCOMValueByIDAsStr
Attention
This command must not be called after RunAnalysis() is called, since RunAnalysis() also
performs a clean-up at the end such that no information about the current values of the
objects in the KULI model is available any more.
GetCOMValueByIDAsStr2
Attention
This command must not be called after RunAnalysis() is called, since RunAnalysis() also
performs a clean-up at the end such that no information about the current values of the
objects in the KULI model is available any more.
GetErrorInfo
Deprecated method
This method will be removed in future versions of KULI.
This command retrieves the number of errors and the error description.
advanced COM 28
GetInputCOMUnitByID
Example
'Define variables
Dim startTempUnit As String
startTempUnit = KULI.GetInputCOMUnitByID("StartTemp")
An error is raised if the COM object's name is not found with the message "Cannot find
COM object". In this case the unit remains empty.
A warning is raised if multiple COM objects are found with the same name withthe
message "Multiple COM-objects with same ID". In this case the unit returned is the first
unit found.
GetOutputCOMUnitByID
Example
'Define variables
Dim startTempUnit As String
startTempUnit = KULI.GetOutputCOMUnitByID("StartTemp")
advanced COM 29
An error is raised if the COM object's name is not found with the message "Cannot find
COM object". In this case the unit remains empty.
GetValue
Attention
This command must not be called after RunAnalysis(), since RunAnalysis() also performs
a clean-up at the end such that no information about the current values of the objects in
the KULI model is available any more.
Input parameters:
component ... a string with the component ID (1.EFan, 2.RAD, ..); case sensitive;If component is '
1.RAD' or '1.RAD ' instead of '1.RAD' --> Invalid component ID and error message
sensor ......... string with the connector ID and the unit in brackets (optional); case sensitive;If
sensor is 'Width ' or ' Width' instead of 'Width' --> Invalid component ID and error message
GetValue('1.RAD', 'Width') --> Value in SI
GetValue('1.RAD', 'Width [mm]') --> Value converted
Attention
Please take care on providing valid indexes if you want to query sensor values of air-side
component parts, battery cells inside battery modules or battery modules inside
batteries.
e.g.: The following command gets the actual inner entry temperature of the block-element "1,2"
of the first radiator:
• KULI.GetValue("1.RAD[1,2]", "TemperatureIMEntry")
advanced COM 30
Info
In the case of the A/C components evaporator and condensor, only the first layer in x-
direction can be accessed.
Only the following sensors are accessable for air-side component parts:
• X • HeatExchangeArea
• Y
• AmountHeatOM
• Z
• Width • ThermalOutputOM
• Height • EntryTempOM
• EntryTempIM
• ExitTempOM
• ExitTempIM
• EntryPressOM
• EntryPressIM
• ExitPressOM
• ExitPressIM
• EntryVelocityOM
• MassFlowRateIM
• ExitVelocityOM
• EntryVelocityIM
• EntryHumidity
• ExitVelocityIM
• ExitHumidity
• ReynoldsNoInner
• MassFlowRateOM
• ReynoldsNoOuter
• NusseltNo
• PrandtlNo
The following commands get the actual SOC from the first battery cell (specified by indexes
"[1,1,1]") inside a battery module:
• KULI.GetValue("1.BATTM/ECELL[1,1,1]", "SOC")
• KULI.GetValue("1.BATTM[1,1,1]", "SOC")
The following commands get the dissipated power from the first battery cell (located at x=1, y=1,
z=1) inside the second battery module (x=2, y=1, z=1) of a battery:
• KULI.GetValue("1.BATT/BATTM[2,1,1]/ECELL[1,1,1]", "PowerDissipated")
advanced COM 31
• KULI.GetValue("1.BATT[2,1,1][1,1,1]", "PowerDissipated")
For further information about the KULI connectors (sensor or actuator name), component types
and units please refer to our clear represented table. Please refer to the file
KULI_COM_Reference.xls in your program folder.
Return value:
A double value containing the current value of the sensor. If one parameter is invalid, the return
value is NaN (Not a Number).
Example:
'Define variables
Dim fileKULI As String
Dim value As Double
GetValueAsStr
Attention
This command must not be called after RunAnalysis() is called, since RunAnalysis() also
performs a clean-up at the end such that no information about the current values of the
objects in the KULI model is available any more.
advanced COM 32
Example:
'Define variables
Dim fileKULI As String
Dim value As String
Info
With the method GetValueAsStr() and the sensor Id IndexWithinBlock you can
additionally request the indexed block element and the Id of the Block (e.g. 1.BL[1,3]).
Example
GetValueUnit
advanced COM 33
Attention
This command must not be called after RunAnalysis() is called, since RunAnalysis() also
performs a clean-up at the end such that no information about the current values of the
objects in the KULI model is available any more.
For further information about the KULI connectors (sensor or actuator name), component types
and units please refer to the file KULI_COM_Reference.xls in your program folder.
Input parameter:
See above. It doesn't matter, if you use brackets for the unit or not.
• GetValueUnit('1.RAD', 'Width', '') --> Value in SI
• GetValueUnit('1.RAD', 'Width', 'mm') --> Value converted
Return value:
a double value containing the current value of the sensor. If a parameter is invalid, the return
value is NaN (Not a Number).
Example:
'Define variables
Dim fileKULI As String
Dim value As Double
advanced COM 34
GetValueUnitAsStr
Attention
This command must not be called after RunAnalysis() is called, since RunAnalysis() also
performs a clean-up at the end such that no information about the current values of the
objects in the KULI model is available any more.
For further information about the KULI connectors (sensor or actuator name), component types
and units please refer to our clear represented table. Please refer to the file
KULI_COM_Reference.xls in your program folder.
Example:
'Define variables
Dim fileKULI As String
Dim value As String
advanced COM 35
GetVersionID
long GetVersionID()
This command retrieves the current KULI version number in long-format.
Input parameters: none
Return value: A long value containing the current KULI version, e.g. "131000".
Example:
GetVersionStr
BSTR GetVersionStr()
This command retrieves the current KULI version number in string-format.
Input parameters: none
Return value: A string with the current KULI version, e.g. "KULI 13.1 SR0".
GetWarningInfo
Deprecated method
This method will be removed in future versions of KULI.
This command retrieves the number of warnings and the warning description.
Initialize
This routine performs several initialization steps. In particular all the objects of the *.scs-file are
created, and the cooling system is initialized with starting values. After a call of this routine
actuators can be set. Use this routine before using StartAnalysis or
SimulateOperatingPoint. Note that this routine also internally calls CleanUp() (such that
advanced COM 36
any possible previous calculations are discarded from memory) and creates a fresh output file
(hdmb file).
Prototype
bool Initialize()
Parameters
None
Return value
A Boolean value specifying whether or not initialization was successful.
Example
IsFinished
This command specifies whether the computation of the current simulation is finished or not.
Usage of this function is recommended if you want to control the iteration process by yourself.
Prototype
bool IsFinished()
Parameters
None.
Return value
A boolean value specifying whether or not the computation of the current simulation is finished.
advanced COM 37
Example
calcOK = KULI.Initialize()
calcOK = KULI.StartAnalysis()
i = 1 Do Until KULI.IsFinished
calcOK = KULI.NextKULIIteration()
wert = KULI.GetCOMValueByID("temperature")
Cells(i, 1) = wert
i = i + 1
Loop
IsNextTimeStep
bool IsNextTimeStep()
Enables a loop over all time steps of a transient analysis. Note that this routine only performs
the necessary initialization steps for the next time step, it does not perform the actual
computation.
Input parameters: none
Return value: a Boolean value specifying whether or not the computation of the current
simulation succeeded. false is also returned if there is no more time step left.
Example:
ListComponents
advanced COM 38
• '1.*' 1.MFan 1.EFan 1.RAD, ..
• '*.?Fan' Get all fans: 1.MFan 1.EFan 2.EFan, ..
The filter string can contain several substrings, separated with blanks. e.g.: '1.?Fan .RAD 2.'
The filter operators '' and '?' can be used several times in one substring. e.g.: '.?Target?' -->
1.FTargetM, 2.FTargetP, ..
Return value:
A string containing the list of component names separated by spaces from the KULI model.
The component 'SimPar' is returned by default. If the filter string is invalid only the component
'SimPar' is returned.
NOTE: If your KULI model contains air side components with parts (e.g. RAD, CAC, OC, ARes),
batteries or battery modules this command also returns a value with maximum number of sub-
components.
e.g.:
for radiators:
• 1.RAD
• 1.RAD/[x,y,z]
x....Maximum number of parts in x-direction
y....Maximum number of parts in y-direction
z....Maximum number of parts in z-direction
Remark: these values give the number of parts in the three directions that are generated within
the block due to user-defined subdivisions, bounds and overlappings with other components. It
is the same number of elements that also appears in KULI lab.
for batteries:
• 1.BATT
• 1.BATT/BATTM[x1,y1,z1]
• 1.BATT/BATTM[x1,y1,z1]/ECELL[x2,y2,z2]
advanced COM 39
x1....Maximum number of battery modules inside battery in x-direction
y1....Maximum number of battery modules inside battery in y-direction
z1....Maximum number of battery modules inside battery in z-direction
x2....Maximum number of battery cells inside battery modules in x-direction
y2....Maximum number of battery cells inside battery mudules in y-direction
z2....Maximum number of battery cells inside battery modules in z-direction
Example:
'Define variables
Dim fileKULI, components As String
Dim componentsArray() As String
ListComponentTypes
BSTR ListComponentTypes()
This command retrieves the IDs of all available component types in KULI.
Input parameter: none
Return value: a string containing the IDs of all KULI component types separated with blanks.
This list is a KULI definition.
Example:
advanced COM 40
'Define variables
Dim componentTypes As String
Dim componentTypesArray() As String
ListConnectors
Note: When listing connectors of battery or battery module, the command also returns sensors
with total number of sub-components and number of sub-components in x, y and z direction.
e.g.:
Sensor list for battery module contains following additional sensors:
• NumberOfCells....Total Number of battery cells inside the module
• NumberOfCellsXDirection....actual number of battery cells inside module in x-direction
• NumberOfCellsYDirection....actual number of battery cells inside module in y-direction
• NumberOfCellsZDirection....actual number of battery cells inside module in z-direction
advanced COM 41
Sensor list for battery contains following additional sensors:
• NumberOfCells....Total Number of battery cells inside the battery
• NumberOfModules....Total Number of battery modules inside the battery
• NumberOfModulesXDirection....actual number of modules inside battery in x-direction
• NumberOfModulesYDirection....actual number of modules inside battery in y-direction
• NumberOfModulesZDirection....actual number of modules inside battery in z-direction
Example:
'Define variables
Dim componentType, connectorType, connectors As String
Dim connectorsArray() As String
componentType = "RAD"
connectorType = "SA"
NextKULIIteration
bool NextKULIIteration()
Starts the computation of the next iteration in the process of the computation of the current
operating point.
Input parameters: none
Return value: a Boolean value specifying if the calculation of the next iteration was successful.
Example:
calcOK = KULI.StartAnalysis()
i = 1
Do Until KULI.IsFinished
calcOK = KULI.NextKULIIteration()
wert = KULI.GetCOMValueByID("temperature")
Cells(i, 1) = wert
i = i + 1
Loop
advanced COM 42
ObjectExists
ResetCurrentSimulationStep
bool ResetCurrentSimulationStep()
Sets the IsFinished flag to false forces a recalculation of the current simulation step.
Input parameters: none
Return value: a boolean value returns, whether or not the computation was successful.
Example:
advanced COM 43
Private Sub CommandDoCalculate()
'...
'set a new KULI-controller
Set KULI = New KuliAnalysisCtr2
'change directory name to your settings
KULI.KuliFileName = fileKULI
'initialize and run simulation
calcOK = KULI.Initialize()
calcOK = KULI.StartAnalysis()
'...
While kuli.IsNextTimeStep
Do Until kuli.IsFinished
calcOK = kuli.SetValue("1.VENTIL", "MassFlowRatioApproach", ...)
calcOK = kuli.NextKULIIteration
Loop
RunAnalysis
bool RunAnalysis()
Performs a complete run of a cooling system, including the generation of the corresponding
output files.
Input parameters: none
Return value: a boolean value returns, whether or not the computation was successful.
Example:
advanced COM 44
RunMonteCarlo
RunOptimization
bool RunOptimization()
Performs an optimization.
RunParameterVariation
bool RunParameterVariation()
Performs a Parameter Variation.
SetCOMValueByID
advanced COM 45
calcOK = KULI.Initialize()
Cells(1, 1) = "resistance par."
Cells(1, 2) = "coolant temp."
For j = 1 To 5
calcOK = KULI.StartAnalysis()
currentParam = j * 20
calcOK = KULI.SetCOMValueByID("Resist", currentParam)
Cells(j + 1, 1) = currentParam
KULI.SimulateOperatingPoint(1)
newvalue = KULI.GetCOMValueByID("Temperature")
Cells(j + 1, 2) = newvalue
Next j
SetCOMValueByIDAsStr
SetCOMValueByIDAsStr2
advanced COM 46
SetValue
Attention
Please take care on providing valid indexes if you want to set actuator values of air-side
component parts, battery cells inside battery modules or battery modules inside
batteries.
e.g.
The following command sets the entry temperature of the inner medium of a the first radiator's
block-element "1,2" to 20°C (coordinates specified by indexes "[x,y,z]"):
• SetValue("1.RAD[1,2]", "TemperatureIMEntry", "20[°C]")
In the case of the AC components evaporator and condensor, only the first layer in x-
direction can be accesed.
advanced COM 47
Only the following actuators are accessable for air-side component parts:
• EntryTempIM • AmountHeatOM
• ExitTempIM • ThermalOutputOM
• EntryPressIM • EntryTempOM
• ExitPressIM • ExitTempOM
• MassFlowRateIM • EntryPressOM
• EntryVelocityIM • ExitPressOM
• ExitVelocityIM • EntryVelocityOM
• ReynoldsNoInner • ExitVelocityOM
• EntryHumidity
• ExitHumidity
• MassFlowRateOM
• ReynoldsNoOuter
• NusseltNo
• PrandtlNo
The following commands set the initial SOC of a battery cell inside a battery module of a battery
(coordinates specified by indexes "[x,y,z]"):
• KULI.SetValue("1.BATT/BATTM[2,2,1]/ECELL[1,1,1]", "SOCStart", 60)
• KULI.SetValue("1.BATT[2,2,1][1,1,1]", "SOCStart", 60)
Return value: none
Example:
advanced COM 48
'Define variables
Dim fileKULI As String
Dim rpm, press, speed As Double
SetValueAsStr
Attention
For the decimal separator you must use '.'.
If a parameter is invalid, the actuator uses the predefined value in the .scs file.
Example:
advanced COM 49
'Define variables
Dim fileKULI As String
Dim rpm, press, speed As String
SetValueUnit
advanced COM 50
'Define variables
Dim fileKULI As String
Dim rpm, press, speed As String
SetValueUnitAsStr
advanced COM 51
'Define variables
Dim fileKULI As String
Dim rpm, press, speed As String
SimulateCFD
SimulateOperatingPoint
advanced COM 52
calcOK = KULI.Initialize()
calcOK = KULI.SimulateOperatingPoint(1)
Attention
SimulateOperatingPoint(0) is equivalent to SimulateOperatingPoint().
SimulateOperatingPoint is a function that may take a long time. During this time
there is no interaction between Excel and KULI which can lead to a time-out error
message in Excel. Instructions on how to solve this problem can be found at Some
standard procedures, section Fix OLE-DB error message in Excel during simulation.
StartAnalysis
bool StartAnalysis()
Starts analysis and performs initialization. This function must be used to enable stepping
through single iterations or time steps in KULI.
Input parameters: none
Return value: a Boolean value specifying whether or not these start-up computations were
successful.
Example:
...
calcOK = KULI.StartAnalysis()
Do Until KULI.IsFinished
calcOK = KULI.NextKULIIteration()
...
Loop
• OnCheckForCancel
• OnEndOfOperatingPoint
advanced COM 53
• OnEndOfTimeStep
• OnError
• OnMessage
• OnNextIteration
• OnNextTime
• OnNotification
These events can be handled by your application, but it is not necessary to do so.
KULI = actxcontrol('KuliAnalysisServer.KuliAnalysisCtr2.13',...
[0 0 200 200],gcf,...
{'OnMessage', 'KULIEventsDemo';...
'OnError', 'KULIEventsDemo';...
'OnCheckForCancel',
'KULIEventsDemo';...
'OnNextIteration', 'KULIEventsDemo';...
'OnNextTime', 'KULIEventsDemo';...
'DrawAC', 'KULIEventsDemo';...
'OnEndOfTimeStep', 'KULIEventsDemo'});
then there must be a file KULIEventsDemo.m in which the specified events are handled. This
file might then look like this:
advanced COM 54
function KULIEventsDemo(varargin)
global STOPKULI
len_event=length(varargin);
event_name=varargin{len_event};
event_struct=varargin{len_event-1};
if strcmp(event_name,'OnMessage')
% Prototypes of Events
% OnMessage = void ...
% OnMessage(string s_fct, string s_error, string s_add,int32 l_flag)
if and(~strcmp(event_struct.s_msg,'Time: '),~strcmp(event_struct.s_msg,''))
display(event_struct.s_msg)
end
elseif strcmp(event_name,'OnError')
% Prototypes of Events
% OnError = ...
% void OnError(string s_fkt, string s_msg, string s_add, int32 l_type)
STOPKULI.value=1;
STOPKULI.message=[char(event_struct.s_msg) char(event_struct.s_add)];
STOPKULI.structure=event_struct;
display(STOPKULI.message);
elseif strcmp(event_name,'OnCheckForCancel')
% Prototypes of Events
% OnCheckForCancel = void OnCheckForCancel()
elseif strcmp(event_name,'OnNextIteration')
% Prototypes of Events
% OnNextIteration = void OnNextIteration(int32 l_itNo)
elseif strcmp(event_name,'OnNextTime')
% Prototypes of Events
% OnNextTime = void OnNextTime(int32 l_timeStepNo, double d_time)
elseif strcmp(event_name,'OnEndOfTimeStep')
% Prototypes of Events
% OnEndOfTimeStep = void OnEndOfTimeStep(int32 l_timeStepNo, doubled_time)
else
display('---------------------------------')
display(['Not handled Event: ' event_name ])
end
OnCheckForCancel
This event is fired if the user may interrupt analysis. To interrupt analysis, call Cancel() within
this event.
advanced COM 55
Prototype
HRESULT OnCheckForCancel();
Return value
None.
OnEndOfOperatingPoint
This event is fired at the end of each operating point.
Prototype
Parameters
operatingPoint
[in] The parameter op gives the number of the current operating point.
Return value
None.
Remarks
Use this event in particular when you do parameter variation, optimization, or Monte Carlo
analysis (using the appropriate commands RunParameterVariation, RunOptimization,
RunMonteCarlo), then you can use this command to perform some operations (e.g. read output
values via COM objects) after each operating point has been completed. In the case of
optimization you can use this to view the progress of the optimization process.
OnEndOfTimeStep
This event gives notice that (in particular for a transient simulation) the computation of the
current time step has been finished.
advanced COM 56
Prototype
Parameters
timeStepNo
[in] Specifies how many time steps have already been considered (including the current one).
time
[in] Gives the actual value of the time.
Return value
None.
Remarks
This event will be fired when you run the simulation using either RunAnalysis or
SimulateOperatingPoint.
OnError
Deprecated
This event is deprecated. Use OnNotification instead.
Prototype
advanced COM 57
Parameters
fkt
[in] Gives the name of the offending routine. It is a good idea to provide this information if you
contact KULI customer support.
msg
[in] Gives a short description of the error.
add
[in] Additional information of the error. Might be empty.
type
[in] Provides a code for the error which gives information about the severity of the error. The
type is best considered in hex format with the following interpretation:
• type = 0x10000: the error is considered as a fatal error; in this case the calculation should
be stopped.
• type = 0x20000: the error is of medium severity; in some cases it is still safe to continue; in
any case the describing variables msg and add should be observed.
• type = 0x40000: the error has "information character". In most cases the simulation can
safely continue.
Return value
None.
Remarks
It is strongly recommended that you take care of this event, since usually an error that causes
this event is a sign of some serious problem.
Examples
In Visual Basic an event handler for this error in a simple way might look like this:
Private Sub KULI_OnError(ByVal fkt As String, ByVal msg As String, ByVal add As
String, ByVal type As Long)
Debug.Print fkt, msg, add
End Sub
advanced COM 58
A more complete implementation would also include message boxes depending on the type of
the error. In the example below the icon in the message box and the buttons of the message box
depend on the type of the error:
'Hault execution
If (Answer = vbYes) Then
End
End If
End Sub
OnMessage
Deprecated
This event is deprecated. Use OnNotification instead.
advanced COM 59
Prototype
Parameters
kt
[in] Gives the name of the offending routine. It is a good idea to provide this information if you
contact KULI customer support.
msg
[in] Gives a short description of the message.
add
[in] Additional information of the message. Might be empty.
type
[in] Provides a code for the message which gives information about the severity.
Return value
None.
Remarks
The messages that incur this event are those that are also displayed in the Output window of
KULI itself if the computation is done in KULI.
Examples
See the event OnError for an example.
OnNextIteration
This message gives notice that the next iteration has begun.
advanced COM 60
Parameters
itNo
[in] Provides the number of this iteration.
Return value
None.
Remarks
OnNextTime
This event gives notice that (in particular for a transient simulation) the next time step has been
reached.
Prototype
Parameters
timeStepNo
[in] Specifies how many time steps have already been considered (including the current one),
and time gives the actual value of the time.
time
[in] Gives the actual value of the time.
Return value
None.
advanced COM 61
Remarks
This event will be fired when you run the simulation using either RunAnalysis or
SimulateOperatingPoint.
Note that this event is fired at the beginning of a time step, so you can safely set actuator values
(using SetCOMValueByID), but when you try to read values (using GetCOMValueByID ), you will
get the results of the previous time step. Compare also OnEndOfTimeStep.
OnNotification
This event is called whenever a relevant information occurred in the KULI simulation kernel.
Prototype
Parameters
message
[in] Contains the message text of the notification.
severity
[in] Severity of the occurred notification. The different severity levels are provided with the data
type KuliAnalysisServerLib.KuliMsgClassification.
Prototype
enum
{
KuliFatal = 5,
KuliError = 4,
KuliWarning = 3,
KuliInfo = 2
} KuliMsgSeverity;
The different severity levels correspond to the logging level. See the description of the Log
Levels for further details.
advanced COM 62
classification
[in] Notifications are assigned to different classes. This means that you can react differently to
notifications in your application. These classes are provided with the data
type KuliAnalysisServerLib.KuliMsgClassification.
Prototype
enum
{
KuliNone = 1,
KuliNotification = 2,
KuliProgressOutline = 4,
KuliProgressDetails = 8,
KuliAlert = 16,
KuliSystem = 32,
} KuliMsgClassification;
The values of the KuliMsgClassification data type reflect the following information:
Value Description
advanced COM 63
occurence
[in] Specifies the time step or operating point where the notification occured.
systemTime
[in] Time when the notification occured. Specified as milliseconds since 1.1.1970.
Return value
None.
Remarks
If OnNotification is used, OnError and OnMessage can be omitted. OnNotification essent
ially provides the same information as the other two events. Furthermore, future versions of
KULI will not provide the events OnError and OnMessage anymore.
Examples
The OnNotification event can be handled as follows in VBA:
End Sub
advanced COM 64
VBA events are bound to the COM control using the name of the control instance
followed by an "_" and the event signature (<instance_name>_<event_signature>). In
the example above the control name is Kuli and the event signature
is OnNotification(ByVal message As String, ByVal severity As
KuliMsgSeverity, ByVal classification As KuliMsgClassification,
ByVal occurence as String, ByVal systemTime as Double) .
Matlab configuration
• The Matlab COM server must be registered on the system. Therefore, open the
windows command prompt as administrator and call the command "matlab
-regserver" (ensure that the right Matlab version is used) or call
"regmatlabserver" from within Matlab.
• Add the "bin" and "bin\win32" (or "bin\win64") subfolders from the Matlab
installation directory to the system "PATH" variable. Depending on the installed
Matlab version these folders are typically "C:\Program Files
(x86)\MATLAB\R2013b\bin" and "C:\Program Files
(x86)\MATLAB\R2013b\bin\win32".
• Extend the Matlab paths by the location of the calculated scs file as well as the
used Simulink model on your machine. For details, it is referred to the Matlab
online help.
advanced COM 65
1.4.1 The KULI - Simulink interface
Ico Description
n
advanced COM 66
• Model remains open during entire computation / Model will be stopped after each call: This
specifies whether or not the Simulink model should run in parallel with the KULI
computation.
• Show Simulink model: Here you can specify if the window of the Simulink model should be
opened. This is useful if you have e.g. scopes in your model.
• Save Simulink model on close: During a calculation KULI changes the value of the Simulink
constants representing the interface. Here you can choose whether or not these changes
should be saved when the model is closed by KULI.
• Number of input parameters (max. 6): Here you can specify how many values should be
transferred to Simulink. For each parameter you have to specify the Simulink variable and
the unit, in which the variable will be sent to Simulink. The Simulink variable is defined in
the mask of the 'MyControl' subsystem.
• Output: Here you also have to specify the exact name of a ToWorkspace variable in your
Simulink model that represents the value that should be transferred from Simulink back
to KULI. The poptext unit specifies the unit in which this variable is given inside the
Simulink model.
Attention
Be sure to avoid special characters in your Simulink variable names, in particular
German umlauts (ä,ö,ü) cause problems in later versions of Matlab (Release 13 and
later).
The appearance of the icon of a Simulink controller in the graphics window will be
adjusted according to the number of input parameters. The icon cannot be rotated. The
input and output ports can be connected with sensors, actuators, other Simulink
controllers, etc. in the usual way.
advanced COM 67
If you take a look at a demo controller you will first note that on the top level there is a Discrete
Pulse Generator leading into a subsystem. This must be contained in all Simulink models for use
in KULI! It is recommended that you do not change it.
Mask Editor
advanced COM 68
By using the buttons Add and Delete you can add or remove variables. In the edit field Variable
you have to specify the exact name, which is shown in the Simulink dialog within KULI, too. The
name you enter in the edit field Prompt can be defined freely. It only influences the appearance
of the mask, but has no influence to the calculation. You must add a variable for all input values
specified within KULI. These variables can then be used in your block 'MyControl' e.g. as
constants. They are updated whenever there is a data transfer between KULI and Simulink.
Attention
Be sure to avoid special characters in your variable names, in particular German umlauts
(ä,ö,ü) cause problems in later versions of Matlab (Release 13 and later).
The block 'MyControl' must also contain a 'To Workspace' element. If you double-click on this
object, the following dialog window will appear.
To Workspace
The Variable name must be exactly the one that you specified as the name of the output variable
within KULI. Also be sure that the Save format is set to Array. The field Limit data points to last
can be set to any number greater than or equal to one.
advanced COM 69
The time settings within Simulink are defined in the Simulink simulation parameters. To edit or
change them select the menu item Simulation / Simulation parameters... in Simulink.
Be sure that you choose Fixed-step as the Type in the Solver options.
KULI sends the data to Simulink, i.e., KULI sets the variables that are specified in the mask of the
block 'MyControl' to the current values. Simulink then runs the model until it pauses or stops
and gives control back to KULI. The time when the Simulink model pauses is controlled by the
Discrete Pulse Generator. To change these settings, double-click on the icon of the Discrete
Pulse Generator. The following dialog window appears.
advanced COM 70
Discrete Pulse Generator
Be sure that the Pulse type is Sample-based. The sample time must be a multiple of the Fixed
step size specified in the simulation parameters (see further above). The sample time provided
here essentially determines when the model stops since the subsystem to which the Discrete
Pulse Generator leads pauses the model whenever the pulse changes its value.
KULI then reads the 'To Workspace' block with the specified name.
The data transfer now depends on whether or not the checkbox Model remains open during
entire computation is activated. If it is NOT checked, then the data transfer happens for each
iteration step, i.e., for each KULI iteration the Simulink model calculates new output. This is
useful for steady state simulation or for Simulink models that do not depend on the time. In this
case the Simulink model is also stopped after each call. It is recommended that you do not
activate the checkbox Model remains open during entire computation for steady state points.
If the checkbox Model remains open during entire computation is checked, then for transient
simulation the data transfer will be done just once for each time step. The Simulink model will
only be paused and will be continued at the next time step. In the case of a steady state point
the Simulink model will receive data for each KULI iteration but will only be paused and not
stopped between two calls.
advanced COM 71
1.4.4 Working with variable time step solvers
It is also possible to use Simulink-models with a variable time step solver. In this case you must
replace the discrete pulse generator by a standard pulse generator.
When you double-click on the pulse generator be sure to check 'Time-based' as the Pulse type.
The period should be twice as much as the time step in the KULI model, because when the Pulse
Width is 50% of the period, then the signal changes exactly at those times at which the KULI
model is calculated.
Pulse Generator
Finally, when you select the Simulation Parameters in the Simulink model, then you can choose
any variable-step solver that you like
advanced COM 72
Simulation parameters with variable-step solver
Attention
Be careful when you use a variable-step solver in Simulink with KULI. The problem is that
Simulink may perform more time steps than KULI, but the input parameters are updated
only at those time steps at which also a KULI computation takes place. This may lead to
unwanted 'jumps' in the parameters, which may lead to unpredictable behavior of e.g.
PID-controllers, which depend on the derivative of parameters! This is the reason, why it
is recommended to use a fixed step solver with the same step size as KULI.
advanced COM 73
2 advanced optimize
advanced optimize 74
advanced optimize 75
On the page Analysis you can see the result of the analysis. In the region Variable specific values
several statistical values for each of the two variables are computed and displayed. The first line
counts the number of data entries (need not necessarily be the same for the two variables),
followed by mean, standard deviation, variance, minimum, maximum, range, skewness, and
kurtosis. The skewness indicates how asymmetric the data is, the Kurtosis indicates how similar
the data is to a normally distributed data (values close to 0 indicate similarity to normal
advanced optimize 76
distribution).
In the group Test on normal distribution a statistical test on normal distribution is performed for
each of the two variables. A green color signals that the data can be interpreted as normally
distributed, a red color indicates, that this cannot be said. A yellow color is in between those
two. The value displayed in the field is the p-value for the Shapiro-Wilk W-test.
If the two variables A and B have the same sample number, then two additional tests are
performed. The Test on linear correlation computes the empirical correlation coefficient, a value
indicating if there is a linear dependence of the two variables. The slider indicates this
dependence, when you move the mouse over the slider then a tooltip shows the actual value of
this test. In a similar way the Test on common correlation computes the Spearman rank
correlation coefficient, indicating if there is a general, not necessarily linear relation between
the two variables.
The toolbar optimization components offers three objects: Parameter variation, optimization
target, and optimization parameter. These objects are described in detail in their respective
chapters. If some of those objects appear in the KULI model, then a dialog will appear at the
start of a KULI simulation that offers various possibilities for the simulation:
Standard KULI simulation:
In this case a standard KULI simulation will be performed; all optimization and parameter
variation objects will be ignored.
Optimization (available if there is at least one optimization target and one optimization
parameter):
This option starts the KULI optimization. Parameters will be found by KULI in order to obtain a
desired target.
Parameter variation (available if there is at least one parameter variation object):
This option starts the standard KULI parameter variation where the parameters are varied
according to a user-specified law in order to see the influence of those parameters.
advanced optimize 77
Sensitivity studies (available if there is at least one parameter variation object):
This option starts the sensitivity studies which give a graphical representation of the influence of
various parameters on specified output results.
Monte Carlo simulation (available if there is at least one parameter variation object):
This option requires the input of a Number of samples. Then this number of simulation runs will
be performed. In each simulation all parameter variation objects will get new random values
according to a user-specified law for each object.
advanced optimize 78
Note: Most of the items above work for steady state simulation only. The exception to
this rule is the usage of an analysis object with which a useful single value at the end of a
transient simulation can be specified.
2.3 Optimization
Ico Description
n
To create a new optimization target click on the yellow symbol of the toolbar advanced
components. You can place the icon wherever you want in the graphical network,
which is displayed on the page Circuits / Air Path.
The optimization target has a port In and can thus be connected to any sensor or output-port of
an element in the signal path. If you double-click on the icon 1.Opt.target, its dialog will be
displayed, where you can define your target value specifications.
There are three kinds of specification:
• Minimum: The parameter values are chosen (within their specified range) such that the
optimization target assumes its minimum value. It is possible to specify a bound such that
the optimization process stops if the result value is smaller than this bound. This can save
a lot of computation time if such a bound for a sufficiently good solution is known and
specified.
advanced optimize 79
• Maximum: The parameter values are chosen (within their specified range) such that the
optimization target assumes its maximum value. It is possible to specify a bound such that
the optimization process stops if the result value is greater than this bound. This can save
a lot of computation time if such a bound for a sufficiently good solution is known and
specified.
advanced optimize 80
• Value: The parameter values are chosen (within their specified range) such that the
optimization target assumes the specified value. You also have to specify the unit of the
value. If the value cannot be reached, the parameter values are chosen such that the value
of the optimization target is closest to the specified value. The field Accuracy specifies the
desired accuracy. The optimization stops when the result is within the specified distance
of the desired value. Note that the accuracy is only considered in the case of an
optimization with one target and one optimization parameter.
With the help of the checkbox active you can quickly activate or deactivate an optimization
target. This gives you the possibility to change the targets without having to remove the targets
and their sensors and connection lines.
Attention
There are some restrictions concerning the number of optimization targets.
There are two main possibilities:
• If all your optimization targets are set to Value, then you can have either one active
target or as many active targets as there are parameters.
• In all other cases you can only have one active optimization target.
advanced optimize 81
2.3.2 Optimization parameter
KULI offers two types of logic components for optimization work. One type is called Optimization
parameter, which represents a parameter value varying in the defined range. The second type is
the Optimization Target, which will define a target value that should be found by the
optimization of KULI optimize, automatically.
Icon Description
Optimization parameter
The optimization parameter has a port Out and can thus be connected to any actuator or input
port of the signal path. You can add as many optimization parameters to your system as you
like. By double-clicking on the icon 1.Opt.parameter its component's dialog will be displayed.
Here, the unit and both bounds, lower and upper, have to be specified. Only parameter values
within this range are considered for the optimization problem. The main purpose of the bounds
is to prevent KULI from computing the cooling system for values which are completely out of
range and might cause strange results.
With the help of the checkbox active you can activate or deactivate an optimization parameter.
This gives you the possibility to change the parameters without having to remove the
parameters and their actuators and connection lines. A deactived Opt. Parameter delivers a
advanced optimize 82
value of Zero in combination with a Calculation object. In all other cases the default value in the
component Parameter window or Component window is used.
advanced optimize 83
Tip
It is possible to combine the optimization and the parameter variation. If a model
contains an active optimization and an active parameter variation, then for each variant
of the parameter variation the optimization is performed.
2.3.4 Applications
The general approach of the optimization allows a wide field of applications. With the help of
sensors and actuators, it gets easy to e.g. determine the optimal resistance value of a built-in
resistance, which is needed to find the desired target value. This can be the output temperature
of the coolant in a radiator, for example.
Ico Description
n
Thus, simply add the desired sensor to the radiator, create a new optimization target
and connect both. Double-click on the Optimization Target, choose Value and supply
the appropriate temperature. You should always be sure to choose the correct unit.
Optimization Example
Ic Description
o
n
advanced optimize 84
Next, create a built-in resistance in the graphics network and add an actuator for the
resistance parameter. For our optimization purpose you have to add only one
optimization parameter and connect it to the actuator port. Specify lower and upper
bounds of the 1.Opt. parameter. In this case you have to select the hyphen ("-") as the
unit, since our optimization parameter is dimensionless.
Finally, save your file and start the simulation run. As a result the computed value will be
the parameter a in the parameter description of the resistance in the output file. (The
parameters b and c are set to zero and the type of pressure loss definition is set to
"parameter".)
Other applications include an adjustment of the fan RPM or questions like "Up to which outside
temperature does my charge air cooler work?". In the latter case the optimization parameter
would be the outside temperature (so add an actuator for the outside temperature to the
simulation parameters) and the optimization target would be e.g. the outlet temperature of the
charge air, where the target is set to Value and the critical temperature is entered. As a result
KULI computes the outside temperature for which the critical temperature of the charge air is
assumed.
advanced optimize 85
Example cooling system for the sensitivity analysis
The COM-ID that is specified in the COM controller dialog is later used in the output report and in
the output diagram as an identifier.
Attention
Note, that in sensitivity analysis each parameter variation object must be linked to an
actuator directly!
advanced optimize 86
Correct connection
Fault connection
After the complete definition of input and output values, Start the analysis and choose
Sensitivity Analysis... to open the window Sensitivity Analysis. Here, the sensitivity analysis can
be performed.
On the left side of the window a tree structure represents the specified input Parameter
(parameter variation objects). As soon as the analysis results are available, the output data will
be accessible by the item Output.
If a parameter is selected in the tree view, the corresponding parameter values and its options
will be displayed on the right side of the window.
Parameter options:
• Use parameter in sensitivity analysis - activate this option to consider the parameter in the
sensitivity analysis.
• Parameter is reference for output - activate this option, if the parameter should be the
reference parameter for the output.
• Modify parameter values - activate this option to modify the values, which are specified in
the parameter variation. If this is not activated, the default parameter variation object
values will be used.
advanced optimize 87
• Minimum, Maximum, Step size - these values represent the specified input values of a
parameter variation. The value for step size is not relevant, because it is not needed for
the sensitivity analysis.
• Standard value - this value is combined during calculation with the minimum and
maximum value of another parameter. If the option Modify parameter values is not active,
the Standard value will be the mean of minimum and maximum value.
2.4.2 Calculation
The variation of one parameter requires two simulation steps in KULI. The first simulation run is
performed with the minimum and the second one with the maximum value of the first
parameter. Then, the next parameter will be varied in the same way.
Icon Description
If one parameter is varied, the other parameter values are set to the so-called Reference Value.
Therefore, this reference value will be calculated by the mean value of the minimum and the
maximum of the parameter by default. Moreover, if the checkbox Modify parameter values is
activated, the user can set the reference value to any number.
After the complete sensitivity analysis with all parameter variations the result can be found in
the tree view.
2.4.3 Results
Report
Icon Description
To view the output report, click the report item in the tree view.
advanced optimize 88
Input file: C:
\ECS\KULI_101000\data\CoolingSystems\ExTRUCK_sens.scs
Date: Tuesday, 09. December 2014 15:03:18
__________________________________________________________________
____________
Sensitivity Analysis
====================
User ............. : ECS
Editing date ..... : Monday, 10. November 2014 11:08:08
Department ......... :
Purpose .......... :
Result description :
Report ........... :
__________________________________________________________________
____________
advanced optimize 89
2000 [1/min]
advanced optimize 90
1.Radiator: Width 2.02917 2.02880
90.82 53.06
On the top of the report general project data are listed. Then, the report contains the specified
input parameters and finally, the calculation results are shown.
The input parameter listing shows, if a parameter was considered during calculation or not,
which is the reference parameter and the specified values.
Input parameter Definition
1.Parameter: KULI_SIM_PARAMETER Speed
-------------------------------------
Act. Ref. Min. Max.
Step. RefVal.
x - 10 [km/h] 110 [km/h] 50 [km/h]
60 [km/h]
The result of the sensitivity analysis illustrates a COM controller with its results for each
parameter. The Min. and Max. values are the results, which were generated during the
calculation with the minimum and maximum parameter values. If a parameter is specified as
reference parameter, the difference between its minimum and maximum result is set to 100%
and it is used as a base for the calculation of the percentage values of all other results.
WK1 Exit Press IM [bar] - 1.Simulation parameter
------------------------------------------------
Min. Max. Min.
advanced optimize 91
[%] Max. [%]
1.Radiator: Height 2.02828 2.02926
0.00 100.00
Sim.parameter: RPM 2.02968 2.02727
142.86 -103.06
Sim.parameter: Speed 2.02899 2.02899
72.45 72.45
1.Radiator: Width 2.02917 2.02880
90.82 53.06
If the result value with the maximum parameter value is less than the result value with the
minimum, the difference for the reference parameter is -100%.
WK1 Exit Temp IM [°C] - 1.Simulation parameter
----------------------------------------------
Min. Max. Min.
[%] Max. [%]
1.Radiator: Height 75.108 69.136
0.00 -100.00
Sim.parameter: RPM 87.510 63.822
207.65 -188.98
Sim.parameter: Speed 72.642 68.787
-41.30 -105.85
1.Radiator: Width 78.644 67.543
59.19 -126.68
Diagrams
Ico Description
n
To visualize the calculation results click to the diagram item in the tree view. A bar chart
will be displayed that presents the calculation results. Each bar represents one input
parameter and each end of a bar shows the result values with minimum and maximum
input parameter value.
Furthermore, one chart (in that case 4 bars) represents one output parameter (COM controller).
advanced optimize 92
Arrows are used to differentiate whether the result value with the minimum parameter value is
less or more than the result value with the maximum parameter value. If an arrow points from
the bottom up the result with the maximum value is higher than the result with the minimum
and vice versa.
If an input parameter takes no influence on an output parameter, this means when the results
with the minimum and maximum value is the same, an arrow will be shown, which points in
both directions, up and down. In this case the bar is reduced to a thin line.
Example diagram
The object "Parameter variation" offers various possibilities to vary a parameter. This
object is used for the standard parameter variation and for the Monte Carlo analysis.
advanced optimize 93
2.5.1 Usage
The parameter variation object is a source in the signal path. So it can be connected directly to
an actuator, but it is also possible to place branches, calculation controllers, etc. between a
parameter variation object and an actuator.
During the standard parameter variation the parameter values will be varied according to the
specified type as described later on. Note that all possible combinations of the parameter will be
simulated.
In the case of a Monte Carlo analysis the user-specified number of simulation runs (usually a
rather large number) will be performed. In each simulation every parameter will randomly get a
new value according to the specified type as described later on.
A parameter variation object can be deactivated by unchecking the Active box in the dialog
window which is also reflected in the appearance of the icon of the object. This gives you the
possibility to change the parameters without having to remove the parameters and their
actuators and connection lines. Inactive parameter variation objects will simply be ignored. Any
advanced optimize 94
actuator that would receive a value from an inactive parameter variation object will
consequently also be ignored.
At the end of a parameter variation or a Monte Carlo simulation the results can be viewed in
KULI lab. Note that in particular in the case of a Monte Carlo Simulation the usage of an analysis
object is strongly recommended to see various statistically relevant values after the simulation.
There are three main types of parameter variation: Discrete values, distribution, and Files. In the
top part of the window there are radio buttons for the Type which specify the current type of the
parameter variation. In the notepages below the individual properties can be specified for each
type.
advanced optimize 95
2.5.2 Handling of units
In the dialog window of the parameter variation object you can specify the unit of the values.
This affects the discrete values and the distribution values as well. It has no effect in the case
when file variation is selected.
2.5.3 Discrete
For discrete values there are again two different possibilities: Equidistant values and individual
values. In the case of equidistant values the minimum and maximum values as well as the step
size have to be specified. During parameter variation KULI begins with the minimum value and
adds the step size as long as the new value is smaller than or equal to the upper bound. Note
that the upper bound does not need to be obtained exactly. If e.g. the lower bound is 100, the
upper bound is 200, and the step size is 30, then the values 100, 130, 160, and 190 will be used.
If individual values are selected, then the user can specify the desired values in the table.
In the case of a Monte Carlo simulation one of the discrete values will be picked randomly.
2.5.4 Distribution
If the type Distribution is selected, then several parameters must be entered. First the desired
distribution type must be selected from the list. The following distributions are available:
normal distribution, log-normal distribution, and uniform distribution. In the case of normal and
log-normal distribution, the parameters µ and σ (mean and standard deviation) must be
advanced optimize 96
provided. In the case of a uniform distribution the lower bound a and the upper bound b need to
be specified.
In the case of a Monte Carlo simulation the value will be chosen randomly with respect to the
selected distribution type.
In the case of a standard parameter variation, the simulation begins with the value specified in
Lower bound and ends with the value specified in Upper bound, using as many equidistant
points as specified in Number of samples. If Number of Samples is just 1 (or 0), then the mean
value (either µ or (a+b)/2) will be used.
The edit texts for Lower bound and Upper bound allow arbitrary input values, but there are
selection lists for common values like µ±σ etc. Note that in the case of a uniform distribution you
cannot enter values for those bounds. In this case the lower bound is automatically set to a and
the upper bound is automatically set to b.
2.5.5 Files
If the type is Files, then you can select a list of component files. Note that in this case the
parameter variation object must be directly connected to a Filename actuator of a component
before the files are selected because then KULI is able to determine the type of component. With
the help of the button File select one or more files can be added to the list. This does not
eliminate the components that are already in the list! With the help of the button Clear file list
the current list can be deleted.
advanced optimize 97
Info
Take into consideration, only the performance of the component based on the
difference in the geometric size will be changed. The component in the cooling package
will not change the geometric size based on the change of the property File.
advanced optimize 98
Cooling System containing a System Resistance Curve Subsystem
advanced optimize 99
3 advanced CFD
With KULI - CFD (CFD = Computational Fluid Dynamics) it is possible to consider non-uniform air
flow distributions on heat exchangers in KULI. An uneven flow distribution can be caused by a
fan, by inlets and by non-ideal cooling air channels. In some cases the effect of uneven air flow
distributions on heat transfer has to be considered. The cooling air velocity distribution on the
heat exchanger has to be determined by CFD analysis. The results of the CFD analysis will be
transferred to KULI. Based on these CFD data, a system of flow resistance correction factors will
be generated. In KULI such a system of flow resistance correction factors is known as Resistance
Matrix. With the resistance matrix the uneven air flow distribution can be modeled.
CFD File: Using the context menu of the edit field you can select the file containing the CFD
analysis velocity (or pressure) field. The names of the coordinates and the field properties will be
show in the lower part of the window (Field coordinates and Field properties).
Comment, Component, Width, Height, Depth: These entries can be considered as comments for
the KULI CFD-file and are not needed for the calculation of the resistance matrix. However, it is
recommended to complete them to ensure clear identification of the data for future use.
CFD velocity field, CFD pressure distribution: Choose one option according to the type of the
imported data.
Unit coordinates: Here You specify the unit of the field coordinates, which apply to the
coordinates of the CFD file.
Attention
Please consider the correct unit of the coordinates (m or mm).
Write KULI CFD file: Use this button to generate the KULI CFD-file containing the velocity field in a
KULI compatible file format (you must choose a file name immediately after pressing this
button).
The velocity field must be stored in columns. In KULI, the air flow is defined in x-direction. For
this reason the velocity values point into the x-direction and the y- and z-coordinates indicate
their position. It is important that the y- and z-coordinates of the velocity field corresponds with
the coordinate system in KULI (y- and z-coordinates should not be mixed up). An example of a
file with a velocity distribution is provided below.
All necessary items are printed bold. The other items are optional. However, it is recommended
to complete them to ensure clear identification of the data for future use.
Example: C:\...\CFD-Data\ExCFD-2.cfd
It is also possible to generate a KULI CFD file manually using a graphical user interface as it is
shown below. It is still essential to specify the necessary input as described above. To start this
window, please use the menu Data / Import User Data from the Resistance matrix window.
At first enter the file names for both, the geometry and the velocity field from Ensight. By clicking
on the button Open file one file can be found on your disk. As a result the selected file name will
be shown in the input field. Do this for both input files ending in .geo and .vnode.
Next, you will set the name for the KULI CFD file, where the translated CFD data will be saved
after conversion. Here, the button Save File As will help you to find the output file ending with
cfd.
The input field Scaling factor velocity gives you the possibility to scale all velocity values by this
factor during conversion.
First load the KULI CFD file that needs modification using the context menu of the input field
KULI CFD file. Afterwards the number of points, the minimum and maximum value of the y- and z-
coordinates as well as the unit of the coordinates are written into the appropriate fields. You can
choose any name for the modified KULI CFD file except the name of the original file.
Now you have the following options for modifying your file:
Reduction of the number of points: If the original CFD file contains many points, then it is often
possible to reduce the number of points without decreasing the accuracy in the computation of
the resistance matrix. A smaller number of points result in significantly shorter computation
times for the computation of the resistance matrix. (The computation time depends in a
KULI file: Using the context menu of the edit field, open the library to select the KULI file with the
cooling system for which the resistance matrix was determined. The cooling system must
contain the block with an appropriate raster.
Block No.: If there is no input, block number '1' is edited automatically after selecting a KULI file.
If the first block already has a resistance matrix and the cooling system contains more blocks the
number of the next block is edited. If the resistance matrix shall be generated for a different
block, the block number has to be entered by the user. The correct block number can be found
in the block table at the Air side. If the block already contains a resistance matrix, it has to be
removed before a new one can be generated for this block.
Block height, Block width: These items show the block size and are automatically edited after
generating the resistance matrix.
By pressing the button Align CFD data with blocks KULI can
automatically determine a suitable position of the CFD data relative to
the KULI coordinate system. If this button is pressed, then the position
will be chosen such that the center of the CFD data and the center of the
rectangle covering all affected blocks (Blocks used for CFD Matrix) will
coincide. The result will be filled into the fields Position y-direction and
Position z-direction. This function can also be enabled with the help of
the menu CFD-data / Align CFD data with blocks.
Max. number of shown velocity values: The number of velocity values in the KULI CFD file can be
quite high (e.g. 10000 values). To ensure rapid graphical display of the velocity field, the number
of the velocity values shown can be limited. The default is set to '1000', but can be changed by
the user. However, it is recommended not to choose extra large numbers. If the KULI CFD file
contains fewer velocity values than the specified maximum, all values will be shown. The
specified maximum only influences the graphical display, it has no influence on the calculation
of the resistance matrix.
• Air mass/volume flow rate from CFD data: These values are calculated together with the
resistance matrix and are displayed for information purposes. The volume flow rate is the
integrated value of the centre point velocity of each single element of the resistance
matrix velocity field.
with
........................ flow velocity at ambient point (vehicle velocity)
....................... static pressure at infinite ambient point
........................ static pressure at the at the inlet grill
.......................... non dimensional pressure coefficient
with
........................ intake velocity at the inlet grill
If you want to change the resistance matrix of a block, you will call Add/Edit resistance matrix in
the context menu of the block table. Then load a new resistance matrix.
If you want to remove the resistance matrix, you will call Remove resistance matrix in the context
menu of the block table.
3.5 Results
KULI lab provides a clear overview of the results. The temperature distribution of the coolant,
the cooling air and further the cooling air velocity field can be visualized with the Diagram of
radiator areas.
During simulation KULI uses a linear interpolation of the resistance matrices specified in the
table. Suppose the table contains a resistance matrix mat1.kuliResmat for 50 km/h and a
second matrix mat2.kuliResmat for 100 km/h. Now if e.g. the simulation runs at 75 km/h, then
the arithmetic mean of the zeta correction factors in the two resistance matrices is used. KULI
however does not perform extrapolation. If during simulation a driving speed or COM value
outside the supplied range is encountered, then the closest boundary value will be taken.