Documentation for OpenFLUID 2.2.1
Single-column value generator

This appendix provides insight about use cases and set up of generators to provide variable data easily. It deals only with single-column csv, for multi-column data files, see Multi-column generators : setup and use

What data types can be generated?

The available data types depend from the kind of wanted generation:

Generator type Double Vector (Double) Matrix (Double) Integer Boolean String Map
Fixed values Yes Yes* Yes* Yes Yes Yes No
Random values Yes Yes Yes Yes Yes No No
Values from file interpolation Yes No No No No No No
Values from file injection Yes Yes Yes Yes Yes Yes Yes

Note: expected format for Map is (key: String, value: openfluid::core::Value)

Floating-point variables

*The non-scalar double generator can be used either with a single value for all, or a value for each cell of the container If a single value is given, a parameter varsize is required with expected dimension (eg "[3]" for a vector or "[2,4]" for a matrix).

An example for every time step and every unit of the given unit class, for a generator of vector of size 4 containing doubles:

  • "3" with varsize parameter being [4] will produce as variable value [3.0, 3.0, 3.0, 3.0]
  • "[1,4,2.2,3]" will produce as variable value [1.0, 4.0, 2.2, 3.0]

An option is available for the random generator, to be able to have identical or different values inside the container. Eg with a vector of 4 double:

  • same value activated: t0: [2.1, 2.1, 2.1, 2.1], t1: [43, 43, 43, 43]
  • same value disabled: t0: [4.5, 2.0, 22.1, 1.7], t1: [10.2, 2.3, 7,4, 9.9]

Boolean

Currently the random generator for boolean gives a balanced probability between true and false (50% each)

File formats for generators

Note
Currently, these files formats are used by interp and inject generators only.

Sources file

The sources file format is an XML based format which defines a list of sources files associated to an unique ID.
The sources must be defined in a section delimited by the <datasources> tag, inside an <openfluid> tag and must be structured following these rules:

  • Inside the <datasources> tag, there must be a set of <filesource> tags
  • Each <filesource> tag must bring an ID attribute giving the identifier of source, and a file attribute giving the name of the file containing the source of data. The files must be placed in the input directory of the simulation.
<?xml version="1.0" standalone="yes"?>
<openfluid>
<datasources>
<filesource ID="1" file="source1.dat" />
<filesource ID="2" file="source2.dat" />
</datasources>
</openfluid>
Note
As a sources file is not part of the standard input dataset, it must not have a .fluidx extension. Using the .fluidx extension may lead to an unexpected behaviour (such as deletion of the sources file).
The recommended extension for this file is .xml (e.g. sources.xml)

An associated source data file is a two columns text file, containing a serie of values in time. The first column is the date using the ISO format YYYY-MM-DD'T'HH:MM:SS. The second column is the value itself.

1999-12-31T12:00:00 -1.0
1999-12-31T23:00:00 -5.0
2000-01-01T00:30:00 -15.0
2000-01-01T00:40:00 -5.0
2000-01-01T01:30:00 -15.0

Distribution file

A distribution file is a two column file associating a unit ID (first column) to a source ID (second column).

1 1
2 2
3 1
4 2
5 1

Type-specific generator

By default, the values injected by inject generators are Double type.
To inject data of a specific type, add the vartype attribute to the generator element with appropriate type as value.

Warning
String representation of values defined in source files must match the string representation of specified variable type.
See String representation of values

The available values for vartype depend from the openfluid::core::Value type:

OpenFLUID value vartype
openfluid::core::StringValue string
openfluid::core::BooleanValue boolean
openfluid::core::IntegerValue integer
openfluid::core::VectorValue vector
openfluid::core::MatrixValue matrix
openfluid::core::MapValue map
openfluid::core::NullValue null

Example of a boolean inject generator:

<generator varname="gas.atm.V.windspeed.bool" unitsclass="AU" vartype="boolean" method="inject" enabled="true">
<param name="sources" value="sources.xml"/>
<param name="distribution" value="distribution.dat"/>
</generator>