Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[csg] H5MD reader: reads the wrong unit #807

Open
junghans opened this issue May 21, 2020 · 15 comments
Open

[csg] H5MD reader: reads the wrong unit #807

junghans opened this issue May 21, 2020 · 15 comments
Assignees
Labels

Comments

@junghans
Copy link
Member

If I run:

csg_stat --nt 1 --options settings.xml --top topol.xml --trj traj.h5 --begin 0 --first-frame 0

with these inputs, the output (CG-CG.dist.new) is all zeros, even though the positions in traj.h5 looks ok.

Longer trajectories works fine as well.

@junghans
Copy link
Member Author

In contrast:

csg_stat --nt 1 --options settings.xml --top topol.xml --trj spce.gro --begin 0 --first-frame 0

works.

@jkrajniak
Copy link
Member

I have debug a bit the example and the simulation script (so nice it is included in h5md file). I think the zeros are not because of not reading the first frame but because the .h5 uses angstroms and the settings.xml are in nm? If you change <max> to 9.0 then it calculates distribution.

@junghans
Copy link
Member Author

Good catch it seems we forgot to fix the reader after merging votca/csg-tutorials#34. The simulation is now done in Angstrom, but the reader still thinks numbers are in nm.

Is there a field to store the units in the h5md format?

@jkrajniak
Copy link
Member

jkrajniak commented May 23, 2020

There is a module called units which holds the information about the unit system (https://nongnu.org/h5md/modules/units.html) This is nothing more than an unit attribute assigned to the dataset. However, if I am correct Espresso does not use this attribute to store the units (which I admit, could be beneficial)

btw, readers in VOTCA treat data as they are in Angstrom by default ?

@junghans
Copy link
Member Author

VOTCA internal units are nm, hence the missing factor 10.

As a workaround we could assume h5md is in Angstrom if no unit is given.

@JoshuaSBrown what do you think?

@jkrajniak is there are way to set the unit manually in the espresso script?

@jkrajniak
Copy link
Member

As a workaround we could assume h5md is in Angstrom if no unit is given.

If VOTCA expects that length is expressed in nm then I would assume that the numbers in
H5MD are in nm units (so no conversion) and do the conversion only if the units is enabled. Just to follow the principle of garbage-in-garbage-out.

@JoshuaSBrown what do you think?

@jkrajniak is there are way to set the unit manually in the espresso script?

AFAIK not without modifying the h5md.H5md module in Espresso

@JoshuaSBrown
Copy link
Contributor

I think if there is a units attribute in h5md it should be used, and if it is not specified either a warning should be thrown indicating that a default is being used or an error should be thrown.

@JoshuaSBrown
Copy link
Contributor

JoshuaSBrown commented May 23, 2020

I would use the default units for csg as well.

@JoshuaSBrown JoshuaSBrown reopened this May 23, 2020
@junghans junghans changed the title H5MD reader: skip the first frame H5MD reader: reads the wrong unit May 26, 2020
@junghans
Copy link
Member Author

@jngrad @fweik @RudolfWeeber could you expose the unit property for the h5md reader to the user in espresso?

@jngrad
Copy link
Contributor

jngrad commented May 26, 2020

@junghans espresso simulation data is typically dimensionless. I just tried to create a new field "particles/atoms/id/time/unit", 1, type_cstring} with h5xx::datatype type_cstring = h5xx::datatype(H5T_NATIVE_CHAR), but I get an exception creating dataset "particles/atoms/id/time/unit" from 5xx/dataset/dataset.hpp#L145 without information about what's wrong.

@junghans
Copy link
Member Author

junghans commented May 26, 2020

@junghans espresso simulation data is typically dimensionless. I just tried to create a new field "particles/atoms/id/time/unit", 1, type_cstring} with h5xx::datatype type_cstring = h5xx::datatype(H5T_NATIVE_CHAR), but I get an exception creating dataset "particles/atoms/id/time/unit" from 5xx/dataset/dataset.hpp#L145 without information about what's wrong.

That is a question for @jkrajniak ;-)

@junghans
Copy link
Member Author

junghans commented Jun 7, 2020

ping @jkrajniak can you have a look into the error @jngrad found in h5xx in espresso?

@jkrajniak
Copy link
Member

I've just added PR to espresso with the ability to store units alongside with the H5MD file (espressomd/espresso#3751)

@junghans
Copy link
Member Author

junghans commented Jul 3, 2020

Writing of units was added to espresso in espressomd/espresso#3751, reading is added in votca/csg#549, now we just need to wait for the next espresso release and update our tutorial.

@junghans
Copy link
Member Author

junghans commented Jul 8, 2020

Espresso-4.1.3 is out, but it doesn't include the h5md unit fix, waiting for the next release.

In the tutorials there is only one line that needs to be added, something like:
https://github.com/espressomd/espresso/blob/9b62aa2bfc1eb808ad71f4640f65af93e99a2bba/samples/h5md.py#L46

@junghans junghans transferred this issue from votca/csg Sep 26, 2021
@junghans junghans added the csg label Sep 26, 2021
@junghans junghans changed the title H5MD reader: reads the wrong unit [csg] H5MD reader: reads the wrong unit Sep 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants