Download as pdf or txt
Download as pdf or txt
You are on page 1of 131

Version 15 (18.08.

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

1.3 Controlling KULI from external applications ..................................................................9


1.3.1 Initializing KULI ....................................................................................................................................... 10
1.3.2 Some standard procedures .................................................................................................................... 11
1.3.3 List of properties ..................................................................................................................................... 16
1.3.4 List of methods........................................................................................................................................ 20
1.3.5 List of events ........................................................................................................................................... 53

1.4 The Simulink Interface...................................................................................................65


1.4.1 The KULI - Simulink interface ................................................................................................................. 66
1.4.2 Suitable Simulink models for KULI ........................................................................................................ 67
1.4.3 How the interface works......................................................................................................................... 69
1.4.4 Working with variable time step solvers................................................................................................ 72

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

2.4 Sensitivity Analysis.........................................................................................................85


2.4.1 Input data ................................................................................................................................................ 85
2.4.2 Calculation .............................................................................................................................................. 88
2.4.3 Results ..................................................................................................................................................... 88

2.5 Parameter variation.......................................................................................................93


2.5.1 Usage ....................................................................................................................................................... 94
2.5.2 Handling of units..................................................................................................................................... 96
2.5.3 Discrete.................................................................................................................................................... 96
2.5.4 Distribution ............................................................................................................................................. 96
2.5.5 Files.......................................................................................................................................................... 97

2.6 System Resistance Curve...............................................................................................98


2.6.1 Create System Resistance Curve............................................................................................................ 98
2.6.2 View System Resistance Curve ............................................................................................................... 99

3 advanced CFD............................................................................................ 100


3.1 CFD Interface File .........................................................................................................100
3.1.1 Considering an uneven pressure distribution ..................................................................................... 100
3.1.2 Generating KULI CFD file....................................................................................................................... 101
3.1.3 Ensight Interface ................................................................................................................................... 104
3.1.4 Modifying a KULI CFD file...................................................................................................................... 106
3.1.5 Import 2D Data to CFD .......................................................................................................................... 108

3.2 Build the Resistance Matrix .........................................................................................111


3.2.1 Input Data.............................................................................................................................................. 113
3.2.2 CFD Velocity Field.................................................................................................................................. 114
3.2.3 KULI Resistance Matrix ......................................................................................................................... 118
3.2.4 CFD Pressure Field ................................................................................................................................ 120

3.3 Modeling of the Resistance Matrix ..............................................................................121


3.4 Direct CFD interface .....................................................................................................123
3.4.1 Adding a direct CFD interface to a KULI model ................................................................................... 123
3.4.2 The direct CFD interface ....................................................................................................................... 125
3.4.3 How the direct CFD interface works..................................................................................................... 127

3.5 Results ..........................................................................................................................127


3.6 Resistance Matrix depending on velocity ...................................................................128
3.6.1 Resistance matrix depending on velocity............................................................................................ 128
1 advanced COM

1.1 The COM interface


The COM interface (Component Object Model), developed by Microsoft®, provides a
standardized interface for programs to communicate with each other, independent of
programming language. KULI has a set of built-in COM commands, which allow other programs
to run and control a KULI simulation. The interface can be used with 32 and 64 bit application.

1.2 Defining the interface in KULI


If you just want to run your already existing KULI model from within another application without
setting or reading any parameter, then you do not need to make any modifications to your KULI
model at all. However, if you do want to set a value or read a value from within your application,
you must specify those values/parameters of your KULI model that should be accessible from
outside.
The general rule is that any sensor value can be read and any actuator value can be set by the
COM interface. The following sections show how this can be accomplished.

Sensor and actuator made available to external applications

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).

1.2.2 Defining actuator values to be set from external applications


Suppose you want to set the width of a radiator from within your application. Then, go to the
page Circuits / Air Path, select your radiator and choose Show connection attributes from the
context menu. Select the actuator that you want to make available to other programs (so in this
case mark the actuator for Width) and close the dialog afterwards.

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

1.3 Controlling KULI from external applications


The part of KULI that performs the calculations is implemented as a standalone calculation
server. This KuliAnalysisServer.exe is called by the KULI user interface. It has a set of built-in
COM commands that can be executed from any application that can handle COM commands.
Among those applications are popular ones like Excel (using Visual Basic Scripts) and Matlab.
The source code examples used in this manual are valid for Visual Basic scripts. Sometimes also
the corresponding code for Matlab scripts is given. Please refer to the reference manual of your
application to learn how it handles COM commands.
See
KULI Project Handling

advanced COM 9
1.3.1 Initializing KULI

Using KULI in Microsoft Excel


Before you can use KuliAnalysisServer.exe you have to initialize it. In Visual Basic you must first
tell the program to use it. For this purpose open the Visual Basic editor and choose the menu
Tools/References and ensure that the checkbox for the appropriate KULI Analysis version is
marked. For example, for KULI 13 choose "KuliAnalysisServer 13 Type Library".

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

Using KULI in Matlab and Simulink


Since Matlab handles COM in a different way, here is an example of the corresponding
commands in Matlab:

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".

1.3.2 Some standard procedures


Here some complete scripts are presented. They will show some common tasks using the COM
interface. For a complete description of all the commands see the following sections.

Running a KULI model remotely


The following simple Visual Basic script shows how to make a complete run of a KULI model
without using the KULI user interface. The script launches the KULI dynamic link library,
specifies a file name and runs the computation. Then it opens another file and runs KULI on this.
The corresponding output and KULI lab files (*.hdmb, rep.) are generated automatically. This
script assumes that you have a button CompleteKULIRun on your Excel-sheet. A click on this
button then starts this script. In your implementation you should do some error handling with
calcOK.

advanced COM 11
Public WithEvents KULI As KuliAnalysisCtr2

Private Sub CompleteKULIRun_Click()


Dim calcOK As Boolean
Set KULI = New KuliAnalysisCtr2

'change directory name to your settings


KULI.KuliFileName = "D:\myCoolingSystem\ExTruck1.scs"
Cells(1, 3) = "Running model 1"
calcOK = KULI.RunAnalysis

'do some error handling if calcOK is not true


KULI.KuliFileName = "D:\myCoolingSystem\ExTruck2.scs"
Cells(2, 3) = "Running model 2"
calcOK = KULI.RunAnalysis
Set KULI = Nothing

Cells(3, 3) = "done."
End Sub

Setting and reading parameters


The following Matlab script now does a little bit more. It opens the connection with KULI,
specifies the file, and then, within a loop, the Matlab code sets the rpm of a fan, and then
computes the KULI model. Finally, the resulting temperature of a radiator is read and put into a
vector containing all results.

myfig = figure('pos',[100 200 200 200]);

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.

Controlling the iteration process


The following script now shows how external applications can control even the single iteration
steps within the KULI computation.

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.

Public WithEvents KULI As KuliAnalysisCtr2

Private Sub CommandButton1_Click()


Dim calcOK As Boolean
Dim temperature As Double
Dim i As Integer

Set KULI = New KuliAnalysisCtr2


KULI.KuliFileName = "C:\mykuli\ExTruck_COMSet.scs"
calcOK = KULI.Initialize()
calcOK = KULI.StartAnalysis()
i = 2
Do Until KULI.IsFinished
calcOK = KULI.NextKULIIteration()
temperature = KULI.GetCOMValueByID("Temperature")
Cells(i, 1) = temperature
i = i + 1
Loop

Set KULI = Nothing


End Sub

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.)

Setting the output file name


When running a KULI model, the automatically generated KULI lab files (*.hdmb) are given the
same name as the model's filename by default. However, one may set a custom filename for the
ouput file by setting the ResultFileName property as the following example script shows:

Set KULI = New KuliAnalysisCtr2


