Encyclopaedia Index

WORKSHOP - Modifying GROUND

 

This session is intended to provide hands-on experience of the expansion of PHOENICS capabilities through the insertion of FORTRAN coding. The structure of GROUND is described here, and the use of GROUND is explained here.

During this session, the Ideal Gas law for density will be coded into GROUND. This is, in fact, a built-in option in GREX, but it is representative of the kind of modification typically effected in GROUND. Furthermore, its availability in GREX will allow an easy check of the correctness of the new coding, by simple comparison of results.

Introduction

The Ideal Gas law for density is:

r = P / (R * T)

where: R - is the gas constant for the particular gas. It will have to be passed from Q1, using, say, RG(1). The value for air is 286.4.

P - is the pressure. Note that in PHOENICS the pressure is obtained by adding the constant PRESS0 to the values held in the P1 store.

T - is the temperature. The integer index used to reference cell-by-cell values of temperature is TEMP1.

In the SI unit system, R is in J/kg/K, P is in N/m**2 and T is in K.

 

Insertion of GROUND Coding

An empty, or model, GROUND is provided for the user’s private use by clicking on the EDIT button of the PHOENICS-VR Environment and then clicking on Ground.

A model GROUND will appear on the screen in Notepad, and can now be edited. On saving, this GROUND will normally reside in the D_PRIV1 directory.

Insert GROUND coding for the Ideal Gas law by use of two different techniques:

1. The FN function subroutines, which operate directly on the F array. See the FUNCTion library entry in POLIS for a complete list of FN subroutines; and

2. Direct access to the F array, using the L0F function to obtain starting locations.

The entry to GROUND for density will be activated in Q1 by setting RHO1=GRND. (In VR, this means selecting USER for the density formula.)

 

Compiling and Linking

The new GROUND has to be compiled before a new EARTH can be built.  Compilation is performed via the COMPILE / Ground menu of VR-Environment, and building through BUILD / Earth.

If a 'private' Earth is selected to be run (see below), and the GROUND file is newer than the Earth executable, the option of recomiling and relinking will be offered.

 

Testing the Coding

The coding will be tested by comparing the results generated by the GREX option and the new coding. Library case B529 (which is concerned with supersonic flow around a rocket) happens to use the Ideal Gas Law, and hence can be used for testing. The following steps should be followed:

  1. VR must be turned off to enable the multi-run to work. Click on Run, then Commander. From this environment, any of the PHOENICS modules can be run.
  2. Click on Run, Pre processor, Text mode (Satellite) - T and load library case B529. This can be done from command mode (F2) by typing LOAD(B529), or from the Top Menu, by going to Library (F4), selecting '2 Load specified case' and entering B529. End (F7), saving the input file.
  3. Edit the Q1- click on File, Open file for Editing, select Q1. Modify the first line to read RUN(1,3) instead of RUN(1,1). This indicates that three EARTH runs will be made in one submission. This is called a multi-run. See the Encyclopaedia entry on RUN for more information.
  4. Change LSWEEP from 100 to 2 in order to reduce run time. We are not interested in converged solutions, just identical solutions!
  5. Before the STOP at the bottom of the file, insert NOWIPE=T. This will prevent the input data being reset to default values for subsequent runs. Each run then becomes a parameter variation on the first.
  6. By default, EARTH writes out the flow field into a file called PHI (or PHIDA). In this case, each run would overwrite the PHI file from the previous run. This can be avoided by changing the name of PHI for each run. This is done by setting NSAVE=RUN1 (say) for the first run.
  7. This case happens to set USEGRD =F. Delete this line, otherwise the new GROUND coding will never be executed!!

The settings before the STOP define the default case, against which we will test the new coding.

  1. After the STOP, insert RHO1=GRND, which will switch off the built-in coding, and activate the new coding. Set RG(1) to the required gas constant.
  2. Set IG(1)=1 to elect the first method of calculation, and set NSAVE=RUN2 (say) to prevent the PHI file being overwritten. The name of the PHI file will be changed to RUN2. You may also wish to change the TEXT command to identify the particular case. Finally, add another STOP to indicate the end of the data settings for run 2.
  3. Repeat for the other coding style option, setting IG(1) and NSAVE appropriately.

The bottom of the Q1 should look like this:

     GROUP 23. Field print-out and plot control
NPRINT=LSWEEP;NYPRIN=1;NZPRIN=2
PATCH(YZ,CONTUR,1,1,1,NY,1,NZ,1,1)
PLOT(YZ,P1,0.0,20.0)
LIBREF=529

   #### new lines added for GROUND Workshop
USEGRD=T
NOWIPE=T
LSWEEP=2
NSAVE=RUN1
STOP

   #### Data for Run 2
RHO1=GRND
RG(1)=286.4
IG(1)=1
NSAVE=RUN2
STOP

   #### Data for Run 3
IG(1)=2
NSAVE=RUN3
STOP

Running the Test Cases

Run the Satellite again to process the modified input file.

We now need to run the local ‘private’ Earth, not the default ‘public’ one used up to now. To do this:

Run the solver by clicking on the Run - Solver - Local solver (Earth) button of the PHOENICS Commander.

Note the residuals for each case. They should be the same, regardless of the coding style.

The RESULT file produced will contain the output from all the runs, one after the other. Inspection of the density fields will show whether or not they are identical.

Also, the PHI files produced can be accessed through AUTOPLOT, and the results compared graphically. Again they should produce identical plots.

 

Solution - required GROUND Coding

You should try to avoid looking at this page unless you are completely stuck.