PHOTON USE
  p
  p10
 
 
  up z
  gr z 1
  gr out x 1
  gr out x 4
  vec x 1 sh
  vec x 3 sh
  msg Velocity vectors at time step=10
  msg Press RETURN to continue
  pause
  cont h1 x 1 fil;0.001
  cont h1 x 3 fil;0.001
  msg Temperature contours at time step=10
  msg Press RETURN to continue
  pause
  p
  p20
 
 
  up z
  gr z 1
  gr out x 1
  gr out x 4
  vec x 1 sh
  vec x 3 sh
  msg Velocity vectors at time step=20
  msg Press RETURN to continue
  pause
  cont h1 x 1 fil;0.001
  cont h1 x 3 fil;0.001
  msg Temperature contours at time step=20
  msg Press RETURN to continue
  pause
  p
  p30
 
 
  up z
  gr z 1
  gr out x 1
  gr out x 4
  vec x 1 sh
  vec x 3 sh
  msg Velocity vectors at time step=30
  msg Press RETURN to continue
  pause
  cont h1 x 1 fil;0.001
  cont h1 x 3 fil;0.001
  msg Temperature contours at time step=30
  msg Press RETURN to continue
  pause
  p
  p40
 
 
  up z
  gr z 1
  gr out x 1
  gr out x 4
  vec x 1 sh
  vec x 3 sh
  msg Velocity vectors at time step=40
  msg Press RETURN to continue
  pause
  cont h1 x 1 fil;0.001
  cont h1 x 3 fil;0.001
  msg Temperature contours at time step=40
  msg Press RETURN to continue
  pause
  p
  p50
 
 
  up z
  gr z 1
  gr out x 1
  gr out x 4
  vec x 1 sh
  vec x 3 sh
  msg Velocity vectors at time step=50
  msg Press RETURN to continue
  pause
  cont h1 x 1 fil;0.001
  cont h1 x 3 fil;0.001
  msg Temperature contours at time step=50
  msg Press e to END
  ENDUSE
 
    GROUP 1. Run title and other preliminaries