KULI.KuliFileName = "ExCar.scs"
KULI.ResultFileName = "Result1.hdmb"
calcOK = KULI.RunAnalysis

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.

Setting user defined media path


When running a KULI model, the media path specified in Settings/Media root Path is used by
default. However, one may set a custom media path for simulating by setting the
MediaPath property as the following example script shows:

Set KULI = New KuliAnalysisCtr2


KULI.KuliFileName = "ExCar.scs"
Kuli.MediaPath = "C:\Program Files (x86)\ECS\KULI_132000\System"
calcOK = KULI.RunAnalysis

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.")

Fix OLE-DB error message in Excel during simulation


In Microsoft Excel, when calling long lasting methods like SimulateOperatingPoint() or
RunAnalysis() an error message might occur telling you that "Microsoft Excel is waiting for
another application to complete an OLE action".
This happens when the methods calls exceed Excel's timeout of 60sec for COM automation calls.

There are 3 known solutions to overcome this limitation:

1. Use iteration based simulation


In the VBA script, replace SimulateOperatingPoint() or RunAnalysis() with the iteration
based simulation control (see Control the iteration process ).

2. Disable Excel alerts


To disable Excel alerts, add the following code snippet to your VBA script before the KULI
simulation is triggered.

Application.DisplayAlerts = False

Please note, this command disables all Excel alert. Use solution 3 to hide exactly the
message in this context.

3. Disable Excel message via message filter


Instead of disabling all messages, the relevant message can be disabled selectively.

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

...

Dim lMsgFilter As Long

''' Remove the message filter


CoRegisterMessageFilter 0&, lMsgFilter

''' Call your critical code here....


kuli.SimulateOperatingPoint(0)

