Skip to content

Commit

Permalink
Updated benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
elinscott committed Sep 8, 2023
2 parents b262bb2 + 70ea20c commit 00bf7f1
Show file tree
Hide file tree
Showing 1,195 changed files with 591,011 additions and 587,461 deletions.
6 changes: 6 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
# Required
version: 2

# Specify the python version
build:
os: "ubuntu-22.04"
tools:
python: "3.8"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ preferred-citation:
repository-code: https://github.com/epfl-theos/koopmans/
title: koopmans
type: software
version: 1.0.0rc1
version: 1.0.0
899 changes: 282 additions & 617 deletions LICENSE

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@

import os
import sys
from calendar import month_name
from datetime import date

import pybtex.plugin
import sphinx_rtd_theme
from pybtex.style.formatting.plain import Style as PlainStyle
from pybtex.style.formatting.unsrt import Style as UnsrtStyle
from pybtex.style.sorting import BaseSortingStyle
from sphinx_pyproject import SphinxConfig

# If extensions (or modules to document with autodoc) are in another directory,
Expand Down Expand Up @@ -68,3 +74,33 @@
autodoc_typehints = 'none'
autodoc_mock_imports = ['ase']
numpydoc_show_class_members = False

# -- Chronological bibliography style -----------------------------------------


class ChronoSortingStyle(BaseSortingStyle):
def sort(self, entries):
def get_date(entry):
month_lookup = list(month_name)
year = int(entry.fields['year'])
month = month_lookup.index(entry.fields.get('month', 'January'))
return date(year, month, 1)
return sorted(entries, key=get_date)


class MyChronoStyle(UnsrtStyle):
def __init__(self, *args, **kwargs):
kwargs.update(sorting_style=ChronoSortingStyle, abbreviate_names=True)
return super().__init__(*args, **kwargs)


pybtex.plugin.register_plugin('pybtex.style.formatting', 'chrono', MyChronoStyle)


class MyAbbrevPlainStyle(PlainStyle):
def __init__(self, *args, **kwargs):
kwargs.update(abbreviate_names=True)
return super().__init__(*args, **kwargs)


pybtex.plugin.register_plugin('pybtex.style.formatting', 'plainabbrev', MyAbbrevPlainStyle)
73 changes: 71 additions & 2 deletions docs/references.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,76 @@
References
==========
For publications using Koopmans spectral functionals, please cite :cite:`Borghi2014`, :cite:`Nguyen2018`, and ...

Selected references
-------------------

In any publication arising from the use of Koopmans functionals and/or the ``koopmans`` code, please cite

.. bibliography::
:style: chrono
:filter: False
:list: bullet

Linscott2023

Other relevant references include

**Papers introducing Koopmans functionals**

.. bibliography::
:style: chrono
:filter: False
:list: bullet

Dabo2009
Dabo2010
Borghi2014
Borghi2015

**Linear-response formalism**

.. bibliography::
:style: chrono
:filter: False
:list: bullet

Colonna2018

**Application to molecules**

.. bibliography::
:style: chrono
:filter: False
:list: bullet

Dabo2013
Nguyen2015
Nguyen2016
Colonna2019

**Application to solids**

.. bibliography::
:style: chrono
:filter: False
:list: bullet

Nguyen2018
Colonna2022
DeGennaro2022

**Connection with many-body formulations**

.. bibliography::
:style: chrono
:filter: False
:list: bullet

Ferretti2014

All references
--------------

.. bibliography::
:style: plain
:style: plainabbrev
:all:
1 change: 1 addition & 0 deletions docs/theory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ This section contains a brief introduction to Koopmans functionals.
theory/ingredients
theory/workflows
theory/limitations
theory/related_methods

For more details, refer to our various :ref:`publications <references:references>`.
10 changes: 10 additions & 0 deletions docs/theory/related_methods.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Related methods
===============

Koopmans functionals have resonance with various methods developed by other groups. These include...

