Skip to content

Commit

Permalink
feat(ParticleData): add get_coord_list() method, add example data for…
Browse files Browse the repository at this point in the history
… CellBudgetFile.get_pathlines() tests
  • Loading branch information
wpbonelli committed Mar 23, 2023
1 parent e17d336 commit 324ac18
Show file tree
Hide file tree
Showing 18 changed files with 5,187 additions and 16 deletions.
80 changes: 71 additions & 9 deletions autotest/test_particledata.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import numpy as np
import pytest
from autotest.test_grid_cases import GridCases

from flopy.modpath import ParticleData

structured_plocs = [(1, 1, 1), (1, 1, 2)]
structured_cells = [(0, 1, 1), (0, 1, 2)]
structured_dtype = np.dtype(
[
("k", "<i4"),
Expand All @@ -17,35 +19,95 @@
)
structured_array = np.core.records.fromrecords(
[
(1, 1, 1, 0.5, 0.5, 0.5, 0.0, 0),
(1, 1, 2, 0.5, 0.5, 0.5, 0.0, 0),
(0, 1, 1, 0.5, 0.5, 0.5, 0.0, 0),
(0, 1, 2, 0.5, 0.5, 0.5, 0.0, 0),
],
dtype=structured_dtype,
)


def test_particledata_structured_partlocs_as_list_of_tuples():
locs = structured_plocs
def test_particledata_structured_ctor_with_partlocs_as_list_of_tuples():
locs = structured_cells
data = ParticleData(partlocs=locs, structured=True)

assert data.particlecount == 2
assert data.dtype == structured_dtype
assert np.array_equal(data.particledata, structured_array)


def test_particledata_structured_partlocs_as_ndarray():
locs = np.array(structured_plocs)
def test_particledata_structured_ctor_with_partlocs_as_ndarray():
locs = np.array(structured_cells)
data = ParticleData(partlocs=locs, structured=True)

assert data.particlecount == 2
assert data.dtype == structured_dtype
assert np.array_equal(data.particledata, structured_array)


def test_particledata_structured_partlocs_as_list_of_lists():
locs = [list(p) for p in structured_plocs]
def test_particledata_structured_ctor_with_partlocs_as_list_of_lists():
locs = [list(p) for p in structured_cells]
data = ParticleData(partlocs=locs, structured=True)

assert data.particlecount == 2
assert data.dtype == structured_dtype
assert np.array_equal(data.particledata, structured_array)


def test_particledata_structured_get_coord_list_with_ids():
data = ParticleData(
partlocs=structured_cells,
structured=True,
particleids=range(len(structured_cells)),
)
grid = GridCases().structured_small()
coords = data.get_coord_list(grid)

assert len(coords) == len(structured_cells)
assert all(
len(c) == 4 for c in coords
) # each coord should be a tuple (id, x, y, z)
for ci, c in enumerate(coords):
assert ci == c[0]


def test_particledata_structured_get_coord_list_no_ids():
data = ParticleData(partlocs=structured_cells, structured=True)
grid = GridCases().structured_small()
coords = data.get_coord_list(grid)

assert len(coords) == len(structured_cells)
assert all(
len(c) == 3 for c in coords
) # each coord should be a tuple (x, y, z)

for ci, cell in enumerate(structured_cells):
# check containing cell is correct
coord = coords[ci]
assert cell == grid.intersect(*coord)

# check global coords are equivalent to local
k, i, j = cell
verts = grid.get_cell_vertices(i, j)
xs, ys = list(zip(*verts))
minx, maxx = min(xs), max(xs)
miny, maxy = min(ys), max(ys)
minz, maxz = grid.botm[k, i, j], grid.top[i, j]
assert np.isclose(
coord[2], minz + (structured_array[ci][3] * (maxz - minz))
)
assert np.isclose(
coord[0], minx + (structured_array[ci][4] * (maxx - minx))
)
assert np.isclose(
coord[1], miny + (structured_array[ci][5] * (maxy - miny))
)


@pytest.mark.skip(reason="todo")
def test_lrcparticledata_get_coord_list():
pass


@pytest.mark.skip(reason="todo")
def test_nodeparticledata_get_coord_list():
pass
171 changes: 171 additions & 0 deletions examples/data/prt_test/mfsim.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
MODFLOW 6
U.S. GEOLOGICAL SURVEY MODULAR HYDROLOGIC MODEL
VERSION 6.3.0 release candidate 07/30/2021
***DEVELOP MODE***

MODFLOW 6 compiled Mar 21 2023 14:01:53 with GCC version 11.3.0

This software is preliminary or provisional and is subject to
revision. It is being provided to meet the need for timely best
science. The software has not received final approval by the U.S.
Geological Survey (USGS). No warranty, expressed or implied, is made
by the USGS or the U.S. Government as to the functionality of the
software and related material nor shall the fact of release
constitute any such warranty. The software is provided on the
condition that neither the USGS nor the U.S. Government shall be held
liable for any damages resulting from the authorized or unauthorized
use of the software.


As a work of the United States Government, this USGS product is
in the public domain within the United States. You can copy,
modify, distribute, and perform the work, even for commercial
purposes, all without asking permission. Additionally, USGS
waives copyright and related rights in the work worldwide
through CC0 1.0 Universal Public Domain Dedication
(https://creativecommons.org/publicdomain/zero/1.0/).

The following GNU Lesser General Public License (LGPL) libraries
are used in this USGS product:

SPARSKIT version 2.0
ilut, luson, and qsplit
(https://www-users.cse.umn.edu/~saad/software/SPARSKIT/)

RCM - Reverse Cuthill McKee Ordering
(https://people.math.sc.edu/Burkardt/f_src/rcm/rcm.html)

BLAS - Basic Linear Algebra Subprograms Level 1
(https://people.math.sc.edu/Burkardt/f_src/blas1_d/blas1_d.html)

SPARSEKIT - Sparse Matrix Utility Package
amux, dperm, dvperm, rperm, and cperm
(https://people.sc.fsu.edu/~jburkardt/f77_src/sparsekit/sparsekit.html)

The following BSD-3 License libraries are used in this USGS product:

Modern Fortran DAG Library
Copyright (c) 2018, Jacob Williams
All rights reserved.
(https://github.com/jacobwilliams/daglib)

MODFLOW 6 compiler options: -fdiagnostics-color=always -cpp -I
src/libmf6core.a.p -I src -I ../src -I src/libmf6_external.a.p -imultiarch
x86_64-linux-gnu -D _FILE_OFFSET_BITS=64 -D __linux__ -mtune=generic
-march=x86-64 -g -O0 -Wall -Wpedantic -Wcharacter-truncation
-Wno-unused-dummy-argument -Wno-intrinsic-shadow -Wno-maybe-uninitialized
-Wno-uninitialized -std=f2008 -fcheck=all
-ffpe-trap=overflow,zero,invalid,denormal -fPIC -J src/libmf6core.a.p
-fpre-include=/usr/include/finclude/math-vector-fortran.h

System command used to initiate simulation:
/home/wbonelli/dev/prt-examples-temp/venv/bin/mf6

MODFLOW was compiled using uniform precision.

Real Variables
KIND: 8
TINY (smallest non-zero value): 2.225074-308
HUGE (largest value): 1.797693+308
PRECISION: 15
BIT SIZE: 64

Integer Variables
KIND: 4
HUGE (largest value): 2147483647
BIT SIZE: 32

Long Integer Variables
KIND: 8
HUGE (largest value): 9223372036854775807
BIT SIZE: 64

Logical Variables
KIND: 4
BIT SIZE: 32


OPENED mfsim.nam
FILE TYPE:NAM UNIT 1001 STATUS:OLD
FORMAT:FORMATTED ACCESS:SEQUENTIAL
ACTION:READ

# File generated by Flopy version 3.3.7 on 03/22/2023 at 10:04:40.

READING SIMULATION OPTIONS
END OF SIMULATION OPTIONS

READING SIMULATION TIMING

OPENED mp7-p04_prt.tdis
FILE TYPE:TDIS UNIT 1002 STATUS:OLD
FORMAT:FORMATTED ACCESS:SEQUENTIAL
ACTION:READ


TDIS -- TEMPORAL DISCRETIZATION PACKAGE,
VERSION 1 : 11/13/2014 - INPUT READ FROM UNIT 1002
# File generated by Flopy version 3.3.7 on 03/22/2023 at 10:04:40.
PROCESSING TDIS OPTIONS
SIMULATION TIME UNIT IS DAYS
END OF TDIS OPTIONS
PROCESSING TDIS DIMENSIONS
1 STRESS PERIOD(S) IN SIMULATION
END OF TDIS DIMENSIONS
PROCESSING TDIS PERIODDATA


STRESS PERIOD LENGTH TIME STEPS MULTIPLIER FOR DELT
----------------------------------------------------------------------------
1 10000.00 1 1.000
END OF TDIS PERIODDATA
END OF SIMULATION TIMING

READING SIMULATION MODELS
PRT6 model MP7-P04_PRT will be created as model 1
END OF SIMULATION MODELS

READING SIMULATION EXCHANGES
END OF SIMULATION EXCHANGES

READING SOLUTIONGROUP

Creating explicit solution (EMS): SLN_1


OPENED mp7-p04_prt.ems
FILE TYPE:IMS UNIT 1010 STATUS:OLD
FORMAT:FORMATTED ACCESS:SEQUENTIAL
ACTION:READ

END OF SIMULATION SOLUTIONGROUP

PROCESSING MODEL CONNECTIONS

Solving: Stress period: 1 Time step: 1

1
STRESS PERIOD NO. 1, LENGTH = 10000.00
-----------------------------------------------
NUMBER OF TIME STEPS = 1
MULTIPLIER FOR DELT = 1.000
INITIAL TIME STEP SIZE = 10000.00

MEMORY MANAGER TOTAL STORAGE BY DATA TYPE, IN MEGABYTES
-------------------------------
ALLOCATED
DATA TYPE MEMORY
-------------------------------
Character 2.67600000E-03
Logical 3.60000000E-05
Integer 8.2978240
Real 32.566992
-------------------------------
Total 40.867528
-------------------------------



Run end date and time (yyyy/mm/dd hh:mm:ss): 2023/03/22 10:04:40
Elapsed run time: 0.029 Seconds
Normal termination of simulation.
19 changes: 19 additions & 0 deletions examples/data/prt_test/mfsim.nam
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# File generated by Flopy version 3.3.7 on 03/22/2023 at 10:04:40.
BEGIN options
END options

BEGIN timing
TDIS6 mp7-p04_prt.tdis
END timing

BEGIN models
prt6 mp7-p04_prt.nam mp7-p04_prt
END models

BEGIN exchanges
END exchanges

BEGIN solutiongroup 1
ims6 mp7-p04_prt.ems mp7-p04_prt
END solutiongroup 1

1 change: 1 addition & 0 deletions examples/data/prt_test/mp7-p04.gwfprt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# File generated by Flopy version 3.3.7 on 03/20/2023 at 13:24:52.
Binary file added examples/data/prt_test/mp7-p04_bkwd.bud
Binary file not shown.
Binary file added examples/data/prt_test/mp7-p04_bkwd.hds
Binary file not shown.
Binary file added examples/data/prt_test/mp7-p04_prt.cbb
Binary file not shown.
43 changes: 43 additions & 0 deletions examples/data/prt_test/mp7-p04_prt.dis
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# File generated by Flopy version 3.3.7 on 03/20/2023 at 13:45:29.
BEGIN options
LENGTH_UNITS feet
END options

BEGIN dimensions
NLAY 1
NROW 21
NCOL 26
END dimensions

BEGIN griddata
delr
CONSTANT 500.00000000
delc
CONSTANT 500.00000000
top
CONSTANT 100.00000000
botm
INTERNAL FACTOR 1.0
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
END griddata

Loading

0 comments on commit 324ac18

Please sign in to comment.