Safe Haskell  None 

This module contains functions for reading the GSE one and twoelectron integral data from a file, converting this data from spatial to spin indices, and accessing the data.
The external interface consists of the type GSEData
and the
function load_gse_data
.
The Quipper distribution contains example data files
"h_1e_ascii
" and "h_2e_ascii
". These files contain enough
data for M = 32 spin orbitals (corresponding to M/2 = 16
spatial orbitals). Note that the example data was randomly
generated and is only a mockup. In actual applications, physically
meaningful data should be substituted.
 data GSEData = GSEData {
 gse_data_M :: Int
 gse_data_h1 :: (Int, Int) > Double
 gse_data_h2 :: (Int, Int, Int, Int) > Double
 load_gse_data :: Int > String > String > IO GSEData
 access_1e :: Array (Int, Int) e > (Int, Int) > e
 access_2e :: Array (Int, Int, Int, Int) e > (Int, Int, Int, Int) > e
 is_comment :: String > Bool
 parsefile1 :: Int > String > Array (Int, Int) Double
 parsefile2 :: Int > String > Array (Int, Int, Int, Int) Double
 spin1 :: ((Int, Int) > Double) > (Int, Int) > Double
 spin2 :: ((Int, Int, Int, Int) > Double) > (Int, Int, Int, Int) > Double
 print_1e :: GSEData > String
 print_2e :: GSEData > String
 gse_data_test :: Int > IO ()
Data abstraction
A data structure describing the GSE Data  the number of integrals and the functions to access the data by index.
GSEData  

Reading GSE data from files
This section provides function for reading one and twoelectron GSE data from files. The file formats are as follows. The file for the oneelectron data consists of lines of the form:
((i, j), h)
where i and j are integer indices in the range from 0 to M−1, and h = h_{i,j} is a real floating point number. Please note that the file contains data for (i, j) and (j, i), and that the indices i and j are in spatial coordinates. The file data is sorted in order of increasing i, then j.
The file for the twoelectron data consists of lines of the form:
((i, j, k, l), h)
where i, j, k, and l are integer indices in the range from 0 to M−1, and h = h_{i,k,l,j} is a real floating point number. Please note that the indices i, j, k, and l are in spatial coordinates, and the ordering of indices in the file follows the chemists' convention. Also, to save storage space, the file only contains data for i ≥ j, k ≥ l, and either i > k, or i = k and j ≥ l. The remaining data must be inferred from symmetries. The file data is sorted in order of increasing i, then j, then k, then l.
We also note that the data files, and the functions of this module where noted, are the only places where we use Chemists' notation and spatial orbitals. The remainder of our implementation uses physicists' notation and spin orbitals throughout.
load_gse_data :: Int > String > String > IO GSEData Source #
Read the GSEData
from two files. The first argument is M, the
number of spin orbitals. The second and third argument are the
filenames for the oneelectron and twoelectron data, respectively.
If the file contains data for more than M spin orbitals, ignore the excess data (this is useful for generating smaller problem sizes for testing). In this case, only the necessary portion of the file is read. If the file contains data for fewer than M spin orbitals, this is silently ignored, but will lead to an "undefined" error later.
Lowlevel access functions
access_1e :: Array (Int, Int) e > (Int, Int) > e Source #
Access 1electron integral data. The indices are spatial, i.e., they run from 0 to M/2 − 1.
access_2e :: Array (Int, Int, Int, Int) e > (Int, Int, Int, Int) > e Source #
Access 2electron integral data. The input array is sparse (i.e., contains only one representative of each equivalence class), and uses chemists' conventions. The output uses physicists' conventions. The indices in both input and output are spatial, i.e., they run from 0 to M/2 − 1.
Lowlevel parsing functions
is_comment :: String > Bool Source #
Decide whether a string is a comment. A comment is a line with only whitespace characters, or where the first nonwhitespace character is '#'.
parsefile1 :: Int > String > Array (Int, Int) Double Source #
Extract an array from the oneelectron file data. We do this lazily, i.e., we stop reading as soon as enough data is found. The resulting array uses spatial indices.
parsefile2 :: Int > String > Array (Int, Int, Int, Int) Double Source #
Extract an array from the twoelectron file data. We do this lazily, i.e., we stop reading as soon as enough data is found. The resulting array uses spatial indices in chemists' notation. Also, the output array is sparse; it only contains as much data as the file itself.
Conversion of spin to spatial indices
spin1 :: ((Int, Int) > Double) > (Int, Int) > Double Source #
In the molecule we have twice as many orbitals (spin orbitals) than data in the integral file (spatial orbitals). This function converts h_{1} from spatialorbitals (M/2 = 104) to spin orbitals (M = 208).
Spin orbitals are indexed by p=(i, σ_{i}), where i is a spatial index and σ_{i} is a spin (up or down). For two spin indices p=(i, σ_{i}) and q=(j, σ_{j}), the transition integral h_{pq} is given by the following formula:
The Hamiltonian vanishes for σ_{i} ≠ σ_{j} because we assume that there is no spin orbital coupling.
Given M/2 spatial orbitals, we remap the spin orbitals to integers from 0 to M−1 using the formula p = 2i+σ_{i}, where σ_{i} is 0 or 1.
The function spin1
inputs (h_{ij}), the table of 1electron
integrals for M/2 spatial orbitals, and outputs the
corresponding table (h_{pq}) for M spin orbitals.
spin2 :: ((Int, Int, Int, Int) > Double) > (Int, Int, Int, Int) > Double Source #
Like spin1
, but for 2electron integrals. Here, the transition
integrals in spin coordinates are given by:
The Hamiltonian vanishes for σ_{i} ≠ σ_{l} or σ_{j} ≠ σ_{k} because we assume that there is no spin orbital coupling.
The function spin2
inputs (h_{ijkl}), the table of
2electron transition amplitudes for M/2 spatial orbitals, and
outputs the corresponding table (h_{pqrs}) for M spin
orbitals. Index ordering follows the physicists' convention.
Testing
gse_data_test :: Int > IO () Source #
A main function to test the GSEData module.