#cls
text(3D heating spiral: 768)
title
libref=768

  DISPLAY

  This case exemplifies the setting of sources in In-Form objects. 

  It concerns the temperature of water flowing within a
  cylindrical vessel which contains a spiral heating element.

  The spiral is an In-Form object formed by use of the SPHERE
  function with the cartesian x, y and coordinates of the sphere 
  centre varying with the angular coordinate xg of the
  cylindrical-polar co-ordinate system (CARTES=F), as follows

  (INFOB at PATCH1 is SPHERE(1+.5*sin(xg),1+.5*cos(xg),1+.5*xg,$
  .2)+SPHERE(1+.5*sin(xg),1+.5*cos(xg),4.14+.5*xg,.2) with INFOB_1)

  Two SPHERE functions are used because two turns of the spiral are 
  required.
  
  The following formula sets a heat source: 
  char(heatfl)
  heatfl=2000.
  (SOURCE of TEM1 at PATCH1 is :heatfl: with INFOB_1)

  The flow resistance exerted by the spiral is represented by a momentum
  source as follows:
  
  char(uresis,vresis,wresis)
  uresis=-1000.*VABS*VOL*U1
  vresis=-1000.*VABS*VOL*V1
  wresis=-1000.*VABS*VOL*W1
  (SOURCE of U1 at PATCH1 is :uresis: with LINE!INFOB_1)
  (SOURCE of V1 at PATCH1 is :vresis: with LINE!INFOB_1)
  (SOURCE of W1 at PATCH1 is :wresis: with LINE!INFOB_1)

  The following formulae defines MARK variable.
  MARK is used by PHOTON for marks of borders of a spiral.

  (INITIAL of MARK at PATCH1 is 1. with INFOB_1)

  In addition this example illustrates how RESIDUALS and CORRECTIONS
  can be stored with In-Form using.

  First declare 3D storage of TRES and TCOR variables in which 
  residuals and corrections values will be saved.

  STORE(TRES,TCOR)

  Then store residuals of temperature in TRES by the statement:

  (STORED of TRES is RESI(TEM1))

  Then store temperature corrections in TCOR by the statement:

  (STORED of TCOR is CORR(TEM1))

  The Q1 contains PHOTON USE commands    
  ENDDIS  
    GROUP 1. Run title and other preliminaries
