Beispiel #1
0
/**
 * set the origin vector of the system box
 */
FCSResult fcs_set_box_origin(FCS handle, const fcs_float *box_origin)
{
  CHECK_HANDLE_RETURN_RESULT(handle, __func__);

  if (box_origin == NULL)
    return fcs_result_create(FCS_ERROR_NULL_ARGUMENT, __func__, "null pointer supplied as argument");

  handle->box_origin[0] = box_origin[0];
  handle->box_origin[1] = box_origin[1];
  handle->box_origin[2] = box_origin[2];
  
  fcs_set_values_changed(handle, 1);

  return FCS_RESULT_SUCCESS;
}
Beispiel #2
0
/**
 * set the periodicity of the system
 */
FCSResult fcs_set_periodicity(FCS handle, const fcs_int *periodicity)
{
  const char *fnc_name = "fcs_set_periodicity";

  CHECK_HANDLE_RETURN_RESULT(handle, fnc_name);

  if (periodicity == NULL)
    return fcs_result_create(FCS_ERROR_NULL_ARGUMENT, fnc_name, "null pointer supplied as argument");

  handle->periodicity[0] = periodicity[0];
  handle->periodicity[1] = periodicity[1];
  handle->periodicity[2] = periodicity[2];

  fcs_set_values_changed(handle, 1);

  return FCS_RESULT_SUCCESS;
}
Beispiel #3
0
/**
 * set the third base vector of the system box
 */
FCSResult fcs_set_box_c(FCS handle, const fcs_float *box_c)
{
  const char *fnc_name = "fcs_set_box_c";

  CHECK_HANDLE_RETURN_RESULT(handle, fnc_name);

  if (box_c == NULL)
    return fcs_result_create(FCS_ERROR_NULL_ARGUMENT, fnc_name, "null pointer supplied as argument");

  handle->box_c[0] = box_c[0];
  handle->box_c[1] = box_c[1];
  handle->box_c[2] = box_c[2];
  
  fcs_set_values_changed(handle, 1);

  return FCS_RESULT_SUCCESS;
}
Beispiel #4
0
/**
 * tune method specific parameters depending on the particles
 */
FCSResult fcs_tune(FCS handle, fcs_int local_particles,
  fcs_float *positions, fcs_float *charges)
{
  const char *fnc_name = "fcs_tune";

  CHECK_HANDLE_RETURN_RESULT(handle, fnc_name);

  if (local_particles < 0)
    return fcs_result_create(FCS_ERROR_WRONG_ARGUMENT, fnc_name, 
                             "number of local particles must be non negative");

  if (!fcs_init_check(handle) || !fcs_tune_check(handle))
    return fcs_result_create(FCS_ERROR_MISSING_ELEMENT, fnc_name, 
                             "not all needed data has been inserted into the given handle");

  fcs_set_values_changed(handle, 0);

  if (handle->tune == NULL)
    return fcs_result_create(FCS_ERROR_NOT_IMPLEMENTED, fnc_name, "Tuning solver method '%s' not implemented", fcs_get_method_name(handle));

  return handle->tune(handle, local_particles, positions, charges);
}
Beispiel #5
0
/**
 * tune method specific parameters depending on the particles
 */
FCSResult fcs_tune(FCS handle, fcs_int local_particles,
  fcs_float *positions, fcs_float *charges)
{
  FCSResult result;

  CHECK_HANDLE_RETURN_RESULT(handle, __func__);

  if (local_particles < 0)
    return fcs_result_create(FCS_ERROR_WRONG_ARGUMENT, __func__, "number of local particles must be non negative");

  if (!fcs_init_check(handle) || !fcs_tune_check(handle))
    return fcs_result_create(FCS_ERROR_MISSING_ELEMENT, __func__, "not all needed data has been inserted into the given handle");

  fcs_set_values_changed(handle, 0);

  if (handle->tune == NULL)
    return fcs_result_create(FCS_ERROR_NOT_IMPLEMENTED, __func__, "Tuning solver method '%s' not implemented", fcs_get_method_name(handle));

  fcs_float original_box_origin[3] = { handle->box_origin[0], handle->box_origin[1], handle->box_origin[2] };

  if (handle->shift_positions)
  {
    fcs_shift_positions(local_particles, positions, original_box_origin);
    handle->box_origin[0] = handle->box_origin[1] = handle->box_origin[2] = 0;
  }

  result = handle->tune(handle, local_particles, positions, charges);

  if (handle->shift_positions)
  {
    fcs_unshift_positions(local_particles, positions, original_box_origin);
    handle->box_origin[0] = original_box_origin[0];
    handle->box_origin[1] = original_box_origin[1];
    handle->box_origin[2] = original_box_origin[2];
  }

  return result;
}