GTPack: A Mathematica group theory package for application in solid-state physics and photonics

We present the Mathematica group theory package GTPack providing about 200 additional modules to the standard Mathematica language. The content ranges from basic group theory and representation theory to more applied methods like crystal field theory, tight-binding and plane-wave approaches capable for symmetry based studies in the fields of solid-state physics and photonics. GTPack is freely available via http://GTPack.org. The package is designed to be easily accessible by providing a complete Mathematica-style documentation, an optional input validation and an error strategy. We illustrate the basic framework of the package and show basic examples to present the functionality. Furthermore, we give a complete list of the implemented commands including references for algorithms within the supplementary material.


INTRODUCTION
Symmetry and symmetry breaking are basic concepts of nature. Thus, arguments based on the symmetry of the considered system play a significant role within almost all branches of physics. Group theory represents the mathematical language to deal with symmetry, since all transformations that leave a physical system invariant (usually described in terms of transformations of algebraic or differential equations) naturally form a group. The application of group theory in physics has a long tradition ranging back to the beginning of the 20th century [1,2]. Concentrating on solid-state and condensed matter physics, examples for the application of group theory can be found in the theory of the degeneracy of energy bands [3], color centers, d 0 magnetism and impurity states [4,5,6], optical transitions [7], phase transitions, atoms and molecules on surfaces [8], x-ray diffraction and crystallography in Fourier space [9], construction of effective low-energy excitation Hamiltonians [10], the classification of the superconducting states of matter [11,12,13,14,15], and, more recently, topological band theory [16,17,18,19,20] and topological quantum computation [21]. Due to the similarity of the underlying formalism, several concepts can be transferred to the field of photonics, for example, the band theory of photonic crystals [22,23,24], impurities and defect modes [25], and selection rules and uncoupled modes [26,27].
In many cases, non-trivial results can be obtained from basic group theoretical information like the characters of the irreducible representations or the Clebsch-Gordan coefficients. In the past decades these information were tabulated in various books (e.g., [28,29]). A comprehensive and widely used online group theory tool is provided by the Bilbao crystallographic server [30]. The work with printed group theory tables is not suitable for automation and the probability of copying and pasting misprints is high. However, modern computer algebra systems are capable to provide the same information, assumed that the necessary algorithms are implemented. Especially, the computer algebra system GAP (groups, algorithms and programming) [31] represents a powerful program to deal with computationally demanding questions in abstract algebra. Similarly, the computer algebra system Mathematica is well established within the research community. However, a stable group theory package designed for applications in solid-state physics and photonics is not included in the standard version.
The development of the Mathematica group theory package GTPack was designed to fill this gap. The functionality was planned to cover both, an application in active research and an application in university teaching. Therefore a main focus is the development of a user-friendly application, via self-explanatory names for new commands, a comprehensive documentation system and an optional input validation.
The aim of the paper is to report on the initial version of the Mathematica group theory package GTPack which is freely available for academic usage via http://GTPack.org. In the first part of the paper we introduce the main functionality and structure of the package. Afterwards we give general information about the implementation of the commands. In the last part we provide simple examples to illustrate the package. The supplementary material contains a full reference of all implemented modules. A more comprehensive guide about applied group theory in connection to GTPack can be found in Ref. [32].

