TALK=T;RUN(1,1)
  DISPLAY
                                    valve vent
              /////////////////////›  ›///
              --------------------------/
                     ------            ›/
         crank/ .      pis›            ›/
             / conn.   ton›            ›/
            /      rod.   ›            ›/
           *_ . _ . _ . _*. _ . _ . _ .›_ . _  . Symmetry axis
                          ›            ›/
                          ›            ›/

                     z1  zwn

   The compression of gas by a piston-cylinder combination is
   simulated by the use of the In-Form BOX function.

   The "fluid" within the piston is given a velocity which
   corresponds the rotation of the crank.


   At a precribed instant a valve provides a fixed-pressurse outlet
   in the cylinder wall. This is achieved by use of a boundary
   condition embodying the In-Form IF condition.
  ENDDIS
  PHOTON USE
  p
  p1


  up z; gr z 1
  gr out x 1; gr out x 4
  con w1 x 1 fi;0.001;  con w1 x 3 fi;0.001
  surf mark x .99 col 4
  surf mark y .99 col 4
  msg Velocity contours at time step=1
  msg Press RETURN to continue
  pause; vec off; red
  cont p1 x 1 fil;0.001
  cont p1 x 3 fil;0.001
  surf mark x .99 col 4
  surf mark y .99 col 4
  msg Pressure contours at time step=1
  msg Press RETURN to continue
  pause
  cont h1 x 1 fil;0.001
  cont h1 x 3 fil;0.001
  surf mark x .99 col 4
  surf mark y .99 col 4
  msg Temperature contours at time step=1
  msg Press RETURN to continue
  pause
  p
  p5


  up z; gr z 1
  gr out x 1; gr out x 4
  con w1 x 1 fi;0.001;  con w1 x 3 fi;0.001
  surf mark x .99 col 4
  surf mark y .99 col 4
  msg Velocity contours at time step=5
  msg Press RETURN to continue
  pause; vec off; red
  cont p1 x 1 fil;0.001
  cont p1 x 3 fil;0.001
  surf mark x .99 col 4
  surf mark y .99 col 4
  msg Pressure contours at time step=5
  msg Press RETURN to continue
  pause
  cont h1 x 1 fil;0.001
  cont h1 x 3 fil;0.001
  surf mark x .99 col 4
  surf mark y .99 col 4
  msg Temperature contours at time step=5
  msg Press RETURN to continue
  pause
  p
  p10


  up z; gr z 1
  gr out x 1; gr out x 4
  con w1 x 1 fi;0.001;  con w1 x 3 fi;0.001
  surf mark x .99 col 4
  surf mark y .99 col 4
  msg Velocity contours at time step=10
  msg Press RETURN to continue
  pause; vec off; red
  cont p1 x 1 fil;0.001
  cont p1 x 3 fil;0.001
  surf mark x .99 col 4
  surf mark y .99 col 4
  msg Pressure contours at time step=10
  msg Press RETURN to continue
  pause
  cont h1 x 1 fil;0.001
  cont h1 x 3 fil;0.001
  surf mark x .99 col 4
  surf mark y .99 col 4
  msg Temperature contours at time step=10
  msg Press e to END
  ENDUSE
 ************************************************************
  Group 1. Run Title and Number
 ************************************************************
 ************************************************************
 
 TEXT(3D Piston by In-Form                    )
 
 ************************************************************
 ************************************************************
 
 IRUNN = 1 ;LIBREF = 783
 ************************************************************
  Group 2. Time dependence
 STEADY = F
    * Set overall time and no. of steps
 TFIRST =0. ;TLAST =0.0125
 FSTEP = 1 ;LSTEP = 10
 TFRAC(1)=0.1 ;TFRAC(6)=0.6
 ************************************************************
  Group 3. X-Direction Grid Spacing
 CARTES = F
 NX = 4
 XULAST =3.14159
 XFRAC(1)=0.3 ;XFRAC(2)=0.5
 XFRAC(3)=0.7 ;XFRAC(4)=1.
 ************************************************************
  Group 4. Y-Direction Grid Spacing
 NY = 4
 YVLAST =0.05
 YFRAC(1)=0.5 ;YFRAC(2)=0.8
 YFRAC(3)=0.95 ;YFRAC(4)=1.
 ************************************************************
  Group 5. Z-Direction Grid Spacing
 PARAB = F
 NZ = 100
 ZWLAST =0.1111
 ZFRAC(1)=1.0E-02 ;ZFRAC(21)=0.21
 ZFRAC(41)=0.41 ;ZFRAC(61)=0.61
 ZFRAC(81)=0.81
 ************************************************************
  Group 6. Body-Fitted Coordinates
 ************************************************************
  Group 7. Variables: STOREd,SOLVEd,NAMEd
 ONEPHS = T
 NAME(1)=P1 ;NAME(3)=U1
 NAME(5)=V1 ;NAME(7)=W1
 NAME(14)=H1 ;NAME(149)=MARK
 NAME(150)=RHO1
    * Y in SOLUTN argument list denotes:
    * 1-stored 2-solved 3-whole-field
    * 4-point-by-point 5-explicit 6-harmonic averaging 
 SOLUTN(P1,Y,Y,Y,N,N,N)
 SOLUTN(U1,Y,Y,N,N,N,Y)
 SOLUTN(V1,Y,Y,N,N,N,Y)
 SOLUTN(W1,Y,Y,N,N,N,Y)
 SOLUTN(H1,Y,Y,N,N,N,Y)
 SOLUTN(MARK,Y,N,N,N,N,Y)
 SOLUTN(RHO1,Y,N,N,N,N,Y)
 DEN1 = 150
 ************************************************************
  Group 8. Terms & Devices
    * Y in TERMS argument list denotes:
    * 1-built-in source 2-convection 3-diffusion 4-transient
    * 5-first phase variable 6-interphase transport         
 TERMS(P1,Y,Y,Y,N,Y,Y)
 TERMS(U1,Y,Y,Y,Y,Y,Y)
 TERMS(V1,Y,Y,Y,Y,Y,Y)
 TERMS(W1,Y,Y,Y,Y,Y,Y)
 TERMS(H1,Y,Y,Y,Y,Y,Y)
 DIFCUT =0.5 ;ZDIFAC =1.
 GALA = F ;ADDDIF = F
 NEWRH1 = T
 HUNIT =1.
 ISOLX = -1 ;ISOLY = -1 ;ISOLZ = -1
 ************************************************************
  Group 9. Properties used if PRPS is not
  stored, and where PRPS = -1.0 if it is!
 RHO1 = GRND5 ;TMP1 = GRND2
 EL1 =0.
 TSURR =0. ;TEMP0 =0.
 PRESS0 =0.
 DVO1DT =0. ;DRH1DP = GRND5
 RHO1A =0. ;RHO1B =3.49162E-03
 RHO1C =0.
 TMP1A =0. ;TMP1B =1.0E-03
 TMP1C =0.
 TMP2A =0. ;TMP2B =0.
 TMP2C =0.
 EMISS =0. ;SCATT =0.
 RADIA =0. ;RADIB =0.
 ENUL =1.0E-05 ;ENUT =1.0E-03
 PRNDTL(U1)=1. ;PRNDTL(V1)=1.
 PRNDTL(W1)=1. ;PRNDTL(H1)=1.
 PRT(U1)=1. ;PRT(V1)=1.
 PRT(W1)=1. ;PRT(H1)=1.
 CP1 =1000. ;CP2 =1.
 ************************************************************
  Group 10.Inter-Phase Transfer Processes
 ************************************************************
  Group 11.Initial field variables (PHIs)
 FIINIT(P1)=1.0E+05 ;FIINIT(U1)=1.0E-10
 FIINIT(V1)=1.0E-10 ;FIINIT(W1)=1.0E-10
 FIINIT(H1)=9.0E+05 ;FIINIT(MARK)=1.0E-10
 FIINIT(RHO1)=1.0E-10
   No PATCHes yet used for this Group
 INIADD = F
 FSWEEP = 1
 NAMFI =CHAM
 ************************************************************
  Group 12. Patchwise adjustment of terms
  Patches for this group are printed with those
  for Group 13.
  Their names begin either with GP12 or &
 ************************************************************
  Group 13. Boundary & Special Sources
 
 PATCH(HEAD ,LWALL , 1, 4, 1, 4, 1, 1, 1, 10)
 COVAL(HEAD ,U1 , GRND2 ,0. )
 COVAL(HEAD ,V1 , GRND2 ,0. )
 
 PATCH(CYL ,NWALL , 1, 4, 4, 4, 1, 100, 1, 10)
 COVAL(CYL ,U1 , GRND2 ,0. )
 COVAL(CYL ,W1 , GRND2 ,0. )
 
 PATCH(PCR ,HWALL , 1, 4, 1, 4, 100, 100, 1, 10)
 COVAL(PCR ,U1 , GRND2 ,0. )
 COVAL(PCR ,V1 , GRND2 ,0. )
 
 PATCH(ONECELL1,CELL , 1, 1, 1, 1, 1, 1, 1, 1)
 
 PATCH(PISTON1 ,CELL , 1, 4, 1, 4, 1, 100, 1, 1)
 COVAL(PISTON1 ,W1 ,In-Form:source - see Grp 19)
 
 PATCH(ONECELL2,CELL , 1, 1, 1, 1, 1, 1, 2, 10)
 
 PATCH(PISTON2 ,CELL , 1, 4, 1, 4, 1, 100, 2, 10)
 COVAL(PISTON2 ,W1 ,In-Form:source - see Grp 19)
 
 PATCH(EXHAUST ,NORTH , 1, 1, 4, 4, 95, 100, 2, 10)
 COVAL(EXHAUST ,P1 ,In-Form:source - see Grp 19)
 XCYCLE = F
 EGWF = T
 WALLCO = GRND2
 ************************************************************
  Group 14. Downstream Pressure For PARAB
 ************************************************************
  Group 15. Terminate Sweeps
 LSWEEP = 30 ;ISWC1 = 1
 LITHYD = 1 ;LITFLX = 1 ;LITC = 1 ;ITHC1 = 1
 SELREF = T
 RESFAC =1.0E-04
 ************************************************************
  Group 16. Terminate Iterations
 LITER(P1)=10 ;LITER(U1)=1
 LITER(V1)=1 ;LITER(W1)=1
 LITER(H1)=5
 ENDIT(P1)=1.0E-03 ;ENDIT(U1)=1.0E-03
 ENDIT(V1)=1.0E-03 ;ENDIT(W1)=1.0E-03
 ENDIT(H1)=1.0E-03
 ************************************************************
  Group 17. Relaxation
 RELAX(P1,LINRLX,0.05)
 RELAX(U1,FALSDT,5.0E-05)
 RELAX(V1,FALSDT,5.0E-05)
 RELAX(W1,FALSDT,5.0E-05)
 RELAX(H1,FALSDT,1.0E+09)
 RELAX(MARK,LINRLX,1.)
 RELAX(RHO1,LINRLX,1.)
 OVRRLX =0.
 EXPERT = F ;NNORSL = F
 ************************************************************
  Group 18. Limits
 VARMAX(P1)=1.0E+10 ;VARMIN(P1)=1.0E+04
 VARMAX(U1)=1.0E+06 ;VARMIN(U1)=-1.0E+06
 VARMAX(V1)=1.0E+06 ;VARMIN(V1)=-1.0E+06
 VARMAX(W1)=1.0E+06 ;VARMIN(W1)=-1.0E+06
 VARMAX(H1)=1.0E+10 ;VARMIN(H1)=-1.0E+10
 VARMAX(MARK)=1.0E+10 ;VARMIN(MARK)=-1.0E+10
 VARMAX(RHO1)=1.0E+10 ;VARMIN(RHO1)=-1.0E+10
 ************************************************************
  Group 19. Data transmitted to GROUND
 PARSOL = F
 ISG62 = 1
 SPEDAT(SET,MAKE,ZWO,C,=1.E-10)
 SPEDAT(SET,MAKE,ZWN,C,=1.E-10)
 SPEDAT(SET,MAKE,VENT,C,=1.E-10)
 SPEDAT(SET,STORED,ZWO!ONECELL1,C,=0!ZSLFIN)
 SPEDAT(SET,STORED,ZWN!ONECELL1,C,=1.849461E-03!ZSLFIN)
 SPEDAT(SET,INFOB,*!PISTON1,C,=BOX(0.&0.&0.&.1&.1&1.849461E-03&0.&$)
 SPEDAT(SET,INFOB,*!PISTON1,C,0.&0.)!INFOB_1)
 SPEDAT(SET,STORED,ZWO!ONECELL2,C,=ZWN!IF(ISWEEP.EQ.1)!ZSLFIN)
 SPEDAT(SET,STORED,ZWN!ONECELL2,C,=0.05*(SQRT(4.^2-SIN(251.327209*$)
 SPEDAT(SET,STORED,ZWN!ONECELL2,C,TIM)^2)-COS(251.327209*TIM)-4.+1$)
 SPEDAT(SET,STORED,ZWN!ONECELL2,C,.)!IF(ISWEEP.EQ.1)!ZSLFIN)
 SPEDAT(SET,INFOB,*!PISTON2,C,=BOX(0.&0.&0.&.1&.1&ZWN&0.&0.&0.)!IN$)
 SPEDAT(SET,INFOB,*!PISTON2,C,FOB_1)
 SPEDAT(SET,SOURCE,W1!PISTON1,C,=1.849461E-03!INFOB_1!FIXVAL)
 SPEDAT(SET,SOURCE,W1!PISTON2,C,=(ZWN-ZWO)/DT!INFOB_1!FIXVAL)
 SPEDAT(SET,STORED,VENT!ONECELL1,C,=0.!ZSLFIN)
 SPEDAT(SET,STORED,VENT!ONECELL2,C,=1.!IF(ISWEEP.EQ.1.AND.P1[&&NZ-$)
 SPEDAT(SET,STORED,VENT!ONECELL2,C,1].GE.3.E5)!ZSLFIN)
 SPEDAT(SET,SOURCE,R1!EXHAUST,C,=-10.!IF(VENT.NE.0.))
 SPEDAT(SET,STORED,MARK,C,=0!IF(ISWEEP.EQ.1)!ZSLFIN)
 SPEDAT(SET,STORED,MARK,C,=1!INFOB_1!IF(ISWEEP.EQ.1)!ZSLFIN)
 ************************************************************
  Group 20. Preliminary Printout
 DISTIL = T ;NULLPR = F
 NDST = 0
 DSTTOL =1.0E-02
 EX(P1)=1.912E+05 ;EX(U1)=0.1406
 EX(V1)=0.08936 ;EX(W1)=2.305
 EX(H1)=1.001E+06 ;EX(MARK)=0.87
 EX(RHO1)=0.4367
 ************************************************************
  Group 21. Print-out of Variables
 INIFLD = F ;SUBWGR = F
    * Y in OUTPUT argument list denotes:
    * 1-field 2-correction-eq. monitor 3-selective dumping      
    * 4-whole-field residual 5-spot-value table 6-residual table
 OUTPUT(P1,Y,N,Y,Y,Y,Y)
 OUTPUT(U1,Y,N,Y,Y,Y,Y)
 OUTPUT(V1,Y,N,Y,Y,Y,Y)
 OUTPUT(W1,Y,N,Y,Y,Y,Y)
 OUTPUT(H1,Y,N,Y,Y,Y,Y)
 OUTPUT(MARK,Y,N,Y,N,N,N)
 OUTPUT(RHO1,Y,N,Y,N,N,N)
 ************************************************************
  Group 22. Monitor Print-Out
 IXMON = 1 ;IYMON = 1 ;IZMON = 99
 NPRMON = 100000 ;NPRMNT = 1 ;TSTSWP = -1
 UWATCH = T ;USTEER = T
 HIGHLO = F
 ************************************************************
  Group 23.Field Print-Out & Plot Control
 NPRINT = 30 ;NUMCLS = 5
 NTPRIN = 5 ;ISTPRF = 1 ;ISTPRL = 100000
 NXPRIN = -1 ;IXPRF = 1 ;IXPRL = 10000
 NYPRIN = 0 ;IYPRF = 1 ;IYPRL = 1
 NZPRIN = 20 ;IZPRF = 1 ;IZPRL = 10000
 XZPR = T ;YZPR = F
 IPLTF = 1 ;IPLTL = 30 ;NPLT = -1
 ISWPRF = 1 ;ISWPRL = 100000
 ITABL = 3 ;IPROF = 1
 ABSIZ =0.5 ;ORSIZ =0.4
 NTZPRF = 1 ;NCOLPF = 50
 ICHR = 2 ;NCOLCO = 45 ;NROWCO = 20
   No PATCHes yet used for this Group
 ************************************************************
  Group 24. Dumps For Restarts
 SAVE = T ;NOWIPE = F
 NSAVE =CHAM
 IDISPA = 1 ;IDISPB = 0 ;IDISPC = 0
 CSG1    ='P'
STOP