Hex: src/db.cpp File Reference

| Hex 2.2 Hydrogen-electron collision solver

Functions | Variables
db.cpp File Reference
`#include <algorithm>`
`#include <complex>`
`#include <cstdio>`
`#include <cstdlib>`
`#include <cstring>`
`#include <string>`
`#include <vector>`
`#include <fstream>`
`#include <sqlitepp/sqlitepp.hpp>`
`#include "hex-arrays.h"`
`#include "hex-special.h"`
`#include "hex-interpolate.h"`
`#include "db.h"`
`#include "quantities.h"`
Include dependency graph for db.cpp:

## Functions

void | hex_initialize (const char *dbname)
void | hex_initialize_ (const char *dbname)
| Initialize the environment. More...
void | hex_new ()
void | hex_new_ ()
| Create new database. More...
void | hex_import (const char *sqlname)
void | hex_import_ (const char *sqlname)
| Import SQL batch file. More...
void | hex_update ()
void | hex_update_ ()
| Update integral and complete cross section. More...
void | hex_optimize ()
void | hex_optimize_ ()
| Optimize the SQLite database file. More...
void | hex_dump (const char *dumpfile)
void | hex_dump_ (const char *dumpfile)
| Dump contents of the T-matrix table. More...
int | hex_run (std::vector< std::string > const &vars, std::map< std::string, std::string > const &sdata)

## Variables

sqlitepp::session | db
eUnit | Eunits = eUnit_Ry
lUnit | Lunits = lUnit_au
aUnit | Aunits = aUnit_deg

## Function Documentation

## ◆ hex_dump()

void hex_dump | ( | const char * | dumpfile | ) |

## ◆ hex_dump_()

void hex_dump_ | ( | const char * | dumpname | ) |

The output can be used to construct an equivalent table. The corresponding code is

sqlite> .mode insert
sqlite> select * from tmat

## ◆ hex_import()

void hex_import | ( | const char * | sqlname | ) |

## ◆ hex_import_()

void hex_import_ | ( | const char * | sqlname | ) |

The effect of this function should be equivalent to direct use of sqlite3 program:

sqlite3 hex.db < batchfile.sql

The function uses one line at a time and splits the lines into statements on semicolons. For this reason it does not allow multi-line statements. The statements produced by computational modules have always one statement per line.

Parameters

  sqlname | Zero-terminated character string.

## ◆ hex_initialize()

void hex_initialize | ( | const char * | dbname | ) |

## ◆ hex_initialize_()

void hex_initialize_ | ( | const char * | dbname | ) |

The function will open existing database with path specified in "dbname". If the database does not exist, a new empty database will be created. Also, all registered variables will be given chance to initialize by the function

Variable::initialize (sqlitepp::session & db)

This can be used to register special functions needed later in the SQL statements. For example the variable IntegralCrossSection registeres two functions: the simple square root and a more complicated numerical integrator that uses ClenshawCurtis quadrature.

The function "initialize" also disables journalling to speed up insertion of data.

Parameters

  dbname | Zero-terminated character string.

## ◆ hex_new()

void hex_new | ( |  | ) |

## ◆ hex_new_()

void hex_new_ | ( |  | ) |

This will create the necessary table structure in a new empty database. It is necessary to call initialize first, so that the databse file is created and opened. The tables are created by the call to

Variable::SQL_CreateTable();

for every registered variable. The return value is a vector of SQL statement which are executed.

## ◆ hex_optimize()

void hex_optimize | ( |  | ) |

## ◆ hex_optimize_()

void hex_optimize_ | ( |  | ) |

Reduces the occupied space using the VACUUM statement.

## ◆ hex_run()

int hex_run | ( | std::vector< std::string > const & | vars,
|  | std::map< std::string, std::string > const & | sdata
| ) |  |

Run the computations.

## ◆ hex_update()

void hex_update | ( |  | ) |

## ◆ hex_update_()

void hex_update_ | ( |  | ) |

This function is used after import of T-matrices. All variables will be given chance to update themselves using the function

Variable::SQL_Update();

which returns SQL statement that should do the update. If a variable uses other variables besides T-matrices for its update, it must be inserted to VariableList AFTER those variables, because the order of update is set by the order in the list.

## Variable Documentation

## ◆ Aunits

aUnit Aunits = aUnit_deg

## ◆ db

sqlitepp::session db

## ◆ Eunits

eUnit Eunits = eUnit_Ry

## ◆ Lunits

lUnit Lunits = lUnit_au