FUNCTIONALITY AND STRUCTURE
According to the functionality of the modules, GTPack is divided into various subpackages as illustrated in Fig. 1. In general, the subpackages can be assembled in three groups, "basic functionality", "structure" and "applications". Subpackages belonging to the class of "basic functionality" are Auxiliary.m, Basic.m, Install.m and RepresentationTheory.m. The package Auxiliary.m contains modules which are needed by GTPack or extend the general Mathematica language. Among others tesseral harmonics (real spherical harmonics) were added and also the Cartesian form of tesseral and spherical harmonics was implemented. Furthermore, the package contains modules for the handling with quaternions, the calculation of Gaunt coefficients, Dirac matrices or SU(2)-rotation matrices, to name but a few. The package Basic.m concentrates on general abstract group theory and, for example, provides modules for the calculation of classes, multiplication tables, left and right cosets and several logical commands to check for groups, Abelian groups, subgroups or invariant subgroups.  contained in the package RepresentationTheory.m. This package comprises the calculation of character tables, handling of irreducible representations, the calculation of Clebsch-Gordan coefficients, etc.. Modules for the installation of point and space groups or symmetry elements can be found in Install.m.
The second class "structure" comprises of the packages CrystalStructure.m, Lattice.m and Molecules.m. Within CrystalStructure.m, modules for loading, saving and handling of crystal structures can be found. Modules with similar functionality but specialized on molecules are contained within Molecules.m. The construction and manipulation of atomic clusters as well as several commands for dealing with the reciprocal space are summarized in the package Lattice.m.
Next to basic group theory GTPack also contains subpackages for particular applications in solid state physics and photonics. The third class "Applications" contains the subpackages CrystalField.m, ElectronicStructure.m, Photonics.m, PseudoPotential.m, TightBinding.m and Vibrations.m. The crystal field package CrystalField.m is capable of automatically generating crystal field Hamiltonians. Furthermore, it contains the generation of standard operator equivalents like Stevens [? ] and Buckmaster-Smith-Thornley [33] operators. GTPack also allows for electronic structure calculations for periodic systems, i.e. crystals, in the framework of the tight-binding and the pseudopotential approximation. Modules to construct tight-binding Hamiltonians are summarized in TightBinding.m and modules for the pseudopotential approximation in PseudoPotential.m. The calculation of band structures, density of states as well as the calculation of a Fermi surface is practically independent of the underlying model Hamiltonian. Therefore such commands are contained within the package ElectronicStructure.m. In the framework of plane-waves it is also possible to calculate the band structure of photonic crystals. The necessary modules for the construction of the master equation for various geometrical objects can be found in the package Photonics.m. Commands for the investigation of phonons or molecular vibrational modes are contained in Vibrations.m.
For various applications it is necessary to incorporate data, for example, tight-binding parameters, crystal field parameters and crystal structures. Therefore, GTPack contains several modules for the creation and handling of databases (cf. Fig. 1). Here, special file endings are used, such as *.parm and *.struc. Databases can be easily created, extended and modified by the user. Furthermore, GTPack includes commands for the interaction with external data formats and ab initio software. This concerns the import and export of structural data files *.cif [34] and *.xsf [35] and the output of the programs MIT Photonic Bands -MPB [36,37]. For the future it is intended to implement similar modules for VASP [38] and abinit [39].

IMPLEMENTATION
To distinguish new commands provided by GTPack from the standard Mathematica language and to prevent conflicts with new versions of Mathematica, all GTPack commands are starting with the characters GT (e.g. GTInstallGroup, GTCharacterTable, ...). Options are denoted with a suffix GO (e.g. GOVerbose, GOIrepNotation, ...). One of the main features of GTPack is the symbolic representation of symmetry elements. Symmetry elements for various standard axes (see Figure 2)) are predefined and the respective symbols, such as C3z for a 3-fold rotation about the z-axis are protected. As a standard form they are displayed with subscripts, i.e., C 3z . Internally all symmetry elements are represented using matrices. The conversion between symbols and matrices can be done using GTGetMatrix and GTGetSymbol, respectively. Every module is implemented such that it is capable to handle lists of matrices in arbitrary representations. Depending on the application, GTPack uses a certain standard representation to provide In the special case of planar groups, the standard representation can be chosen to be O(2). Symmetry elements within double groups are represented according to Damhus [40], where elements of groups not containing the inversion are represented by SU (2) matrices and elements of groups containing the inversion are represented by matrices of the direct product group SU (2) ⊗ S with S = {1, −1}. Additionally, users can also define a group by providing a multiplication table. In this case GTPack automatically installs the provided elements within the multiplication table as new symmetry elements using permutation matrices as faithful representations.
Character tables are frequently needed and can be calculated using GTCharacterTable. The module uses the Burnside algorithm [41], which is a reasonable choice for relatively small groups, such as point groups. Representation matrices can be generated using GTGetIrep, where the algorithm of Flodmark and Blokker is implemented [42]. Clebsch-Gordan coefficients, which are necessary to generate the basis of a direct product representation, can be calculated using GTClebschGordanCoefficients. Here, the algorithm of van Den Broek and Cornwell is implemented [43]. To calculate band structures of solids, GTPack supports a plane-wave basis [44,45] and a tight-binding method in the two-and three-center form [46,47]. The Master equation for photonic crystals is constructed by GTPhMaster as described in Ref. [24].