TEXT(3D heating spiral: 768
    GROUP 3. X-direction grid specification
CARTES=F;GRDPWR(X,40,6.28,1.0)
    GROUP 4. Y-direction grid specification
GRDPWR(Y,40,1.,1.0)
    GROUP 5. Z-direction grid specification
GRDPWR(Z,40,8.,1.0)
    GROUP 7. Variables stored, solved & named
NAME(150) =TEM1
SOLUTN(P1,Y,Y,Y,N,N,Y)
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(TEM1,Y,Y,Y,N,N,Y)
STORE(MARK)
  The square root of symmetrically-computed velocity-squared quantity
STORE(VABS)
  
  *** The next In-Form statements store residuals
      and corrections of temperature
STORE(TRES,TCOR)
  INFORM7BEGIN
      The storage residuals of temperature in TRES
(STORED of TRES is RESI(TEM1))

      The storage corrections of temperature in TCOR
(STORED of TCOR is CORR(TEM1))
  INFORM7END

    GROUP 9. Properties of the medium (or media)
RHO1=9.9823E+02
PRESS0=1.E+05
TEMP0=2.73E+02
CP1=4.1818E+03
ENUL=1.006E-06
ENUT=0.
DVO1DT=1.18E-04
PRNDTL(TEM1)=-5.97E-01
    GROUP 11. Initialization of variable or porosity fields
INIADD=F; FIINIT(MARK)=0.0; FIINIT(TEM1)=0.

  *** Patch for heating spiral
PATCH(PATCH1,CELL,1,NX,1,NY,1,NZ,1,LSTEP)
  INFORM11BEGIN
  *** In-Form formula describes a spiral:
  It is required to create a spiral with two coils.

  The SPHERE(xce,yce,zce,radius) function creates In-Form object
  with the sphere shape where radius is a sphere radius (radius is
  equal 0.2 for this case) and xce, yce and zce are constants
  describing in X, Y and Z coordinates of the sphere center
  in a own local cartesian coordinates system.

  For cartesian examples this coordinates system coincides with
  coordinates system of domain. But they differ for polar cases.
  The local system is located so the XY plane of a polar coordinate
  system lies in positive part of the XY plane of the local
  cartesian system. Thus the origin of a local system will be
  always outside of the polar domain and X and Y the coordinates
  of the origin of the polar system will be equal YVLAST + RINNER
  in the local system. For this case they are equal 1.
  The Z coodinates of oridins and the directions of Z axes of both
  coordinate systems coincide with one another.
 
  If coordinates of the sphere centre will depend upon current
  coordinates of cells of the domain then the sphere will be moved
  inside the domain.

  To create In-Form object with the ring shape it is enough to
  define X and Y coordinates of the sphere centre by the following
  formulas

  SPHERE(1+.5*sin(xg),1+.5*cos(xg), 1. , 0.2 )

  where 1 is the coordinates of the origin of the polar system,
  .5 is a radius of a circle on which the sphere will be moved
  and xg is current X polar coordinate of cell cetnre in radians.
  The Z coordinate will constant and be equal for example 1.

  For creation of In-Form object with the spiral shape the Z
  coordinate of the sphere center should depend upon cells
  coordinates also. Thus for creation of the spiral is offered
  to use following formula for the calculation of Z coordinates
  of the sphere centre:
 
     1+.5*xg

  where 1 is Z coordinate of the start point of the spiral.
  The Z coordinate of the final point of the spiral will be

     1+.5*XULAST=1+.5*6.28=4.13

  The complete In-Form statement will look as

  (INFOB at PATCH1 is SPHERE(1+.5*sin(xg),1+.5*cos(xg),1+.5*xg,.2)
        with INFOB_1)

  Thus the spiral with one coil will be created. The additional
  In-Form statement is required for creation of the second spiral
  coil. That they were connected without a break the Z coordinate
  of the starting point of the second coil should be equal for
  the Z coordinate of the final point of the first coil. In this
  case Z coordinate will be calculated by the next formula

     4.14+.5*xg

  Thus the In-Form object with shape of the spiral with two coits
  can be created by following two In-Form statements

  (INFOB at PATCH1 is SPHERE(1+.5*sin(xg),1+.5*cos(xg),1+.5*xg,.2)
        with INFOB_1)

  (INFOB at PATCH1 is SPHERE(1+.5*sin(xg),1+.5*cos(xg),4.14+.5*xg,
        .2) with INFOB_1)

  Moreover they can be incorporated into one statement thus:

(INFOB at PATCH1 is SPHERE(1+.5*sin(xg),1+.5*cos(xg),1+.5*xg,$
.2)+SPHERE(1+.5*sin(xg),1+.5*cos(xg),4.14+.5*xg,.2) with INFOB_1)
  
  *** Setting of MARK values into spiral
(INITIAL of MARK at PATCH1 is 1. with INFOB_1)
  INFORM11END
    GROUP 13. Boundary conditions and special sources
PATCH(INLET,LOW,1,NX,1,NY,1,1,1,LSTEP)
COVAL(INLET,P1,FIXFLU,9.9823)
COVAL(INLET,U1,ONLYMS,0.)
COVAL(INLET,V1,ONLYMS,0.)
COVAL(INLET,W1,ONLYMS,.01)
COVAL(INLET,TEM1,ONLYMS,0.)
 
PATCH(OUTLET,HIGH,1,NX,1,NY,NZ,NZ,1,LSTEP)
COVAL(OUTLET,P1,1000.,0.)
COVAL(OUTLET,TEM1,0.,SAME)
 
PATCH(WALLN,NWALL,1,NX,NY,NY,1,NZ,1,LSTEP)
COVAL(WALLN,U1,1.,0.)
COVAL(WALLN,W1,1.,0.)
  INFORM13BEGIN
  *** Heat source inside heating spiral 
char(heatfl); heatfl=2000.
(SOURCE of TEM1 at PATCH1 is :heatfl: with INFOB_1)

  *** Resistance inside spiral
char(uresis,vresis,wresis)
uresis=-1000.*VABS*VOL*U1
vresis=-1000.*VABS*VOL*V1
wresis=-1000.*VABS*VOL*W1
(SOURCE of U1 at PATCH1 is :uresis: with LINE!INFOB_1)
(SOURCE of V1 at PATCH1 is :vresis: with LINE!INFOB_1)
(SOURCE of W1 at PATCH1 is :wresis: with LINE!INFOB_1)
  INFORM13END

    GROUP 15. Termination of sweeps
LSWEEP=100
    GROUP 17. Relaxation
    GROUP 18. Limits
VARMIN(TEM1)=0.
    GROUP 19. Data transmitted to ground
ISG62 = 0
    GROUP 21. Print-out of Variables
OUTPUT(P1,Y,Y,Y,N,Y,Y)
OUTPUT(U1,Y,Y,Y,N,Y,Y)
OUTPUT(V1,Y,Y,Y,N,Y,Y)
OUTPUT(W1,Y,Y,Y,N,Y,Y)
OUTPUT(TEM1,Y,N,Y,Y,Y,Y)
    GROUP 22. Spot-value print-out
NPRMON=LSWEEP;IXMON=NX/4+1;IYMON=NY/4+1;IZMON=NZ/4+1
    GROUP 23. Print-out & plot control
TSTSWP=-1
libref=768
DISTIL=T
EX(P1)=2.545E-02; EX(U1)=1.398E-04; EX(V1)=1.123E-04
EX(W1)=1.006E-02; EX(TCOR)=1.262E-02; EX(TRES)=2.509E-01
EX(MARK)=3.159E-02; EX(TEM1)=1.660E+01; EX(VABS)=1.006E-02
  
  In-Form debug commands
  infrbegin
  debug f
  formula t
  stored t
  infrend
  
  PHOTON USE
  p



  up z
  gr ou y m
  ve x 1 sh
  ve x 20 sh
  msg Please wait
  surf mark x 0.99
  surf mark z 0.99
  msg Velocity vectors
  msg Press  to continue
  pause
  ve cl
  con p1 x 1 fil;.01
  con p1 x 20 fil;.01
  red
  msg Pressure contours
  msg Press  to continue
  pause
  con cl
  con tem1 x 1 fil;.01
  con tem1 x 20 fil;.01
  red
  msg Temperature contours
  pause
  con cl
  con tres x 1 fil;.01
  con tres x 20 fil;.01
  red
  msg Residuals of temperature contours
  pause
  con cl
  con tcor x 1 fil;.01
  con tcor x 20 fil;.01
  red
  msg Corrections of temperature contours
  pause
  con cl
  do izz=1,40,8
  con tem1 iz izz fi;0.001
  enddo
  ENDUSE
STOP