-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding projection operator for NH3 and ethylene
- Loading branch information
Showing
8 changed files
with
230 additions
and
20 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
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{ | ||
"name":"d2h", | ||
"classes": [ | ||
{ | ||
"symbol": "E", | ||
"multiplicity": 1 | ||
}, | ||
{ | ||
"symbol": "C2(z)", | ||
"multiplicity": 1 | ||
}, | ||
{ | ||
"symbol": "C2(y)", | ||
"multiplicity": 1 | ||
}, | ||
{ | ||
"symbol": "C2(x)", | ||
"multiplicity": 1 | ||
}, | ||
{ | ||
"symbol": "i", | ||
"multiplicity": 1 | ||
}, | ||
{ | ||
"symbol": "sigma(xy)", | ||
"multiplicity": 1 | ||
}, | ||
{ | ||
"symbol": "sigma(xz)", | ||
"multiplicity": 1 | ||
}, | ||
{ | ||
"symbol": "sigma(yz)", | ||
"multiplicity": 1 | ||
} | ||
], | ||
"symmetry_groups": [ | ||
{ | ||
"symbol": "Ag", | ||
"characters": [1,1,1,1,1,1,1,1] | ||
}, | ||
{ | ||
"symbol": "B1g", | ||
"characters": [1,1,-1,-1,1,1,-1,-1] | ||
}, | ||
{ | ||
"symbol": "B2g", | ||
"characters": [1,-1,1,-1,1,-1,1,-1] | ||
}, | ||
{ | ||
"symbol": "B3g", | ||
"characters": [1,-1,-1,1,1,-1,-1,1] | ||
}, | ||
{ | ||
"symbol": "Au", | ||
"characters": [1,1,1,1,-1,-1,-1,-1] | ||
}, | ||
{ | ||
"symbol": "B1u", | ||
"characters": [1,1,-1,-1,-1,-1,1,1] | ||
}, | ||
{ | ||
"symbol": "B2u", | ||
"characters": [1,-1,1,-1,-1,1,-1,1] | ||
}, | ||
{ | ||
"symbol": "B3u", | ||
"characters": [1,-1,-1,1,-1,1,1,-1] | ||
} | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import numpy as np | ||
from collections import Counter | ||
|
||
class ProjectionOperator: | ||
|
||
def __init__(self, ct, so): | ||
# | ||
# ToDo: assert that the objects have the right type | ||
# | ||
|
||
self.ct = ct # character table | ||
self.so = so # symmetry operations | ||
self.groups = None | ||
self.irreps = None | ||
|
||
def collect(self): | ||
""" | ||
Construct groups of basis functions that can transform among each | ||
other and figure out which irreps these span | ||
""" | ||
# create one logical matrix that shows the interaction | ||
groupmatrix = np.zeros_like(self.so.operation_matrices[0], dtype=np.bool8) | ||
for m in self.so.operation_matrices: | ||
bm = np.abs(m) > 1e-9 | ||
groupmatrix = np.logical_or(groupmatrix, bm) | ||
|
||
#print(groupmatrix) | ||
|
||
# collect the groups | ||
self.groups = [] | ||
for i,row in enumerate(groupmatrix): | ||
if np.sum(row) > 1: | ||
idx = np.where(row)[0] | ||
self.groups.append(np.array(idx, dtype=np.int64)) | ||
else: | ||
self.groups.append(np.array([i], dtype=np.int64)) | ||
|
||
# create unique list | ||
self.groups = np.array(self.groups, dtype=object) | ||
res = Counter(map(tuple, self.groups)) | ||
self.groups = [r for r in res] | ||
|
||
# determine irreps per lips | ||
self.irreps = [] | ||
for g in self.groups: | ||
chars = [np.sum(np.take(np.diagonal(m),g)) for m in self.so.operation_matrices] | ||
self.irreps.append(self.ct.lot(chars)) | ||
|
||
def build_mos(self): | ||
# check if groups have been collected | ||
if self.groups is None: | ||
self.collect() | ||
|
||
# build molecular orbitals | ||
self.mos = np.zeros((len(self.so.mol.basis), len(self.so.mol.basis)), | ||
dtype=np.float64) | ||
mo_idx = 0 | ||
for g,irreplist in zip(self.groups,self.irreps): | ||
for j,irrep in enumerate(irreplist): # loop over irreps | ||
|
||
# early exit if there are no irreps of this type | ||
if irrep == 0: | ||
continue | ||
|
||
irrep_e = self.ct.get_character(j,0) # get dimensionality of irrep | ||
|
||
irrepres = np.zeros((int(irrep * irrep_e), len(self.so.mol.basis))) | ||
for k in range(int(irrep * irrep_e)): # loop over times the irrep is present | ||
#label = self.ct.get_label_irrep(j) | ||
res = self.apply_projection_operator(g[k], j) | ||
irrepres[k,:] = res | ||
|
||
# perform orthogonalization if the irrep space is larger than 1 | ||
if len(irrepres) > 1: | ||
S = irrepres @ irrepres.transpose() | ||
e,v = np.linalg.eigh(S) | ||
X = v @ np.diag(1.0 / np.sqrt(e)) @ v.transpose() | ||
irrepres = X @ irrepres | ||
|
||
for mo in irrepres: | ||
self.mos[mo_idx] = mo | ||
mo_idx += 1 | ||
else: | ||
self.mos[mo_idx] = irrepres[0,:] | ||
mo_idx += 1 | ||
|
||
return self.mos | ||
|
||
|
||
def apply_projection_operator(self, bf_idx, irrep_idx): | ||
""" | ||
Apply the projection operator to a basis function | ||
""" | ||
res = np.zeros(len(self.so.mol.basis)) | ||
for i,m in enumerate(self.so.operation_matrices): | ||
res += self.ct.get_character(irrep_idx, i) * m[bf_idx,:] | ||
|
||
# return result and normalize it | ||
return np.array(res, dtype=np.float64) / np.linalg.norm(res) |
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