INSTALLATION OF GTPACK
GTPack is installed similarly to all other Mathematica packages. After downloading and decompressing GTPack, the content of the package has to be copied to the application folder of Mathematica within the respective base directory. Here, the user can choose between making the package available for all users of the computer or only for her-or himself. If the package should be available for all users of the computer, the corresponding folder to copy to can be found by opening a Mathematica notebook and typing $BaseDirectory. If the package should be available exclusively for the current user of the computer the respective base directory can be found by typing $UserBaseDirectory. According to the path of the base or user base directory (called $dir in the following), the folder containing GTPack needs to be copied to the directory $dir\Applications. Afterwards, the package and the documentation are available. The package itself can be loaded within a Mathematica notebook by typing Needs["GroupTheory'"].

Installation of groups and character table
In the first example, the installation of point groups and the calculation of character tables will be shown. Within the example, the point group T is considered. Using GTPack, the point group is installed with the command GTInstallGroup as shown in Fig. 3. The output is a list of symmetry elements, where each element is given in symbolic form. In total T contains 12 elements, where the symmetry elements are denoted using the Schönflies notation [32], where C na denotes a rotation about the angle 2π/n about the rotation axis a. The implemented standard axes are shown in Figure 2. Additional rotation axes can be installed using GTInstallAxis. Each symbol can be transformed into a rotation matrix using GTGetMatrix. A character table for a point group is installed using GTCharacterTable.
The command applies the Burnside algorithm for the calculation of the character table [41]. Within the command several options can be specified optionally, such as an input validation (GOFast), a The standard representation has changed to O(3) In [4]:= GTCharacterTablegroup, GOIrepNotation → "Mulliken", GOReality → True; The standard representation has changed to SU(2) In[6]:= GTCharacterTabledoublegroup; Figure 3. Installation of groups and double groups and calculation of the character tables using the commands GTInstallGroup and GTCharacterTable.
Frontiers control of the printed output (GOVerbose), or the choice of notation for the irreducible representations (GOIrepNotation). For example, possible options for the names of irreducible representations are: the Mulliken notation [48,49], which is widely used in chemistry and spectroscopy; the notation according to Bouckaert, Smoluchowski and Wigner [3], which is usually used in connection to band structure calculations; and a simple index notation, which is denoted by Bethe notation. To determine additional degeneracies of energy levels due to time-reversal symmetry, the reality of irreducible representations plays a central role [50]. Given a point group G, a representation Γ of G is called: potentially real, if Γ is equivalent to a real representation and Γ ∼ Γ * ; pseudo-real, if Γ is not equivalent to a real representation, but Γ ∼ Γ * ; and essentially complex, if Γ Γ * . This property can be determined by means of the equation of Frobenius and Schur [50], given by (1) Equation (1) can be evaluated using GTReality, or during the calculation of the character table by specifying the option GOReality. In the second part of the example in Figure 3 the character table is calculated for the double group of T . The double group is installed by specifying the option GORepresentation within the command GTInstallGroup and choosing SU (2) as standard representation.
The additional symbols of the double group elements are denoted with an overline. Instead of four, the double group of T has seven classes and irreducible representations. The additional classes are classified by the theorem of Opechowski [51,52]. The respective extra representations of the double group can be determined using GTExtraRepresentations.

