astro-turing / Integrating-diagenetic-equations-using-Python

Reactive-transport model simulating formation of limestone-marl alternations
Apache License 2.0
0 stars 1 forks source link

Save metadata #30

Closed HannoSpreeuw closed 1 year ago

HannoSpreeuw commented 1 year ago

This simple addition info=kwargs is enough to save metadata.

To read the attributes added to the hdf5 file written in this way, run something like

import h5py
hf =h5py.File("file_just_created.h5", "r"); 
hf.attrs.keys()

Btw, hf.keys() will give you the names of the datasets saved in file_just_created.h5.

Fixes #19

HannoSpreeuw commented 1 year ago

Are the solver parameters really missing? We have

storage = FileStorage(stored_results, info=kwargs)

and kwargs also includes solver parameters.

EmiliaJarochowska commented 1 year ago

Oh, sorry. Yes, all parameters from kwargs are saved. I thought solver parameters would also include things like solver="explicit", scheme = "rk", adaptive = True etc. So I should close #19 ?

HannoSpreeuw commented 1 year ago

Yeah, o now I see what you mean. Yes, this only includes the parameters from the parameters.Solver dataclass. So good point! How about me adding arguments like the ones you mentioned, i.e. solver="explicit", scheme = "rk", adaptive = True to the Solver dataclass?

EmiliaJarochowska commented 1 year ago

I don't know to what extent we were going to change these arguments in the future. I still have in mind what Karline suggested (and seems in line with many textbooks) that implicit solvers would be more appropriate for our case. So if we are going to do runs with different solvers, it would be worth adding. But then you'd probably have to consider the whole range of parameters different solvers can take, as in https://py-pde.readthedocs.io/en/latest/packages/pde.solvers.html ?

HannoSpreeuw commented 1 year ago

Yes, but it seems fine to accommodate for all these solvers and beyond, i.e. solve_ivp without the py-pde wrapper, which gives more options, such as a functional Jacobian, see the Use_solve_ivp_without_py-pde_wrapper branch.

To control this through the parameters.Solver dataclass is indeed the most elegant solution. I just published a commit to provide for this.