<commit_before>[![Build Status](https://travis-ci.org/dftlibs/numgrid.svg?branch=master)](https://travis-ci.org/dftlibs/numgrid/builds)
[![Coverage Status](https://coveralls.io/repos/dftlibs/numgrid/badge.png?branch=master)](https://coveralls.io/r/dftlibs/numgrid?branch=master)
[![License](https://img.shields.io/badge/license-%20MPL--v2.0-blue.svg)](../master/LICENSE)

![alt text](https://github.com/dftlibs/numgrid/raw/master/img/truegrid.jpg "numgrid")

- [Authors](../master/AUTHORS.md)
- [Build and test history](https://travis-ci.org/dftlibs/numgrid/builds)
- [Code coverage](https://coveralls.io/r/dftlibs/numgrid)
- Licensed under [MPL v2.0](../master/LICENSE) (except <NAME>'s Lebedev code which is redistributed under LGPL v3.0)
- Built with [Autocmake](https://github.com/coderefinery/autocmake)


# About

Numgrid is a library that produces numerical integration grid for molecules
based on atom coordinates, atom types, and basis set information.
Numgrid can be built with C, Fortran, and Python bindings.


# Contributing

Yes please! Please follow [this excellent
guide](http://www.contribution-guide.org).  We do not require any formal
copyright assignment or contributor license agreement. Any contributions
intentionally sent upstream are presumed to be offered under terms of the
Mozilla Public License Version 2.0.


# Requirements

- CMake
- C and C++ compiler
- Fortran compiler (to build the optional Fortran interface)
- [CFFI](https://cffi.readthedocs.org) (to access the optional Python interface)
- [pytest](http://pytest.org) (to test the optional Python interface)


# Building and testing

```
git clone https://github.com/dftlibs/numgrid.git
cd numgrid
./setup --fc=gfortran --cc=gcc --cxx=g++
cd build
make
make test
```


# API

We provide a context-aware C interface. In addition we also provide a Fortran
and Python interfaces as thin layers on top of the C interface:

```
Fortran: api/numgrid.f90
  \
   \     Python: api/numgrid.py
    \   /
  C interface: api/numgrid.h
      |
implementation
```


## Creating and destroying contexts

Create a new context:

```c
numgrid_context_t *numgrid_new();
```

Destroy the context and deallocates all data:

```c
void numgrid_free(numgrid_context_t *context);
```

You can keep several contexts alive at the same time.

Generate grid and hold it in memory for the lifetime of the context (returns 0 if the call
completed without errors):

```c
int numgrid_generate(numgrid_context_t *context,
                     const double radial_precision,
                     const int    min_num_angular_points,
                     const int    max_num_angular_points,
                     const int    num_centers,
                     const double center_coordinates[],
                     const int    center_elements[],
                     const int    num_outer_centers,
                     const double outer_center_coordinates[],
                     const int    outer_center_elements[],
                     const int    num_shells,
                     const int    shell_centers[],
                     const int    shell_l_quantum_numbers[],
                     const int    shell_num_primitives[],
                     const double primitive_exponents[]);
```

Get number of grid points:

```c
int numgrid_get_num_points(const numgrid_context_t *context);
```

Get the pointer to the memory which holds the grid:

```c
double *numgrid_get_grid(const numgrid_context_t *context);
```

The grid is saved in a one-dimensional array with the following ordering:

```
point 1, x coordinate
point 1, y coordinate
point 1, z coordinate
point 1, weight
point 2, x coordinate
point 2, y coordinate
point 2, z coordinate
point 2, weight
...
point N, x coordinate
point N, y coordinate
point N, z coordinate
point N, weight
```<commit_msg>add more sections in doc<commit_after>[![Build Status](https://travis-ci.org/dftlibs/numgrid.svg?branch=master)](https://travis-ci.org/dftlibs/numgrid/builds)
[![Coverage Status](https://coveralls.io/repos/dftlibs/numgrid/badge.png?branch=master)](https://coveralls.io/r/dftlibs/numgrid?branch=master)
[![License](https://img.shields.io/badge/license-%20MPL--v2.0-blue.svg)](../master/LICENSE)

![alt text](https://github.com/dftlibs/numgrid/raw/master/img/truegrid.jpg "numgrid")

- [Authors](../master/AUTHORS.md)
- [Build and test history](https://travis-ci.org/dftlibs/numgrid/builds)
- [Code coverage](https://coveralls.io/r/dftlibs/numgrid)
- Licensed under [MPL v2.0](../master/LICENSE) (except <NAME>'s Lebedev code which is redistributed under LGPL v3.0)
- Built with [Autocmake](https://github.com/coderefinery/autocmake)


# About

Numgrid is a library that produces numerical integration grid for molecules
based on atom coordinates, atom types, and basis set information.
Numgrid can be built with C, Fortran, and Python bindings.


# Contributing

Yes please! Please follow [this excellent
guide](http://www.contribution-guide.org).  We do not require any formal
copyright assignment or contributor license agreement. Any contributions
intentionally sent upstream are presumed to be offered under terms of the
Mozilla Public License Version 2.0.


# Requirements

- CMake
- C and C++ compiler
- Fortran compiler (to build the optional Fortran interface)
- [CFFI](https://cffi.readthedocs.org) (to access the optional Python interface)
- [pytest](http://pytest.org) (to test the optional Python interface)


# Building and testing

```
git clone https://github.com/dftlibs/numgrid.git
cd numgrid
./setup --fc=gfortran --cc=gcc --cxx=g++
cd build
make
make test
```


# API

We provide a context-aware C interface. In addition we also provide a Fortran
and Python interfaces as thin layers on top of the C interface:

```
Fortran: api/numgrid.f90
  \
   \     Python: api/numgrid.py
    \   /
  C interface: api/numgrid.h
      |
implementation
```


## Creating and destroying contexts

Create a new context:

```c
numgrid_context_t *numgrid_new();
```

Destroy the context and deallocates all data:

```c
void numgrid_free(numgrid_context_t *context);
```

You can keep several contexts alive at the same time.


## Generating the grid

Generate grid and hold it in memory for the lifetime of the context (returns 0 if the call
completed without errors):

```c
int numgrid_generate(numgrid_context_t *context,
                     const double radial_precision,
                     const int    min_num_angular_points,
                     const int    max_num_angular_points,
                     const int    num_centers,
                     const double center_coordinates[],
                     const int    center_elements[],
                     const int    num_outer_centers,
                     const double outer_center_coordinates[],
                     const int    outer_center_elements[],
                     const int    num_shells,
                     const int    shell_centers[],
                     const int    shell_l_quantum_numbers[],
                     const int    shell_num_primitives[],
                     const double primitive_exponents[]);
```


## How to query the grid

Get number of grid points:

```c
int numgrid_get_num_points(const numgrid_context_t *context);
```

Get the pointer to the memory which holds the grid:

```c
double *numgrid_get_grid(const numgrid_context_t *context);
```

The grid is saved in a one-dimensional array with the following ordering:

```
point 1, x coordinate
point 1, y coordinate
point 1, z coordinate
point 1, weight
point 2, x coordinate
point 2, y coordinate
point 2, z coordinate
point 2, weight
...
point N, x coordinate
point N, y coordinate
point N, z coordinate
point N, weight
```
{'fraction_non_alphanumeric': 0.10048033233805011, 'fraction_numerical': 0.005452421134622874, 'mean_word_length': 3.153099730458221, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 22, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '843977', 'n_tokens_mistral': 2382, 'n_tokens_neox': 2229, 'n_words': 738}