MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
particlemodule Module Reference

Data Types

type  particletype
 Particle tracked by the PRT model. More...
type  particlestoretype
 Structure of arrays to store particles. More...

Enumerations

enum  {
  active = 1 , term_boundary = 2 , term_weaksink = 3 , term_no_exits = 5 ,
  term_stopzone = 6 , term_inactive = 7 , term_unreleased = 8 , term_no_exits_sub = 9 ,
  term_timeout = 10
}
 Particle status enumeration. More...

Functions/Subroutines

subroutine create_particle (particle)
 Create a new particle.
subroutine create_particle_store (store, np, mempath)
 Allocate particle store.
subroutine destroy (this, mempath)
 Destroy particle store after use.
subroutine destroy_particle (particle)
 Destroy a particle after use.
subroutine resize (this, np, mempath)
 Reallocate particle storage to the given size.
subroutine get (this, particle, imdl, iprp, ip)
 Load a particle from the particle store.
subroutine put (this, particle, ip)
 Save a particle's state to the particle store.
subroutine copy_from (this, source)
 Copy all particle state from source to this store.
subroutine transform_coords (this, xorigin, yorigin, zorigin, sinrot, cosrot, invert)
 Transform particle coordinates.
subroutine reset_transform (this)
 Reset particle coordinate transformation properties.
subroutine get_model_coords (this, x, y, z)
 Return the particle's model coordinates, inverting any applied transformation if needed. The particle's state is not altered.
integer function num_stored (this)
 Return the number of particles.
character(len=:) function, allocatable get_id (this)
 Get a string identifier for the particle.

Variables

integer, parameter max_level = 4
 Tracking "levels" defined in method modules. Currently only 3 used.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Particles begin in status 1 (active) at release time. Status may only increase over time. Status values greater than one imply termination. A particle may terminate for several reasons, all mutually exclusive. A particle's final tracking status will always be greater than one.

Status codes 1-3 and 5-8 correspond directly to MODPATH 7 status codes. Code 4 does not apply to PRT because PRT does not distinguish forwards from backwards tracking. Status code 9 provides more specific, subcell- level information about a particle which terminates due to no outflow. Code 10 distinguishes particles which have "timed out" upon reaching a user-specified stop time or the end of the simulation.

Enumerator
active 
term_boundary 

terminated at a boundary face

term_weaksink 

terminated in a weak sink cell

term_no_exits 

terminated in a cell with no exit face

term_stopzone 

terminated in a cell with a stop zone number

term_inactive 

terminated in an inactive cell

term_unreleased 

terminated permanently unreleased

term_no_exits_sub 

terminated in a subcell with no exit face

term_timeout 

terminated at stop time or end of simulation

Definition at line 31 of file Particle.f90.

Function/Subroutine Documentation

◆ copy_from()

subroutine particlemodule::copy_from ( class(particlestoretype), intent(inout) this,
class(particlestoretype), intent(in) source )
private

This store must be at least as large as the source. Particles are copied to the first sourcenum_stored() slots. Any slots after that are left as they are.

Definition at line 367 of file Particle.f90.

368 ! dummy
369 class(ParticleStoreType), intent(inout) :: this
370 class(ParticleStoreType), intent(in) :: source
371 ! local
372 integer(I4B) :: np
373
374 np = source%num_stored()
375
376 if (this%num_stored() < np) then
377 write (errmsg, '(a,i0,a,i0,a)') &
378 'Cannot copy particle store, destination too small (source=', &
379 np, ', dest=', this%num_stored(), ')'
380 call pstop(1, errmsg)
381 end if
382
383 this%name(1:np) = source%name(:)
384 this%imdl(1:np) = source%imdl(:)
385 this%iprp(1:np) = source%iprp(:)
386 this%irpt(1:np) = source%irpt(:)
387 this%extend(1:np) = source%extend(:)
388 this%frctrn(1:np) = source%frctrn(:)
389 this%istopweaksink(1:np) = source%istopweaksink(:)
390 this%istopzone(1:np) = source%istopzone(:)
391 this%idrymeth(1:np) = source%idrymeth(:)
392 this%iexmeth(1:np) = source%iexmeth(:)
393 this%icycwin(1:np) = source%icycwin(:)
394 this%extol(1:np) = source%extol(:)
395 this%itrdomain(1:np, :) = source%itrdomain(:, :)
396 this%iboundary(1:np, :) = source%iboundary(:, :)
397 this%icu(1:np) = source%icu(:)
398 this%ilay(1:np) = source%ilay(:)
399 this%izone(1:np) = source%izone(:)
400 this%istatus(1:np) = source%istatus(:)
401 this%x(1:np) = source%x(:)
402 this%y(1:np) = source%y(:)
403 this%z(1:np) = source%z(:)
404 this%trelease(1:np) = source%trelease(:)
405 this%tstop(1:np) = source%tstop(:)
406 this%ttrack(1:np) = source%ttrack(:)
Here is the call graph for this function:

