-
Notifications
You must be signed in to change notification settings - Fork 5
Loops
Table of Contents
This page is about creating loops with FDSgeogen.
A loop tag in FDSgeogen has the following basic structure:
<loop var="loop_variable_name" start="start_value" stop="stop_value" >
<!-- loop body -->
</loop>
The above loop defines:
- The name of the new variable (attribute
var
, here with the valueloop_variable_name
) which will be used to iterate the loop values. - The starting and ending values of the loop variable, here
start_value
andstop_value
. The value of the loop variable starts with thestart_value
is incremented by 1 until it reaches the valuestop_value
. - The instructions inside the loop tag are evaluated for each iteration.
FDSgeogen allows to use loops via the loop tag. A simple loop tag defines a loop variable and the loop range (start and stop). The example file basic_loop.xml illustrates a simple loop:
<fds>
<!-- file naming -->
<info chid="'basic_loop'" outfile="'basic_loop.fds'"/>
<!-- the following loop iterates the value of the variable 'count' from 1 to 10 -->
<loop var="count" start="1" stop="10">
<!-- print the following message for each loop iteration -->
<dbg print="'value of count: %d'%count" />
</loop>
</fds>
The above example defines a loop with following properties:
- the loop variable, i.e. the variable which values will be changed from iteration to iteration, is named
count
- the starting value of the loop variable is 1, it is increased by 1 until it reaches the last value of 10
- for each iteration, the loop body (here the tag dbg) is evaluated
The output of the above example is a dummy FDS input file (basic_loop.fds
) and at the console the following lines:
[...]
value of count: 1
value of count: 2
value of count: 3
value of count: 4
value of count: 5
value of count: 6
value of count: 7
value of count: 8
value of count: 9
value of count: 10
While the above example did just create some debug output, the following one shows the creation of obstacles via a loop. See obst_loop.xml.
<fds>
<!-- file naming -->
<info chid="'obst_loop'" outfile="'obst_loop.fds'"/>
<!-- fixed input parameter -->
<input text="TIME T_END=0.0" />
<!-- create mesh -->
<fds_mesh ijk="32, 32, 32" xb="0, 32, 0, 32, 0, 32" />
<!-- create obstractions in a loop -->
<!-- position and height as a function of the loop variable 'count' -->
<loop var="count" start="1" stop="10">
<dbg print="'value of count: %d'%count" />
<var x="10+count" z="count * 2" />
<fds_obst xb="x, x+1.0, 0, 32, 0, z"/>
</loop>
</fds>
Explanation:
- The part before the loop creates a basic FDS input file structure.
- The loop iterates the
count
variable from 1 to 10. - The body of the loop contains
- a simple dbg output
- the computation of two new variables
x
andz
which will determine the position in x-direction and the height of the obstructions to be created - the creation of a obstruction as a function of
x
andz
The resulting FDS input file is
&HEAD CHID='obst_loop', TITLE='title' /
&TIME T_END=0.0 /
&MESH ID='none', IJK=32, 32, 32, XB=0, 32, 0, 32, 0, 32/
&OBST ID='none', XB=11, 12.000000, 0, 32, 0, 2/
&OBST ID='none', XB=12, 13.000000, 0, 32, 0, 4/
&OBST ID='none', XB=13, 14.000000, 0, 32, 0, 6/
&OBST ID='none', XB=14, 15.000000, 0, 32, 0, 8/
&OBST ID='none', XB=15, 16.000000, 0, 32, 0, 10/
&OBST ID='none', XB=16, 17.000000, 0, 32, 0, 12/
&OBST ID='none', XB=17, 18.000000, 0, 32, 0, 14/
&OBST ID='none', XB=18, 19.000000, 0, 32, 0, 16/
&OBST ID='none', XB=19, 20.000000, 0, 32, 0, 18/
&OBST ID='none', XB=20, 21.000000, 0, 32, 0, 20/
&TAIL/
The following example extends the simple burner setup by a variable device placement. This illustrates how to define a series of devices as a function of prescribed values, here the position of a fire, in a loop. The relevant parts are:
<fds>
<!-- variables for the position and diameter of the burner -->
<var xpos = "0.6" ypos = "1.2" diameter = "0.4"/>
[...]
<!--================================
========= fire definition ==========
=================================-->
<!-- definition of the reaction -->
<fds_reac id="'METHANE'" fuel="'METHANE'" soot_yield="0.05"/>
<!-- burning surface -->
<fds_surf id="'burner'" hrrpua="1000" />
<!-- creating and positioning the burner -->
<fds_obst xb="xpos-diameter/2., xpos+diameter/2., ypos-diameter/2., ypos+diameter/2., 0.0, 0.4" surf_ids="'burner', 'INERT', 'INERT'"/>
<!--================================
======== output definition =========
=================================-->
<!-- creates 10 temperature devices with vertical distance of 0.1 m above the center of the burner. The lowest device is in a height of 0.5m -->
<loop var="z" start="0" stop="9">
<devc id="'TEMP_z%i'%(z)" x="xpos" y="ypos" z="0.5+0.1*z" q="'TEMPERATURE'" />
</loop>
<fds_slcf pby="ypos" quantity="'VELOCITY'" vector="True" />
</fds>
Explanation:
- As previously described, the position and extension of the fire in the ''simple burner'' example is defined by
xpos
,ypos
anddiameter
. - The fire definition is done in the "fire definition" section.
- The "output definition" section defines two outputs:
- Ten temperature devices with the following properties are defined as a function of the loop variable
z
- The device id depends on the loop variable
- The position in x- and y-direction depends on the fire placement
- The height, i.e. the position in z-direction, is a function of
z
- A single velocity slice, which is placed according to the fire position