mirror of https://github.com/phonopy/phonopy.git
forcefit displacement matrix implementation in C
This commit is contained in:
parent
d6ac90f7d6
commit
62aa1645d0
|
@ -101,8 +101,9 @@ class FC4Fit:
|
|||
site_syms_cart = np.double([similarity_transformation(self._lattice, sym)
|
||||
for sym in site_symmetry])
|
||||
|
||||
triplets_c, num_triplets = self._create_displacement_triplets_for_c(
|
||||
disp_triplets)
|
||||
(disp_triplets_rearranged,
|
||||
num_triplets) = self._create_displacement_triplets_for_c(disp_triplets)
|
||||
max_num_disp = np.amax(num_triplets[:, :, :, 1])
|
||||
|
||||
for second_atom_num in range(self._num_atom):
|
||||
print second_atom_num + 1
|
||||
|
@ -114,10 +115,11 @@ class FC4Fit:
|
|||
rot_disps_set.append(self._create_displacement_matrix_c(
|
||||
second_atom_num,
|
||||
third_atom_num,
|
||||
triplets_c,
|
||||
disp_triplets_rearranged,
|
||||
num_triplets,
|
||||
site_syms_cart,
|
||||
rot_map_syms))
|
||||
rot_map_syms,
|
||||
max_num_disp))
|
||||
except ImportError:
|
||||
rot_disps_set.append(self._create_displacement_matrix(
|
||||
second_atom_num,
|
||||
|
@ -167,7 +169,6 @@ class FC4Fit:
|
|||
column_num,
|
||||
1e-13,
|
||||
info)
|
||||
inv_disps_set = []
|
||||
inv_disps_set = [
|
||||
inv_disps[i, :row_nums[i] * column_num].reshape(column_num, -1)
|
||||
for i in range(self._num_atom)]
|
||||
|
@ -250,11 +251,13 @@ class FC4Fit:
|
|||
disp_triplets,
|
||||
num_disps,
|
||||
site_syms_cart,
|
||||
rot_map_syms):
|
||||
rot_map_syms,
|
||||
max_num_disp):
|
||||
import anharmonic._forcefit as forcefit
|
||||
num_row_elem = 27 * 10 + 9 * 6 + 3 * 3 + 1
|
||||
disp_matrix_tmp = np.zeros((len(disp_triplets) * len(site_syms_cart),
|
||||
num_row_elem), dtype='double')
|
||||
disp_matrix_tmp = np.zeros(
|
||||
(len(num_disps) * max_num_disp * len(site_syms_cart), num_row_elem),
|
||||
dtype='double')
|
||||
num_elems = forcefit.displacement_matrix_fc4(disp_matrix_tmp,
|
||||
second_atom_num,
|
||||
third_atom_num,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
static PyObject * py_phonopy_pinv(PyObject *self, PyObject *args);
|
||||
static PyObject * py_phonopy_pinv_mt(PyObject *self, PyObject *args);
|
||||
static PyObject * py_displacement_matrix_fc4(PyObject *self, PyObject *args);
|
||||
void get_tensor1(double sym_u[9], const double u[9], const double *sym);
|
||||
void get_tensor1(double sym_u[9], const double *u, const double *sym);
|
||||
int set_tensor2(double *disp_matrix, const double u[9]);
|
||||
int set_tensor3(double *disp_matrix, const double u[9]);
|
||||
|
||||
|
@ -115,7 +115,7 @@ static PyObject * py_displacement_matrix_fc4(PyObject *self, PyObject *args)
|
|||
const int *rot_map_syms = (int*)rot_map_syms_py->data;
|
||||
|
||||
int i, j, k, l, rot_num2, rot_num3, address, num_disp, count;
|
||||
double u[9], sym_u[9];
|
||||
double sym_u[9];
|
||||
|
||||
count = 0;
|
||||
for (i = 0; i < num_first_disps; i++) {
|
||||
|
@ -131,10 +131,9 @@ static PyObject * py_displacement_matrix_fc4(PyObject *self, PyObject *args)
|
|||
for (k = 0; k < num_disp; k++) {
|
||||
disp_matrix[count] = -1;
|
||||
count++;
|
||||
for (l = 0; l < 9; l++) {
|
||||
u[l] = disp_triplets[address + k * 9 + l];
|
||||
}
|
||||
get_tensor1(sym_u, u, site_syms_cart + j * 9);
|
||||
get_tensor1(sym_u,
|
||||
disp_triplets + (address + k) * 9,
|
||||
site_syms_cart + j * 9);
|
||||
for (l = 0; l < 9; l++) {
|
||||
disp_matrix[count] = sym_u[l];
|
||||
count++;
|
||||
|
@ -147,14 +146,15 @@ static PyObject * py_displacement_matrix_fc4(PyObject *self, PyObject *args)
|
|||
return PyInt_FromLong((long) count);
|
||||
}
|
||||
|
||||
void get_tensor1(double sym_u[9], const double u[9], const double *sym)
|
||||
void get_tensor1(double sym_u[9], const double *u, const double *sym)
|
||||
{
|
||||
int i, j, k;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (j = 0; j < 3; j++) {
|
||||
sym_u[i * 3 + j] = 0;
|
||||
for (k = 0; k < 3; k++) {
|
||||
sym_u[i * 3 + j] = sym[j * 3 + k] * u[i * 3 + k];
|
||||
sym_u[i * 3 + j] += sym[j * 3 + k] * u[i * 3 + k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue