Giter Club home page Giter Club logo

spgrep's Introduction

Spglib

CI Status Documentation Status Codecov Status

License Status CMake Status Python Versions

Release Status Conda Status PyPI Status Fedora Status Homebrew Status Spack Status Vcpkg Status

PyPI Downloads Conda Downloads

C library for finding and handling crystal symmetries

What does Spglib do?

A crystal structure is given to a spglib function to obtain symmetry information. spg_get_dataset is the function that returns most fruitful space group information. This returns the result in the C-structure SpglibDataset. We don't know the length of symmetry operations to be returned, the memory spaces are allocated dynamically, which means we have to free them. by spg_free_dataset. To tolerate tiny distortion of crystal structure, it has to be specified when calling symmetry search function. The following pages show the details.

#include <assert.h>
#include "spglib.h"

int main(void) {
    SpglibDataset *dataset;
    // Wurtzite structure (P6_3mc)
    double lattice[3][3] = {
        {3.111, -1.5555, 0}, {0, 2.6942050311733885, 0}, {0, 0, 4.988}};
    double position[4][3] = {
        {1.0 / 3, 2.0 / 3, 0.0},
        {2.0 / 3, 1.0 / 3, 0.5},
        {1.0 / 3, 2.0 / 3, 0.6181},
        {2.0 / 3, 1.0 / 3, 0.1181},
    };
    int types[4] = {1, 1, 2, 2};
    int num_atom = 4;
    double symprec = 1e-5;

    // SplibDataset has to be freed after use.
    dataset = spg_get_dataset(lattice, position, types, num_atom, symprec);

    // Obtain data in SpglibDataset.
    // The space group number 186 corresponds to the wurtzite-type (P6_3mc).
    // See https://www.cryst.ehu.es/cgi-bin/cryst/programs/nph-table
    assert(dataset->spacegroup_number == 186);

    // Deallocate SpglibDataset, otherwise induce memory leak.
    spg_free_dataset(dataset);
}

Requirements

  • C standard: As of version 2.1.0, Spglib explicitly enforces a minimum standard of C11

How to use Spglib

We currently only officially support conda and pip packaging of spglib, with plans to expand to FedoraProject in the near future. We are looking for additional contributors to package on other linux distributions. For the systems that are not yet officially supported please look at the instructions for manual compilation

The main interface for spglib is the C api, but we also officially support Fortran and Python interfaces. For a minimal example of how to use this library please check the provided examples

How install the python library

Spglib is available on PyPi, so it can be installed as:

$ pip install spglib

Alternatively you can install the conda package that bundles the C and Fortran libraries

$ conda install -c conda-forge spglib

This python library will default to the system installed Spglib library detected, specified via LD_LIBRARY_PATH on Linux or DYLD_LIBRARY_PATH on MacOS, otherwise defaulting to a bundled version.

For more details and how to build the python project from source, see the python documentation.

How to manually compile

The minimum configuration, build and install instructions are as follows:

$ cmake . -B ./build
$ cmake --build ./build
$ cmake --install ./build

For more details on configuration options and how to link your project check the cmake documentation. A minimal example project using spglib is available at example.

How to run test

The C library tests are incorporated in the CMake projects and enabled by default. To execute these tests, run the following command with the appropriate path to the build directory

$ ctest --test-dir ./build

Additionally, there are python tests that cover more use-cases. See the README in the python folder for more details

How to cite Spglib

If you use spglib in your research, please consider citing the following work:

