crunchflow 2.0.0__tar.gz → 2.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: crunchflow
3
- Version: 2.0.0
3
+ Version: 2.0.2
4
4
  Summary: A Python toolbox for working with the CrunchFlow reactive transport code
5
5
  License: GPL-3.0-or-later
6
6
  Author: Zach Perzan
@@ -12,7 +12,7 @@ Classifier: Programming Language :: Python :: 3.9
12
12
  Classifier: Programming Language :: Python :: 3.10
13
13
  Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
- Requires-Dist: matplotlib (>=3.9.0,<4.0.0)
15
+ Requires-Dist: matplotlib (>=3.7.0,<4.0.0)
16
16
  Requires-Dist: numpy (>=2.0.0,<3.0.0)
17
17
  Requires-Dist: pandas (>=2.2.2,<3.0.0)
18
18
  Description-Content-Type: text/markdown
@@ -169,7 +169,7 @@ class Output(KeywordBlock):
169
169
  else:
170
170
  result.append(f"time_series_print {self.time_series_print}")
171
171
  for ts in self.time_series:
172
- result.append(f"time_series {ts}")
172
+ result.append(f"time_series {ts}")
173
173
  for key, value in self.other.items():
174
174
  result.append(f"{key:<22} {value}")
175
175
  return "\n".join(result)
@@ -292,9 +292,9 @@ class Flow(KeywordBlock):
292
292
  self.gravity = ''
293
293
  self.infiltration = ''
294
294
  self.initialize_hydrostatic = ''
295
- self.permeability_x = ''
296
- self.permeability_y = ''
297
- self.permeability_z = ''
295
+ self.permeability_x = []
296
+ self.permeability_y = []
297
+ self.permeability_z = []
298
298
  self.porosity_update = ''
299
299
  self.pressure = []
300
300
  self.pump = ''
@@ -307,7 +307,7 @@ class Flow(KeywordBlock):
307
307
  def set_parameters(self, parameters):
308
308
  for key, value in parameters.items():
309
309
  key = key.lower()
310
- if key == 'pressure':
310
+ if key in ['pressure', 'permeability_x', 'permeability_y', 'permeability_z']:
311
311
  self.pressure.append(value)
312
312
  elif hasattr(self, key):
313
313
  setattr(self, key, value)
@@ -315,20 +315,33 @@ class Flow(KeywordBlock):
315
315
  self.other[key] = value
316
316
 
317
317
  def __str__(self):
318
+ exceptions = ['other', 'pressure', 'permeability_x', 'permeability_y', 'permeability_z']
318
319
  result = []
319
320
  for attr, value in self.__dict__.items():
320
- if attr not in ['other', 'pressure'] and (value or isinstance(value, bool)):
321
+ if attr not in exceptions and (value or isinstance(value, bool)):
321
322
  if isinstance(value, list):
322
323
  result.append(f"{attr:<22} {' '.join(map(str, value))}")
323
324
  elif isinstance(value, bool):
324
325
  result.append(f"{attr:<22} {str(value).lower()}")
325
326
  else:
326
327
  result.append(f"{attr:<22} {value}")
328
+
329
+ # Print pressure, since it can be defined multiple times
327
330
  for press in self.pressure:
328
331
  line = f"pressure "
329
332
  for p in press.split():
330
333
  line += f"{p:<8} "
331
334
  result.append(line.strip())
335
+
336
+ # Print permeability, since it can be defined multiple times
337
+ for perm in self.permeability_x:
338
+ result.append(f"permeability_x {perm}")
339
+ for perm in self.permeability_y:
340
+ result.append(f"permeability_y {perm}")
341
+ for perm in self.permeability_z:
342
+ result.append(f"permeability_z {perm}")
343
+
344
+ # Finally, the other category
332
345
  for key, value in self.other.items():
333
346
  result.append(f"{key:<22} {value}")
334
347
  return "\n".join(result)
@@ -5,6 +5,7 @@ from crunchflow.input.blocks import (
5
5
  PrimarySpecies, SecondarySpecies, Gases, Minerals, AqueousKinetics,
6
6
  Isotopes, DatabaseBlock
7
7
  )
