Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Fix units (for good) #188

Merged
merged 25 commits into from Sep 27, 2017
Merged

Fix units (for good) #188

merged 25 commits into from Sep 27, 2017

Conversation

ceriottm
Copy link
Collaborator

Let's face it. The latest round of IO/units changes has been a clusterf**k. @ipoltavskyi found it was slowing down things too much, @mahrossi and @venkatkapil24 reported that the units specification in the input was confusing and leading to more problems than it fixed. So here is another try at getting this right. I hope y'all can contribute to making sure we don't have to touch this boring part of the code in the next year at least. Main concepts are:

  • one should be able to specify units both in the input and in the structure file. if no units are specified in the input, i-PI tries to guess from the comment line, otherwise assumes atomic units, or angstrom for PDB.
  • if units are specified in both places, and match, conversion happens just once. if they mismatch, an error is raised.
  • conversion happens in the IO functions as far as possible. this might also be a prequel to a more flexible output infrastructure, but for the moment main change is trajectory outputting passes around indication of units, but the conversion happens in print_file
  • read_file_raw (and possibly print_file_raw?) are added to access the positions and labels with no conversion and no creation of i-pi objects

@@ -86,7 +86,7 @@ def __init__(self, value="", mode="", units="", index=-1, bead=-1):
super(InitIndexed,self).__init__(value=value, mode=mode, units=units, index=index, bead=bead)


def init_file(mode, filename):
def init_file(mode, filename, dimension="length", units="automatic", cell_units="automatic"):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Collaborator

@mahrossi mahrossi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest that this infrastructure gets a proper documentation in the documentation if possible before the branch is merged? That way we don't forget to document it.

@mahrossi
Copy link
Collaborator

Hello: what I read and what I tested works as intended. I'm asking for the documentation anyways. I think that one big issue with all the previous infrastructures is that nothing was properly documented. In fact we need to look carefully at the documentation, but we can start small with this one. How to best do it?

@ceriottm
Copy link
Collaborator Author

ceriottm commented Jun 20, 2017 via email

@mahrossi
Copy link
Collaborator

Yes, this was my next question: So we just put it in the manually written part of the manual? If so I'll just do it in this branch.

@ceriottm
Copy link
Collaborator Author

@OndrejMarsalek and @ipoltavskyi I'd like to hear your opinion, and -- possibly -- to have your help making sure that all post-processing tools still work with this revised infrastructure

@ipoltavskyi
Copy link
Collaborator

Dear Michele,

My scripts should be modified for the new infrastructure. I will do it ASAP. Also I would add some warning when PDB format is used for output. The actual coordinates may not match the allowed digits in this format, which will lead to a mess in the trajectory files. An example is qtip water in the examples folder. If you run this calculations you will find that the water molecules go away from the original box and may have rather large coordinates. PDB output is useless in this case.

Best wishes
Igor

@ceriottm
Copy link
Collaborator Author

Hi all, @ipoltavskyi in particular. Any chance we can move this forward, fixing tools and merging ASAP?

@ipoltavskyi
Copy link
Collaborator

Hi guys. To be honest I do not understand this new infrastructure with automatic units and increased number of functions for no obvious reasons (for instance "print_file_raw" function is just a copy of the "return" line in "print_file" function with extra parameters which is used only once in the whole code). In fact the half of "auto_units" function in "io_units.py" contain "if" conditions in order to change useless "automatic" unit into "atoms_unit" or something else. I thought that the idea of this brunch was to make the code lighter and faster. Now it looks heavier and less user friendly. I do not get the idea behind these changes.

@ceriottm
Copy link
Collaborator Author

Hello Igor, the idea was twofold:
(1) solve the "units specified in the xml or in the file" conundrum, having units specified in the xml take precedence, and avoiding double conversions
(2) provide for each I/O funcion a "raw" mode that assumes data is already passed (or gathered) in the desired units, and a normal function that also takes care of units conversion
basically the idea would be that in your script you can always use "raw" functions and hardcode unit conversions so that "ifs" don't get evaluated at each frame

@ipoltavskyi
Copy link
Collaborator

OK, I see. But right now the implementation simply does not work at all. I think it will be better if the person who had made all this changes first make the branch comparable with the master branch. For instance, I cannot run now even the harmonic oscillator example. Errors with files writing functions. Then, we can think how efficient the code is and do some tests. Now the brunch is in a semi finished state. And I still do not understand why we need "automatic" units. The default can be "atomic_unit", and then we just check the comment line for units specification. This removes a lot of if statements which must be performed every step right now. If someone need raw data, it is much easier to add a key and if the key is true just skip all units transformation. But, the first is first. Right now the branch is simply broken.

@ceriottm
Copy link
Collaborator Author

ceriottm commented Sep 18, 2017 via email

@ceriottm
Copy link
Collaborator Author

BTW, @ipoltavskyi please read the description of the pull request. It's months old but explains quite clearly what is the rationale and what we're trying to achieve. If you disagree with some of the objectives, I'm open to discussion, but reading that part carefully might help understand why there are new functions, and why the units conversion has moved to io from the trajectory outputs.py code

@ceriottm
Copy link
Collaborator Author

@venkatkapil24 there is still a request for you to clean up also the iter_file functions. Also, could you help making sure all postprocessing tools are compatible with the new infrastructure (perhaps wait until we are all on the same page with architecture before doing that). Thanks!

@ceriottm
Copy link
Collaborator Author

Hey all, @ipoltavskyi and @OndrejMarsalek in particular. Venkat has implemented iterator routines, and cleaned up a bit the code. I am all for open development and taking into account everyone's opinion but this PR has been open and tagged for review for three months. Please have a look, benchmark if you care about speed, and help making sure all the code paths and examples are compatible and working. If I don't hear anything, I'll merge early next week, and then avoid touching units until i-PI v3.0

@venkatkapil24
Copy link
Collaborator

venkatkapil24 commented Sep 21, 2017 via email

@venkatkapil24
Copy link
Collaborator

venkatkapil24 commented Sep 23, 2017

read_file is now silenced (as in the info statement is commented) since it leads to an absurd number of printouts during post processing.
Can the creator of xyz2bin and bin2xyz check if the results are exactly as expected ? @ceriottm : Can you test if kinetic2tag is working (just for the sake of completeness).
Also, I have not touched the PPI related tools.

@ceriottm ceriottm merged commit 2e191c1 into master Sep 27, 2017
@ceriottm ceriottm deleted the fix-units branch September 27, 2017 16:07
@ceriottm ceriottm restored the fix-units branch December 20, 2017 12:27
@ceriottm ceriottm deleted the fix-units branch December 20, 2017 12:30
@ceriottm ceriottm restored the fix-units branch December 20, 2017 13:51
@ceriottm ceriottm deleted the fix-units branch December 20, 2017 13:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants