Esempio n. 1
0
/* method to check if pepc parameters are entered into checked FCS */
FCSResult fcs_pepc_check(FCS handle)
{
  const fcs_float *a,*b,*c;
  fcs_float eps, theta;
  FCSResult res;

  if ((res = fcs_pepc_get_epsilon(handle, &eps))) return res;
  if (eps == -1.0)
    return fcs_result_create(FCS_ERROR_MISSING_ELEMENT, __func__, "pepc: epsilon not set");
  if ((res = fcs_pepc_get_theta(handle, &theta))) return res;
  if (theta == -1.0)
    return fcs_result_create(FCS_ERROR_MISSING_ELEMENT, __func__, "pepc: theta not set");

  a = fcs_get_box_a(handle);
  b = fcs_get_box_b(handle);
  c = fcs_get_box_c(handle);
  if (!fcs_uses_principal_axes(a,b,c))
    printf("%s\n", "WARNING: support of pepc for non-cubic simulation boxes currently is experimental.");

  if (!fcs_get_near_field_flag(handle))
    return fcs_result_create(FCS_ERROR_INCOMPATIBLE_METHOD, __func__, 
			    "pepc performs near field computations by itself!");

  return FCS_RESULT_SUCCESS;
}
Esempio n. 2
0
FCSResult fcs_fmm_check(FCS handle)
{
  const fcs_float *a,*b,*c;
  const fcs_int *periodicity;
  int i,p;

  fcs_int absrel;
  fcs_fmm_get_absrel(handle, &absrel);
  if (absrel == -1)
    return fcs_result_create(FCS_ERROR_MISSING_ELEMENT, __func__, "fmm: absrel not set");

  fcs_float deltaE;
  fcs_fmm_get_deltaE(handle, &deltaE);
  if (deltaE == -1.0)
    return fcs_result_create(FCS_ERROR_MISSING_ELEMENT, __func__, "fmm: deltaE not set");

  a = fcs_get_box_a(handle);
  b = fcs_get_box_b(handle);
  c = fcs_get_box_c(handle);
  periodicity = fcs_get_periodicity(handle);

  p = 0;
  for (i = 0; i < 3; ++i)
    if (periodicity[i]) p++;

  switch(p)
  {
    case 0:
      return FCS_RESULT_SUCCESS;
    case 1:
      for (i = 0; i < 3; ++i)
        if (periodicity[i]) break;
      switch(i)
      {
        case 0:
          if (!( (fcs_norm(a) >= fcs_norm(b)) && (fcs_norm(a) >= fcs_norm(c)) ))
            return fcs_result_create(FCS_ERROR_INCOMPATIBLE_METHOD, __func__, 
              "fmm: longest box vector not in direction of 1D-periodicity direction");


          return FCS_RESULT_SUCCESS;
        case 1:
          if (!( (fcs_norm(b) >= fcs_norm(a)) && (fcs_norm(b) >= fcs_norm(a)) ))
            return fcs_result_create(FCS_ERROR_INCOMPATIBLE_METHOD, __func__, 
              "fmm: longest box vector not in direction of 1D-periodicity direction");
          return FCS_RESULT_SUCCESS;
        case 2:
          if (!( (fcs_norm(c) >= fcs_norm(a)) && (fcs_norm(c) >= fcs_norm(b)) ))
            return fcs_result_create(FCS_ERROR_INCOMPATIBLE_METHOD, __func__, 
              "fmm: longest box vector not in direction of 1D-periodicity direction");
          return FCS_RESULT_SUCCESS;
      }
    case 2:
      for (i = 0; i < 3; ++i)
        if (!periodicity[i]) break;
      switch(i)
      {
        case 0:
          if (!( (fcs_float_is_equal(fcs_norm(b),fcs_norm(c))) && (fcs_norm(b) >= fcs_norm(a)) ))


            return fcs_result_create(FCS_ERROR_INCOMPATIBLE_METHOD, __func__, 
              "fmm: longest box vector not in direction of 2D-periodicity direction");
          return FCS_RESULT_SUCCESS;
        case 1:
          if (!( (fcs_float_is_equal(fcs_norm(a),fcs_norm(c))) && (fcs_norm(a) >= fcs_norm(b)) ))
            return fcs_result_create(FCS_ERROR_INCOMPATIBLE_METHOD, __func__, 
              "fmm: longest box vector not in direction of 2D-periodicity direction");
          return FCS_RESULT_SUCCESS;
        case 2:
          if (!( (fcs_float_is_equal(fcs_norm(a),fcs_norm(b))) && (fcs_norm(a) >= fcs_norm(c)) ))
            return fcs_result_create(FCS_ERROR_INCOMPATIBLE_METHOD, __func__, 
              "fmm: longest box vector not in direction of 2D-periodicity direction");
          return FCS_RESULT_SUCCESS;
      }
    case 3:
      if (!(fcs_uses_principal_axes(a,b,c))) 
        return fcs_result_create(FCS_ERROR_INCOMPATIBLE_METHOD, __func__, "fmm: cannot use a non-cubic system in 3D-periodicity");
      return FCS_RESULT_SUCCESS;
  }

  return FCS_RESULT_SUCCESS;
}
Esempio n. 3
0
/* method to check if fmm parameters are consistent with requirements */
FCSResult fcs_fmm_check(FCS handle, fcs_int local_particles)
{
  const fcs_float *a,*b,*c;
  fcs_float norm[3],period_length;
  const fcs_int *periodicity;
  MPI_Comm comm;
  fcs_int total_particles;
  int comm_size;
  int i,p,ok;

  fcs_int absrel;
  fcs_fmm_get_absrel(handle, &absrel);
  if (absrel == -1)
    return fcs_result_create(FCS_ERROR_MISSING_ELEMENT, __func__, "fmm: absrel not set");

  fcs_float tolerance_energy;
  fcs_fmm_get_tolerance_energy(handle, &tolerance_energy);
  if (tolerance_energy == -1.0)
    return fcs_result_create(FCS_ERROR_MISSING_ELEMENT, __func__, "fmm: energy tolerance not set");

  comm = fcs_get_communicator(handle);
  MPI_Comm_size(comm, &comm_size);
  total_particles = fcs_get_total_particles(handle);
  if (total_particles < comm_size)
    return fcs_result_create(FCS_ERROR_INCOMPATIBLE_METHOD, __func__, "fmm: there have to be at least as much particles as processes");
  
  if (local_particles <= 0)
    return fcs_result_create(FCS_ERROR_INCOMPATIBLE_METHOD, __func__, "fmm: each process has to receive at least one particle");
  
  a = fcs_get_box_a(handle); 
  norm[0] = fcs_norm(a);
  b = fcs_get_box_b(handle);
  norm[1] = fcs_norm(b);
  c = fcs_get_box_c(handle);
  norm[2] = fcs_norm(c);
  periodicity = fcs_get_periodicity(handle);

  p = 0; ok = 1;
  for (i = 0; i < 3; ++i)
    if (periodicity[i]) 
    {
      if (0==p) 
        period_length = norm[i];
      else 
        ok = ok && fcs_float_is_equal( period_length, norm[i] );
      p++;
    }

  if (p && !(fcs_uses_principal_axes(a,b,c))) 
    return fcs_result_create(FCS_ERROR_INCOMPATIBLE_METHOD, __func__, 
      "fmm: with periodic boundaries, box must be arranged along principle axes");

  if (p && !ok)
    return fcs_result_create(FCS_ERROR_INCOMPATIBLE_METHOD, __func__, 
      "fmm: all periodic directions must have equal length");

  if (p && (p<3)) 
  {
    ok = 1;
    for (i = 0; i < 3; ++i)
      if (!periodicity[i]) 
        ok = ok && (norm[i] <= period_length);
    if (!ok)
      return fcs_result_create(FCS_ERROR_INCOMPATIBLE_METHOD, __func__, 
        "fmm: axes in non-periodic directions must not be longer than periodic ones");
  }

  return FCS_RESULT_SUCCESS;
}
Esempio n. 4
0
extern FCSResult fcs_vmg_check(FCS handle)
{
  char fnc_name[] = "fcs_vmg_check";
  FCSResult result;

  fcs_int max_level;
  result = fcs_vmg_get_max_level(handle, &max_level);
  if (result != NULL)
    return result;
  if (max_level == -1)
    return fcsResult_create(FCS_MISSING_ELEMENT, fnc_name, "vmg finest level not set.");
  if (max_level < 3)
    return fcsResult_create(FCS_LOGICAL_ERROR, fnc_name, "vmg finest level must be greater than 2.");

  fcs_int max_iterations;
  result = fcs_vmg_get_max_iterations(handle, &max_iterations);
  if (result != NULL)
    return result;
  if (max_iterations == -1)
    return fcsResult_create(FCS_MISSING_ELEMENT, fnc_name, "vmg maximum number of iterations not set.");
  if (max_iterations < 1)
    return fcsResult_create(FCS_LOGICAL_ERROR, fnc_name, "vmg maximum number of iterations must be positive.");

  fcs_int smoothing_steps;
  result = fcs_vmg_get_smoothing_steps(handle, &smoothing_steps);
  if (result != NULL)
    return result;
  if (smoothing_steps == -1)
    return fcsResult_create(FCS_MISSING_ELEMENT, fnc_name, "vmg number of smoothing steps not set.");
  if (smoothing_steps < 1)
    return fcsResult_create(FCS_LOGICAL_ERROR, fnc_name, "vmg number of smoothing steps must be positive.");

  fcs_int cycle_type;
  result = fcs_vmg_get_cycle_type(handle, &cycle_type);
  if (result != NULL)
    return result;
  if (cycle_type == -1)
    return fcsResult_create(FCS_MISSING_ELEMENT, fnc_name, "vmg cycle number not set.");
  if (cycle_type < 1)
    return fcsResult_create(FCS_LOGICAL_ERROR, fnc_name, "vmg cycle number must be positive.");

  fcs_float precision;
  result = fcs_vmg_get_precision(handle, &precision);
  if (result != NULL)
    return result;
  if (precision == -1.)
    return fcsResult_create(FCS_MISSING_ELEMENT, fnc_name, "vmg desired precision not set.");

  fcs_int near_field_cells;
  result = fcs_vmg_get_near_field_cells(handle, &near_field_cells);
  if (result != NULL)
    return result;
  if (near_field_cells == -1)
    return fcsResult_create(FCS_MISSING_ELEMENT, fnc_name, "vmg number of near field cells not set.");
  if (near_field_cells < 1)
    return fcsResult_create(FCS_LOGICAL_ERROR, fnc_name, "vmg number of near field cells must be positive.");

  fcs_int interpolation_order;
  result = fcs_vmg_get_interpolation_order(handle, &interpolation_order);
  if (result != NULL)
    return result;
  if (interpolation_order == -1)
    return fcsResult_create(FCS_MISSING_ELEMENT, fnc_name, "vmg interpolation order not set.");
  if (interpolation_order < 3)
    return fcsResult_create(FCS_LOGICAL_ERROR, fnc_name, "vmg interpolation order must be greater or equal three.");

  fcs_int discretization_order;
  result = fcs_vmg_get_discretization_order(handle, &discretization_order);
  if (result != NULL)
    return result;
  if (discretization_order == -1)
    return fcsResult_create(FCS_MISSING_ELEMENT, fnc_name, "vmg discretization order not set.");
  if (discretization_order != 2 && discretization_order != 4)
    return fcsResult_create(FCS_LOGICAL_ERROR, fnc_name, "vmg discretization order must be 2 or 4.");

  fcs_float* box_a = fcs_get_box_a(handle);
  fcs_float* box_b = fcs_get_box_b(handle);
  fcs_float* box_c = fcs_get_box_c(handle);

  if (!fcs_is_cubic(box_a, box_b, box_c))
    return fcsResult_create(FCS_LOGICAL_ERROR, fnc_name, "vmg requires the box to be cubic.");

  if (!fcs_uses_principal_axes(box_a, box_b, box_c))
    return fcsResult_create(FCS_LOGICAL_ERROR, fnc_name, "vmg requires the box vectors to be parallel to the principal axes.");

  return NULL;
}