h5md / VMD-h5mdplugin

This plugin enables VMD to display data stored in h5 files that are structured according to the H5MD specifications (http://nongnu.org/h5md/)
Other
10 stars 9 forks source link

particle group name fixed to "atoms" #4

Closed fhoefling closed 10 years ago

fhoefling commented 10 years ago

The current version strictly requires the particle data to be stored at "/particles/atoms". It does not allow for a different name or even multiple particle groups.

Would it be possible to read all particle groups that are found in the file and to assign the group name as atom "name", such that the coloring may be according to "Name" in VMD?

jonaslandsgesell commented 10 years ago

Thank you for the hint. According to the h5md specification this is needed. The discovery of all position datasets will be implemented in one of the next commits.

Right now I see one way to implement this feature: all position coordinates are read together (=> only one coords array of VMD). A possible issue is that the coordinate datasets then should to be consistent with each other (e.g. have the same Delta t between timesteps and the same number of timesteps).

A more flexible option would be to treat the different position datasets as independent files. But I don't see an easy way to do this after the plugin was called from VMD.

fhoefling commented 10 years ago

I have no idea about the VMD internals. Ideally, the user would select which groups to read, but such a possibility is apparently not yet available in VMD.

So one has to go for a minimalist solution which does not crash. (A plugin that crashes on a valid H5MD file is the most annoying thing for the user I would say.) For example, the plugin could select only those time steps which are present in all particle subgroups. This would require something like numpy's intersect1d. (BTW, compare integer steps not floating-point time!)

jonaslandsgesell commented 10 years ago

The current version should detect all position datasets and try to read them. If the position dataset have a different number of timesteps, only the first one is read and the the others are ignored. In one of the next commits the type of the particle will be set to the group name.

fhoefling commented 10 years ago

Thanks, it seems to work. With the example binary_mixture.h5 I get the following error:

ERROR: /parameters/vmd_structure/indexOfSpecies does not contain as much different species as different species are present in /particles/atoms/species !

indexOfSpecies contains (1, 2) and the datasets in /position/*/species have 0 and 1. Changing indexOfSpeciesto (0, 1) does not remove the error. What could be wrong here?

jonaslandsgesell commented 10 years ago

In gerneral the above message indicates that either the dataset "/parameters/vmd_structure/indexOfSpecies" is not present in the file or that the dataset indexOfSpecies lists not the same number of species as there are different species listed in all the datasets /particles/*/species/value (where * denotes all h5md groups, that also contain a dataset /particles/*/position/value)

The example "binary_mixture.h5" which is present in the git repository does not contain an dataset "/parameters/vmd_structure/indexOfSpecies". Therefore the plugin prints this message.

Is the message "ERROR: ..." misleading, should it be dropped or rephrased?

PS: Another problem is that the plugin assumes the datasets /particles/*/species/value to be onedimensional datasets, where the index in the list is associated to the particle index in the position dataset. This means the plugin assumes that the species information does not change over time (and VMD does not really support time-dependent particle properties http://www.ks.uiuc.edu/Research/vmd/mailing_list/vmd-l/23255.html).

fhoefling commented 10 years ago

I think the problem the shape of the species dataset. If it is not changing in time, it is named particles/*/species. Otherwise, it is in particles/*/species/value. The data files produces by HALMD so far generate a time-dependent species element, although the values don't change. I can fix this and write a single dataset species (but not species/value).

jonaslandsgesell commented 10 years ago

Ok, I did not read the documentation like this. As far as I see it, this behaviour is documented under http://nongnu.org/h5md/h5md.html#particles-group and maybe could be a bit more detailed or beginner friendly.

To become h5md conform the plugin will be reading only the time-independent datasets 'particles/*/species' as you suggested.

jonaslandsgesell commented 10 years ago

Time-independent species datasets are now in the correct path in the sample files. For the moment coloring and specifying different properties for the particles within VMD is done with the help of the datasets in the group vmd_parameters.

An example for different coloring of different species can be found in "binary_mixture.h5" in the examples folder.

fhoefling commented 10 years ago

Thanks for the fix. It now works nicely with HALMD output after adding the vmd_parameters.

What seems to be missing still is the interpretation of the "image" data. I suggest to modify the positions according to the formula in the H5MD spec if the field is present (and to do nothing if it is absent).

jonaslandsgesell commented 10 years ago

Ok, for the image data there is a new issue.