TRNSYS     Type 62: TRNSYS-Excel link     

Content

- Quick Start instructions

- Type 62 Inputs / Outputs / Parameters description

- How to add the required files to TRNSYS

Quick Start instructions

This section gives step-by-step instructions for reasonably advanced TRNSYS users who are using TRNSYS 15.3.00, Excel 97 and higher and Compaq Visual Fortran 6.6B.
Please refer to the next sections for detailed instructions and troubleshooting.
  1. Run the setup file (trnsys-excel.exe)
  2. Select your Trnsys15 installation folder (%TrnsysRoot%) for the destination to unzip files
  3. Open your TRNSYS workspace in the compiler (%TrnsysRoot%\WorkSpace\CVF66B\CVF66B.dsw)
  4. Add Type62.f90 and xl_contr.f90 (both are in %TRNSYSRoot%\TrnLib\RWTH-Aachen\SourceCode\) to the "Types" folder under TRNLIB Files (right click, select add, browse to the files)
  5. Rebuild Trnlib (F7)
  6. Launch IISiBat and open %TRNSYSRoot%\TrnLib\RWTH-Aachen\Examples\trnsys-excel.tpf
  7. Press F8 to run the simulation.

Note: To add Type 62 to a new project, select its proforma in \TrnLib\RWTH-Aachen\Calling Excel

Type 62 Description

Object TRNSYS - Excel link
Abstract This TYPE allows the user to embed models that are programmed in Microsoft Excel
 

 

 

Detailed description

This TRNSYS Type implements a link with Excel. The Fortran routine communicates with Excel through a Component Object Model (COM) interface, which allows a fast data transfer.

TRNSYS sends the component's inputs to given cells in your excel worksheets. Those cells must be identified by defining an excel-name ("Input1" ... "Input10"). In Excel, names can be defined i.e. by using the shortcut "Strg+F5". In the same way outputs must get names like "Output1" ... "Output10".

The Type's parameters are the path and name of your *.xls-file, the number of inputs and outputs and whether the excel application should be visible or not. During the simulation the input values will be transferred to your specified excel cells and (after recalculating) the output values will be sent back to Type 62. An optimized algorithm reduces the amount of data transferred between the TRNSYS-code and the excel application to improve the simulation speed

Icon
Author Oertker/Wriske
Organization Chair of Technical Thermodynamics, RWTH-Aachen, Germany
Editor MKu
Creation date 2003-04-10
Modification date 2003-07-24
Model type Empirical
Validation Qualitative
Experimental
Type number 62
Allowed instances
Keywords Excel
external
link

Parameters

Indice Name Dimension Unit Type Min Max Default Comment
1 number of inputs dimensionless - integer 0 10 3 Number of inputs (please define the corresponding names in the Excel workbook, Input1 to InputN)
2 number of outputs dimensionless - integer 1 10 3 Number of outputs (please define the corresponding names in the Excel workbook, Output1 to OutputN)
3 Excel is visible dimensionless - boolean 0 1 0 Set this parameter to 1 if you want excel to be visible during the simulation. If this parameter is set to 0, excel will run hidden in the background
4 Filename Dimensionless - string -Inf +Inf See comment Attention: The filename is entered as a comment, after a dummy value for the parameter.
The parameter should look as follows:
1 * path_and_filename
E.g.
1 * C:\Trnsys15\TrnLib\RWTH-Aachen\Examples\Profile.xls

Inputs

Indice Name Dimension Unit Type Min Max Default Comment
1..n input any - real -Inf +Inf 0 Input sent to Excel. The total number of inputs is set by parameter 1

Outputs

Indice Name Dimension Unit Type Min Max Default Comment
1..n output any - real -Inf +Inf 0 Output from Excel. The total number of outputs is set by parameter 2

 

How to add the required files to TRNSYS

1. General information

The following information applies to TRNSYS 15.3.00 and above and assumes you are using the Compaq Visual Fortran 6.6B compiler. However, you should be able to apply the method to other versions and different compilers.

In the following, the strings hereunder will refer to the folders in which these 3 programs are installed:

Program Install Folder Example (default install folder)
TRNSYS 15.3.00 %TRNSYSRoot% C:\Trnsys15
Compaq Visual Fortran 6.6B %CVFRoot% C:\Program Files\Microsoft Visual Studio\DF98

1.1. Included files and their location

Note: if you unzip the files in the package and select your TRNSYS root folder for the destination directory, all files should be saved at the correct location. This will replace your current param.inc but the new one is fully compatible with TRNSYS 15.3.00 (see 3.1)

Type62.f90, xl_contr.f90:
Type 62 source code
%TRNSYSRoot%\TrnLib\RWTH-Aachen\SourceCode\

Type155.tmf and type155.bmp
:
IISiBat proforma and icon for Type62
%TRNSYSRoot%\IIsiBat3\Data\TrnLib\RWTH-Aachen\Calling Excel\

trnsys-excel.tpf, schedule.xls, MousePos.xls
:
Example files
%TRNSYSRoot%\TrnLib\RWTH-Aachen\Examples\

type62-manual.html, trnsys-excel-example.html
:
Documentation files
%TRNSYSRoot%\TrnLib\RWTH-Aachen\Documentation\

2. Computer Setup

If the programs (TRNSYS 15.3.00 and above, Excel 97 and above) have been correctly installed, you should not need to do anything.

3. Add Type62 to your Trnlib DLL

3.1. If you are using CVF 6.6B

Open the Trnsys Workspace (%TRNSYSRoot%\WorkSpace\CVF66B\CVF66B.dsw). In the left pane, select "Trnlib files", then the "Types" folder. Right-click and select "add files to folder". Browse to the location where you have saved Type62.f90 (e.g. %TRNSYSRoot%\TrnLib\SEL\SourceCode) and select it. Repeat for xl_contr.f90 (in the same folder).

3.2. If you are not using CVF 6.6B

You should modify your project to include Type62, as you would do for any non-standard Type. Instructions are available on the TRNSYS website (http://sel.me.wisc.edu/trnsys, see "Fortran Info").

5. Rebuild Trnsys

The easiest way to rebuild the entire workspace is to use the "Build/Batch Build" command. You can then select the appropriate configuration for each one of the three projects. For example, if you want to be able to debug your application, select:

DummyLib - Win32 Debug
ExtDLL - Win32 Debug
TrnLib - Win32 Debug

Then click on "Rebuild all"

The following files should be created:

\Trnsys15\Dummy\CVF66BDummy.lib
\Trnsys15\ExtDLL.dll
\Trnsys15\ExtDLL.lib
\Trnsys15\ExtDLL.exp
\Trnsys15\Trnlib.dll
\Trnsys15\Trnlib.lib
\Trnsys15\Trnlib.exp

6. Launch IISiBat and run the example

Open the example (trnsys-excel.tpf, which should be in %TrnsysRoot%\TrnLib\RWTH-Aachen\Examples\trnsys-excel) and press F8 to run it.
Please read trnsys-excel-example.html for more details on that example.

To use Type62 in other projects, you should drag it from the direct access tool (the proforma will be in %TRNSYSRoot%\IIsiBat3\Data\TrnLib\RWTH-Aachen\Calling Excel\)

Comments, Questions? Please contact type62@ltt.rwth-aachen.de
 

Authors:
Jochen Wriske & Markus Oertker
Lehrstuhl für Technische Thermodynamik, RWTH Aachen

Editor:
Michaël Kummert
Solar Energy Lab, UW-Madison
2003-07-23