''' Restore the message filter


CoRegisterMessageFilter lMsgFilter, lMsgFilter

1.3.3 List of properties

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

In Matlab the corresponding commands are

Matlab example

set(KULI, 'propertyname', newpropertyvalue)


getpropertyvalue = get(KULI, 'propertyname')

BatchMode

BatchMode (Read / Write)

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

EnableEvents (Read / Write)

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

KuliFileName (Read / Write)

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

MediaPath (Read / Write)

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

ResultFileName (Read / Write)

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

SensitiveAnalysis (Read / Write)

boolean SensitiveAnalysis

This boolean variable defines the state of "Sensitive Analysis" feature.

WriteResults

WriteResults (Read / Write)

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.

1.3.4 List of methods

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

' function call with return value


returnvalue = KULI.methodname(arguments)

' sub routine call


KULI.routineName arg1, arg2

' example with different parameter datatypes


Dim ok as boolean
ok = KULI.SetCOMValueByID "vehicleSpeed", 240.0
if ok then
Msgbox "COM value 'vehicleSpeed' is set to 240. Your COM object specifies the
actual unit in KULI!"
end if

The corresponding command in Matlab® is:

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))

computes the second operating point.

Easy identification of cooling system components:


Parameters can identify a component name that refers to your cooling system. The component
name is predefined by KULI automatically. On the other side your cooling system can contain
one COM object. The COM id is defined by the user and can also be used as a method parameter.
A COM object can handle one value e.g. T_ambient.
KULI direct access
In KULI some functions are more effective on access to the cooling system. Now, not cooling
system components are needed internally, instead of you can access an actuator or sensor value
directly. As a result the simulation run controlled by an external application will be faster and
needs less memory.

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

void AddToBatchList(BSTR filename)

Deprecated method

This method will be removed in future versions of KULI.

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()

Note: BatchMode must be set to TRUE

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

BSTR GetCOMCodes(bool input)


This command retrieves the IDs of all COM objects in your KULI-model.
Input parameter: A boolean variable specifying if the names of input or output COM objects
should be returned. Use True to get input COM names and False to get output COM names.
Return value: A string containing the IDs of all input or output COM objects, separated with a
semicolon
Example:

advanced COM 24
Dim codesInput, codesoutput As String
Dim codeArrayInput() As String
Dim codeArrayOutput() As String

'Read IDs of COM objects from scs file


codesInput = KULI.GetCOMCodes(True)
codesoutput = KULI.GetCOMCodes(False)
codeArrayInput = Split(codesInput, ";")
codeArrayOutput = Split(codesoutput, ";")

GetComponentConnectorUnit

BSTR GetComponentConnectorUnit(BSTR component, BSTR connector)


This command retrieves the SI-unit of a specified sensor or actuator (connector), belonging to
the specified component.
Input parameter:
• component........ string with a specified component type (Rad, CCFC, ..); case sensitive.
• connector ........ string with a specified sensor/actuator of a comp. type (MeanEffPress,
Speed, RPMEng, ..); case sensitive
For further information about the KULI connectors (sensor or actuator name) and units please
refer to the description here.
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

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"

'set a new KULI-controller


Set KULI = New KuliAnalysisCtr2
'get connector unit
connectorUnit = KULI.GetComponentConnectorUnit(component, connector)
'connectorUnit is [Pa]
Cells(20, 8) = connectorUnit

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

BSTR GetComponentDescription(BSTR componentType)


This command retrieves the IDs of all available component types in KULI.
Input parameters:
componentType ... string with the ID of a component type ('EFan', 'MFan', 'RAD', ...); case
insensitive;
If componentType is ' RAD' or 'R AD' or '1.RAD' instead of the valid 'RAD', the invalid component
type ID will return an error message.
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.
Return value:
a string containing the component description ('Radiator' for 'RAD' or 'Simulationsparameter'
for 'SimPar')
an empty string if component ID is invalid.
Example:

advanced COM 26
'Define variables
Dim fileKULI, compType, compDescr As String

fileKULI = "C:\Program Files\ECS\KULI_101000\data\CoolingSystems\ExCAR_COM.scs"


compType = "AIRTUBE"

'set a new KULI-controller


Set KULI = New KuliAnalysisCtr2

'change directory name to your settings


KULI.KuliFileName = fileKULI

'get component description for AIRTUBE


compDescr = KULI.GetComponentDescription(compType)
Cells(20, 8) = compDescr

GetCOMValueByID

double GetCOMValueByID(BSTR comName)


This command returns the following value:
• output COM object: the current value.
• input COM object that has already been set (e.g. using SetCOMValueByID): currently set
value
• input COM object that has not yet been set but has a default value: default value
• input COM object that has not yet been set and has not default value: zero
Input parameter: A string with the exact name as specified in the edit field COM-ID of the COM
object in your KULI model (see COM-object)
Return value: A double value containing the current value of the COM object
Example:

Dim newvalue As Double


newvalue = KULI.GetCOMValueByID("Temperature")

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

BSTR GetCOMValueByIDAsStr(BSTR* comName)


Same as GetCOMValueByID, return value is a string. comName is passed by reference, which
may cause problems with Matlab. Use GetCOMValueByIDAsStr2 instead if you experience
problems.

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

BSTR GetCOMValueByIDAsStr2(BSTR comName)


Same as GetCOMValueByIDAsStr. comName is passed by value (as in the case of
GetCOMValueByID), which should work with programs that have problems with call by
reference.

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

long GetErrorInfo(BSTR* s_errors)

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

BSTR GetInputCOMUnitByID(BSTR comName)


This command retrieves the unit of an input COM object.
Input parameter: A string with the exact name as specified in the edit field COM-ID of the COM
object in your KULI model (see COM-object)
Return value: a string containing the unit of the COM object

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

BSTR GetOutputCOMUnitByID(BSTR comName)


This command retrievess the unit of an output COM object.
Input parameter: A string with the exact name as specified in the edit field COM-ID of the COM
object in your KULI model (see COM-object)
Return value: a string containing the unit of the COM object

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

double GetValue(BSTR component, BSTR sensor)


This command retrieves the value of a component connector in your KULI-model.

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

fileKULI = "C:\Program Files\ECS\KULI_101000\data\CoolingSystems\ExCAR_COM.scs"


'set a new KULI-controller
Set KULI = New KuliAnalysisCtr2

'Select KULI File


KULI.KuliFileName = fileKULI

'initialize the cooling system


calcOK = KULI.Initialize()

'KULI calculates the values


KULI.SimulateOperatingPoint (1)

'get the parameter-value with direct access


value = KULI.GetValue("1.RAD", "EntryTempIM [°C]")
Cells(20, 8) = value

GetValueAsStr

BSTR GetValueAsStr(BSTR component, BSTR sensor)


Same as GetValue, but the return value is a string. If a parameter is invalid, the return value is an
empty string.

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

fileKULI = "C:\Program Files\ECS\KULI_101000\data\CoolingSystems\ExCAR_COM.scs"


'set a new KULI-controller
Set KULI = New KuliAnalysisCtr2

'Select KULI File


KULI.KuliFileName = fileKULI

'initialize the cooling system


calcOK = KULI.Initialize()

'KULI calculates the values


KULI.SimulateOperatingPoint (1)

'get the parameter-value with direct access


value = KULI.GetValueAsStr("1.RAD", "EntryTempIM [°C]")
Cells(20, 8) = value

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

'get the parameter-value with direct access


value = KULI.GetValueAsStr("1.RAD[1,1]", "IndexWithinBlock")
Cells(20, 8) = value

GetValueUnit

double GetValueUnit(BSTR component, BSTR sensor, BSTR unit)


Same as GetValue, but the unit is not part of the connector ID. It's an additional parameter.

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

fileKULI = "C:\Program Files\ECS\KULI_101000\data\CoolingSystems\ExCAR_COM.scs"


'set a new KULI-controller
Set KULI = New KuliAnalysisCtr2

'Select KULI File


KULI.KuliFileName = fileKULI

'initialize the cooling system


calcOK = KULI.Initialize()

'KULI calculates the values


KULI.SimulateOperatingPoint (1)

'get the parameter-value with direct access


value = KULI.GetValueUnit("1.RAD", "EntryTempIM", "[°C]")
Cells(20, 8) = value

advanced COM 34
GetValueUnitAsStr

BSTR GetValueUnitAsStr(BSTR component, BSTR sensor, BSTR unit)


Same as GetValueUnit, but the return value is a string. If a parameter is invalid, the return value
is an empty string.

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

fileKULI = "C:\Program Files\ECS\KULI_101000\data\CoolingSystems\ExCAR_COM.scs"


'set a new KULI-controller
Set KULI = New KuliAnalysisCtr2

'Select KULI File


KULI.KuliFileName = fileKULI

'initialize the cooling system


calcOK = KULI.Initialize()

'KULI calculates the values


KULI.SimulateOperatingPoint (1)

'get the parameter-value with direct access


value = KULI.GetValueUnitAsStr("1.RAD", "EntryTempIM", "[°C]")
Cells(20, 8) = value

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:

Dim newvalue As Long


newvalue = KULI.GetVersionID()

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

long GetWarningInfo(BSTR* s_warnings)

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

Dim initOK, calcOK As Boolean


initOK = KULI.Initialize()
calcOK = KULI.SimulateOperatingPoint(0)

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:

Set KuliC = New KuliAnalysisCtr2


KuliC.KuliFileName = "C:\kuli\extrucktrans.scs"
calcOK = KuliC.Initialize
calcOK = KuliC.StartAnalysis
While KuliC.IsNextTimeStep
Do Until KuliC.IsFinished
calcOK = KuliC.NextKULIIteration()
Loop
Wend

ListComponents

BSTR ListComponents(BSTR filter)


This command retrieves all components of your KULI-model.
Input parameter: filter string to filter data
• '*' Get all components

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 battery modules:


• 1.BATTM
• 1.BATTM/ECELL[x,y,z]
x....Maximum number of battery cells inside module in x-direction
y....Maximum number of battery cells inside mudule in y-direction
z....Maximum number of battery cells inside module in z-direction

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

fileKULI = "C:\Program Files\ECS\KULI_101000\data\CoolingSystems\ExCAR_COM.scs"


'set a new KULI-controller
Set KULI = New KuliAnalysisCtr2

'Select KULI File


KULI.KuliFileName = fileKULI
'initialize the cooling system
calcOK = KULI.Initialize()

'List components of the KULI-model and safe to an array


components = KULI.ListComponents("1.?Fan .RAD 2.")
componentsArray = Split(components)

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

'set a new KULI-controller


Set KULI = New KuliAnalysisCtr2

'List components of the KULI-model and safe to an array


componentTypes = KULI.ListComponentTypes()
componentTypesArray = Split(componentTypes)

ListConnectors

BSTR ListConnectors(BSTR componentType, BSTR connectorType)


This command retrieves the IDs of all connectors (sensors and/or actuators) of a component
type.
Input parameters:
componentType - string with the ID of a component type (EFan, MFan, RAD, ..) case insensitive;
If componentType is ' RAD' or 'R AD' or '1.RAD' instead of 'RAD' --> Invalid component ID and
error message
connectorType - a filter string; can be 'S' for sensor, 'A' for actuator or 'SA' for sensor and
actuator; case insensitive; It doesn't matter if the connectorType is 'S' or ' S' or 'S A '
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 section Component
Connectors.
Return value:
A string containing the connector IDs of a component type separated with blanks. This list is a
KULI definition.

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"

'set a new KULI-controller


Set KULI = New KuliAnalysisCtr2

'List sensor AND actuator IDs of a Radiator and safe to an array


connectors = KULI.ListConnectors(componentType, connectorType)
connectorsArray = Split(connectors)

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

bool ObjectExists(BSTR comName, BSTR flag)


Checks if a COM object of name comName exists in the currently chosen KULI model. This
routine can only be called after the current model has been initialized using Initialize.
Input parameters:
comName: The name of the COM object.
flag: if flag is Out, then ObjectExists returns if there is an Output-COM-Object of this name, i.e.,
an object that can be used by GetCOMValueByID; if flag is In, then ObjectExists returns if there is
an Input COM object of this name, i.e., an object that can be used by SetCOMValueByID; for any
other value of flag the routine returns if there is any COM object of the specified name.
Return value:
a Boolean value specifying whether or not the object could be found.
Example:

Set KULI = New KuliAnalysisCtr2


KULI.KuliFileName = "D:\mykulisystems\ExTruck1.scs"
calcOK = KULI.Initialize()
if (KULI.ObjectExists("FanSpeed","Out")) Then
rpm = KULI.GetCOMValueByID("FanSpeed")
End if
Set KULI = Nothing

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

'Query some sensors and check their values


'...

'force a recalculation of the current time step


'if a condition is not fulfilled
If forceReCalc Then
calcOK = KULI.ResetCurrentSimulationStep()
End If
Wend
'...
'End simulation and clean-up KULI
'...
End Sub

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:

Set KULI = New KuliAnalysisCtr2


'change directory name to your settings
KULI.KuliFileName = "D:\mykulisystems\ExTruck1.scs"
calcOK = KULI.RunAnalysis()
Set KULI = Nothing

advanced COM 44
RunMonteCarlo

bool RunMonteCarlo(long noOfSamples)


Performs a Monte Carlo Analysis using the number of samples from input.

RunOptimization

bool RunOptimization()
Performs an optimization.

RunParameterVariation

bool RunParameterVariation()
Performs a Parameter Variation.

SetCOMValueByID

bool SetCOMValueByID(BSTR comName, double value)


This routine sets the value of a COM object in your KULI model to a new specified value.
Input parameters:
The first parameter is a string with the exact name as specified in the edit field COM-ID of the
COM object in your KULI model (compare section). The second parameter is a double value with
the new value for the COM object. If the current scs-file contains several COM objects with the
specified COM-ID, then all of those COM objects will be set to the new value.
Return value:
a Boolean value specifying whether or not setting of the new value was successful.
Example:

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

bool SetCOMValueByIDAsStr(BSTR* comName, BSTR* svalue)


Same as SetCOMValueByID if svalue is a number, passed as a string. If svalue is a string with a
filename, then SetCOMValueByIDAsStr can be used to set the file for a component. In this case
the COM object must be directly attached to a filename actuator. svalue must include the
extension but not the entire path of the component. Both comName and svalue are passed by
reference, which may cause problems in Matlab. If you experience such problems, try using
SetCOMValueByIDAsStr2 instead.
Example:

Set KULI = New KuliAnalysisCtr2


KULI.KuliFileName = "C:\coolingsystems\ExTruck_COM.scs"
calcOK = KULI.Initialize()
calcOK = KULI.SimulateOperatingPoint(0)
value = KULI.GetCOMValueByID("Watertemp")
Cells(2, 2) = value
calcOK = KULI.SetCOMValueByIDAsStr("Radiator","ExCFD-1.wk")
calcOK = KULI.SimulateOperatingPoint(0)
value = KULI.GetCOMValueByID("Watertemp")
Cells(2, 3) = value

SetCOMValueByIDAsStr2

bool SetCOMValueByIDAsStr2(BSTR comName, BSTR svalue)


Same as SetCOMValueByIDAsStr, but comName and svalue are passed by value, which should
work with programs that have problems with call by reference.

advanced COM 46
SetValue

void SetValue(BSTR component, BSTR actuator, double value)


This command sets the value of a component connector in your KULI model.Input parameters:
component ... 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
actuator ....... string with the connector ID and the unit in brackets (optional); case sensitive; If
actuator is 'Width ' or ' Width' instead of 'Width' --> Invalid component ID and error message
• SetValue('1.MFan', 'InputSpeed', 1200) --> value in SI
• SetValue('1.MFan', 'InputSpeed [1/min]', 1200) --> Value converted
value .......... double value with the new value for the actuator
If a parameter is invalid, the actuator uses the predefined value in the .scs file.

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

fileKULI = "C:\Program Files\ECS\KULI_101000\data\CoolingSystems\ExCAR_COM.scs"


rpm = 2650.23
press = 9
speed = 50

'set a new KULI-controller


Set KULI = New KuliAnalysisCtr2

'Select KULI File


KULI.KuliFileName = fileKULI

'initialize the cooling system


calcOK = KULI.Initialize()

'Set actuator values


KULI.SetValue "SimPar", "RPMEng [1/min]", rpm
KULI.SetValue "SimPar", "MeanEffPress [bar]", press
KULI.SetValue "SimPar", "Speed [km/h]", speed

'KULI calculates the values


KULI.SimulateOperatingPoint (1)

SetValueAsStr

void SetValueAsStr(BSTR component, BSTR actuator, BSTR value)


Same as SetValue, but the parameter 'value' is a string.
Parameter: see above
value .... string sets actuator value.

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

fileKULI = "C:\Program Files\ECS\KULI_101000\data\CoolingSystems\ExCAR_COM.scs"


rpm = "2650.23"
press = "9"
speed = "50"

'set a new KULI-controller


Set KULI = New KuliAnalysisCtr2

'Select KULI File


KULI.KuliFileName = fileKULI

'initialize the cooling system


calcOK = KULI.Initialize()

'Set actuator values


KULI.SetValueAsStr "SimPar", "RPMEng [1/min]", rpm
KULI.SetValueAsStr "SimPar", "MeanEffPress [bar]", press
KULI.SetValueAsStr "SimPar", "Speed [km/h]", speed

'KULI calculates the values


KULI.SimulateOperatingPoint (1)

SetValueUnit

void SetValueUnit(BSTR component, BSTR actuator, BSTR unit, double value)


Same as SetValue, but the unit is not part of the actuator ID. It's an additional parameter.
Parameter: see above
It doesn't matter, if you use brackets for the unit or not.
• SetValue('1.MFan', 'InputSpeed', '', 1200) --> Value in SI
• SetValue('1.MFan', 'InputSpeed', ' [1/min]', 1200) --> Value converted
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:

advanced COM 50
'Define variables
Dim fileKULI As String
Dim rpm, press, speed As String

fileKULI = "C:\Program Files\ECS\KULI_101000\data\CoolingSystems\ExCAR_COM.scs"


rpm = "2650.23"
press = "9"
speed = "50"

'set a new KULI-controller


Set KULI = New KuliAnalysisCtr2

'Select KULI File


KULI.KuliFileName = fileKULI

'initialize the cooling system


calcOK = KULI.Initialize()

'Set actuator values


KULI.SetValueUnit "SimPar", "RPMEng", "1/min", rpm
KULI.SetValueUnit "SimPar", "MeanEffPress", "bar", press
KULI.SetValueUnit "SimPar", "Speed", "km/h", Speed

'KULI calculates the values


KULI.SimulateOperatingPoint (1)

SetValueUnitAsStr

void SetValueUnitAsStr(BSTR component, BSTR actuator, BSTR unit, BSTR value)


Same as SetValueUnit, but the parameter 'value' is a string.
Parameter: see above
For the decimal separator you must use '.' otherwise the command doesn't work correctly. If a
parameter is invalid, the actuator uses the predefined value in the .scs file.
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:

advanced COM 51
'Define variables
Dim fileKULI As String
Dim rpm, press, speed As String

fileKULI = "C:\Program Files\ECS\KULI_101000\data\CoolingSystems\ExCAR_COM.scs"


rpm = "2650.23"
press = "9"
speed = "50"

'set a new KULI-controller


Set KULI = New KuliAnalysisCtr2

'Select KULI File


KULI.KuliFileName = fileKULI

'initialize the cooling system


calcOK = KULI.Initialize()

'Set actuator values


KULI.SetValueUnitAsStr "SimPar", "RPMEng", "1/min", rpm
KULI.SetValueUnitAsStr "SimPar", "MeanEffPress", "bar", press
KULI.SetValueUnitAsStr "SimPar", "Speed", "km/h", speed

'KULI calculates the values


KULI.SimulateOperatingPoint (1)

SimulateCFD

bool SimulateCFD(BSTR cfdFile, BSTR zResFile)

SimulateOperatingPoint

bool SimulateOperatingPoint(long simNumber)


Performs the computation of the current operating point, without generating an output file. Use
Initialize before using this routine.
Input parameters: simNumber: specifies, which active operating point should be calculated; a
value of 0 for simNumber computes all active operating points. simNumber is of no relevance for
transient computations.
Return value: a Boolean value, specifying whether or not the computation of the operating point
was successful.
Example:

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

1.3.5 List of events


KULI fires several events during a simulation:

• 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.

Event handling in VBA


In Visual Basic a subroutine that catches an event would begin with

Private Sub KULI_EventName(arglist)

See the example for OnNotification.

Event handling in Matlab


In Matlab the situation is quite different. Here you have to define your event handling when you
open the connection to KuliAnalysis2.ctr. If your KULI initialization was like

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

See the Matlab documentation on actxcontrol for further information.

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

HRESULT OnEndOfOperatingPoint(long operatingPoint);

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

HRESULT OnEndOfTimeStep(long timeStepNo, double time);

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.

This event is fired if somewhere an error has occurred.

Prototype

HRESULT OnError(BSTR fkt, BSTR msg, BSTR add, long type);

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:

Private Sub KULI_OnError(ByVal fkt As String, _


ByVal msg As String, _
ByVal add As String, _
ByVal xtype As Long)

Dim Style, Question, Answer


Const fatalError = &H10000
Const standardError = &H20000
Const infoError = &H40000

If (xtype And infoError) Then 'info only


Style = vbOKOnly + vbInformation
Question = ""
ElseIf (xtype And standardError) Then 'warning
Style = vbYesNo + vbExclamation + vbDefaultButton2
Question = vbCrLf & vbCrLf & "Do you want to stop calculation?"
Else 'fatal error
Style = vbYesNo + vbCritical + vbDefaultButton1
Question = vbCrLf & vbCrLf & "Do you want to stop calculation?"
End If

'Display message box


Answer = MsgBox(msg + add + Question, Style, fkt)

'Hault execution
If (Answer = vbYes) Then
End
End If

End Sub

OnMessage

Deprecated
This event is deprecated. Use OnNotification instead.

This event is fired if KULI wants to display some message.

advanced COM 59
Prototype

HRESULT OnMessage(BSTR fkt, BSTR msg, BSTR add, long type);

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.

HRESULT OnNextIteration(long itNo);

advanced COM 60
Parameters

itNo
[in] Provides the number of this iteration.

Return value
None.

Remarks

This event will not be thrown if the simulation is performed


with NextKULIIteration().

OnNextTime
This event gives notice that (in particular for a transient simulation) the next time step has been
reached.

Prototype

HRESULT OnNextTime(long timeStepNo, double time);

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

HRESULT OnNotification(BSTR message, KuliAnalysisServerLib.Severity severity,


KuliAnalysisServerLib.Classification classification, BSTR occurence, double
systemTime);

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

KuliNone Status information during simulation.

KuliNotification Information for special event, which is more important


for the user than default messages (e.g. stop controller
has become active)

KuliProgressOutline Outline of a progress information, which is only one line


and limited in length

KuliProgressDetails Detailed information about progress information


spanning over multiple lines (e.g. number of operating
point, values of optimization variables)

KuliAlert Critical or exceptional event during simulation, active


user notification of the message content is necessary
(e.g. error opening scs file)

KuliSystem Additional background information for diagnostic


purposes (e.g. report from which file system location
REFPROP dll is loaded)

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:

Sub Kuli_OnNotification(ByVal message As String, ByVal severity As KuliMsgSeverity,


ByVal classification As KuliMsgClassification, ByVal occurence as String, ByVal
systemTime as Double)

If classification = KuliAlert Then


MsgBox message, vbOKOnly, "Alert" ' show notifications of type "Alert"
in a message box
End If

If messageType = KuliError Then


MsgBox message, vbOKOnly, "Error" ' show all errors in a message box
End If

Debug.Print message ' trace all notifications to the VBA


intermediate window

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) .

1.4 The Simulink Interface


KULI advanced is equipped with an interface to Simulink® to handle arbitrarily complex
controllers. A MATLAB®/Simulink installation is necessary to be able to use such controllers. A
Simulink controller can receive up to 6 input parameters from KULI and gives one value back to
KULI.

Matlab configuration

Before calling MATLAB®/Simulink from KULI the following pre-requisites must be


fulfilled:

• 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

A Simulink® controller is inserted similarly to a 2D or 3D controller. Click on the icon of


the controller and insert it into the graphical network on the page Circuits / Air Path. By
double-clicking on the icon its dialog will be displayed.

Simulink dialog window in KULI


The meaning of various checkboxes, input fields, and radio buttons:
• Identifier: A unique identifier that is automatically generated by KULI and that is only used
within KULI. You cannot edit it.
• Name of Simulink model: Here you have to specify the exact name of your Simulink model.
Be sure to specify it without the extension .mdl.

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.

1.4.2 Suitable Simulink models for KULI


A Simulink model must confirm to certain guidelines in order to be usable by KULI. All Simulink
models, m-files and s-functions must be in a directory, where MATLAB can find them at startup,
for instance, in the directory work within your MATLAB-directory. In particular you have to be
sure that PauseSFun.m is in this directory.
It is strongly recommended that you copy a demo-Simulink controller from the KULI CD and
modify it to your needs. This ensures that most settings are already usable for KULI.

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.

Top level of the Simulink controller


The actual controller is now implemented in the subsystem 'MyControl'. The name of this
subsystem must not be changed! This is a masked subsystem. In order to specify the variables
that this subsystem receives from KULI, right-click on the icon 'MyControl' and choose Edit mask
from the context menu. The following window will appear after you have selected the sheet
Initialization:

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.

1.4.3 How the interface works


The interface is initiated by KULI. If within a KULI computation the value of a Simulink controller
is requested, MATLAB and the corresponding Simulink model are opened. Hence, it is not
necessary that you start MATLAB before running KULI.
The data transfer works in the following way:

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.

Simulink Simulation Parameters

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.

Model with 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

2.1 Statistical Analysis

Statistical analysis in the menu Extras


The statistical analysis tool analyses data in a table. In the sheet Data you can enter data for
either one or two variables. You can either enter data by hand or paste from the clipboard.
Clicking Reset clears the complete table. Clicking to the button Analyze performs several
analysis tasks.

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.

2.2 Optimization and parameter variation possibilities in KULI


Optimization and parameter variation is implemented in KULI based on the concept of sensors
and actuators. Any actuator can be a parameter, any sensor values can be an optimization
target.

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

2.3.1 Optimization target

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

To create a new optimization parameter, 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.

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.

2.3.3 How the optimization works


When you have added optimization targets and optimization parameters to your system, you
can then simply start the simulation as usual. KULI asks you whether you want to compute the
optimization now.
Say No, if KULI should ignore all optimization logic during simulation.
Say Yes, if the optimization should be computed now.
If you have chosen Minimum or Maximum for the optimization target, then the parameters are
varied according to KULI's optimization routines such that the target assumes its minimum/
maximum value. It is possible that the optimization routine stops at a local minimum which is
not the global one. Avoid this simulation result by defining the range of your parameters
sufficiently narrow.
If you have chosen an exact target value, then there is a difference between a single and a
multiple parameter optimization. In the case of a single parameter KULI first uses an equation
solver to find a parameter value which exactly matches the defined target value. For this routine
it is advisable to provide a large interval within which the parameter can be found. If such a
parameter cannot be found, KULI switches to an optimization routine which finds a parameter
such that the target is closest to the desired value.
If you have more than one optimization target and the same number of optimization
parameters, then KULI uses a solver for a system of nonlinear equations. This method might
require a lot of iterations.
In all other cases of more than one optimization parameter KULI always uses an optimization
routine. Most times solutions are not unique. For example a radiator with dimension
400x300mm might have the same heat transfer as another one with 600x200mm. KULI's
simulation ends by showing the first solution found.
The main results of the optimization are displayed on screen. You can also review the
optimization results in KULI lab by selecting the optimization target(s) and optimization
parameter(s) in the list of available components.

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.

2.4 Sensitivity Analysis


Sensitivity analysis offers the possibility to assess the influence of certain input values - so-called
parameter variation objects - on certain output values (COM controller).

2.4.1 Input data


The procedure of defining input and output values is the same as in the parameter variation
method (see user manual KULI advanced). Input values are given by parameter variation objects
and output values are represented by COM controllers.
In this example four parameters are defined. Two of them are linked to both actuators of the
simulation parameter, RPM (engine revolutions) and Speed (driving speed of the vehicle). The
other parameters are linked to the actuators of the radiator, Width and Height.
The COM controllers are connected to both sensors of the radiator, Exit temperature IM and the
Exit pressure IM.

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

To start the calculation click to the 'GO' button in the toolbar.

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.

Here, you can see an example report:


Example report Project Data

advanced optimize 88
Input file: C:
\ECS\KULI_101000\data\CoolingSystems\ExTRUCK_sens.scs
Date: Tuesday, 09. December 2014 15:03:18

Version: KULI 10.1 (101000)

__________________________________________________________________
____________

Sensitivity Analysis
====================
User ............. : ECS
Editing date ..... : Monday, 10. November 2014 11:08:08
Department ......... :
Purpose .......... :
Result description :
Report ........... :

__________________________________________________________________
____________

Example report Input parameters


Variation of parameters:
========================

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]

2.Parameter: KULI_SIM_PARAMETER RPM


------------------------------------
Act. Ref. Min. Max.
Step. RefVal.
x - 1000 [1/min] 3000 [1/min] 1000 [1/min]

advanced optimize 89
2000 [1/min]

3.Parameter: WK1 Width


----------------------
Act. Ref. Min. Max.
Step. RefVal.
x - 400 [mm] 700 [mm] 100
[mm] 550 [mm]

4.Parameter: WK1 Height


-----------------------
Act. Ref. Min. Max.
Step. RefVal.
x x 500 [mm] 800 [mm] 100 [mm]
650 [mm]

Act. .........Active parameter


Ref. .........Reference parameter
Min. .........Minimum value
Max. .........Maximum value
Step. .........Step size
RefVal. .........Comparative value

Example report Results


Analysis results
================

WK1 Exit Press IM [bar] - 1.Simulation parameter


------------------------------------------------
Min. Max. Min.
[%] 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

advanced optimize 90
1.Radiator: Width 2.02917 2.02880
90.82 53.06

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

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

2.5 Parameter variation


Ico Description
n

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.

2.6 System Resistance Curve

2.6.1 Create System Resistance Curve


This feature automatically inserts a Subsystem containing all required Controllers to generate a
System Resistance Curve. The menu item Create Objects for System Resistance Curve is
available from the File menu in KULI.
There are two different models available
• Create System Resistance Curve (Including Fan)
• Create System Resistance Curve (Without Fan)
When a cooling system is completely set up, KULI can insert additional components, which are
able to create a system resistance curve. These components are a Parameter Variation Object, a
Mass Flow Target and two COM Objects.
A Mass Flow Target in combination with the Parameter Variation Object varies the mass flow
through the cooling system in order to generate the System Resistance Curve. The flow range of
the Parameter Variation Object is defined by default and has to be adapted to your
requirements.
The content of the Subsystem, especially the identifiers of the COM objects must not be
modified.
Note:
The Influence of CP values and the influence of the fan is ignored if System Resistance Curve
without Fan is selected, and the System resistance curve gets positive ordinate values.
Result data are stored in KULI's Results folder with filename: InputFile.kuliSysResCurv. (e.g.
ExTruck.kuliSysResCurv.)

advanced optimize 98
Cooling System containing a System Resistance Curve Subsystem

Subsystem System Resistance Curve

2.6.2 View System Resistance Curve


After a simulation of a cooling system containing a Subsystem "System Resistance Curve", result
data are available from the menu "Output / System Resistance Curve".
Result data are stored in KULI's Results folder with filename: InputFile.kuliSysResCurv.
(e.g. ExTruck.kuliSysResCurv.)
Of course you are able to show the results and graph in KULI lab too.

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.

3.1 CFD Interface File


To obtain the velocity distribution of the heat exchanger, CFD analysis of the cooling air path is
required. The CFD analysis should be made with the cold air flow. The change of velocity caused
by heat transfer in the heat exchanger will be considered in the KULI simulation. Surrounding
pressure and temperature, which are set as boundary conditions for the CFD analysis, are also
needed for the calculation of the Resistance matrix. Usually the pressure loss in the heat
exchanger is modeled by 'porous media'. The parameters of the porous media should be set
according to the flow direction of the heat exchanger. The velocity field has to be gained from
the first cell layer (cell centre values) on the inlet side of the heat exchanger. The values should
not be taken from the front surface, because there could be still velocity components parallel to
the cooler surface. The velocity field has to be saved as a text file (ASCII format) and stored in a
folder for CFD data, to which KULI has access.

3.1.1 Considering an uneven pressure distribution


The Resistance matrix can not only be used to consider uneven air velocity fields at the front of a
heat exchanger but also to consider uneven pressure distributions in front of a car caused by
different cp-values along the radiator grill. To calculate a Resistance matrix containing cp-values
instead of non-dimensional zeta values a given pressure distribution in front of the radiator grill
is the necessary input. Anyway, the use of the resistance matrix is very similar even if the
resistance matrix contains pressure distribution (and calculated cp-values) data instead of
velocity information.

advanced CFD 100


The file containing the CFD data needs to have a certain format, so it can be read by KULI.

3.1.2 Generating KULI CFD file


To generate a KULI CFD file (file extension *.cfd) an import routine is provided. Select Resistance
Matrix from the Library menu. In the window Resistance Matrix, go to the menu Data and select
Import... [FLUENT, STAR CD, 2D Characteristic Line, User Data]. In the window Import the file
with the velocity or pressure field (from CFD analysis) will be selected. Based on these data the
KULI CFD file will be generated. The following section describes the additional input required to
complete the import routine.
The import dialog can also be directly called from the context menu of the edit field KULI CFD
file.

Dialog Import CFD data and generate a KULI CFD file

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).

advanced CFD 101


CFD data field (right section): Here, you have to select relevant field properties (velocity and the
coordinates), which describe the position of the velocity values on the radiator surface.
Generated in the CFD program, the CFD file can contain a number of field properties. Be careful
to select the correct 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.

Surrounding pressure, Surrounding temperature, Relative moisture: The material properties,


which were used for the CFD analysis have to be entered here. These data will be used for the
calculation of the resistance matrix to provide similar conditions as within the CFD analysis.

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

advanced CFD 102


//beginning of file
[CFD_DATA]
COMMENT_USERCOMMENTS = 'Example'
COMMENT_COMPONENT= 'Radiator'
COMMENT_WIDTH = 800
COMMENT_HEIGHT = 450
COMMENT_DEPTH = 20
SURROUNDING_PRESSURE = 1013
SURROUNDING_TEMPERATURE= 20
RELATIVE_MOISTURE= 50
UNIT_COORDINATES = 'm'
METHODE_KENNF_INTERP = 'IMSL'
SURFIT_SMOOTHING_FKT = 0
{Y Z V}
0.0000 0.2193 2.8659
0.0196 0.2192 2.8977
0.0391 0.2192 2.9648
..............................
0.0750 -0.0196 3.3092
//end of file

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.

advanced CFD 103


Dialog Import

3.1.3 Ensight Interface


Since KULI 5.3 the user is able to import velocity fields from Ensight. To start the import process
call in the menu Extras the item Ensight to KULI converter. Then, a dialog will be displayed,
where the names of the files and some options have to be defined.
The result of the import will be a CFD file in the right format for KULI. Now, if a block - for
instance two coolers and a fan in one block - is used in your cooling system model, then a
resistance matrix can be provided with the CFD file. As a result the CFD data from Ensight is
included in a KULI model and can be simulated.

Dialog for import of velocity field from Ensight


To start the import you have to call in the menu Extras the item Ensight to KULI converter. The
figured dialog will be displayed. Define the files and set the options for the conversion. After you
have pressed the button Convert the KULI CFD file will be generated.

advanced CFD 104


If you want to close the dialog without starting the conversion, you can press the button Cancel.
All entered data will be shown, when you open the dialog next time.

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.

advanced CFD 105


If the velocity field from Ensight has other axis used, you can map each axis in the KULI CFD file
to another axis in the input files. Here, you have to select the axis (y-, z- and velocity) for KULI, as
they are defined in the input files from Ensight.
It is also possible to scale and shift the velocity field as a whole by entering scaling factors other
than 1 and offset values in Millimetres other than 0. The rotation by entering the angle in
degrees can be done by the converter.
Finally, the input fields Temperature, Pressure and Rel. Humidity defines the ambient conditions
of the velocity field.

3.1.4 Modifying a KULI CFD file


Sometimes the KULI CFD file obtained as described above is not ready for use and needs some
modification. KULI provides several possibilities for doing this. In the dialog window resistance
matrix choose the menu item modify CFD file in the menu File; then the following dialog
window appears:

advanced CFD 106


Dialog Modify CFD file

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

advanced CFD 107


nonlinear way on the number of points.) You can either choose every x-th point (recommended)
or choose the first x points of your CFD file.
Creating a regular raster: Here you can compute new points and the appropriate velocity
values in a way such that the points form a regular raster. The maximal/minimal values for the y-
and z-coordinate are set to default values as computed before but can be changed in order to fit
the needs of the user. So for example you can set the raster to cover just a certain part of your
cooler or block. The computation of such a raster can take some time if there are a large number
of points. On the other hand CFD files with a regular raster are significantly quicker concerning
the computation of the resistance matrix. The minimum number of subdivisions is 3 and is set to
this value if the user enters a smaller one.
If a point reduction is chosen then only the reduced number of points is taken for the creation of
the raster.
Change of coordinates: Sometimes it happens that the coordinates of the CFD field do not
coincide with those of the KULI system. Here you can now rotate the field in 90°-steps, you can
reflect the field in either axis or you can switch the coordinates. These alterations are applied
after a possible point reduction or a creation of a regular raster such that the minimal/maximal
values for the coordinates in the creation of the raster apply to the unrotated/reflected field.
Scale a rectangle: This option makes it possible to scale only the field vectors that are inside a
defined rectangle. The length and the height of the rectangle and also the offset to the original
CFD-data coordinate system must be specified. It is also possible to rotate the rectangle by
specify a rotating angle.

3.1.5 Import 2D Data to CFD


In some cases, a fan velocity profiles is available as 2D curve where the ordinate is the velocity in
[m/s] and the abscissa is the radius of the fan where zero is the centre.
The 2D Data (Characteristic Line) can be defined as any 2D Line in KULI using the "Library 2D /
3D Char Line / Map" menu.

advanced CFD 108


2D Data of a Fan Velocity Profile
KULI can import data of this format to a Resistance Matrix using the menu "CFD-Data / Import
2D Characteristic Line"
The file containing 2D Data can be selected in the "Characteristic Curve" field. To convert 2D Data
to 3D Data, the button "Write Data To File" is used.
All available data are transferred automatically to the import window. Units of coordinates
should be checked again.
Pressing the "Write KULI CFD file.. " completes this task.

advanced CFD 109


Import 2D Data Window
Data generated by this method can be used in the same way as data imported from other
sources e.g. data from StarCD.
See description of Generating KULI CFD File for more details.

advanced CFD 110


3D Fan velocity profile generated from 2D M-Curve

3.2 Build the Resistance Matrix


The Resistance matrix has to be generated before it can be used in a KULI simulation. The
necessary input data for the Resistance matrix are the CFD file with the velocity field, the
corresponding KULI file and the position of the velocity field relative to the cooling system. The
cooling system has to be modeled before generating the resistance matrix. The resistance
matrix can only be used in connection with a cooling system block, which already has to be
defined in the system model. If the heat exchangers are posed tightly one behind the other, they
can be combined into one block and only one resistance matrix is necessary. In case of higher
distances between the heat exchangers, the flow pattern of the cooling air will be different.
Therefore, every heat exchanger has to be defined as a block, each with its own resistance
matrix.

advanced CFD 111


The cooling system block must be divided into elements. The division is not defined at the block
but at the heat exchangers. If the front side of at least one heat exchanger covers the whole
block, this division has to be defined just for this one to create a raster. The block will be divided
into elements automatically according to the raster. If none of the heat exchangers cover the
whole block, a division has to be defined on more than one heat exchanger. It is important that
the division into elements covers all heat exchangers contained in the block. The raster defines
the resolution of the cooling air flow distribution in the block. It is recommended that the
number of elements should be between 100 to 300. A higher resolution usually will not improve
the result of the simulation and increases the calculation time.

Heat exchanger with raster of divisions


As mentioned before, the CFD analysis for the cooling air flow should be carried out without heat
transfer. Also the generation of the resistance matrix is based on the cold air flow and the
material properties of the KULI CFD file will be used. The influence of the heat transfer on the
velocity distribution is considered in the KULI simulation.
To generate a resistance matrix select Resistance Matrix in the menu Library. Input data is
needed on the pages Input data and CFD velocity field. All parameters colored red must be
entered, all other inputs are optional or will be set automatically if not entered.

advanced CFD 112


3.2.1 Input Data

Resistance matrix input and generating

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.

advanced CFD 113


Attention
Calculation option settings are saved in the resistance matrix file. If a difference exists in
the settings between the resistance matrix file and the general options a warning is given
when calculating.

3.2.2 CFD Velocity Field

CFD velocity field


KULI CFD file: Using the context menu of the edit field, open the library to select the KULI CFD file
that contains the velocity field. The velocity field is in the same direction as the x-coordinate in
the KULI model. The resistance matrix distinguishes between positive and negative flow
directions. The final non-dimensional flow resistance distribution calculated based on the given
velocity distribution is able to consider also possible re-circulation effects if they occur.

advanced CFD 114


Note: By the help of the context menu it is also possible to import CFD-data directly from
FLUENT, STAR CD or from another source. In this case the import dialog is opened, and
afterwards the generated *.cfd-file is automatically entered into the edit field.
Blocks used for CFD Matrix: Usually a resistance matrix in KULI does not change the overall air
flow through the block. It only changes the distribution of the flow. In some cases, however, it
might be useful to use a single cfd-file for more than one block and thus for more than one
resistance matrix. In this case the air flow through the sum of the affected blocks should remain
constant, the air flow through a single block can be changed. For such applications you can
specify all blocks that are affected by the cfd-file. The resistance matrix is then computed such
that the overall air flow through the sum of all blocks that are specified in this field remains
constant.
Ambient air pressure, Ambient temp., Air humidity: When the KULI CFD file is loaded, the material
properties are displayed in the edit fields. The material properties are used for the calculation of
the resistance matrix. They cannot be changed in the edit field.
Unit of field coordinates: The same applies to the units of the coordinates of the velocity field.
They must be set correctly in the KULI CFD file and cannot be changed in the edit field.
Modify KULI CFD file...: With this button the currently chosen KULI CFD file can be modified. See
the separate page for detailed information about the possibilities for modification.
Position CFD velocity field: Position y-direction, Position z-direction: The position of the CFD
velocity field has to be defined relative to the cooling system block. The velocity field has its own
local coordinate system. With Position y-direction and Position z-direction, the position of this
local coordinate system is defined in the cooling system. The position in x-direction is not
needed, because the velocity field refers to the block.

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.

advanced CFD 115


To check if Position y-direction and Position z-direction are entered
correctly open the 3D-diagram by pressing the button 3D-diagram on
the right side. In the 3D-diagram the velocity field and the outlines of the
blocks, the fans and the area resistances of the KULI model are shown.
They are positioned according to Position y-direction and Position z-
direction. The block that the resistance matrix is determined for is
drawn with bold lines. Choose Wire+Faces and press button B (=bottom)
in the menu bar. Now, there is a view exactly in flow direction and the
velocity field position can be easily verified.

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.

advanced CFD 116


3D-Graphics of the velocity field

advanced CFD 117


Velocity field behind the outlines of the block - looking in flow direction

The handling of the 3D-diagram is described in the chapter 3D-diagrams.

3.2.3 KULI Resistance Matrix


In the sheet KULI Resistance matrix, the non-dimensional zeta values (in case of a velocity field
input) or the cp-values (in case of a pressure field input) are displayed after the resistance matrix
has been generated.
Save the data of the resistance matrix and press the button Generate resistance matrix. The first
active simulation point will be taken for the calculation of the resistance matrix.
After KULI has successfully generated the resistance matrix, the calculated zeta values (or cp-
values) are automatically written into the resistance matrix file. The edit field Status changes to
generated. The calculated values can be viewed in 3D by clicking on the graph icon.

advanced CFD 118


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.

advanced CFD 119


3.2.4 CFD Pressure Field

CFD pressure field


The Resistance matrix can be used to consider uneven air velocity fields at the front of a heat
exchanger but also to consider uneven pressure distributions in front of a car caused by different
cp-values along the radiator grill. To calculate a Resistance matrix containing cp-values instead
of non-dimensional zeta values a given pressure distribution in front of the radiator grill is the
necessary input. Anyway, the use of the resistance matrix is very similar even if the resistance
matrix contains pressure distribution (and calculated cp-values) data.
Driving speed: Since KULI is able to calculate a non-dimensional cp-field based on a pressure
field it is necessary to specify the driving speed for which the given pressure distribution is valid.
Cp-Values for leading/trailing air: Makes KULI able to distinguish if the calculated cp-value
distribution should be used together with leading ram air or trailing suction conditions.

advanced CFD 120


Leading with relative velocity/driving speed: To determine the static pressure increase (or
decrease) for the given simulation conditions the user can choose between two formulas (equal
to the two definitions in the component CP-Value).

KULI Definition: Leading with driving speed


Following equation is used to calculate the static pressure at the intake to consider the driving
speed influences. This model works most accurate if the cp-value was calculated using an open
inlet grill (e.g. from CFD analysis).

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

KULI Definition: Leading with relative velocity


Using this model an approximation according to following formula is used to calculate the static
pressure rise. In this case only the difference of ambient flow velocity and velocity at the intake
is used. This model works most accurate if the cp-value was measured using an obstructed inlet
grill (common aerodynamic measurement).

with
........................ intake velocity at the inlet grill

3.3 Modeling of the Resistance Matrix


For the KULI simulation the resistance matrix (resistance or cp-value matrix) has to be added to
the corresponding cooling system block. On the page Air side in the context menu of the block
table call Add/Edit resistance matrix or double click the column. The dialog window Add/Edit
resistance matrix will be opened. Click on or call Use existing components in the context
menu of the input field Component and select the desired resistance matrix file.

advanced CFD 121


Add resistance matrix to block

In the graphics window the resistance matrix is shown as an octagon:

advanced CFD 122


Cooling system block with resistance matrix

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.4 Direct CFD interface

3.4.1 Adding a direct CFD interface to a KULI model


The direct CFD interface can only be added to a KULI block. It is added to a block in the very
same way as a standard resistance matrix. So on the page Air side create a block and in the
column Resistance Matrix click with the right mouse button and choose Add/edit resistance
matrix from the context menu to add the interface. (Alternatively you can also double-click on
the cell in the column Resistance Matrix in the row of the chosen block.) In the following dialog
window you need to choose the option use direct CFD interface. Then you can create a new one,
choose an existing one or view the currently chosen one.

advanced CFD 123


Add direct CFD interface to cooling system block
In the 3D graphics window the existence of such an interface is shown as an octagon.

advanced CFD 124


Cooling system block with resistance matrix
To change the direct CFD interface at the block, go to Air side and select Add/edit resistance
matrix in the context menu of the block table. Then choose a new direct CFD interface.
If you want to remove the direct CFD interface choose Remove resistance matrix in the context
menu of the block table.

3.4.2 The direct CFD interface


When you create a new direct CFD interface, the window for this interface has two tab sheets.
One containing general data in the same way as for other components in KULI. The second sheet
looks like in the following image.

advanced CFD 125


Input data for direct CFD interface
The following options can be chosen:
Front and Back: In this case input and output files are selected and used for both sides (front
and back) for the cooling block. This option is particularly useful for backflow situations.
Front Only: The input data is taken only from the front side; output is only written at the back
side of the block. Useful if you don't have backflows.
Generate Output File: Check this box if KULI should write output files.
Options for the input file(s): First select the file(s) using the context menu. With this menu you
can also open the file in the text editor to check its content.
The CFD input files (front and back) must be ASCII text files containing numbers in columns.
Both files (front and back) must contain the y- and z-coordinates and the velocity (in x-
direction). The checkboxes for T and p indicate, if columns for temperature and pressure exist. If

advanced CFD 126


they exist you can still choose whether or not you want to use them. The units of the columns
can be chosen using the pop texts.
The edit field Shift CFD coordinates in y-direction by specifies by how many mm you want to shift
the CFD coordinates. (same with z-coordinate)
If output files are to be generated then you can specify file names for the output file(s).
Moreover, you can choose which values should be written to the output file(s). The heat Q is
always written as a heat per area. The zeta-values are dimensionless. (Currently the output of p
does not produces precise values and should be avoided.)
If the checkbox shift lower right block corner into origin for output is checked, then KULI shifts the
output in a way such that the lower right corner of the block (facing the block from the front) is
moved to the origin. The following coordinates then always specify the upper left corner of the
cells of the KULI block. If the checkbox is not checked, then KULI writes the coordinates of the
centres of the KULI cells without any shifting.

3.4.3 How the direct CFD interface works


If a KULI model contains a block with a direct CFD interface, then during the KULI computation
KULI imports the values from the input files and maps the CFD values to the KULI cells.
(Currently it is required that each KULI cell, which is usually much larger than CFD cells anyway,
contains at least one point from the CFD values.) During calculation the volume flows are
adjusted such that the desired velocities are assumed. The temperatures are considered in a
way such that if the velocity at a KULI cell is positive, then the entry temperature from the front
side is taken, otherwise from the back side.
Note that since KULI uses the velocity values from the files the influence of fans or cp-values etc.
may be overridden.

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.

advanced CFD 127


3.6 Resistance Matrix depending on velocity

3.6.1 Resistance matrix depending on velocity


Often the resistance matrix significantly depends on the driving speed, on the state of a fan, of a
flap or something else. For this reason KULI offers the possibility to use resistance matrices that
depend on the driving speed and/or on another, user-specified parameter.
The creation of the resistance matrices that are used by this method is exactly the same as in the
case of a standard resistance matrix. The user only must know which resistance matrix belongs
to which driving speed or 'state'.
A velocity-depending resistance matrix can only be used in combination with a block (as in the
case of a standard resistance matrix). When you add a resistance matrix to a block, you have
three options. The third option is the one described here.

dialog window to choose type of resistance matrix


When you choose the velocity-depending resistance matrix you need to configure your settings
using the Configuration button. The following window appears:

advanced CFD 128


Configuration window for resistance matrix depending on velocity
First you have to choose the type of dependency. The resistance matrix can depend on the
driving speed or on the value of a COM object or on both. If you choose the dependency on the
value of COM object then you can either enter the ID of the desired COM object directly into the
edit text or you can click on the button choose... which then lists all available COM objects in the
current model. Select the desired one and click Ok.

advanced CFD 129


Choice of available COM objects
The number and type of columns in the table will be adjusted according to the type of
dependency you have selected. You now have to enter the correct values for the driving speed
and for the COM object for which the corresponding resistance matrix was created. The file for
the resistance matrix, which must be entered in the column Resistance matrix can be selected
using the context menu as shown in the image below.

Context menu to add resistance matrix file

advanced CFD 130


Attention
Note that in the case the resistance matrix depends on driving speed and COM value, the
values for driving speed and COM value in the table must fill a complete raster, i.e., all
possible combinations of COM values and driving speeds must occur in the table.
However, since linear interpolation is used, it is sufficient to have as few as two different
values for the driving speed and for the COM value.

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.

advanced CFD 131

You might also like