Skip to content

Commit 80c10a2

Browse files
fix(mfusg): fix precision loss in CLN/GNC packages writing coordinates
MFUSG CLN/GNC packages were losing significant precision when writing node coordinates, causing coordinate errors up to 3.5 km and affecting model results. ## Root Cause The fmt_string() method in mfusgcln.py and mfusggnc.py used %10.2e format (only 3 significant figures) instead of the standard Util2d format %15.6G (9 significant figures). ## Impact on Real Data Complete line from CLN package showing precision loss: Before (bug - %10.2e): 1 1 0 5.75e+01 1.15e+03 0.00e+00 0 0 4.01e+05 6.90e+06 1.21e+03 4.01e+05 6.90e+06 1.15e+03 After (fixed - %16.9G): 1 1 0 57.4650002 1150.19897 0 0 0 400569 6903567 1207.66394 400569 6903567 1150.19897 The precision loss caused measurable differences in model results. ## Solution Changed fmt_string() to return "%16.9G" format, which: - Provides 9 significant figures (exceeds float32's 7-digit precision) - Uses adaptive format (decimal when readable, scientific when needed) - Maintains proper spacing with 16-character width - Consistent with other MFUSG packages (WEL/DRN/RIV use %G) ## Testing Verified with Valle Copiapo model (142 CLN nodes, 181 stress periods). Model results now match original with negligible differences.
1 parent 75b34a0 commit 80c10a2

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

flopy/mfusg/mfusg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ def fmt_string(array):
550550
if vtype in {"i", "b"}:
551551
fmts.append("%10d")
552552
elif vtype == "f":
553-
fmts.append("%10.2e")
553+
fmts.append("%16.9G")
554554
elif vtype == "o":
555555
fmts.append("%10s")
556556
elif vtype == "s":

0 commit comments

Comments
 (0)