TALK=T;RUN( 1, 1)
  
  DISPLAY
  Simulation of heat conduction in a steel slab of 0.1 m thickness,
  internallly heated by 1. kW/m**3 of electric power, with both its
  faces held to 0.0 deg Celsius.
  
  This file is a simple parameterised Q1, with 4 cases selected via 
  caseno, They add additional features in succession, thus:
  caseno=0 is the basic case
  caseno=1 allows comparison with the exact solution
  caseno=2 adds line-printer plot of temperature profile
  caseno=3 declares reals THICK and HEATINPT with results unchanged
  caseno=4 substitutes copper for steel
 
  The case number can be set interactively, by answering the 
  question which appears on the screen; alternatively the setting
  caseno= 1, 2, 3 or 4 can be made by editing the q1 file.
   
  saveXbegin and saveXend lines ensure that the settings between 
  them are protected from being over-written if the Q1 is processed 
  by the VR-Editor; but they do not influence the calculation.
  
  ENDDIS
  GROUP 1. Run title and other preliminaries 
TEXT(Steady conduction in electrically-heated slab
  save1begin
integer(caseno) ! allows several cases to be run from the same file
caseno=0        ! also the default value, if no  seting is made.

      The following lines print messages to the screen
mesg(caseno=0:
mesg(basic case with minimum settings
mesg(caseno=1:
mesg(allows comparison with exact
mesg(caseno=2:
mesg(adds line-printer plot of profile
mesg(caseno=3:
mesg(declares reals THICK and HEATINPT                     
mesg(caseno=4:
mesg(changes the metal of the slab from steel to copper
mesgm(caseno equals :caseno: OK? If not, enter required value
      The readvdu line below accepts the user's input via the 
      keyboard.
      The default, if the user simply enters 'carriage return', is
      whatever caseno was set above, or 0 if none was set
readvdu(caseno,int,caseno) 
      Once caseno has been set, the following lines are executed by 
      the satellite without interruption
caseno
  save1end
  
  GROUP 3. X-direction grid specification
  save3begin
if(caseno.ge.0) then    ! basic case
 NX=100      ! Dividing the x dimension into 100 elements
 XULAST=0.1  ! The thickness of the slab
 GRDPWR(X,NX,XULAST,1.0) ! To create a uniform grid, namely one with
                        ! a power-law distribution, the exponent
                        ! being 1.0
  save3end
  GROUP 7. Variables stored, solved & named 
  save7begin                      
 SOLVE(TEM1) ! To solve for temperature
 STORE(PRPS) ! To be able to set material properties via PROPS file
 STORE(KOND) ! To be able to check the thermal conductivity
endif       ! End of if(caseno.ge.0)
if(caseno.gt.0) then   ! compare with exact solution
 CHAR(FORMULA) ! Declare the character variable FORMULA, and set it
              ! to the temperature calculated by PHOENICS viz TEM1,
              ! divided by the theoretical temperature: namely, 
              ! that described by the following:
 FORMULA=TEM1/(0.5*1.E3*(XG-.005*:XULAST:)*(.995*:XULAST:-XG)/KOND)
              ! where
              ! 0.5 is a constant in the theoretical expression for
              ! the parabolic profile,
              ! 1.E3 is the volumetric heat input,
              ! xg = x value of any grid point,
              ! .005*:xulast: = xg of first grid point,
              ! .995*:xulast: = xg of last grid point,
              ! KOND is the thermal conductivity of the material
 (STORED var #RAT is :FORMULA:) ! Calculates the temperature ratio
endif         ! End of if(caseno.gt.0)
  save7end
  GROUP 11. Initialization of variable or porosity fields 
  save11begin
FIINIT(PRPS)=STEEL ! To require properties of steel to be used 
if(caseno.gt.3) then
 FIINIT(PRPS)=COPPER ! To require properties of copper to be used 
endif
  save11end
  GROUP 13. Boundary conditions and special sources
  save13begin
PATCH(minXface,WEST,1,1,1,1,1,1,1,1) ! to locate the low-x face
PATCH(maxXface,WEST,NX,NX,1,1,1,1,1,1) ! to locate the high-x face
COVAL(minXface,TEM1,FIXVAL,0.0)   ! to fix the values of both faces
COVAL(maxXface,TEM1,FIXVAL,0.0)   ! to zero
PATCH(HEATER,volume,1,nx,1,1,1,1,1,1)  ! to show that the volumetric
           ! heat flux extends from low x to high, i.e. from 1 to nx
COVAL(HEATER,TEM1,FIXFLU,1.e3) ! to fix the heat flux 1kW/m**3
if(caseno.gt.2) then     ! declare, set and use THICK and HEATINPT
 REAL(THICK,HEATINPT)
 THICK=0.1               ! The thickness of the slab
 HEATINPT=1.0E3          ! The volumetric heat input
 GRDPWR(X,NX,THICK,1.0)  ! To create a uniform grid
 COVAL(HEATER,TEM1,FIXFLU,HEATINPT) ! fix the heat input to HEATINPT
endif                    ! end of if(caseno.gt.2)
  save13end
  GROUP 23. Field print-out and plot control
  save23begin
if(caseno.gt.1) then ! create line-printer temperature plot
 PATCH(TEM1PLOT,PROFIL,1,NX,1,1,1,1,1,1)
 COVAL(TEM1PLOT,TEM1,0.0,0.0)  ! 0.0,0.0 means 'choose scale of plot
                               ! to fit maximum and minimum
 ORSIZ=0.2                   ! Determines how many lines are plotted
endif                ! end of if(caseno.gt.1)
LIBREF=163
  save23end
STOP