Crystal-field splitting
Crystal field theory represents a semi-empirical approach to describe localized states in an atomic or crystallographic surrounding. The crystallographic surrounding or crystal field is described in terms of a small perturbation V cr ( r) leading to the total Hamiltonian The crystal field itself can be expanded in terms of spherical harmonics Y l m [32], or more generally in terms of crystal field operatorsÔ l m , GTPack contains various modules to calculate matrix elements jm 1 |Ô l m |jm 2 for operator equivalents, such as spherical harmonics, Buckmaster-Smith-Thornley operators [33], and Stevens operators [? ]. The respective GTPack commands are given by GTGauntCoefficients, GTBSTOperator, and GTStevensOperator.
Depending on the underlying symmetry of the system some of the expansion coefficients A l,m or B l,m are zero. Given a symmetry group G, then the Hamiltonian of the system and with that the crystal field expansion as to be invariant under the application of the projection operator of the identity representation, However, for any proper coordinate transformationP (T ) corresponding to an element T ∈ G the spherical harmonics (and similarly crystal field operatorsÔ l m ) transform aŝ where D l m m denotes the Wigner-D function. For improper coordinate transformations (inversion, reflections, etc.) a factor of (−1) l has to be taken into account. Evaluating equation (5) From equation (7) it can be concluded which coefficients depend on each other and which coefficients vanish. The final symmetry adapted crystal field expansion can be calculated using GTPack by means of GTCrystalField. Figure 4 illustrates an example for the level splitting for a single d-electron in an octahedral, a cubic and a tetrahedral crystal field. The underlying point groups are O h for the cubic and the octahedral case as well as T d for the tetrahedral case. However, it turns out that both groups lead to the same crystal field expansion. First, the point group O h is installed using GTInstallGroup. Afterwards the crystal field expansion is calculated using GTCrystalField up to a cutoff value of 2l. As we discuss d-electrons, the expansion is truncated after l = 4. Next, we define the surrounding field in terms of the nearest neighbors and create lists containing their positions and ionic charges. The splitting is calculated from the eigenvalues of the matrix elements over radial wave functions ψ l m ( r) = R l (r)Y l m (θ, φ), as where and The latter integral is called Gaunt coefficient and can be calculated by means of GTPack using GTGauntCoefficient. The values for r l are materials specific and can be calculated, e.g., in the framework of the density functional theory [53]. GTPack provides commands to store and load explicit values from a database. However, in this example we introduce the generic parameters  Figure 5. The level splitting for a localized d-electron into E g (E) and T 2g (T 2 ) levels in an octahedral, a cubic and a tetrahedral crystal field. and Dq[oct] = q r 4 24π .
As can be verified from the Mathematica example in Figure 4, in all three cases a two-fold and a three-fold degenerate level can be found. In the cubic and octahedral case the two-fold degenerate state corresponds to the irreducible representation E g and the three-fold degenerate level corresponds to the irreducible representation T 2g . For the tetrahedron the inversion symmetry is broken and the states are denoted by E and T 2 , respectively. The final result is plotted in Figure 5.

Tight-binding bandstructure of graphene
Due to the occurrence of Dirac nodes within the band structure and the resulting properties, graphene counts as one of the most studied materials to date [54,55]. Within the following example the calculation of the band structure using the tight-binding approximation will be illustrated in the framework of GTPack. In Fig. 6 the structure and the construction of the tight-binding Hamiltonian is shown. At first, the structure is given as a list in the standard GTPack format. The list contains the name of the structure and a prototype, four different names for the space group (Pearson symbol, Strukturbericht designation, international notation, and space group number), the lattice, and the sites containing the atom name and the atom position. Note that the first five information are optional and not important for the generation  Figure 6. Structural information and construction of the tight-binding Hamiltonian for graphene.

