D2O File Format
The .d2o file format is a binary file type to store densely packed scalar
fields. Den2Obj uses this file format to store the data in the
relatively unwieldy CHGCAR and PARCHG. In general, .d2o files are
about a factor 5 smaller than their corresponding CHGCAR files and can be
read in only a fraction of the time because the data does not need to be
converted from a human-readable format to binary.
The organization of this file is given in the Table 1.
Position |
Type |
Length |
Description |
|---|---|---|---|
0x00-0x02 |
char |
3 bytes |
Fixed token of “D2O” to identify the file. |
0x03-0x06 |
uint32_t |
4 bytes |
Protocol identifier token (see below). Selected automatically by default. |
0x07-0x2A |
float[9] |
36 bytes |
Unit cell matrix |
0x2B-0x36 |
uint32_t[3] |
12 bytes |
Grid dimensions (its product is the number of data points) |
0x37 |
uint8_t |
1 byte |
Floating point bytesize (float = 4, double = 8). Mainly used for validation purposes. |
0x38-0x3F |
uint64_t |
8 bytes |
Size of the compressed data stream |
0x40.. |
char[DATASIZE] |
DATASIZE bytes |
Compressed data stream containing densely packed scalar field. |
To convert a CHGCAR file to .d2o file format, run the following command:
den2obj -i CHGCAR -o filename.d2o -t
Note
Den2Obj will automatically look for the best compression algorithm
when converting a scalar field to the .d2o format. For the majority of the
cases, this corresponds to either the LZMA type of compression
or one of the newer array-oriented compression methods.
Protocol tokens
GZIP compression
LZMA compression
BZIP2 compression
ZSTD compression
Blosc compression