Пример #1
0
static lapack_complex_double fc3_sum_in_reciprocal_to_normal
(const int bi0,
 const int bi1,
 const int bi2,
 const lapack_complex_double *eigvecs0,
 const lapack_complex_double *eigvecs1,
 const lapack_complex_double *eigvecs2,
 const lapack_complex_double *fc3_reciprocal,
 const double *masses,
 const int num_atom)
{
  int i, j, k, l, m, n, index_l, index_lm, baseIndex;
  double sum_real, sum_imag, mmm, mass_l, mass_lm;
  lapack_complex_double eig_prod, eig_prod1;

  sum_real = 0;
  sum_imag = 0;

  for (l = 0; l < num_atom; l++) {
    mass_l = masses[l];
    index_l = l * num_atom * num_atom * 27;

    for (m = 0; m < num_atom; m++) {
      mass_lm = mass_l * masses[m];
      index_lm = index_l + m * num_atom * 27;

      for (i = 0; i < 3; i++) {
	for (j = 0; j < 3; j++) {
	  eig_prod1 = phonoc_complex_prod
	    (eigvecs0[(l * 3 + i) * num_atom * 3 + bi0],
	     eigvecs1[(m * 3 + j) * num_atom * 3 + bi1]);

	  for (n = 0; n < num_atom; n++) {
	    mmm = 1.0 / sqrt(mass_lm * masses[n]);
	    baseIndex = index_lm + n * 27 + i * 9 + j * 3;

	    for (k = 0; k < 3; k++) {
	      eig_prod = phonoc_complex_prod
		(eig_prod1, eigvecs2[(n * 3 + k) * num_atom * 3 + bi2]);
	      eig_prod = phonoc_complex_prod
		(eig_prod, fc3_reciprocal[baseIndex + k]);
	      sum_real += lapack_complex_double_real(eig_prod) * mmm;
	      sum_imag += lapack_complex_double_imag(eig_prod) * mmm;
	    }
	  }
	}
      }
    }
  }
  return lapack_make_complex_double(sum_real, sum_imag);
}
Пример #2
0
static void real_to_reciprocal_elements(lapack_complex_double *fc4_rec_elem,
					const double q[12],
					const double *fc4,
					const Darray *shortest_vectors,
					const Iarray *multiplicity,
					const int *p2s,
					const int *s2p,
					const int pi0,
					const int pi1,
					const int pi2,
					const int pi3)
{
  int i, j, k, l, m, num_satom;
  lapack_complex_double phase_factor, phase_factors[3];
  double fc4_rec_real[81], fc4_rec_imag[81];
  int fc4_elem_address;

  for (i = 0; i < 81; i++) {
    fc4_rec_real[i] = 0;
    fc4_rec_imag[i] = 0;
  }
  
  num_satom = multiplicity->dims[0];

  i = p2s[pi0];

  for (j = 0; j < num_satom; j++) {
    if (s2p[j] != p2s[pi1]) {
      continue;
    }
    phase_factors[0] =
      get_phase_factor(q, shortest_vectors, multiplicity, pi0, j, 1);

    for (k = 0; k < num_satom; k++) {
      if (s2p[k] != p2s[pi2]) {
	continue;
      }
      phase_factors[1] =
	get_phase_factor(q, shortest_vectors, multiplicity, pi0, k, 2);

      for (l = 0; l < num_satom; l++) {
	if (s2p[l] != p2s[pi3]) {
	  continue;
	}
	phase_factors[2] =
	  get_phase_factor(q, shortest_vectors, multiplicity, pi0, l, 3);
	
	fc4_elem_address = (i * 81 * num_satom * num_satom * num_satom +
			    j * 81 * num_satom * num_satom +
			    k * 81 * num_satom +
			    l * 81);

	phase_factor = phonoc_complex_prod(phase_factors[0], phase_factors[1]);
	phase_factor = phonoc_complex_prod(phase_factor, phase_factors[2]);
	for (m = 0; m < 81; m++) {
	  fc4_rec_real[m] +=
	    lapack_complex_double_real(phase_factor) * fc4[fc4_elem_address + m];
	  fc4_rec_imag[m] +=
	    lapack_complex_double_imag(phase_factor) * fc4[fc4_elem_address + m];
	}
      }
    }
  }

  for (i = 0; i < 81; i++) {
    fc4_rec_elem[i] =
      lapack_make_complex_double(fc4_rec_real[i], fc4_rec_imag[i]);
  }
}