-
Notifications
You must be signed in to change notification settings - Fork 349
Closed
Description
The MODFLOW simulation write step (or specifically, the .set_all_data_external() step) seems to be prohibitively slow, especially for models with a large number of rows and columns, or stress periods. e.g.:
ar = dis.top.array.copy()
ar.shape
(302, 501)
%timeit np.savetxt(os.path.join(gwf.model_ws, 'top_ar.txt'), ar, delimiter=' ', fmt="%15.8f")
45.5 ms ± 3.96 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
%timeit dis.top.store_as_external_file(os.path.join(gwf.model_ws, 'top.txt'))
929 ms ± 77.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
1 sec write time for a single array quickly causes issues when the model contains many stress periods!
This seems to relate to the amount of time spent on overhead for file formatting (esp mffileaccess.get_data_string()). Is there any way to speed this up? Alternatively, would it be possible to support passing no data or empty arrays to Flopy package constructers, set-up the open/close lines in the packages, and then allow the user to write the external arrays etc in a more optimised way (e.g. numpy.savetxt(), and pandas.to_csv() etc.)?
Metadata
Metadata
Assignees
Labels
No labels