Provide access to more information in ScatteringSystem

This commit is contained in:
Marek Nečada 2020-07-03 18:50:44 +03:00
parent 38a4dbfcd7
commit 840744ec97
2 changed files with 45 additions and 1 deletions

View File

@ -535,6 +535,11 @@ cdef class ScatteringSystem:
r.append(self.s[0].p[pi]) r.append(self.s[0].p[pi])
return r return r
property particle_count:
"""Number of particles in the system (or unit cell)"""
def __get__(self):
self.check_s()
return self.s[0].p_count
property fecv_size: property fecv_size:
"""Length of the full excitation coefficient vector""" """Length of the full excitation coefficient vector"""
def __get__(self): def __get__(self):
@ -561,6 +566,44 @@ cdef class ScatteringSystem:
def __get__(self): def __get__(self):
return self.s[0].lattice_dimension return self.s[0].lattice_dimension
property lattice_basis:
"""Direct lattice basis vectors for periodic system in 3D cartesian coordinates"""
def __get__(self):
cdef int d = self.lattice_dimension
if d == 0:
return None
else:
return np.array([[self.s[0].per.lattice_basis[i].x,
self.s[0].per.lattice_basis[i].y,
self.s[0].per.lattice_basis[i].z,
] for i in range(d)])
property reciprocal_basis:
"""Reciprocal lattice basis vectors for periodic system in 3D cartesian coordinates"""
def __get__(self):
cdef int d = self.lattice_dimension
if d == 0:
return None
else:
return np.array([[self.s[0].per.reciprocal_basis[i].x,
self.s[0].per.reciprocal_basis[i].y,
self.s[0].per.reciprocal_basis[i].z,
] for i in range(d)])
def bspec_pi(self, qpms_ss_pi_t pi):
"""Gives the BaseSpec of a particle defined by an index in the internal particles' order, in the form of an array that can be fed to BaseSpec constructor"""
self.check_s()
cdef qpms_ss_pi_t pcount = self.s[0].p_count
if pi >= pcount or pi < 0: raise IndexError("Invalid particle index")
cdef const qpms_vswf_set_spec_t *bspec = qpms_ss_bspec_pi(self.s, pi)
return np.array([ bspec[0].ilist[i] for i in range(bspec[0].n)])
property bspecs:
"""Gives the BaseSpecs of all particles in the internal particles' order, in the form of arrays that can be fed to BaseSpec constructor"""
def __get__(self):
self.check_s()
cdef qpms_ss_pi_t pi, pcount = self.s[0].p_count
return [self.bspec_pi(pi) for pi in range(pcount)]
property unitcell_volume: property unitcell_volume:
def __get__(self): def __get__(self):
self.check_s() self.check_s()
@ -792,7 +835,7 @@ cdef class ScatteringSystem:
cdef np.ndarray[int32_t, ndim=1] ar = np.empty((self.s[0].p_count,), dtype=np.int32) cdef np.ndarray[int32_t, ndim=1] ar = np.empty((self.s[0].p_count,), dtype=np.int32)
cdef int32_t[::1] ar_view = ar cdef int32_t[::1] ar_view = ar
for pi in range(self.s[0].p_count): for pi in range(self.s[0].p_count):
ar_view[pi] = self.s[0].tm[self.s[0].p[pi].tmatrix_id].spec[0].n ar_view[pi] = qpms_ss_bspec_pi(self.s, pi)[0].n
return ar return ar

View File

@ -602,6 +602,7 @@ cdef extern from "scatsystem.h":
qpms_tmatrix_operation_t op qpms_tmatrix_operation_t op
struct qpms_scatsys_periodic_info_t: struct qpms_scatsys_periodic_info_t:
cart3_t lattice_basis[3] cart3_t lattice_basis[3]
cart3_t reciprocal_basis[3]
double unitcell_volume double unitcell_volume
double eta double eta
#etc. #etc.