コード例 #1
0
ファイル: interaction.c プロジェクト: Johnson-Wang/phonopy
static void real_to_normal_sym_q(double *fc3_normal_squared,
				 double *freqs[3],
				 lapack_complex_double *eigvecs[3],
				 const Darray *fc3,
				 const int *atc,
				 const int *atc_rec,
                 const char* g_skip,
				 const double q[9], /* q0, q1, q2 */
				 const Darray *shortest_vectors,
				 const Iarray *multiplicity,
				 const double *masses,
				 const int *p2s_map,
				 const int *s2p_map,
				 const int *band_indices,
				 const int num_band0,
				 const int num_band,
				 const double cutoff_frequency,
				 const double cutoff_hfrequency,
                 const double cutoff_delta)
{
  int i, j, k, l;
  int band_ex[3];
  int band_shape[3];
  int bb = num_band*num_band;
  int *ie;
  int pos_band0=0;
  double q_ex[9];
  double *fc3_normal_squared_ex;
  char *g_skip_new;
//  double dmax=0, dtemp;
  fc3_normal_squared_ex =
    (double*)malloc(sizeof(double) * num_band0 * num_band * num_band);
  g_skip_new = (char*) malloc(sizeof(char)*num_band0 * num_band * num_band);
  for (i = 0; i < num_band0 * num_band * num_band; i++) {
    fc3_normal_squared[i] = 0;
    g_skip_new[i] = 0;
  }

  for (i = 0; i < 6; i++) {

    ie = index_exchange[i];
    for (j = 0; j < 3; j++)
    {
      if (ie[j] == 0)
      {
        band_shape[j] = num_band0;
        pos_band0 = j;
      }
      else
        band_shape[j] = num_band;
    }
    for (j = 0; j < 3; j ++) {
      for (k = 0; k < 3; k ++) {
	q_ex[j * 3 + k] = q[ie[j] * 3 + k];
      }
    }

    for (j = 0; j < num_band0; j++)
      for (k = 0; k < num_band; k++)
        for (l = 0; l < num_band; l++)
        {
          band_ex[0] = j;
          band_ex[1] = k;
          band_ex[2] = l;
          g_skip_new[band_ex[ie[0]] * band_shape[1] * band_shape[2] + band_ex[ie[1]] * band_shape[2] + band_ex[ie[2]]] =
             g_skip[j * num_band * num_band + k * num_band + l];
        }

    real_to_normal(fc3_normal_squared_ex,
		   freqs[ie[0]],
		   freqs[ie[1]],
		   freqs[ie[2]],
		   eigvecs[ie[0]],
		   eigvecs[ie[1]],
		   eigvecs[ie[2]],
		   fc3,
		   atc,
		   atc_rec,
           g_skip_new,
		   q_ex, /* q0, q1, q2 */
		   shortest_vectors,
		   multiplicity,
		   masses,
		   p2s_map,
		   s2p_map,
		   band_indices,
		   num_band0,
		   num_band,
		   pos_band0,
		   cutoff_frequency,
		   cutoff_hfrequency,
           cutoff_delta);

    for (j = 0; j < num_band0; j++) {
      for (k = 0; k < num_band; k++) {
        for (l = 0; l < num_band; l++) {
          band_ex[0] = j;
          band_ex[1] = k;
          band_ex[2] = l;
          fc3_normal_squared[j * num_band * num_band +
                     k * num_band +
                     l] +=
            fc3_normal_squared_ex[band_ex[ie[0]] *
                      band_shape[1] * band_shape[2]+
                      band_ex[ie[1]] * band_shape[2] +
                      band_ex[ie[2]]] / 6.0;
//          dtemp = fabs(fc3_normal_squared[j * num_band * num_band +
//                     k * num_band +
//                     l] * 6 / (i + 1) - fc3_normal_squared_ex[band_ex[index_exchange[i][0]] *
//                      num_band * num_band +
//                      band_ex[index_exchange[i][1]] * num_band +
//                      band_ex[index_exchange[i][2]]]);
//          dmax = (dtemp > dmax)? dtemp: dmax;
        }
      }
    }
  }
  free(g_skip_new);
  free(fc3_normal_squared_ex);
}
コード例 #2
0
ファイル: interaction.c プロジェクト: chueter/phonopy
static void real_to_normal_sym_q(double *fc3_normal_squared,
				 const char *g_zero,
				 double *freqs[3],
				 lapack_complex_double *eigvecs[3],
				 const Darray *fc3,
				 const double q[9], /* q0, q1, q2 */
				 const Darray *shortest_vectors,
				 const Iarray *multiplicity,
				 const double *masses,
				 const int *p2s_map,
				 const int *s2p_map,
				 const int *band_indices,
				 const int num_band0,
				 const int num_band,
				 const double cutoff_frequency,
				 const int triplet_index,
				 const int num_triplets,
				 const int openmp_at_bands)
{
  int i, j, k, l;
  int band_ex[3];
  double q_ex[9];
  double *fc3_normal_squared_ex;

  fc3_normal_squared_ex =
    (double*)malloc(sizeof(double) * num_band * num_band * num_band);

  for (i = 0; i < num_band0 * num_band * num_band; i++) {
    fc3_normal_squared[i] = 0;
  }

  for (i = 0; i < 6; i++) {
    for (j = 0; j < 3; j ++) {
      for (k = 0; k < 3; k ++) {
	q_ex[j * 3 + k] = q[index_exchange[i][j] * 3 + k];
      }
    }
    real_to_normal(fc3_normal_squared_ex,
		   g_zero,
		   freqs[index_exchange[i][0]],
		   freqs[index_exchange[i][1]],
		   freqs[index_exchange[i][2]],
		   eigvecs[index_exchange[i][0]],
		   eigvecs[index_exchange[i][1]],
		   eigvecs[index_exchange[i][2]],
		   fc3,
		   q_ex, /* q0, q1, q2 */
		   shortest_vectors,
		   multiplicity,
		   masses,
		   p2s_map,
		   s2p_map,
		   band_indices,
		   num_band,
		   num_band,
		   cutoff_frequency,
		   triplet_index,
		   num_triplets,
		   openmp_at_bands);
    for (j = 0; j < num_band0; j++) {
      for (k = 0; k < num_band; k++) {
	for (l = 0; l < num_band; l++) {
	  band_ex[0] = band_indices[j];
	  band_ex[1] = k;
	  band_ex[2] = l;
	  fc3_normal_squared[j * num_band * num_band +
			     k * num_band +
			     l] +=
	    fc3_normal_squared_ex[band_ex[index_exchange[i][0]] *
				  num_band * num_band +
				  band_ex[index_exchange[i][1]] * num_band +
				  band_ex[index_exchange[i][2]]] / 6;
	}
      }
    }
  }

  free(fc3_normal_squared_ex);

}
コード例 #3
0
ファイル: interaction.c プロジェクト: Johnson-Wang/phonopy
/* fc3_normal_squared[num_triplets, num_band0, num_band, num_band] */
void get_interaction(Darray *fc3_normal_squared,
		     const Darray *frequencies,
		     const Carray *eigenvectors,
		     const Iarray *triplets,
		     const int *grid_address,
		     const int *mesh,
		     const Darray *fc3,
             const int *atc,
             const int *atc_rec,
             const char* g_skip,
		     const Darray *shortest_vectors,
		     const Iarray *multiplicity,
		     const double *masses,
		     const int *p2s_map,
		     const int *s2p_map,
		     const int *band_indices,
		     const int symmetrize_fc3_q,
		     const double cutoff_frequency,
		     const double cutoff_hfrequency,
             const double cutoff_delta)
{
  int i, j, k, gp, num_band, num_band0;
  double *freqs[3];
  lapack_complex_double *eigvecs[3];
  double q[9];

  num_band = frequencies->dims[1];
  num_band0 = fc3_normal_squared->dims[1];

#pragma omp parallel for private(j, k, q, gp, freqs, eigvecs)
  for (i = 0; i < triplets->dims[0]; i++) {

    for (j = 0; j < 3; j++) {
      gp = triplets->data[i * 3 + j];
      for (k = 0; k < 3; k++) {
	q[j * 3 + k] = ((double)grid_address[gp * 3 + k]) / mesh[k];
      }
      freqs[j] = frequencies->data + gp * num_band;
      eigvecs[j] = eigenvectors->data + gp * num_band * num_band;
    }

    if (symmetrize_fc3_q) {
      real_to_normal_sym_q((fc3_normal_squared->data +
			    i * num_band0 * num_band * num_band),
			   freqs,
			   eigvecs,
			   fc3,
			   atc,
			   atc_rec,
               g_skip + i * num_band0 * num_band * num_band,
			   q, /* q0, q1, q2 */
			   shortest_vectors,
			   multiplicity,
			   masses,
			   p2s_map,
			   s2p_map,
			   band_indices,
			   num_band0,
			   num_band,
			   cutoff_frequency,
			   cutoff_hfrequency,
               cutoff_delta);
    } else {
      real_to_normal((fc3_normal_squared->data +
		      i * num_band0 * num_band * num_band),
		     freqs[0],
		     freqs[1],
		     freqs[2],
		     eigvecs[0],
		     eigvecs[1],
		     eigvecs[2],
		     fc3,
		     atc,
		     atc_rec,
             g_skip + i * num_band0 * num_band * num_band,
		     q, /* q0, q1, q2 */
		     shortest_vectors,
		     multiplicity,
		     masses,
		     p2s_map,
		     s2p_map,
		     band_indices,
		     num_band0,
		     num_band,
		     0,
		     cutoff_frequency,
		     cutoff_hfrequency,
             cutoff_delta);
    }
  }
}
コード例 #4
0
ファイル: interaction.c プロジェクト: chueter/phonopy
static void get_interaction_at_triplet(Darray *fc3_normal_squared,
				       const int i,
				       const char *g_zero,
				       const Darray *frequencies,
				       const Carray *eigenvectors,
				       const Iarray *triplets,
				       const int *grid_address,
				       const int *mesh,
				       const Darray *fc3,
				       const Darray *shortest_vectors,
				       const Iarray *multiplicity,
				       const double *masses,
				       const int *p2s_map,
				       const int *s2p_map,
				       const int *band_indices,
				       const int symmetrize_fc3_q,
				       const double cutoff_frequency,
				       const int num_triplets,
				       const int openmp_at_bands)
{
  int j, k, gp, num_band, num_band0;
  double *freqs[3];
  lapack_complex_double *eigvecs[3];
  double q[9];

  num_band = frequencies->dims[1];
  num_band0 = fc3_normal_squared->dims[1];

  for (j = 0; j < 3; j++) {
    gp = triplets->data[i * 3 + j];
    for (k = 0; k < 3; k++) {
      q[j * 3 + k] = ((double)grid_address[gp * 3 + k]) / mesh[k];
    }
    freqs[j] = frequencies->data + gp * num_band;
    eigvecs[j] = eigenvectors->data + gp * num_band * num_band;
  }

  if (symmetrize_fc3_q) {
    real_to_normal_sym_q((fc3_normal_squared->data +
			  i * num_band0 * num_band * num_band),
			 g_zero + i * num_band0 * num_band * num_band,
			 freqs,
			 eigvecs,
			 fc3,
			 q, /* q0, q1, q2 */
			 shortest_vectors,
			 multiplicity,
			 masses,
			 p2s_map,
			 s2p_map,
			 band_indices,
			 num_band0,
			 num_band,
			 cutoff_frequency,
			 i,
			 num_triplets,
			 openmp_at_bands);
  } else {
    real_to_normal((fc3_normal_squared->data +
		    i * num_band0 * num_band * num_band),
		   g_zero + i * num_band0 * num_band * num_band,
		   freqs[0],
		   freqs[1],
		   freqs[2],
		   eigvecs[0],
		   eigvecs[1],
		   eigvecs[2],
		   fc3,
		   q, /* q0, q1, q2 */
		   shortest_vectors,
		   multiplicity,
		   masses,
		   p2s_map,
		   s2p_map,
		   band_indices,
		   num_band0,
		   num_band,
		   cutoff_frequency,
		   i,
		   num_triplets,
		   openmp_at_bands);
  }
}