In time-dependent cases (STEADY=F), it is often required to specify boundary conditions which vary as functions of time. This, like most things in PHOENICS, can be done in several ways, namely:

- By using In-Form
statements, as in library cases:

704, 705, 711, 719, 766, 767.This is the most flexible method. It is recommended.

- Via special PATCH and COVAL commands. This is the subject of the present
article.
- By way of
PLANT, as in case
z104; this
was the recommended method for complex problems before In-Form appeared.
- Fortran coding introduced by the enthusiast into the GROUND subroutine.

**1. Turning Sources and Boundary Conditions On and Off**

The last two arguments of the PATCH command set the first and last time-step the PATCH is to be active.

PATCH(MYSOURCE, VOLUME, ixf,ixl, iyf,iyl, izf,izl, itf, itl)

sets a PATCH over the block of cells from IX=ixf to IX=ixl, IY=iyf to IY=iyl and IZ=izf
to izl. The first time step at which the PATCH is active is** itf**, and the last is **itl**.
Outside this range, the PATCH is inactive.

Simple time functions can be made by generating a sequence of PATCH commands which together approximate the required source. For example, a heat source which increases then decreases linearly with time might be set as:

PATCH(HEAT1, VOLUME, ixf,ixl, iyf,iyl, izf,izl, 1,LSTEP) COVAL(HEAT1, TEM1, FIXFLU, 5.0)

PATCH(HEAT2, VOLUME, ixf,ixl, iyf,iyl, izf,izl, 6,LSTEP-5) COVAL(HEAT2, TEM1, FIXFLU, 5.0)

PATCH(HEAT3, VOLUME, ixf,ixl, iyf,iyl, izf,izl, 11,LSTEP-10) COVAL(HEAT3, TEM1, FIXFLU, 5.0)

If LSTEP were 25, the resulting heat source would be:

- Steps 1 - 5 : 5W/m
^{3} - Steps 6 - 10 : 10W/m
^{3} - Steps 11 - 15 : 15W/m
^{3} - Steps 16 - 20 : 10W/m
^{3} - Steps 21 - 25 : 5W/m
^{3}

More complicated functions can be set in this way by using PIL DO loops to generate the PATCH commands.

Note that the actual time the sources are active for is controlled by the size of the individual time steps - the PATCH limits refer to time step numbers, not times. If the time-steps are non-uniform, the resulting time variation may not be quite as expected.

**2. Using Built-in Time Variations**

Although simple in concept, the above method can be tedious in practice as it involves hand-editing the Q1 file. Several common forms of time-variation are provided as built-in options. In PHOENICS-VR, these are available as heat sources. From PIL, they can be applied to any SOLVEd variable.

The available source forms are:

- Linear variation with time
- Sine function of time
- Cosine function of time
- Step (battlement) function of time
- Increasing Saw-tooth function of time
- Decreasing Saw-tooth function of time

Note that the variation is with time, not time-step number. The shorter the time-steps, the better the representation will be.

The PIL settings for these sources are:

PATCH(TIMabcde, type, ixf,ixl, iyf,iyl, izf,izl, itf, itl) COVAL(TIMabcde, phi, CO, VAL)

where:

The patch name must start with '**TIM**'. The remaining 'abcde' characters
are at the user's discretion.

**type** can be VOLUME for a volumetric source, or NORTH, SOUTH,
EAST,WEST,HIGH or LOW for a source per unit area.

**phi** is the variable

**CO** can be FIXVAL if the value is to change with time or FIXFLU if the
source is to change with time. For FIXVAL, the time t used in the built-in options is
taken as the current time level, i.e. t=t_{+} (=TIM in PHOENICS). For FIXFLU, t is
taken as the average of the current and previous time levels, i.e. t = 0.5*(t_{+}
+ t_{-}) where t_{+} = t_{- }+ Dt and Dt id the current time step.

**VAL **can be:

GRND4 - Linear source

GRND10 - Sine

GRND6 - Cosine

GRND7 - Step (battlement)

GRND8 - Increasing Saw-tooth

GRND9 - Decreasing Saw-tooth

The figure shows the general form of the source applied, and defines the nomenclature used. Several additional variables must be passed to EARTH. This is done using the SPEDAT command.

For a** Linear source (GRND4)** the formula used is

VAL = F_{s}+ ( F_{e}- F_{s})*(t - t_{s})/(t_{e}- t_{s})

and the additional settings are:
**SPEDAT(TIMabcde,STARTphi, R, Phi value at start of cycle F _{s})
SPEDAT(TIMabcde,ENDphi, R, Phi value at end of cycle F_{e})
SPEDAT(TIMabcde,TSTARTphi, R, Start time t_{s})
SPEDAT(TIMabcde,TENDphi, R, End time t_{e})**

For **sine and cosine sources (GRND10 & GRND6)** the formula used is:

VAL = A sin(or cos) [ {2p/T_{p}} t' ] + M

where

t' = t - t_{s }+ g_{off}* T_{p}

and the extra settings are:

SPEDAT(TIMabcde,PERIODphi, R, Time period for one cycle T_{p}) SPEDAT(TIMabcde,AMPLITUDEphi, R, Amplitude of cycle in cycle A) SPEDAT(TIMabcde,MEANphi, R, Mean value of phi in cycle M) SPEDAT(TIMabcde,TSTARTphi, R, Start time for offset t_{s}) SPEDAT(TIMabcde,OFFSETphi, R, Dimensionless time offset g_{off})

Once active, the source will continue until time-step **itl**.

__Example 1__

A heat-source varying as a sine-function of time, with an amplitude of 25W/m^{3},
a mean value of 50W/m^{3}, and the time for one cycle is 5 minutes.

PATCH(TIM-1, VOLUME, ixf,ixl, iyf,iyl, izf,izl, itf, itl) COVAL(TIM-1, TEM1, FIXFLU, GRND10)

SPEDAT(TIM-1,PERIODTEM1, R, 300.0) SPEDAT(TIM-1,AMPLITUDETEM1, R, 25.0) SPEDAT(TIM-1,MEANTEM1, R, 50.0) SPEDAT(TIM-1,TSTARTTEM1, R, 0.0) SPEDAT(TIM-1,OFFSETTEM1, R, 0.0)

__Example 2__

A fluid enters with a density RHO1, an inlet velocity of 2m/s, and an inlet temperature that is a sine-function of time, with an amplitude of 5 deg C, a mean value of 15 deg C, and a period of 10 seconds.

PATCH(TIMINL, LOW, ixf,ixl, iyf,iyl, izf,izl, itf, itl) COVAL(TIMINL, P1, FIXFLU, RHO1*2.0) COVAL(TIMINL, W1, ONLYMS, 2.0) COVAL(TIMINL, TEM1, ONLYMS, GRND10)

SPEDAT(TIMINL,PERIODTEM1, R, 10.0) SPEDAT(TIMINL,AMPLITUDETEM1, R, 5.0) SPEDAT(TIMINL,MEANTEM1, R, 15.0) SPEDAT(TIMINL,TSTARTTEM1, R, 0.0) SPEDAT(TIMINL,OFFSETTEM1, R, 0.0)