◆ create_particle()

subroutine particlemodule::create_particle ( type(particletype), pointer particle)

Definition at line 165 of file Particle.f90.

166 type(ParticleType), pointer :: particle !< particle
167 allocate (particle)
168 allocate (particle%history)
Here is the caller graph for this function:

◆ create_particle_store()

subroutine particlemodule::create_particle_store ( type(particlestoretype), pointer store,
integer(i4b), intent(in) np,
character(*), intent(in) mempath )
private
Parameters
[in]npnumber of particles
[in]mempathpath to memory

Definition at line 172 of file Particle.f90.

173 type(ParticleStoreType), pointer :: store !< store
174 integer(I4B), intent(in) :: np !< number of particles
175 character(*), intent(in) :: mempath !< path to memory
176
177 allocate (store)
178 call mem_allocate(store%imdl, np, 'PLIMDL', mempath)
179 call mem_allocate(store%irpt, np, 'PLIRPT', mempath)
180 call mem_allocate(store%iprp, np, 'PLIPRP', mempath)
181 call mem_allocate(store%name, lenboundname, np, 'PLNAME', mempath)
182 call mem_allocate(store%icu, np, 'PLICU', mempath)
183 call mem_allocate(store%ilay, np, 'PLILAY', mempath)
184 call mem_allocate(store%izone, np, 'PLIZONE', mempath)
185 call mem_allocate(store%istatus, np, 'PLISTATUS', mempath)
186 call mem_allocate(store%x, np, 'PLX', mempath)
187 call mem_allocate(store%y, np, 'PLY', mempath)
188 call mem_allocate(store%z, np, 'PLZ', mempath)
189 call mem_allocate(store%trelease, np, 'PLTRELEASE', mempath)
190 call mem_allocate(store%tstop, np, 'PLTSTOP', mempath)
191 call mem_allocate(store%ttrack, np, 'PLTTRACK', mempath)
192 call mem_allocate(store%istopweaksink, np, 'PLISTOPWEAKSINK', mempath)
193 call mem_allocate(store%istopzone, np, 'PLISTOPZONE', mempath)
194 call mem_allocate(store%idrymeth, np, 'PLIDRYMETH', mempath)
195 call mem_allocate(store%frctrn, np, 'PLFRCTRN', mempath)
196 call mem_allocate(store%iexmeth, np, 'PLIEXMETH', mempath)
197 call mem_allocate(store%extol, np, 'PLEXTOL', mempath)
198 call mem_allocate(store%extend, np, 'PLEXTEND', mempath)
199 call mem_allocate(store%icycwin, np, 'PLICYCWIN', mempath)
200 call mem_allocate(store%itrdomain, np, max_level, 'PLIDOMAIN', mempath)
201 call mem_allocate(store%iboundary, np, max_level, 'PLIBOUNDARY', mempath)
Here is the caller graph for this function:

◆ destroy()

subroutine particlemodule::destroy ( class(particlestoretype), intent(inout) this,
character(*), intent(in) mempath )
private
Parameters
[in,out]thisstore
[in]mempathpath to memory

Definition at line 205 of file Particle.f90.

