From 256f78a8d105af23ec1b5bc9df0586b6626d38c3 Mon Sep 17 00:00:00 2001 From: wpbonelli Date: Thu, 5 Sep 2024 20:10:32 -0400 Subject: [PATCH] fix(prp): fix release time selection logic (#2017) A conditional expression in the release timing logic was incorrect: we only want to enable the default release time (beginning of the first step of the first period) if no release times are specified via the RELEASETIMES block, the RELEASE_TIME_FREQUENCY option, or period block release time settings. We also did not previously describe said default. Describe this in the PRP definition file and mention it in the release notes. #2014 flushed this bug out, but this is not the main problem reported in that issue. More to come. --- doc/ReleaseNotes/develop.tex | 2 +- doc/mf6io/mf6ivar/dfn/prt-prp.dfn | 4 ++-- src/Model/ParticleTracking/prt-prp.f90 | 32 +++++++++++++------------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/doc/ReleaseNotes/develop.tex b/doc/ReleaseNotes/develop.tex index d6a0e3764a1..7ff4bd0b791 100644 --- a/doc/ReleaseNotes/develop.tex +++ b/doc/ReleaseNotes/develop.tex @@ -39,7 +39,7 @@ \item The PRT model's particle release point (PRP) package previously accepted release time input via options-block RELEASE\_TIMES and RELEASE\_TIMES\_FILE parameters. These have been replaced with an optional RELEASETIMES block accepting a single column of real-valued input. If the block is provided, an NRELEASETIMES value must be provided in the DIMENSIONS block. \item Similarly, the PRT model's output control (OC) package previously accepted tracking time input via options-block TRACK\_TIMES and TRACK\_TIMES\_FILE parameters. These have been replaced with an optional TRACKTIMES block accepting a single column of real-valued input. The block is only considered if the TRACK\_USERTIME option is enabled. If the block is provided, a DIMENSIONS block containing an NTRACKTIMES value must precede it. \item The PRT model's particle release point (PRP) package previously allowed two particles to be released at the same time from the same point. This could occur if an explicitly specified release time happened to coincide with a release time configured via period block settings. Each release point may now only release one particle at a time. Times falling within a configurable tolerance of one another (defaulting to $\sisetup{input-digits = 0123456789\epsilon} \num{\epsilon e+9}$, where $\epsilon$ is machine precision) are considered coincident and merged into a single release time. - \item A new option RELEASE\_TIME\_FREQUENCY was added to the PRT model's particle release point (PRP) package. This option configures release times on a regular interval for the duration of the simulation, with the first release at the simulation start time. The PRP package's release schedule is the union of times configured via RELEASE\_TIME\_FREQUENCY, the RELEASETIMES block, and period block release settings, up to the tolerance mentioned in the previous item. + \item A new option RELEASE\_TIME\_FREQUENCY was added to the PRT model's particle release point (PRP) package. This option configures release times on a regular interval for the duration of the simulation, with the first release at the simulation start time. The PRP package's release schedule is the union of times configured via RELEASE\_TIME\_FREQUENCY, the RELEASETIMES block, and period block release settings, up to the tolerance mentioned in the previous item. If none of these are provided, a single release time is configured at the beginning of the first stress period's first time step. (A related bug has also been fixed which erroneously activated this default when user-specified release times were configured.) \item The PRT model's particle release point (PRP) package's FRACTION period-block release time setting has been removed. Period-block release settings can now be used only to release particles at the beginning of specified time steps, as is the case for period-block timing settings in the output control (OC) packages for all models. For fine control over release timing, specify times explicitly using the RELEASETIMES block. \end{itemize} diff --git a/doc/mf6io/mf6ivar/dfn/prt-prp.dfn b/doc/mf6io/mf6ivar/dfn/prt-prp.dfn index 2ae82f21562..bb5edd48604 100644 --- a/doc/mf6io/mf6ivar/dfn/prt-prp.dfn +++ b/doc/mf6io/mf6ivar/dfn/prt-prp.dfn @@ -190,7 +190,7 @@ type double precision reader urword optional true longname release time frequency -description real number indicating the time frequency at which to release particles. This option can be used to schedule releases at a regular interval for the duration of the simulation, starting at the simulation start time. The release schedule is the union of this option, the RELEASETIMES block, and PERIOD block RELEASESETTING selections. +description real number indicating the time frequency at which to release particles. This option can be used to schedule releases at a regular interval for the duration of the simulation, starting at the simulation start time. The release schedule is the union of this option, the RELEASETIMES block, and PERIOD block RELEASESETTING selections. If none of these are provided, a single release time is configured at the beginning of the first time step of the simulation's first stress period. # --------------------- prt prp dimensions --------------------- @@ -333,7 +333,7 @@ tagged false in_record true reader urword longname -description specifies time steps at which to release a particle. A particle is released at the beginning of each specified time step. For fine control over release timing, specify times explicitly using the RELEASETIMES block. If the beginning of a specified time step coincides with a release time specified in the RELEASETIMES block or configured via RELEASE\_TIME\_FREQUENCY, only one particle is released at that time. Coincidence is evaluated up to the tolerance specified in RELEASE\_TIME\_TOLERANCE, or $\epsilon \times 10^11$ by default, where $\epsilon$ is machine precision. +description specifies time steps at which to release a particle. A particle is released at the beginning of each specified time step. For fine control over release timing, specify times explicitly using the RELEASETIMES block. If the beginning of a specified time step coincides with a release time specified in the RELEASETIMES block or configured via RELEASE\_TIME\_FREQUENCY, only one particle is released at that time. Coincidence is evaluated up to the tolerance specified in RELEASE\_TIME\_TOLERANCE, or $\epsilon \times 10^11$ by default, where $\epsilon$ is machine precision. If no release times are configured via this setting, the RELEASETIMES block, or the RELEASE\_TIME\_FREQUENCY option, a single release time is configured at the beginning of the first time step of the simulation's first stress period. block period name all diff --git a/src/Model/ParticleTracking/prt-prp.f90 b/src/Model/ParticleTracking/prt-prp.f90 index ace431f491d..882e59bce12 100644 --- a/src/Model/ParticleTracking/prt-prp.f90 +++ b/src/Model/ParticleTracking/prt-prp.f90 @@ -563,22 +563,21 @@ subroutine prp_rp(this) end if end if - ! If no period data for the simulation and no specified - ! release times, default to a single release time at the - ! start of first period's first time step. Otherwise read - ! release timing settings from the period data block of the - ! package input file. - if (no_blocks .and. .not. this%schedule%time_select%any()) then - if (kper == 1) then - allocate (lines(1)) - line = "FIRST" - lines(1) = line - print *, lines - call this%schedule%advance(lines=lines) - end if - ! If the current stress period matches the - ! block we are reading continue parsing it + ! If the user hasn't provided any release settings (neither + ! explicit release times, release time frequency, or period + ! block release settings), default to a single release at the + ! start of the first period's first time step. + if (no_blocks .and. & + kper == 1 .and. & + size(this%schedule%time_select%times) == 0) then + allocate (lines(1)) + line = "FIRST" + lines(1) = line + call this%schedule%advance(lines=lines) else if (this%ionper == kper) then + ! If the current stress period matches the + ! block we are reading, parse the setting + ! and register it with the schedule. allocate (lines(0)) recordloop: do call this%parser%GetNextLine(end_of_block) @@ -587,7 +586,8 @@ subroutine prp_rp(this) call ExpandArray(lines) lines(size(lines)) = line end do recordloop - call this%schedule%advance(lines=lines) + if (size(lines) > 0) & + call this%schedule%advance(lines=lines) deallocate (lines) end if