mailhexu / TB2J

a python package for computing magnetic interaction parameters
BSD 2-Clause "Simplified" License
67 stars 29 forks source link

[ENH]: Increase decimals for txt output #33

Closed adrybakov closed 11 months ago

adrybakov commented 11 months ago

Hello!

In some post-processing scenarios improved precision of the atom's coordinates and unit cell parameters is necessary.

For example, if one want to compute distances between atoms from the structure the results differs from the one outputted in the exchange.out

The proposed change increase the decimals after the comma up to 8 in the output for atom's coordinates and unit cell.

The only downside of the proposed change is that the style will be a little bit broken visually for the case of non-collinear calculations: lines with the atom's coordinates exceed headers.

If you have a better idea of how to achieve the same result, please let me know. I thought of the separation of atom's coordinates and charges/magmoms into two different section. However, this change breaks the format of the file and may affect 3rd party post-process tools, if they rely on the exchange.out layout.

Best, Andrey

mailhexu commented 11 months ago

Hello! Thanks! Personally, I would prefer not to use the txt file for postprocessing . But increasing decimals should be fine if it does not make it difficult for human eyes? Could you send me a output so I can see what it looks like?

My opinion is that txt file should not be used for post-processing. The format could change over versions and it is difficult to keep the compatibility. There should always be two output formats, one for humans and one for computers.

Currently there is pickle output which provides more data than the txt and is easier to parse (there is a api to read the file but maybe poorly designed and documented. ), but it is only for Python, and there can be some compatibility issues across Python version. I can add another format that is easier for post-processing (json or netcdf), so that it is easy to parse, and is more general than pickle. I will soon work on a better api/documentation for reading the output.

Best, HeXu

adrybakov commented 11 months ago

Here is the screenshot: Screenshot 2023-09-21 at 15 31 53

Regarding the output format: I agree that the documentation is main obstacle to use of the .pickle format. It stopped me from using it and I'm using .txt file. From the external (of TB2J) point of view the documentation about the structure of the .pickle file content is missing (how to use the content).

For the computer-friendly output, may I suggest yaml? It is subjectively more human-readable, than json and does not depend on python as pickle.

About two formats: If language-independent format for the computers is used (yaml or json), then the (TB2J specific) layout of the data can change anyway, which means the same difficulties for the compatibility (nevertheless, less pronounced, than the ones for .txt). Personally I think that unified format for humans and computer may be considered, as it makes the sharing easier (one does not need to keep the links between human-like and computer-like files). Do you think that the unified output possible for TB2J or is it 100% out of consideration?

Best, Andrey