206 class(ParticleStoreType), intent(inout) :: this !< store
207 character(*), intent(in) :: mempath !< path to memory
208
209 call mem_deallocate(this%imdl, 'PLIMDL', mempath)
210 call mem_deallocate(this%iprp, 'PLIPRP', mempath)
211 call mem_deallocate(this%irpt, 'PLIRPT', mempath)
212 call mem_deallocate(this%name, 'PLNAME', mempath)
213 call mem_deallocate(this%icu, 'PLICU', mempath)
214 call mem_deallocate(this%ilay, 'PLILAY', mempath)
215 call mem_deallocate(this%izone, 'PLIZONE', mempath)
216 call mem_deallocate(this%istatus, 'PLISTATUS', mempath)
217 call mem_deallocate(this%x, 'PLX', mempath)
218 call mem_deallocate(this%y, 'PLY', mempath)
219 call mem_deallocate(this%z, 'PLZ', mempath)
220 call mem_deallocate(this%trelease, 'PLTRELEASE', mempath)
221 call mem_deallocate(this%tstop, 'PLTSTOP', mempath)
222 call mem_deallocate(this%ttrack, 'PLTTRACK', mempath)
223 call mem_deallocate(this%istopweaksink, 'PLISTOPWEAKSINK', mempath)
224 call mem_deallocate(this%istopzone, 'PLISTOPZONE', mempath)
225 call mem_deallocate(this%idrymeth, 'PLIDRYMETH', mempath)
226 call mem_deallocate(this%frctrn, 'PLFRCTRN', mempath)
227 call mem_deallocate(this%iexmeth, 'PLIEXMETH', mempath)
228 call mem_deallocate(this%extol, 'PLEXTOL', mempath)
229 call mem_deallocate(this%extend, 'PLEXTEND', mempath)
230 call mem_deallocate(this%icycwin, 'PLICYCWIN', mempath)
231 call mem_deallocate(this%itrdomain, 'PLIDOMAIN', mempath)
232 call mem_deallocate(this%iboundary, 'PLIBOUNDARY', mempath)

◆ destroy_particle()

subroutine particlemodule::destroy_particle ( class(particletype), intent(inout) particle)
private

Definition at line 236 of file Particle.f90.

237 class(ParticleType), intent(inout) :: particle !< particle
238 deallocate (particle%history)

◆ get()

subroutine particlemodule::get ( class(particlestoretype), intent(inout) this,
class(particletype), intent(inout) particle,
integer(i4b), intent(in) imdl,
integer(i4b), intent(in) iprp,
integer(i4b), intent(in) ip )
private

This routine is used to initialize a particle for tracking. The advancing flag and coordinate transformation are reset.

Parameters
[in,out]thisparticle store
[in]imdlindex of model particle originated in
[in]iprpindex of particle release package particle originated in
[in]ipindex into the particle list

Definition at line 283 of file Particle.f90.

284 class(ParticleStoreType), intent(inout) :: this !< particle store
285 class(ParticleType), intent(inout) :: particle !< particle
286 integer(I4B), intent(in) :: imdl !< index of model particle originated in
287 integer(I4B), intent(in) :: iprp !< index of particle release package particle originated in
288 integer(I4B), intent(in) :: ip !< index into the particle list
289
290 call particle%reset_transform()
291 call particle%history%Clear()
292 particle%imdl = imdl
293 particle%iprp = iprp
294 particle%irpt = this%irpt(ip)
295 particle%ip = ip
296 particle%name = this%name(ip)
297 particle%istopweaksink = this%istopweaksink(ip)
298 particle%istopzone = this%istopzone(ip)
299 particle%idrymeth = this%idrymeth(ip)
300 particle%icu = this%icu(ip)
301 particle%ilay = this%ilay(ip)
302 particle%izone = this%izone(ip)
303 particle%istatus = this%istatus(ip)
304 particle%x = this%x(ip)
305 particle%y = this%y(ip)
306 particle%z = this%z(ip)
307 particle%trelease = this%trelease(ip)
308 particle%tstop = this%tstop(ip)
309 particle%ttrack = this%ttrack(ip)
310 particle%advancing = .true.
311 particle%itrdomain(1:max_level) = &
312 this%itrdomain(ip, 1:max_level)
313 particle%itrdomain(1) = imdl
314 particle%iboundary(1:max_level) = &
315 this%iboundary(ip, 1:max_level)
316 particle%frctrn = this%frctrn(ip)
317 particle%iexmeth = this%iexmeth(ip)
318 particle%extol = this%extol(ip)
319 particle%extend = this%extend(ip)
320 particle%icycwin = this%icycwin(ip)

◆ get_id()

character(len=:) function, allocatable particlemodule::get_id ( class(particletype), intent(in) this)
private

Definition at line 485 of file Particle.f90.

486 class(ParticleType), intent(in) :: this
487 character(len=:), allocatable :: str
488 ! local
489 character(len=LINELENGTH) :: temp
490
491 write (temp, '(I0,1a,I0,1a,I0,1a,G0)') &
492 this%imdl, this%iprp, this%irpt, this%trelease
493 str = trim(adjustl(temp))

◆ get_model_coords()