Frontiers
In[10]:= hpp hamc 3, 3 , hamc 3, 7 , hamc 7, 3 , hamc 7, 7 ; hamrule Superscript " pp0 ", "C1" 0, Superscript " pp0 ", "C2" 0, Subsuperscript " ppΠ ", 1, "C1,C2" 2 ; In of the tight-binding model. GTPack provides modules to import structures, e.g., in the cif-format using GTImportCIF. The structural information can be plotted using the command GTPlotStructure2D. For the construction of the tight-binding model it is necessary to construct a real space cluster. This cluster is reordered into different shells corresponding to nearest neighbor, next nearest neighbor, next next nearest neighbor interactions, etc.. The respective commands to do so are GTCluster and GTShells. From the information of the shells, the tight-binding Hamiltonian is constructed for sand p-electrons. The zero and non-zero entries within the tight-binding Hamiltonian are illustrated using GTHamiltonianPlot. As can be seen within the plot, the p z -orbitals do not hybridize with all the other orbitals. Hence, those can be considered to form a smaller tight-binding Hamiltonian of dimension 2 × 2. Setting up and solving the reduced 2 × 2 tight-binding Hamiltonian is shown in Fig. 7. The high-symmetry path within the Brillouin zone (K , Γ, M , K) is generated using the command GTBZPath. The points K and K denote the corners of the hexagonal Brillouin zone, M points to the middle of an edge and Γ is the Brillouin zone center. The band structure itself is calculated and plotted using GTBandStructure.

ANALYZING PHOTONIC BAND STRUCTURES
Photonic crystals represent the optical analogues of ordinary crystals, where light is traveling through a periodic dielectric. Potential optical band gaps, i.e., forbidden frequencies where photons are not allowed to travel through the medium have motivated research towards for various applications replacing ordinary electronics and information technology [56]. Recently, photonic crystals have been discussed with respect to nodal points [57] and topological states in periodic and quasi periodic arrangements [58,59,60]. A group theory classification of the allowed modes yields to additional information, e.g., with respect to uncoupled bands [27]. For two-dimensional photonic crystals, the vectorial Maxwell's equations can be transformed into two sets of independent equations for two modes [24], which are referred to as transversal Here, the vector r denotes a vector in the xy plane. For the solution of the masters equation, a planewave approach can be applied which transforms the Masters equations into an eigenvalue problem. Such an approach is implemented in GTPack, but also within the code MPB [37]. GTPack can be applied to analyze photonic band structure calculations performed with MPB, as will be shown in the following. We consider a two-dimensional photonic crystal with a square lattice made of circular alumina rods (ε = 8.9) in air. The radius of the rods is given by R = 0.2a (a-lattice constant). This corresponds to a filling factor of γ = 0.126. The photonic band structure was calculated using MPB incorporating a tolerance of 10 −7 . The calculated band structure can be loaded, plotted and analyzed automatically using the command GTPhSymmetryBands as shown in Figure 8 for the transversal magnetic mode. The underlying point group is C 4v , which has four one-dimensional irreducible representation (A 1 , A 2 , B 1 , B 2 ) and one two-dimensional irreducible representation (E). As can be seen in Figure 8, there is a spectral gap between the first and the second band. Degeneracies in the band structure correspond to the dimensions of the corresponding irreducible representation. Therefore, all single bands are associated to the one-dimensional irreducible representations. However, for example, for the second and the third band, a two-fold degeneracy can be found at the M point which corresponds to the two-dimensional irreducible representation E. To revise this point more clearly, the specific fields corresponding to the The point group of the square lattice is CR vF c4vct contains the character table of the group.
Read the 2nd eigenmode at M and analyze.
Read the 3rd eigenmode at M and analyze. Figure 9. Application of the character projection operator to the field corresponding to the degeneracy between the second and third band of the transversal magnetic mode at M . modes can be imported into the Mathematica notebook using GTPhMPBFields. Afterwards, the field is analyzed by applying the character projection operator for each irreducible representation. As expected, only the application of the operator corresponding to E shows non-zero results, as can be seen in Figure  9.

