69 CHARACTER(CHRLEN) :: RCSIdentString = &
70 '$RCSfile: PLAG_ModInjection.F90,v $ $Revision: 1.11 $'
110 itile,icg,burnstat, &
111 nvert,normdirflag,xyzvertex, &
112 fn,fc,cellheight,plagvolratio )
126 INTEGER,
INTENT(IN) :: burnstat,icg,itile,normdirflag,
nvert
128 REAL(RFREAL),
INTENT(IN) :: cellheight,plagvolratio
129 REAL(RFREAL),
DIMENSION(ZCOORD),
INTENT(IN) :: fc,fn
130 REAL(RFREAL),
DIMENSION(ZCOORD,4),
INTENT(IN) :: xyzvertex
132 TYPE(t_plag),
POINTER :: pplag
134 TYPE(t_region
),
POINTER :: pregion
140 INTEGER,
PARAMETER :: iter_cell_locate_max = 20
141 INTEGER :: icont,icvplagmass,icvtilemass,ipcl,ireg,itercelllocate, &
142 ncont,nextidnumber,npcls,npclsmax
143 INTEGER,
POINTER,
DIMENSION(:) :: pcvplagmass, pcvtilemass
144 INTEGER,
POINTER,
DIMENSION(:,:) :: paiv
146 LOGICAL :: celllocate
148 REAL(RFREAL) :: plagmomenrm,sxn,syn,szn,xloc,yloc,zloc
149 REAL(RFREAL),
DIMENSION(3) :: poolxyz
150 REAL(RFREAL),
POINTER,
DIMENSION(:,:) :: parv,pcvplag,pcvtile,pdvtile
157 rcsidentstring =
'$RCSfile: PLAG_ModInjection.F90,v $ $Revision: 1.11 $'
159 global => pregion%global
162 'PLAG_ModInjection.F90' )
169 pcvplagmass => pplag%cvPlagMass
173 pcvtile => ptileplag%cv
174 pcvtilemass => ptileplag%cvTileMass
175 pdvtile => ptileplag%dv
177 ireg = pregion%iRegionGlobal
178 ncont = pregion%plagInput%nCont
185 sxn = fn(xcoord) *normdirflag
186 syn = fn(ycoord) *normdirflag
187 szn = fn(zcoord) *normdirflag
193 pplag%nPcls = pplag%nPcls + 1
196 ptileplag%nPclsInjc(itile) = ptileplag%nPclsInjc(itile) + 1
203 npclsmax = pregion%plag%nPclsMax
205 IF ( npcls >= npclsmax )
THEN
206 WRITE(stdout,*)
' PLAG_EjectParticle: Datastructure Dimension Exceeded ',&
208 CALL
errorstop( global,err_plag_memoverflow,__line__ )
215 pplag%nextIdNumber = pplag%nextIdNumber + 1
216 nextidnumber = pplag%nextIdNumber
223 icvplagmass = pcvplagmass(icont)
224 icvtilemass = pcvtilemass(icont)
225 pcvplag(icvplagmass,ipcl) = pcvtile(icvtilemass,itile) *plagvolratio
228 pcvplag(cv_plag_ener,ipcl) = pcvtile(cv_tile_ener, itile) *plagvolratio
230 plagmomenrm = pcvtile(cv_tile_momnrm,itile) *plagvolratio
231 pcvplag(cv_plag_xmom,ipcl) = plagmomenrm*sxn
232 pcvplag(cv_plag_ymom,ipcl) = plagmomenrm*syn
233 pcvplag(cv_plag_zmom,ipcl) = plagmomenrm*szn
235 pcvplag(cv_plag_enervapor,ipcl) = 0._rfreal
248 fc(xcoord:zcoord),fn(xcoord:zcoord), &
251 xloc = poolxyz(xcoord)
252 yloc = poolxyz(ycoord)
253 zloc = poolxyz(zcoord)
269 IF (celllocate .EQV. .false.)
THEN
270 itercelllocate = itercelllocate+1
271 IF ( itercelllocate > iter_cell_locate_max )
THEN
272 WRITE(stdout,*)
' PLAG_EjectParticle: Unable to create a particle after ',&
273 iter_cell_locate_max,
' iterations'
275 CALL
errorstop( global,err_plag_cellindex,__line__ )
280 pcvplag(cv_plag_xpos,ipcl) = poolxyz(xcoord)
281 pcvplag(cv_plag_ypos,ipcl) = poolxyz(ycoord)
282 pcvplag(cv_plag_zpos,ipcl) = poolxyz(zcoord)
288 paiv(aiv_plag_pidini,ipcl) = nextidnumber
289 paiv(aiv_plag_regini,ipcl) = ireg
290 paiv(aiv_plag_icells,ipcl) = icg
291 paiv(aiv_plag_status,ipcl) = plag_status_keep
292 paiv(aiv_plag_burnstat,ipcl) = burnstat
294 parv(arv_plag_spload,ipcl) = pdvtile(dv_tile_spload,itile)
301 icvplagmass = pcvplagmass(icont)
302 icvtilemass = pcvtilemass(icont)
303 pcvtile(icvtilemass,itile) = pcvtile(icvtilemass, itile) - &
304 pdvtile(dv_tile_spload,itile) * &
305 pcvplag(icvplagmass,ipcl)
308 pcvtile(cv_tile_momnrm,itile) = pcvtile(cv_tile_momnrm,itile) - &
309 pdvtile(dv_tile_spload,itile) * &
312 pcvtile(cv_tile_ener ,itile) = pcvtile(cv_tile_ener ,itile) - &
313 pdvtile(dv_tile_spload,itile) * &
314 pcvplag(cv_plag_ener,ipcl)
355 facecentroid,snormal,cellheight,posplag )
367 INTEGER,
INTENT(IN) ::
nvert,normdirflag
369 REAL(RFREAL),
INTENT(IN) :: cellheight
370 REAL(RFREAL),
DIMENSION(ZCOORD),
INTENT(IN) :: facecentroid,snormal
371 REAL(RFREAL),
DIMENSION(ZCOORD,4),
INTENT(IN) :: xyzvertex
372 REAL(RFREAL),
DIMENSION(ZCOORD),
INTENT(OUT) :: posplag
374 TYPE(t_region
),
POINTER :: pregion
380 LOGICAL :: usetriangle1
382 REAL(RFREAL),
PARAMETER :: height_fraction = 1.0e-3_rfreal
383 REAL(RFREAL) :: areatriangle1,areatriangle2,xrand,xtrirand,yrand,zrand
384 REAL(RFREAL),
DIMENSION(ZCOORD) :: snormalinward, v1,v2
392 rcsidentstring =
'$RCSfile: PLAG_ModInjection.F90,v $ $Revision: 1.11 $'
394 global => pregion%global
397 'PLAG_ModInjection.F90' )
403 snormalinward(xcoord:zcoord) = normdirflag *snormal(xcoord:zcoord)
417 IF ( xrand+yrand > 1.0_rfreal )
THEN
418 xrand = 1.0_rfreal-xrand
419 yrand = 1.0_rfreal-yrand
422 zrand = 1.0_rfreal -(xrand+yrand)
435 usetriangle1 = .true.
443 v1(xcoord:zcoord) = xyzvertex(xcoord:zcoord,2) -xyzvertex(xcoord:zcoord,1)
444 v2(xcoord:zcoord) = xyzvertex(xcoord:zcoord,3) -xyzvertex(xcoord:zcoord,1)
446 areatriangle1 = 0.5_rfreal*abs( snormal(xcoord)*(v1(2)*v2(3)-v1(3)*v2(2)) &
447 + snormal(ycoord)*(v1(3)*v2(1)-v1(1)*v2(3)) &
448 + snormal(zcoord)*(v1(1)*v2(2)-v1(2)*v2(1)) )
450 v1(xcoord:zcoord) = xyzvertex(xcoord:zcoord,3) -xyzvertex(xcoord:zcoord,1)
451 v2(xcoord:zcoord) = xyzvertex(xcoord:zcoord,4) -xyzvertex(xcoord:zcoord,1)
453 areatriangle2 = 0.5_rfreal*abs( snormal(xcoord)*(v1(2)*v2(3)-v1(3)*v2(2)) &
454 + snormal(ycoord)*(v1(3)*v2(1)-v1(1)*v2(3)) &
455 + snormal(zcoord)*(v1(1)*v2(2)-v1(2)*v2(1)) )
461 usetriangle1 = ( (areatriangle1+areatriangle2)*xtrirand < areatriangle1 )
468 IF ( usetriangle1 )
THEN
469 posplag(xcoord:zcoord) = xrand*xyzvertex(xcoord:zcoord,1) &
470 + yrand*xyzvertex(xcoord:zcoord,2) &
471 + zrand*xyzvertex(xcoord:zcoord,3)
473 posplag(xcoord:zcoord) = xrand*xyzvertex(xcoord:zcoord,1) &
474 + yrand*xyzvertex(xcoord:zcoord,3) &
475 + zrand*xyzvertex(xcoord:zcoord,4)
482 posplag(xcoord:zcoord) = posplag(xcoord:zcoord) &
484 facecentroid(xcoord:zcoord), &
485 snormalinward(xcoord:zcoord)) &
486 * snormalinward(xcoord:zcoord)
492 posplag(xcoord:zcoord) = posplag(xcoord:zcoord) &
493 + height_fraction*cellheight &
494 *snormalinward(xcoord:zcoord)
536 itile,icg,burnstat,
nvert, &
537 normdirflag,xyzvertex, &
538 volmeanpart,fn,fc,cellheight )
548 INTEGER,
INTENT(IN) :: burnstat,icg,itile,normdirflag,
nvert
550 REAL(RFREAL),
INTENT(IN) :: cellheight,volmeanpart
551 REAL(RFREAL),
DIMENSION(ZCOORD),
INTENT(IN) :: fc,fn
552 REAL(RFREAL),
DIMENSION(ZCOORD,4),
INTENT(IN) :: xyzvertex
554 TYPE(t_region
),
POINTER :: pregion
555 TYPE(t_plag),
POINTER :: pplag
562 INTEGER :: injcdiamdist
563 INTEGER,
POINTER,
DIMENSION(:) :: pcvplagmass, pcvtilemass
567 REAL(RFREAL) :: injcbeta,
pi,plagvolratio,poolvolsum,tinjccoeff,tinjcsum
568 REAL(RFREAL),
POINTER,
DIMENSION(:,:) :: pcvtile,pdvtile
576 rcsidentstring =
'$RCSfile: PLAG_ModInjection.F90,v $ $Revision: 1.11 $'
578 global => pregion%global
581 'PLAG_ModInjection.F90' )
587 pcvtile => ptileplag%cv
588 pcvtilemass => ptileplag%cvTileMass
589 pdvtile => ptileplag%dv
591 injcdiamdist = pregion%plagInput%injcDiamDist
592 injcbeta = pregion%plagInput%injcBeta
598 poolvolsum =
sum( pcvtile( pcvtilemass(:),itile ) / &
599 pregion%plagInput%dens(:) )
601 pdvtile(dv_tile_poolvold,itile) = poolvolsum
603 tinjccoeff = injcbeta *volmeanpart
605 tinjcsum = 0.0_rfreal
608 tinjccoeff,tinjcsum,poolvolsum, &
609 injectq,plagvolratio )
633 itile,icg,burnstat, &
634 nvert,normdirflag,xyzvertex, &
635 fn,fc,cellheight,plagvolratio )
642 pdvtile(dv_tile_diam, itile), &
643 pdvtile(dv_tile_spload,itile) )
650 tinjccoeff,tinjcsum,poolvolsum, &
651 injectq,plagvolratio )
696 itile,icg,burnstat,
nvert, &
697 normdirflag,xyzvertex, &
698 volmeanpart,fn,fc,cellheight )
708 INTEGER,
INTENT(IN) :: burnstat,icg,itile,normdirflag,
nvert
710 REAL(RFREAL),
INTENT(IN) :: cellheight,volmeanpart
711 REAL(RFREAL),
DIMENSION(ZCOORD),
INTENT(IN) :: fc,fn
712 REAL(RFREAL),
DIMENSION(ZCOORD,4),
INTENT(IN) :: xyzvertex
714 TYPE(t_region
),
POINTER :: pregion
715 TYPE(t_plag),
POINTER :: pplag
722 INTEGER :: ejecmodel,injcdiamdist
723 INTEGER,
POINTER,
DIMENSION(:) :: pcvplagmass, pcvtilemass
725 REAL(RFREAL) :: injcbeta,
pi,plagvolratio,poolvolsum,tinjccoeff,tinjcsum
726 REAL(RFREAL) :: meansuperparticlevolume, spload
727 REAL(RFREAL) :: injcbetafac, injcbetafacinv
728 REAL(RFREAL) :: poolvololdsum, poolvolfinal, remainingvolume
729 REAL(RFREAL) :: currentsuperparticlevolume, poolvolume
730 REAL(RFREAL) :: poolexcess, pexcesss, possibleexcess
731 REAL(RFREAL) :: countdown, countdownnext, deltavolume, randunif
732 REAL(RFREAL) :: currentparticlevolume
733 REAL(RFREAL) :: poolvolcurr
734 REAL(RFREAL),
POINTER,
DIMENSION(:,:) :: pcvtile,pcvoldtile,pdvtile
742 rcsidentstring =
'$RCSfile: PLAG_ModInjection.F90,v $ $Revision: 1.11 $'
744 global => pregion%global
747 'PLAG_ModInjection.F90' )
753 pcvtile => ptileplag%cv
754 pcvoldtile => ptileplag%cvOld
755 pcvtilemass => ptileplag%cvTileMass
756 pdvtile => ptileplag%dv
759 injcdiamdist = pregion%plagInput%injcDiamDist
760 injcbeta = pregion%plagInput%injcBeta
763 spload = pregion%plagInput%spload
764 meansuperparticlevolume = volmeanpart *spload
766 injcbetafac = 2.0_rfreal *injcbeta *meansuperparticlevolume**2
767 injcbetafacinv = 1.0_rfreal/injcbetafac
777 poolvolsum =
sum( pcvtile( pcvtilemass(:),itile ) / &
778 pregion%plagInput%dens(:) )
784 poolvololdsum =
sum( pcvoldtile( pcvtilemass(:),itile ) / &
785 pregion%plagInput%dens(:) )
792 poolvolume = poolvololdsum
799 poolvolfinal = poolvolsum
806 poolvolcurr = poolvolsum
813 remainingvolume = poolvolsum -poolvololdsum
830 currentsuperparticlevolume =
pi/6.0_rfreal *spload &
831 * pdvtile(dv_tile_diam,itile)**3.0_rfreal
833 currentparticlevolume =
pi/6.0_rfreal &
834 * pdvtile(dv_tile_diam,itile)**3.0_rfreal
843 poolexcess = poolvolcurr -currentsuperparticlevolume
851 possibleexcess = poolexcess + remainingvolume
857 IF ( poolexcess > 0.0_rfreal )
THEN
858 pexcesss = poolexcess**2
860 pexcesss = 0.0_rfreal
868 countdown = pdvtile(dv_tile_countdown,itile)
874 IF ( possibleexcess > 0.0_rfreal )
THEN
875 countdownnext = countdown + injcbetafacinv &
876 * (pexcesss -possibleexcess**2.0_rfreal)
878 countdownnext = countdown
890 IF ( countdownnext> 0.0_rfreal )
THEN
891 poolvolume = poolvolume + remainingvolume
892 pdvtile(dv_tile_countdown,itile) = countdownnext
909 deltavolume =
sqrt(injcbetafac*countdown +pexcesss) -poolexcess
914 poolvolume = poolvolume +deltavolume -currentsuperparticlevolume
918 remainingvolume = remainingvolume -deltavolume
924 plagvolratio = currentparticlevolume / poolvolfinal
928 poolvolfinal = poolvolfinal -currentsuperparticlevolume
935 itile,icg,burnstat, &
936 nvert,normdirflag,xyzvertex, &
937 fn,fc,cellheight,plagvolratio )
944 pdvtile(dv_tile_diam, itile), &
945 pdvtile(dv_tile_spload,itile) )
952 poolvolcurr =
sum( pcvtile( pcvtilemass(:),itile ) / &
953 pregion%plagInput%dens(:) )
963 IF ( randunif <= 0.0_rfreal)
THEN
965 pdvtile(dv_tile_countdown,itile) = 50.0_rfreal
967 pdvtile(dv_tile_countdown,itile) = -log(randunif)
977 IF ( abs(poolvolume - poolvolfinal) / poolvolfinal > 1.0e-10_rfreal) &
978 print*,
'CRE check: iTile ', itile,(poolvolume - poolvolfinal) / poolvolfinal
Tfloat sum() const
Return the sum of all the pixel values in an image.
subroutine, public plag_ejectparticle(pRegion, pPlag, pTilePlag, iTile, icg, burnStat, nVert, normDirFlag, xyzVertex, fn, fc, cellHeight, plagVolRatio)
subroutine, public plag_invokeejecmodel1(pRegion, pPlag, pTilePlag, iTile, icg, burnStat, nVert, normDirFlag, xyzVertex, volMeanPart, fn, fc, cellHeight)
subroutine plag_injcsetinjection(region, pTilePlag, iTile, tCoeff, tSum, poolVol, injectQ, ratio)
subroutine registerfunction(global, funName, fileName)
subroutine plag_injcmakeparticle(region, injcDiamDist, diam, spLoad)
REAL(RFREAL) function rand1uniform(rdata)
subroutine plag_injcsetpoolpos(pRegion, nVert, normDirFlag, xyzVertex, faceCentroid, sNormal, cellHeight, posPlag)
LOGICAL function, public rflu_ict_testincell(pRegion, xLoc, yLoc, zLoc, icg)
subroutine errorstop(global, errorCode, errorLine, addMessage)
long double dot_product(pnt vec1, pnt vec2)
subroutine deregisterfunction(global)
subroutine, public plag_invokeconsrandejec(pRegion, pPlag, pTilePlag, iTile, icg, burnStat, nVert, normDirFlag, xyzVertex, volMeanPart, fn, fc, cellHeight)