8
+ from importlib.metadata import version
8
9
  import os
9
10
 
10
11
 
@@ -118,7 +119,8 @@ class InputFile:
118
119
  full_path = os.path.join(path, filename)
119
120
  with open(full_path, 'w') as file:
120
121
  file.write('! CrunchFlow input file\n')
121
- file.write('! Generated automatically by python-crunchflow \n')
122
+ cf_version = version("crunchflow")
123
+ file.write('! Generated automatically by python-crunchflow v%s\n' % cf_version)
122
124
  file.write(str(self) + "\n")
123
125
 
124
126
  # Update PestControl.ant if requested
@@ -162,7 +164,8 @@ class InputFile:
162
164
 
163
165
  # Some attributes can be set multiple times within a single block
164
166
  multiply_defined = ['time_series', 'pressure', 'mineral',
165
- 'primary', 'D_25', 'tortuosityMP']
167
+ 'primary', 'D_25', 'tortuosityMP',
168
+ 'permeability_x', 'permeability_y', 'permeability_z']
166
169
 
167
170
  # List of condition attributes that are not species
168
171
  condition_attributes = ['units', 'equilibrate_surface', 'temperature',
@@ -1,4 +1,5 @@
1
1
  import os
2
+ import re
2
3
  import numpy as np
3
4
  import pandas as pd
4
5
  import matplotlib.pyplot as plt
@@ -17,21 +18,38 @@ def get_ts_coords(tsfile):
17
18
  -------
18
19
  coords : tuple of int
19
20
  Coordinates of the form (x, y, z)"""
20
-
21
+
21
22
  # Open the file and read in the first line
22
23
  with open(tsfile) as f:
23
- for i, line in enumerate(f):
24
- if i == 0:
25
- fields = line.split()[-3:]
26
-
27
- # Final 3 fields are x, y, and z
28
- x = int(fields[0])
29
- y = int(fields[1])
30
- z = int(fields[2])
31
-
32
- # Return tuple
33
- coords = (x, y, z)
34
-
24
+ firstline = f.readline()
25
+ if 'Flux weighted' in firstline:
26
+ # First split on colon
27
+ coord_str = firstline.split(':')[-1]
28
+
29
+ # Then split on both space and hyphen. Sometimes CrunchFlow outputs
30
+ # these coordinates as "1-100" and sometimes as "1- 100"
31
+ raw_coord_list = re.split(r'[-\s]', coord_str)
32
+
33
+ # Remove empty strings
34
+ coord_list = [x for x in raw_coord_list if x]
35
+
36
+ if len(coord_list) == 6:
37
+ coords = ('%s-%s' % (coord_list[0], coord_list[1]),
38
+ '%s-%s' % (coord_list[2], coord_list[3]),
39
+ '%s-%s' % (coord_list[4], coord_list[5]))
40
+ else:
41
+ coords = coord_str
42
+
43
+ else:
44
+ # Final 3 fields are x, y, and z
45
+ fields = firstline.split()[-3:]
46
+ x = int(fields[0])
47
+ y = int(fields[1])
48
+ z = int(fields[2])
49
+
50
+ # Return tuple
51
+ coords = (x, y, z)
52
+
35
53
  return coords
36
54
 
37
55
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "crunchflow"
3
- version = "2.0.0"
3
+ version = "2.0.2"
4
4
  description = "A Python toolbox for working with the CrunchFlow reactive transport code"
5
5
  authors = ["Zach Perzan <zach.perzan@unlv.edu>"]
6
6
  license = "GPL-3.0-or-later"
@@ -9,7 +9,7 @@ readme = "README.md"
9
9
  [tool.poetry.dependencies]
10
10
  python = "^3.9"
11
11
  numpy = "^2.0.0"
12
- matplotlib = "^3.9.0"
12
+ matplotlib = "^3.7.0"
13
13
  pandas = "^2.2.2"
14
14
 
15
15
  [tool.poetry.group.test]
File without changes
File without changes