-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from nomad-coe/gxac_documentation
Analytic Continuation: Documentation + Symmetry constrains
- Loading branch information
Showing
38 changed files
with
18,873 additions
and
712 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
abstract: "Electronic structure calculations based on many-body perturbation theory involve analytic continuation from imaginary axis to real axis. The AnalyticContinuation component of the GreenX library has the aim to provide such tool." | ||
authors: | ||
- name: "GreenX library" | ||
- family-names : Azizi | ||
given-names : Maryam | ||
orcid : 0000-0001-9089-1043 | ||
cff-version: 1.2.0 | ||
contact: [email protected] | ||
- name: "" | ||
- family-names : "" | ||
given-names : "" | ||
orcid : "" | ||
cff-version: "" | ||
contact: "" | ||
preferred-citation: | ||
- doi: 10.21105/joss.05770 | ||
- doi: "" | ||
license: | ||
- Apache-2.0 | ||
message: "If you use this software, please cite the article from preferred-citation DOI contained in this CITATION.cff file." | ||
repository-code: "https://github.com/nomad-coe/greenX/tree/main/GX-TimeFrequency" | ||
repository-code: "https://github.com/nomad-coe/greenX/tree/main/GX-AnalyticContinuation" | ||
title: "Analytic continuation component of the GreenX library" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,88 @@ | ||
## GreenX library - Analytic Continuation | ||
# GreenX library - Analytic Continuation | ||
|
||
The analytic continuation component provides routines to interpolate functions using the thiele pade interpolant. | ||
The analytic continuation component (GX-AC) provides routines to interpolate functions using the thiele pade interpolant. | ||
|
||
> [!Note] | ||
> **Key Features** | ||
> - basic thiele pade algorithm | ||
> - greedy algorithm for thiele pade to enhance numerical stability | ||
> - arbitrary precision arithmetic using the GMP library for even more numerical stability | ||
|
||
## Usage | ||
## Building | ||
|
||
### Basic usage pade interpolation | ||
|
||
> **Default**: | ||
> - use the greedy algorithm | ||
> - use 64 bit float precision (double precision) when GMP is not linked | ||
> - use 128 bit float precision (quadrupel precision) when linked against GMP | ||
|
||
```fortran | ||
use gx_ac, only: create_thiele_pade, evaluate_thiele_pade_at, & | ||
free_params, params | ||
If you want to compile only the Analytic Continuation (AC) component of Greenx, change to the GreenX root, then type: | ||
```bash | ||
mkdir build && cd build | ||
cmake -DMINIMAX_COMPONENT=OFF -DLBASIS_COMPONENT=OFF \ | ||
-DPAW_COMPONENT=OFF -DCOMPILE_SUBMODULES=OFF ../ | ||
make -j | ||
make install | ||
|
||
# optional: for running the regression tests | ||
ctest | ||
``` | ||
|
||
complex(dp), allocatable :: x_ref(:), y_ref(:) | ||
### Linking against GNU Multiple Precision (GMP) Library | ||
|
||
If requested, the arithmetic operations to obtain the pade model are carried out using an user specified precision. These arbitrary precision floats are handeled by the [GMP library](https://gmplib.org/). **By default GreenX tries to find and link GMP automatically** since it is installed already on most systems that use GNU compilers. However, if GreenX is unable to find the GMP library it will note the user during the cmake configuration step. | ||
|
||
#### Compile and link GMP manually: | ||
If for some reason no GMP is found in your system you can build it manually and specify its path in the GreenX build. Assumes that `$GX_ROOT` is set to the root of GreenX: | ||
```bash | ||
cd $GX_ROOT | ||
|
||
# ------------------- Build GMP library | ||
mkdir external && cd external | ||
wget https://gmplib.org/download/gmp/gmp-6.3.0.tar.xz | ||
tar -xf gmp-6.3.0.tar.xz | ||
cd gmp-6.3.0/ && mkdir install | ||
GMP_INSTALL_DIR="$(realpath install)" | ||
./configure --prefix="${GMP_INSTALL_DIR}" --enable-cxx | ||
make -j | ||
make install | ||
# optionally run unit tests of GMP | ||
# make check | ||
|
||
cd $GX_ROOT | ||
|
||
# ------------------- Build GreenX | ||
mkdir build && cd build | ||
cmake -DCMAKE_PREFIX_PATH=$GMP_INSTALL_DIR ../ | ||
make -j | ||
make install | ||
``` | ||
|
||
type(params) :: params_thiele | ||
complex(dp), dimension(:), allocatable :: x_query | ||
complex(dp), dimension(:), allocatable :: y_return | ||
integer :: n_par ! number of pade parameters | ||
|
||
allocate(x_ref(npar), y_ref(npar)) | ||
allocate(x_query(10), y_return(10)) | ||
#### Turn off GMP: | ||
You can turn of linking to GMP by specifiying `ENABLE_GNU_GMP=OFF` in the cmake configuration step. | ||
```bash | ||
cmake -DENABLE_GNU_GMP=OFF ../ # Default: ENABLE_GNU_GMP=ON | ||
``` | ||
|
||
! initialize x_ref, y_ref and x_quer | ||
## Calling the Analytic Continuation Component | ||
|
||
! create the interpolation model and store it in struct | ||
params_thiele = create_thiele_pade(n_par, x_ref, y_ref) | ||
Information on how to use this component is always up-to-date on the [GreenX website](https://nomad-coe.github.io/greenX/gx_ac.html). | ||
|
||
! evaluate the interpolation model at given x points | ||
y_return(1:10) = evaluate_thiele_pade_at(params_thiele, x_query) | ||
Additionally, take a look at the example script in `GX-AnalyticContinuation/examples`. This script shows how this component can be used. | ||
|
||
! Clean-up | ||
call free_params(params_thiele) | ||
## Build the Example Script | ||
In the `GX-AnalyticContinuation/examples` folder you can find a stand-alone fortran program (`pade_example.f90`) showcasing the usage of the GX-AC component. After building the GreenX library, change into the `GX-AnalyticContinuation/examples` folder and type: | ||
```bash | ||
make | ||
``` | ||
|
||
### Advanced usage pade interpolation | ||
e.g. to use the plain thiele pade algorithm (non-greedy) with 10 fold float precision: | ||
```fortran | ||
params_thiele = create_thiele_pade(n_par, x_ref, y_ref, do_greedy=.false., precision=320) | ||
The program can be executed by running: | ||
```bash | ||
./pade_example > output.dat | ||
``` | ||
e.g. to use the greedy algorithm with the faster double precision fortran implementation (doesn't make use of GMP even if it is linked) : | ||
```fortran | ||
params_thiele = create_thiele_pade(n_par, x_ref, y_ref, do_greedy=.true., precision=64) | ||
To plot the reference function and the Padé interpolation call the python script: | ||
```bash | ||
python plot.py output.dat comparison.png | ||
``` | ||
The figure is saved as `comparison.png`. Feel free to change some parameters in the `pade_example.f90` script and compile again to see how it is affecting the pade interpolation. | ||
|
||
## Running the regression tests | ||
Regression tests of the GX-AC component use the testing framework [pytest](https://docs.pytest.org/en/stable/#). Simply type `ctest` in the build directory after the GreenX library has been build. | ||
|
||
### Availability of GMP at runtime | ||
For more information please refer to the main [README.md](https://github.com/nomad-coe/greenX/blob/main/README.md) of this repository. | ||
|
||
It is possible to check whether GMP is linked against GreenX at runtime: | ||
```fortran | ||
use gx_ac, only: arbitrary_precision_available, create_thiele_pade | ||
|
||
if (arbitrary_precision_available) then | ||
! this will succeed | ||
params_thiele = create_thiele_pade(n_par, x_ref, y_ref, do_greedy=.false., precision=320) | ||
else if (.not. arbitrary_precision_available) then | ||
! this will result in an error | ||
params_thiele = create_thiele_pade(n_par, x_ref, y_ref, do_greedy=.false., precision=320) | ||
end if |
Oops, something went wrong.