subroutine particlemodule::get_model_coords ( class(particletype), intent(in) this,
real(dp), intent(out) x,
real(dp), intent(out) y,
real(dp), intent(out) z )
private
Parameters
[in]thisparticle
[out]xx coordinate
[out]yy coordinate
[out]zz coordinate

Definition at line 460 of file Particle.f90.

462 class(ParticleType), intent(in) :: this !< particle
463 real(DP), intent(out) :: x !< x coordinate
464 real(DP), intent(out) :: y !< y coordinate
465 real(DP), intent(out) :: z !< z coordinate
466
467 if (this%transformed) then
468 call transform(this%x, this%y, this%z, x, y, z, &
469 this%xorigin, this%yorigin, this%zorigin, &
470 this%sinrot, this%cosrot, invert=.true.)
471 else
472 x = this%x
473 y = this%y
474 z = this%z
475 end if
subroutine, public transform(xin, yin, zin, xout, yout, zout, xorigin, yorigin, zorigin, sinrot, cosrot, invert)
Apply a 3D translation and optional 2D rotation to coordinates.
Definition GeomUtil.f90:192
subroutine, public compose(xorigin, yorigin, zorigin, sinrot, cosrot, xorigin_new, yorigin_new, zorigin_new, sinrot_new, cosrot_new, invert)
Compose an affine transform onto an existing one, or remove (invert) it.
Definition GeomUtil.f90:252
Here is the call graph for this function:

◆ num_stored()

integer function particlemodule::num_stored ( class(particlestoretype) this)
private

Definition at line 479 of file Particle.f90.

480 class(ParticleStoreType) :: this
481 n = size(this%imdl)

◆ put()

subroutine particlemodule::put ( class(particlestoretype), intent(inout) this,
class(particletype), intent(in) particle,
integer(i4b), intent(in) ip )
private
Parameters
[in,out]thisparticle storage
[in]ipparticle index

Definition at line 324 of file Particle.f90.

325 class(ParticleStoreType), intent(inout) :: this !< particle storage
326 class(ParticleType), intent(in) :: particle !< particle
327 integer(I4B), intent(in) :: ip !< particle index
328
329 this%imdl(ip) = particle%imdl
330 this%iprp(ip) = particle%iprp
331 this%irpt(ip) = particle%irpt
332 this%name(ip) = particle%name
333 this%istopweaksink(ip) = particle%istopweaksink
334 this%istopzone(ip) = particle%istopzone
335 this%idrymeth(ip) = particle%idrymeth
336 this%icu(ip) = particle%icu
337 this%ilay(ip) = particle%ilay
338 this%izone(ip) = particle%izone
339 this%istatus(ip) = particle%istatus
340 this%x(ip) = particle%x
341 this%y(ip) = particle%y
342 this%z(ip) = particle%z
343 this%trelease(ip) = particle%trelease
344 this%tstop(ip) = particle%tstop
345 this%ttrack(ip) = particle%ttrack
346 this%itrdomain( &
347 ip, &
348 1:max_level) = &
349 particle%itrdomain(1:max_level)
350 this%iboundary( &
351 ip, &
352 1:max_level) = &
353 particle%iboundary(1:max_level)
354 this%frctrn(ip) = particle%frctrn
355 this%iexmeth(ip) = particle%iexmeth
356 this%extol(ip) = particle%extol
357 this%extend(ip) = particle%extend
358 this%icycwin(ip) = particle%icycwin

◆ reset_transform()

subroutine particlemodule::reset_transform ( class(particletype), intent(inout) this)
private
Parameters
[in,out]thisparticle

Definition at line 445 of file Particle.f90.

446 class(ParticleType), intent(inout) :: this !< particle
447
448 this%xorigin = dzero
449 this%yorigin = dzero
450 this%zorigin = dzero
451 this%sinrot = dzero
452 this%cosrot = done
453 this%cosrot = done
454 this%transformed = .false.

◆ resize()

subroutine particlemodule::resize ( class(particlestoretype), intent(inout) this,
integer(i4b), intent(in) np,
character(*), intent(in) mempath )
private
Parameters
[in,out]thisparticle store
[in]npnumber of particles
[in]mempathpath to memory

Definition at line 242 of file Particle.f90.

