Input / Output
Julia features a variety of packages facilitating input and output of data. For C++, XDiag provides convenient functionality for TOML and HDF5 files.
Reading from TOML
While XDiag allows for defining a Hamiltonian or other operators in code, it is often preferable to define objects in advance in an input file. In XDiag, we use the TOML language to define basic objects in simple files. Among those, operators represented as an OpSum can be specified in a simple format. As an example, the Hamiltonian of the \(N=8\) site Heisenberg chain we created above can be defined in the following way.
The first entry in every list element denotes the coupling constant \(J\), the second entry denotes the type SdotS, and the following two entries are the sites of the operator. To read in such a Hamiltonian from a TOML file we can use the FileToml object together with the read_opsum function,
In the TOML file, the coupling constant \(J\) is defined as a string, which is then set to a numerical value in the application code. Alternatively, the coupling constant could also be explicitly defined by a numerical value in the TOML file. Complex numbers \(x + iy\) can be represented by a size-two array of the form [x, y]. XDiag also features the functions read_permutation_group and read_representation to conveniently read PermutationGroup and Representation objects used to describe symmetries from file; see Symmetries.
The TOML input files assume that counting starts at \(0\) for both the C++ and Julia version, such that the same input file can be used for both languages. In Julia, however, the site index is increased by one after reading in the OpSum.
Writing results to HDF5
The results of numerical simulations are typically stored in output files. A standard scientific data format is the HDF5 format. Julia supports input and output to HDF5 with the HDF5.jl package. For C++ we provide a convenient way of writing results to HDF5 files. In general all numerical data, including scalar real/complex numbers as well as Armadillo vectors and matrices, can be easily written to files using the FileH5 object.
The second argument "w!" specifies the access mode to the file. "w!" is the forced write mode, where preexisting files are overwritten. Additionally, a protected write mode "w" raising an error for existing files, and a read mode "r" are provided.