Commit 80c10a2
committed
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
550 | 550 | | |
551 | 551 | | |
552 | 552 | | |
553 | | - | |
| 553 | + | |
554 | 554 | | |
555 | 555 | | |
556 | 556 | | |
| |||
0 commit comments