ADVANTAGES AND LIMITATIONS
As an additional package to the standard Mathematica framework, GTPack is embedded into the Mathematica framework. The new modules provided within GTPack are designed for application in solid state physics and photonics and use notations which are common in these research communities. Having a programming framework at hand comes with the advantage of easy automation which is in contrast to recently published group theory tables. Most of the provided modules are kept general and can be applied in connection to any set of matrices forming a group. This allows for applications way beyond the provided point and space group setup. As usual, the package is constructed in a modular form and can be extended easily.
GTPack is under ongoing development and therefore comes with limitations in the first version. Among others, these comprise of the calculation of character tables for space groups and groups containing antiunitary symmetry elements. The implemented modules for the calculation of photonic band structures currently do not reach the same performance as specialized numeric implementations such as MPB. Thus, export and import modules connect MPB with GTPack. Additionally, modules to export analytically generated tight-binding Hamiltonians to Fortran help to generate more efficient numeric codes. An extension to a parallel implementation for the usage of the cluster version of Mathematica is currently not planned. Concerning the symmetry analysis, irreducible representations can currently only be associated to the calculated bands if symmorphic space groups are taken into account. An extension for non-symmorphic groups is under development.

CONCLUSION
We presented the Mathematica group theory package GTPack together with four basic examples. The package contains about 200 additional commands dealing with basic group theory and representation theory and providing tools for applications in solid state physics and photonics. The package itself is structured into several subpackages. In connection to external databases it is possible to load, change and save data, like structural information or parameters for electronic and photonic band structure calculations. The package works externally with a symbolic representation of symmetry elements. Internally, matrices are used. GTPack can be obtained online via the web page http://GTPack.org.

GTStevensTheta
gives multiplet prefactors for the crystal field expansion [? ] CrystalStructure.m gives the structure factor of a prismatic rod GTPhRodSmooth gives a smoothed structure factor of a rectangular rod GTPhShowStructure plots an image of the arrangement of dielectric objects in a photonic structure GTPhSlab gives the structure factor of a slab GTPhSlabSmooth gives a smoothed structure factor of a slab GTPhSphere gives the structure factor of a sphere GTPhSymmetryBands performs a symmetry analysis of electromagnetic fields for a given band structure [24] GTPhSymmetryField performs the symmetry analysis of an electromagnetic field GTPhSymmetryPoint performs the symmetry analysis of electromagnetic fields given in datasets PseudoPotential.m Table 10 Modules of the subpackage PseudoPotential.m. The package contains modules for the construction of plane-wave Hamiltonians.

Name Functionality
Ref.

GTPwDatabaseInfo
gives information about the pseudopotential parameter sets stored in a database GTPwDatabaseRetrieve retrieves pseudopotential parameter sets stored in a database GTPwDatabaseUpdate adds pseudopotential parameter sets to a database GTPwDielectricF defines a screening function GTPwEmptyLatticeIrep determines the irreducible representations of the empty lattice band structure GTPwHamiltonian constructs a Hamiltonian based on pseudopotential theory [44,45] GTPwPrintParmSet prints a parameter set form a pseudopotential database gives a symbol according to the nomenclature of the twocenter approximation GTTbSymmetryBandStructure performs a symmetry analysis of a given band structure GTTbSymmetryPoint performs a symmetry analysis of energy bands at a specified k-point GTTbSymmetrySingleBand performs a symmetry analysis of a single energy band GTTbToFortran transforms a k-space tight-binding Hamiltonian into a FORTRAN module GTTbToFortranList prints a Hamiltonian as FORTRAN code GTTbWaveFunction constructs a tight-binding wave-function

RepresentationTheory.m
Vibrations.m Table 13 Modules of the subpackage Vibrations.m. The package contains modules for the study of vibrational modes of solids and molecules.

Name Functionality
Ref.
GTVibDisplacementRep gives the displacement representation of a molecule GTVibDynamicalMatrix gives the dynamical matrix for a given structure GTVibModeSymmetry gives the vibrational modes of a molecule GTVibSetParameters substitutes spring constants and masses within a dynamical matrix GTVibTbToPhonon transforms a tight-binding p-Hamiltonian into a dynamical matrix [64] GTVibTbToPhononRule gives rules to transform a tight-pinding p-Hamiltonian into a dynamical matrix