Skip to content

Commit

Permalink
add Mesh, NumericalIntegration and MolecularHamiltonianSubTerms
Browse files Browse the repository at this point in the history
  • Loading branch information
EBB2675 committed Nov 19, 2024
1 parent 52d6b9a commit 646430c
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 49 deletions.
13 changes: 13 additions & 0 deletions src/nomad_simulations/schema_packages/model_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -1221,3 +1221,16 @@ class DMFT(ModelMethodElectronic):

def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
super().normalize(archive, logger)


class MolecularHamiltonianSubTerms(BaseModelMethod):
type=Quantity(
type=MEnum('coulomb', 'exchange'),
description="""
Typical sub-terms of the molecular hamiltonian.
Relativistic effects, SOC, .....
""",
)

def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
super().normalize(archive, logger)
127 changes: 78 additions & 49 deletions src/nomad_simulations/schema_packages/numerical_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,66 +52,45 @@ class Smearing(NumericalSettings):

class Mesh(ArchiveSection):
"""
A base section used to specify the settings of a sampling mesh.
It supports uniformly-spaced meshes and symmetry-reduced representations.
A base section used to define the mesh or space partitioning over which a discrete numerical integration is performed.
"""

spacing = Quantity(
type=MEnum('Equidistant', 'Logarithmic', 'Tan'),
shape=['dimensionality'],
dimensionality = Quantity(
type=np.int32,
default=3,
description="""
Identifier for the spacing of the Mesh. Defaults to 'Equidistant' if not defined. It can take the values:
| Name | Description |
| --------- | -------------------------------- |
| `'Equidistant'` | Equidistant grid (also known as 'Newton-Cotes') |
| `'Logarithmic'` | log distance grid |
| `'Tan'` | Non-uniform tan mesh for grids. More dense at low abs values of the points, while less dense for higher values |
Dimensionality of the mesh: 1, 2, or 3. Defaults to 3.
""",
)

quadrature = Quantity(
type=MEnum(
'Gauss-Legendre',
'Gauss-Laguerre',
'Clenshaw-Curtis',
'Newton-Cotes',
'Gauss-Hermite',
),
kind = Quantity(
type=MEnum('equidistant', 'logarithmic', 'tan'),
shape=['dimensionality'],
description="""
Quadrature rule used for integration of the Mesh. This quantity is relevant for 1D meshes:
Kind of mesh identifying the spacing in each of the dimensions specified by `dimensionality`. It can take the values:
| Name | Description |
| --------- | -------------------------------- |
| `'Gauss-Legendre'` | Quadrature rule for integration using Legendre polynomials |
| `'Gauss-Laguerre'` | Quadrature rule for integration using Laguerre polynomials |
| `'Clenshaw-Curtis'` | Quadrature rule for integration using Chebyshev polynomials using discrete cosine transformations |
| `'Gauss-Hermite'` | Quadrature rule for integration using Hermite polynomials |
""",
) # ! @JosePizarro3 I think that this is separate from the spacing

n_points = Quantity(
type=np.int32,
description="""
Number of points in the mesh.
| `'equidistant'` | Equidistant grid (also known as 'Newton-Cotes') |
| `'logarithmic'` | log distance grid |
| `'Tan'` | Non-uniform tan mesh for grids. More dense at low abs values of the points, while less dense for higher values |
""",
)

dimensionality = Quantity(
grid = Quantity(
type=np.int32,
default=3,
shape=['dimensionality'],
description="""
Dimensionality of the mesh: 1, 2, or 3. Defaults to 3.
Amount of mesh point sampling along each axis.
""",
)

grid = Quantity(
n_points = Quantity(
type=np.int32,
shape=['dimensionality'],
description="""
Amount of mesh point sampling along each axis. See `type` for the axes definition.
Number of points in the mesh.
""",
) # ? @JosePizzaro3: should the mesh also contain its boundary information
)

points = Quantity(
type=np.complex128,
Expand All @@ -126,23 +105,73 @@ class Mesh(ArchiveSection):
shape=['n_points'],
description="""
The amount of times the same point reappears. A value larger than 1, typically indicates
a symmetry operation that was applied to the `Mesh`. This quantity is equivalent to `weights`:
multiplicities = n_points * weights
a symmetry operation that was applied to the `Mesh`.
""",
)

weights = Quantity(
type=np.float64,
shape=['n_points'],
pruning = Quantity(
type=MEnum('fixed', 'adaptive'),
description="""
Weight of each point. A value smaller than 1, typically indicates a symmetry operation that was
applied to the mesh. This quantity is equivalent to `multiplicities`:
Pruning method applied for reducing the amount of points in the Mesh. This is typically
used for numerical integration near the core levels in atoms.
In the fixed grid methods, the number of angular grid points is predetermined for
ranges of radial grid points, while in the adaptive methods, the angular grid is adjusted
on-the-fly for each radial point according to some accuracy criterion.
"""
)

def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
super().normalize(archive, logger)

weights = multiplicities / n_points
if self.dimensionality not in [1, 2, 3]:
logger.error('`dimensionality` meshes different than 1, 2, or 3 are not supported.')


class NumericalIntegration(NumericalSettings):
"""
Numerical integration settings used to resolve the following type of integrals by discrete
numerical integration:
```math
\int_{\vec{r}_a}^{\vec{r}_b} d^3 \vec{r} F(\vec{r}) \approx \sum_{n=a}^{b} w(\vec{r}_n) F(\vec{r}_n)
```
Here, $F$ can be any type of function which would define the type of rules that can be applied
to solve such integral (e.g., 1D Gaussian quadrature rule or multi-dimensional `angular` rules like the
Lebedev quadrature rule).
These multidimensional integral has a `Mesh` defined over which the integration is performed, i.e., the
$\vec{r}_n$ points.
"""

coordinate = Quantity(
type=MEnum('all', 'radial', 'angular'),
description="""
Coordinate over which the integration is performed. `all` means the integration is performed in
all the space. `radial` and `angular` describe cases where the integration is performed for
functions which can be splitted into radial and angular distributions (e.g., orbital wavefunctions).
""",
)

integration_rule = Quantity(
type=str, # ? extend to MEnum?
description="""
Integration rule used. This can be any 1D Gaussian quadrature rule or multi-dimensional `angular` rules,
e.g., Lebedev quadrature rule (see e.g., Becke, Chem. Phys. 88, 2547 (1988)).
"""
)

weight_partitioning = Quantity(
type=str,
description="""
Approximation applied to the weight when doing the numerical integration.
See e.g., C. W. Murray, N. C. Handy
and G. J. Laming, Mol. Phys. 78, 997 (1993).
"""
)

mesh = SubSection(sub_section=Mesh.m_def)

def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
super().normalize(archive, logger)

Expand Down Expand Up @@ -908,4 +937,4 @@ class GTOIntegralDecomposition(NumericalSettings):
)

def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
super().normalize(archive, logger)
super().normalize(archive, logger)

1 comment on commit 646430c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/nomad_simulations
   __init__.py4250%3–4
   _version.py11282%5–6
src/nomad_simulations/schema_packages
   __init__.py15287%39–41
   atoms_state.py1902189%13–15, 201–204, 228, 283–284, 352–353, 355, 537, 549–550, 611–615, 630–634, 641
   basis_set.py2502988%8–9, 122–133, 172–185, 244, 290, 471–475, 497–498, 542–545, 664, 695, 697
   general.py89891%4–7, 121, 185, 295–296, 306
   model_method.py2737971%10–12, 171–174, 177–184, 276–277, 297, 318–339, 355–381, 384–401, 587, 780, 791, 833–840, 878, 897, 977, 1034, 1109, 1223, 1236
   model_system.py3483789%45–51, 235, 254, 258, 261, 264, 290, 376–377, 454–455, 472–473, 686–689, 736–743, 917–918, 1140–1144, 1150–1151, 1159–1160, 1165, 1188
   numerical_settings.py2716476%12–14, 127, 176, 246, 248–249, 252–255, 259–260, 267–270, 279–282, 286–289, 291–294, 299–302, 308–311, 498–525, 600, 635–638, 662, 665, 710, 712–715, 719, 723, 770, 774–795, 850–851, 918, 940
   outputs.py1201092%9–10, 252–255, 295–298, 323, 325, 362, 381
   physical_property.py102793%20–22, 202, 331–333
   variables.py861286%8–10, 98, 121, 145, 167, 189, 211, 233, 256, 276
src/nomad_simulations/schema_packages/properties
   band_gap.py51590%8–10, 135–136
   band_structure.py1232580%9–11, 232–265, 278, 285, 321–322, 325, 372–373, 378
   energies.py42979%7–9, 36, 57, 82, 103, 119, 134
   fermi_surface.py17476%7–9, 40
   forces.py22673%7–9, 36, 56, 79
   greens_function.py991387%7–9, 210–211, 214, 235–236, 239, 260–261, 264, 400
   hopping_matrix.py29583%7–9, 58, 94
   permittivity.py48883%7–9, 97–105
   spectral_profile.py26012851%9–11, 57–60, 95–98, 199–300, 356–368, 393–396, 416, 421–424, 466–502, 526, 573–576, 592–593, 598–604
   thermodynamics.py752764%7–9, 35, 56, 72, 81, 90, 101, 110, 137, 147, 157, 172–174, 177, 193, 213–215, 218, 234, 254–256, 259
src/nomad_simulations/schema_packages/utils
   utils.py791680%8–11, 65–74, 83–84, 89, 92, 169–170
TOTAL261551980% 

Tests Skipped Failures Errors Time
402 0 💤 0 ❌ 0 🔥 5.889s ⏱️

Please sign in to comment.