@misc{spglibv1,
  Author = {Atsushi Togo and Isao Tanaka},
  Title = {$\texttt{Spglib}$: a software library for crystal symmetry search},
  Eprint = {arXiv:1808.01590},
  howpublished = {\url{https://github.com/spglib/spglib}},
  year = {2018}
}

If you use functions to search for magnetic symmetry operations in spglib, please also consider citing the following work:

@article{spglibv2,
  author = "Shinohara, Kohei and Togo, Atsushi and Tanaka, Isao",
  title = "{Algorithms for magnetic symmetry operation search and identification of magnetic space group from magnetic crystal structure}",
  journal = "Acta Cryst. A",
  year = "2023",
  volume = "79",
  number = "5",
  pages = "390--398",
  month = "Sep",
  doi = {10.1107/S2053273323005016},
  url = {https://doi.org/10.1107/S2053273323005016},
}

Contributing

We welcome any contribution from the core development of the library to documentation improvements. See Contributing.md for more details.

Documentation

See https://spglib.readthedocs.io/ for further documentation. See the documentation for more information on how to contribute to the documentation.

spgrep's People

Contributors

danielskatz avatar dependabot[bot] avatar lan496 avatar pre-commit-ci[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

spgrep's Issues

Irreducible Force Constant Examples

I was wondering if there are any examples or if you are aware of anyone who has used spgrep to find the irreducible force constants for a given crystal? I saw the examples on lattice vibrations which are very similar, however, not quite what I was after.

I am no expert in group theory, so best I understand it is that the block diagonalization of the dynamical matrix is somehow related to the irreducible form (maybe it is the irreducible form), but then my questions are:

  • How does this extend to tensors (e.g. third order force constants)
  • Where can I find resources combining the irreducible representation idea with lattice vibrations (phonons). Many of the group theory papers are too dense and most of the lattice vibration papers gloss over these steps.

Thanks!

Current implementation may return wrong number of symmetrized tensors for higher rank...

I noticed the following note in the source code:

Note
----
Current implementation may return wrong number of symmetrized tensors for higher rank...
"""

Can you give an example to illustrate this situation? How large a rank will trigger this problem, and is there a way to deal with it, such as performing some sort of decomposition to lower the rank?

Regards,
Zhao

Get the irreducible representations for a space-group represented on non-standard basis.

See my following example:

gap> SGGenSet227me;
[ [ [ 0, -1, 0, 1/2 ], [ 0, 0, -1, 1/2 ], [ -1, 0, 0, 1/2 ], [ 0, 0, 0, 1 ] ], [ [ -15/4, 29/4, -15/4, -15/16 ], [ -33/8, 55/8, -25/8, -25/32 ], 
      [ -25/8, 55/8, -33/8, -41/32 ], [ 0, 0, 0, 1 ] ] ]
gap> S1:=SpaceGroupOnLeftIT(3,227);
SpaceGroupOnLeftIT(3,227,'2')
gap> S2:=AffineCrystGroupOnLeft(SGGenSet227me);
<matrix group with 2 generators>
gap> conj:=AffineIsomorphismSpaceGroups(S2, S1);
[ [ 5/2, 3, 5/2, -5 ], [ 5/2, 5/2, 3, -21/4 ], [ 3, 5/2, 5/2, -5 ], [ 0, 0, 0, 1 ] ]
gap> S2^(conj^-1)=S1;
true

Here, S1 is the 3d space group 227 given in ITA, then how can I use your package to compute the irreducible representations of S2?

Regards,
Zhao

Calculate topological invariants to facilitate topological material analysis.

In recent years, topological materials science is a great revolutionary progress in the field of materials science, which is closely related to group theory, in which, a typical representative emerging discipline is Topological Quantum Chemistry. So, add some related features are also intriguing.

Related literature and studies:

https://doi.org/10.1038/nature23268
https://doi.org/10.1103/PhysRevB.102.115117
https://github.com/oashour/AbInitioTopo.jl

Regards,
Zhao

Some confusion on the description in the joss paper of this project.

In the joss paper of this project, I noticed the following description:

image

  1. You said "Although these packages do not rely on tabulations of irreps"

According to my understanding, the irvsp program also relies on table lookups. More specifically, it depends on the necessary information from the appropriate BCS database to execute its tasks, and its calculations are restricted to trace information exclusively.

  1. You said "spgrep provides unique irreps for given space groups"

If the basis/wave function is specified first, then the representation matrix is completely determined; however, if the representation matrix is given first, the basis/wave function is naturally not unique.

So, I'm still unclear about what you're trying to express by saying "spgrep provides unique irreps for given space groups". It's unclear what you're referring to.

The representation matrix you provided naturally corresponds to a specific basis, and after changing the basis, it simply changes to an equivalent representation too.

  1. What's "a deterministic symmetry-adapted basis" and why must it be unique?

Regards,
Zhao

Interface with DFT codes to calculate/analyze the irreducible representations of electronic states.

It's well known that one of the most important applications of group representation theory in quantum mechanics is the analysis of irreducible representation of wave function of the system under study. Indisputably, it's a very meaningful thing to interface this package with other DFT codes or their auxiliary analysis tools, say, py4vasp, so that we can calculate and analysis the irreducible representations of electronic states based on the result of DFT calculation.

See here for some related discussion.

Regards,
Zhao

Identify a possible isomorphism between two space groups.

Based on the generators of space group 141 listed here, the following GAP checking can be performed:

gap> gensSGITA141O1:=[
>  [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0,0,0,1]],
>  [[-1, 0, 0, 1/2], [0, -1, 0, 1/2], [0, 0, 1, 1/2], [0,0,0, 1]],
>  [[0, -1, 0, 0], [1, 0, 0, 1/2], [0, 0, 1, 1/4], [0,0,0, 1]],
>  [[-1, 0, 0, 1/2], [0,  1, 0,  0], [0,  0,  -1, 3/4], [0,0,0, 1]],
>  [[-1, 0, 0, 0], [0, -1, 0, 1/2], [0, 0, -1, 1/4], [0,0,0, 1]],
>  [[1, 0, 0, 1/2], [0, 1, 0, 1/2], [0, 0, 1, 1/2], [0,0,0, 1]]
> ];;
gap> gensSGITA141O2:=[
>  [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0,0,0, 1]],
>  [[-1, 0, 0, 1/2], [0, -1, 0, 0], [0, 0, 1, 1/2], [0,0,0, 1]],
>  [[0, -1, 0, 1/4], [1, 0, 0, 3/4], [0, 0, 1, 1/4], [0,0,0, 1]],
>  [[-1, 0, 0, 1/2], [0, 1, 0, 0], [0, 0, -1, 1/2], [0,0,0, 1]],
>  [[-1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0,0,0, 1]],
>  [[1, 0, 0, 1/2], [0, 1, 0, 1/2], [0, 0, 1, 1/2], [0,0,0, 1]]
> ];;
gap> SGITA141O1:=AffineCrystGroupOnLeft(gensSGITA141O1);
<matrix group with 6 generators>
gap> SGITA141O2:=AffineCrystGroupOnLeft(gensSGITA141O2);
<matrix group with 6 generators>
gap> ConjugatorSpaceGroups(SGITA141O1, SGITA141O2);
[ [ 1, 0, 0, 0 ], [ 0, 1, 0, 1/4 ], [ 0, 0, 1, 7/8 ], [ 0, 0, 0, 1 ] ]

Can the package perform the above or similar work to identify a possible isomorphism between two space groups?

Regards,
Zhao

About the k-point used in the document example.

Here gives the following example:

from spgrep import get_spacegroup_irreps
from spgrep.representation import get_character

# Rutile structure (https://materialsproject.org/materials/mp-2657/)
# P4_2/mnm (No. 136)
a = 4.603
c = 2.969
x_4f = 0.3046
lattice = [
    [a, 0, 0],
    [0, a, 0],
    [0, 0, c],
]
positions = [
    [0, 0, 0],  # Ti(2a)
    [0.5, 0.5, 0.5],  # Ti(2a)
    [x_4f, x_4f, 0],  # O(4f)
    [-x_4f, -x_4f, 0],  # O(4f)
    [-x_4f + 0.5, x_4f + 0.5, 0.5],  # O(4f)
    [x_4f + 0.5, -x_4f + 0.5, 0.5],  # O(4f)
]
numbers = [0, 0, 1, 1, 1, 1]

kpoint = [0.5, 0, 0]  # X point
irreps, rotations, translations, mapping_little_group = get_spacegroup_irreps(
    lattice, positions, numbers, kpoint
)

# Symmetry operations by spglib
assert len(rotations) == 16
assert len(translations) == 16

# At X point, the little co-group is isomorphic to mmm (order=8)
assert len(mapping_little_group) == 8
print(mapping_little_group)  # [ 0,  1,  4,  5,  8,  9, 12, 13]

# Two two-dimensional irreps
for irrep in irreps:
    print(get_character(irrep))
# [2.+0.j 0.+0.j 0.+0.j 2.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j]
# [2.+0.j 0.+0.j 0.+0.j -2.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j]

In this example, the space group is P4_2/mnm (No. 136), and the selected k point is [0.5, 0, 0] (X point). I checked this information from BCS KVEC's convention represented here, as shown below:

image

image

As you can see, the two coordinates given above are not consistent. Any hints for this problem?

Regards,
Zhao

Construct the little group based on Wyckoff positions.

According to my understanding, the little group in nature is the site symmetry group in reciprocal space. On the other hand, the site symmetry group and the Wyckoff position has the following relationship:

In crystallography, a Wyckoff position is a point belonging to a set of points for which site symmetry groups are conjugate subgroups of the space group.

So, I think it should be possible to build/construct the little group based on Wyckoff positions.

Any hints/comments/corrections on this idea will be appreciated.

N.B.: I also noticed the related - to some extent, if not all - application here.

Regards,
Zhao

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.