- the Wannier transition-state method of Anisimov and Kozhevnikov :cite:`Anisimov2005`
- the optimally-tuned range-separated hybrid functionals of Kronik, Neaton, and others :cite:`Kronik2012,Wing2021`
- the localized orbital scaled correction of Yang and others :cite:`Li2018`
- the ensemble DFT method of Kreisler, Kronik and others :cite:`Kraisler2013`
- the Koopmans-Wannier method of Wang and others :cite:`Ma2016`
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "koopmans"
version = "1.0.1"
description = "Koopmans spectral functional calculations with python and Quantum ESPRESSO"
readme = "README_pypi.rst"
requires-python = ">=3.7"
requires-python = ">=3.8"
authors = [
{ name = "Edward Linscott", email = "[email protected]" },
{ name = "Riccardo De Gennaro", email = "[email protected]" },
Expand All @@ -13,7 +13,6 @@ classifiers = [
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand All @@ -31,7 +30,7 @@ dependencies = [
"pybtex>=0.24",
"spglib>=1.9",
"upf-to-json>=0.9.5",
"ase-koopmans==0.1.1",
"ase-koopmans==0.1.4",
"scikit-learn>=1.0",
"deepdiff>=5.8.1",
]
Expand Down
2 changes: 1 addition & 1 deletion quantum_espresso/q-e
Submodule q-e updated from 564a7b to b4c5e8
2 changes: 1 addition & 1 deletion src/koopmans/bands.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def _check_array_shape_match(self, array, array_name):
f'array of length {len(array)}'
for i, (subarray, n_bands) in enumerate(zip(array, self.n_bands)):
assert len(subarray) == n_bands, f'Bands.{array_name}[{i}] must be length {n_bands} but you provided an ' \
f'array with length {len(subarray)}'
f'array with length {len(subarray)}. The file_alpharef files should reflect the number of states in the supercell.'

@property
def filling(self) -> List[List[bool]]:
Expand Down
17 changes: 15 additions & 2 deletions src/koopmans/calculators/_ph.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ase import Atoms
from ase.calculators.espresso import EspressoPh

from koopmans.commands import ParallelCommand
from koopmans.commands import ParallelCommand, Command
from koopmans.settings import PhSettingsDict

from ._utils import CalculatorABC, CalculatorExt
Expand Down Expand Up @@ -42,7 +42,11 @@ def is_complete(self):

def _calculate(self):
super()._calculate()
self.read_dynG()
if self.parameters.trans:
self.read_dynG()
else:
self.read_stdout()


def read_dynG(self):
with open(self.parameters.fildyn, 'r') as fd:
Expand All @@ -52,3 +56,12 @@ def read_dynG(self):
k = [x.strip() for x in flines].index('Effective Charges E-U: Z_{alpha}{s,beta}')
epsilon = np.array([x.split() for x in flines[i + 2: k - 1]], dtype=float)
self.results['dielectric tensor'] = epsilon

def read_stdout(self):
path=f'{self.prefix}{self.ext_out}'
with open(path, 'r') as fd:
flines = fd.readlines()

i = [x.strip() for x in flines].index('Dielectric constant in cartesian axis')
epsilon = np.array([x.split()[1:4] for x in flines[i + 2: i + 5]], dtype=float)
self.results['dielectric tensor'] = epsilon
29 changes: 29 additions & 0 deletions src/koopmans/kpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class Kpoints:
offset : List[int]
a list of three integers, either zero or one. If one, the regular k-point grid is offset by half a grid step
in that dimension
offset_nscf : Union[List[Union[int, float]]], int, float]
a list of three numbers, within the interval (-1, 1].
It has the same meaning of offset, but it is applied only to the grid of PWnscf calculations. Additionally it allows to provide explicitly any fractional offset.
path : ase.dft.kpoints.BandPath
an ASE ``BandPath`` object specifying the k-path as defined by the special points of the Bravais
lattice
Expand All @@ -35,10 +38,12 @@ class Kpoints:

_grid: Optional[List[int]]
_offset: Optional[List[int]]
_offset_nscf: Optional[Union[List[Union[int, float]], int, float]]
_path: Optional[BandPath]
gamma_only: bool

def __init__(self, grid: Optional[List[int]] = [1, 1, 1], offset: Optional[List[int]] = [0, 0, 0],
offset_nscf: Optional[Union[List[Union[int, float]], int, float]] = None,
path: Optional[Union[str, BandPath]] = None, gamma_only: bool = False, cell: Optional[Cell] = None,
density: float = 10.0):
"""
Expand All @@ -57,9 +62,11 @@ def __init__(self, grid: Optional[List[int]] = [1, 1, 1], offset: Optional[List[
raise ValueError(f'gamma_only = {gamma_only} and grid != None are incompatible')
self.grid = None
self.offset = [0, 0, 0]
self.offset_nscf = None
else:
self.grid = grid
self.offset = offset
self.offset_nscf = offset_nscf

self.set_path(path, cell, density)

Expand Down Expand Up @@ -100,6 +107,28 @@ def offset(self, value: Optional[List[int]]):
raise ValueError('"offset" must only contain either 0 or 1s')
self._offset = value

@property
def offset_nscf(self) -> Optional[Union[List[Union[int, float]], int, float]]:
return self._offset_nscf

@offset_nscf.setter
def offset_nscf(self, value: Optional[Union[List[Union[int, float]], int, float]]):
if isinstance(value, list):
if len(value) != 3:
raise ValueError('"offset" must be a list of three numbers')
if any([k <= -1 or k > 1 for k in value]):
raise ValueError('"offset_nscf" elements take values within (-1, 1]')
if all([k - int(k) == 0 for k in value]):
self._offset_nscf = [int(k) for k in value]
else:
self._offset_nscf = value
elif isinstance(value, (int, float)):
self._offset_nscf = int(value) if value - int(value) == 0 else value
elif value is None:
self._offset_nscf = value
else:
raise ValueError('"offset_nscf" must be a number or a list of three numbers')

@property
def path(self) -> Optional[BandPath]:
return self._path
Expand Down
Loading

0 comments on commit 00bf7f1

Please sign in to comment.