TEXT(Two Stroke Loop Scavenge Cycle 3D 
TITLE
mesg(PC486/50 time last reported as appx. 4.5 min
  DISPLAY
  This example considers a two-stroke engine with loop scavenging.
  It is an unsteady three-dimensional flow with mixing of hot and
  cold streams and with time-varying domain boundaries.
  The exhaust and intake processes take place through ports
  in the lower part of the cylinder wall which are
  progressively uncovered by the descending piston. The
  exhaust port opens first and the cylinder pressure falls
  due to both outflow and cylinder volume change. The inlet
  port opens soon afterwards and inflow begins when the
  cylinder pressure has fallen below the total pressure in the
  inlet port. The incoming cold gas displaces and partially
  mixes with the hot exhaust gas.
  The inlet port flow direction makes an angle of 30 deg. to both
  the radial and horizontal directions.
  A single expanding grid is used in the z-direction so that
  the cells representing the ports both expand and are uncovered.
  The patches representing the port cells are active over a range
  of time steps.
  ENDDIS
INTEGER(ID1,ID2,ID3,KNZ1,KNZ2,KNZ3)
REAL(RPS,PI ,A1,AN,ANGLE,DEGS,VOLF)
PI=3.14159
 
    GROUP 2. Transience; time-step specification
STEADY=F
   ** Revolutions per second.
RPS=40.
   ** mean vol flowrate
VOLF=0.8E-3*RPS
   ** Exhaust port opens at 70 deg BBDC.
A1=-70.
   ** End of simulation 1 deg. ABDC
AN=30.
ANGLE=AN - A1
DEGS=RPS*360.
TFIRST=A1/DEGS
TLAST=AN/DEGS
LSTEP=50
TFRAC(1)=-80.
   ** 2-degree steps
TFRAC(2)= 2./ANGLE
 
    GROUP 3. X-direction grid specification
CARTES=F;NX=4
   ** Edges of exhaust and transfer ports at x-cell boundaries.
XFRAC(1)=0.3;XFRAC(2)=0.5;XFRAC(3)=0.7;XFRAC(4)=1.
XULAST=PI
 
    GROUP 4. Y-direction grid specification
NY=4
YFRAC(1)=0.5;YFRAC(2)=.8;YFRAC(3)=.95;YFRAC(4)=1.
   ** Cylinder radius
YVLAST=.05
 
    GROUP 5. Z-direction grid specification
   ** Grid specified at BDC.
NZ=10
GRDPWR(Z,NZ,.1111,-1.532)
 
    GROUP 7. Variables stored, solved & named
SOLVE(P1,U1,V1,W1,H1);SOLUTN(P1,Y,Y,Y,N,N,N);STORE(RHO1)
 
    GROUP 9. Properties of the medium (or media)
ENUL=1.E-5;ENUT=1.E-3
   ** Temperature from enthalpy field.
TMP1=LINH
   ** Set reciprocal of the specific heat...
TMP1B=1.E-3   ; CP1 = 1.0/tmp1b
   ** Perfect gas law.
RHO1=IDEALGAS
DRH1DP=IDEALGAS
   ** Gas Constant   m/R
RHO1B=29./8305.6
 
    GROUP 11. Initialization of variable or porosity fields
FIINIT(P1)=3.0E5;FIINIT(H1)=9.0E5
 
    GROUP 13. Boundary conditions and special sources
   ** Cylinder Head
WALL (HEAD,LOW,1,NX,1,NY,1,1,1,LSTEP)
   ** Cylinder Wall
WALL (CYL,NORTH,1,NX,NY,NY,1,NZ,1,LSTEP)
   ** Piston Crown
WALL (PCR,HIGH,1,NX,1,NY,NZ,NZ,1,LSTEP)
   ** Exhaust port; atmospheric back pressure.
PATCH(EXH1,NORTH,1,1,NY,NY,NZ,NZ,1,70)
COVAL(EXH1,P1,1000.,1.0E5)
COVAL(EXH1,U1,ONLYMS,0.0)
COVAL(EXH1,V1,ONLYMS,0.0)
COVAL(EXH1,W1,ONLYMS,0.0)
COVAL(EXH1,H1,ONLYMS,SAME)
KNZ1=NZ-1
PATCH(EXH2,NORTH,1,1,NY,NY,KNZ1,KNZ1,3,67)
COVAL(EXH2,P1,1000.,1.0E5)
COVAL(EXH2,U1,ONLYMS,0.0)
COVAL(EXH2,V1,ONLYMS,0.0)
COVAL(EXH2,W1,ONLYMS,0.0)
COVAL(EXH2,H1,ONLYMS,SAME)
KNZ2=NZ-2
PATCH(EXH3,NORTH,1,1,NY,NY,KNZ2,KNZ2,7,63)
COVAL(EXH3,P1,1000.,1.0E5)
COVAL(EXH3,U1,ONLYMS,0.0)
COVAL(EXH3,V1,ONLYMS,0.0)
COVAL(EXH3,W1,ONLYMS,0.0)
COVAL(EXH3,H1,ONLYMS,SAME)
KNZ3=NZ-3
PATCH(EXH4,NORTH,1,1,NY,NY,KNZ3,KNZ3,14,56)
COVAL(EXH4,P1,1000.,1.0E5)
COVAL(EXH4,U1,ONLYMS,0.0)
COVAL(EXH4,V1,ONLYMS,0.0)
COVAL(EXH4,W1,ONLYMS,0.0)
COVAL(EXH4,H1,ONLYMS,SAME)
   ** Transfer port; patch TRA1-TRA3
PATCH(TRA1,NORTH,3,3,NY,NY,NZ,NZ,8,62)
COVAL(TRA1,P1,-3.14,1.4E5)
COVAL(TRA1,U1,ONLYMS,80.)
COVAL(TRA1,V1,ONLYMS,-140.)
COVAL(TRA1,W1,ONLYMS,-80.)
COVAL(TRA1,H1,ONLYMS,300000.)
PATCH(TRA2,NORTH,3,3,NY,NY,KNZ1,KNZ1,12,58)
COVAL(TRA2,P1,-3.14,1.4E5)
COVAL(TRA2,U1,ONLYMS,80.)
COVAL(TRA2,V1,ONLYMS,-140.)
COVAL(TRA2,W1,ONLYMS,-80.)
COVAL(TRA2,H1,ONLYMS,300000.)
PATCH(TRA3,NORTH,3,3,NY,NY,KNZ2,KNZ2,17,53)
COVAL(TRA3,P1,-3.14,1.4E5)
COVAL(TRA3,U1,ONLYMS,80.)
COVAL(TRA3,V1,ONLYMS,-140.)
COVAL(TRA3,W1,ONLYMS,-80.)
COVAL(TRA3,H1,ONLYMS,300000.)
 
    GROUP 15. Termination of sweeps
LSWEEP=10
RESREF(P1)=2.0E-4*VOLF
RESREF(W1)=0.2*RPS*RESREF(P1)
RESREF(U1)=RESREF(W1);RESREF(V1)=RESREF(W1)
RESREF(H1)=RESREF(P1)*300000.
 
    GROUP 16. Termination of iterations
LITER(P1)=10;LITER(U1)=1;LITER(V1)=1;LITER(W1)=1;LITER(H1)=5
 
    GROUP 17. Under-relaxation devices
RELAX(V1,FALSDT,5.E-3)
RELAX(W1,FALSDT,5.E-3)
RELAX(U1,FALSDT,5.E-3)
 
    GROUP 18. Limits on variables or increments to them
VARMIN(P1)=1.E4
 
    GROUP 19. Special calls from EARTH to GROUND
   ** Specification of moving grid for reciprocating engine.
W1AD=ZMOVE
IZW1=10
   ** Angular velocity
AZW1=RPS*PI*2.
   ** Crank radius
BZW1=.050
   ** Conrod centre distance/crank radius
CZW1=4.
SPEDAT(SET,GXMONI,TRANSIENT,L,F)
    GROUP 22. Spot-value print-out
NPRMON=100
IXMON=2;IYMON=3;IZMON=8
 
    GROUP 23. Field print-out and plot control
NYPRIN=NY/5;NZPRIN=NZ/5;NPRINT=LSWEEP;NTPRIN=5
XZPR=T;IYPRF=NY;IYPRL=NY
IPLTL=LSWEEP
PATCH(RVEL,PROFIL,1,4,3,3,9,9,1,LSTEP)
PLOT(RVEL,U1,0.0,0.0)
PATCH(YZ,CONTUR,1,1,1,4,1,10,1,LSTEP)
PLOT(YZ,H1,0.,20.0)
PATCH(TIMPLOT,PROFIL,1,1,3,3,9,9,1,LSTEP)
COVAL(TIMPLOT,P1,0.0,0.0);COVAL(TIMPLOT,H1,0.0,0.0)
 
  ***actdem***
idispa=10;csg1=p
tstswp=-1