243 ! dummy
244 class(ParticleStoreType), intent(inout) :: this !< particle store
245 integer(I4B), intent(in) :: np !< number of particles
246 character(*), intent(in) :: mempath !< path to memory
247
248 ! Skip if the size is unchanged, so pointers to the
249 ! store's arrays (e.g. via the API) remain valid.
250 if (np == this%num_stored()) return
251
252 call mem_reallocate(this%imdl, np, 'PLIMDL', mempath)
253 call mem_reallocate(this%iprp, np, 'PLIPRP', mempath)
254 call mem_reallocate(this%irpt, np, 'PLIRPT', mempath)
255 call mem_reallocate(this%name, lenboundname, np, 'PLNAME', mempath)
256 call mem_reallocate(this%icu, np, 'PLICU', mempath)
257 call mem_reallocate(this%ilay, np, 'PLILAY', mempath)
258 call mem_reallocate(this%izone, np, 'PLIZONE', mempath)
259 call mem_reallocate(this%istatus, np, 'PLISTATUS', mempath)
260 call mem_reallocate(this%x, np, 'PLX', mempath)
261 call mem_reallocate(this%y, np, 'PLY', mempath)
262 call mem_reallocate(this%z, np, 'PLZ', mempath)
263 call mem_reallocate(this%trelease, np, 'PLTRELEASE', mempath)
264 call mem_reallocate(this%tstop, np, 'PLTSTOP', mempath)
265 call mem_reallocate(this%ttrack, np, 'PLTTRACK', mempath)
266 call mem_reallocate(this%istopweaksink, np, 'PLISTOPWEAKSINK', mempath)
267 call mem_reallocate(this%istopzone, np, 'PLISTOPZONE', mempath)
268 call mem_reallocate(this%idrymeth, np, 'PLIDRYMETH', mempath)
269 call mem_reallocate(this%frctrn, np, 'PLFRCTRN', mempath)
270 call mem_reallocate(this%iexmeth, np, 'PLIEXMETH', mempath)
271 call mem_reallocate(this%extol, np, 'PLEXTOL', mempath)
272 call mem_reallocate(this%extend, np, 'PLEXTEND', mempath)
273 call mem_reallocate(this%icycwin, np, 'PLICYCWIN', mempath)
274 call mem_reallocate(this%itrdomain, np, max_level, 'PLIDOMAIN', mempath)
275 call mem_reallocate(this%iboundary, np, max_level, 'PLIBOUNDARY', mempath)

◆ transform_coords()

subroutine particlemodule::transform_coords ( class(particletype), intent(inout) this,
real(dp), intent(in), optional xorigin,
real(dp), intent(in), optional yorigin,
real(dp), intent(in), optional zorigin,
real(dp), intent(in), optional sinrot,
real(dp), intent(in), optional cosrot,
logical(lgp), intent(in), optional invert )
private

Apply a translation and/or rotation to particle coordinates. No rescaling. It's also possible to invert a transformation. Be sure to reset the transformation after using it.

Parameters
[in,out]thisparticle
[in]xoriginx coordinate of origin
[in]yoriginy coordinate of origin
[in]zoriginz coordinate of origin
[in]sinrotsine of rotation angle
[in]cosrotcosine of rotation angle
[in]invertwhether to invert

Definition at line 415 of file Particle.f90.

418 class(ParticleType), intent(inout) :: this !< particle
419 real(DP), intent(in), optional :: xorigin !< x coordinate of origin
420 real(DP), intent(in), optional :: yorigin !< y coordinate of origin
421 real(DP), intent(in), optional :: zorigin !< z coordinate of origin
422 real(DP), intent(in), optional :: sinrot !< sine of rotation angle
423 real(DP), intent(in), optional :: cosrot !< cosine of rotation angle
424 logical(LGP), intent(in), optional :: invert !< whether to invert
425
426 call transform(this%x, this%y, this%z, &
427 this%x, this%y, this%z, &
428 xorigin, yorigin, zorigin, &
429 sinrot, cosrot, invert)
430
431 ! Compose is needed only because we have to untransform
432 ! coordinates: we may need to report a particle event
433 ! at any point in the tracking method hierarchy, so we
434 ! need to know how to map the particle position back to
435 ! model coords from coords local to the current domain.
436 call compose(this%xorigin, this%yorigin, this%zorigin, &
437 this%sinrot, this%cosrot, &
438 xorigin, yorigin, zorigin, &
439 sinrot, cosrot, invert)
440
441 this%transformed = .true.
Here is the call graph for this function:

Variable Documentation

◆ max_level

integer, parameter particlemodule::max_level = 4

Definition at line 15 of file Particle.f90.