Exemplo n.º 1
0
int morse_set_params(int part_type_a, int part_type_b,
		     double eps, double alpha,
		     double rmin, double cut, double cap_radius)
{
  double add1, add2;
  IA_parameters *data = get_ia_param_safe(part_type_a, part_type_b);

  if (!data) return ES_ERROR;

  data->MORSE_eps   = eps;
  data->MORSE_alpha = alpha;
  data->MORSE_rmin  = rmin;
  data->MORSE_cut   = cut;

  /* calculate dependent parameter */
  add1 = exp(-2.0*data->MORSE_alpha*(data->MORSE_cut - data->MORSE_rmin));
  add2 = 2.0*exp(-data->MORSE_alpha*(data->MORSE_cut - data->MORSE_rmin));
  data->MORSE_rest = data->MORSE_eps * (add1 - add2); 
 
  if (cap_radius > 0) {
    data->MORSE_capradius = cap_radius;
  }

  /* broadcast interaction parameters */
  mpi_bcast_ia_params(part_type_a, part_type_b);

  mpi_cap_forces(force_cap);

  return ES_OK;
}
Exemplo n.º 2
0
int lennard_jones_set_params(int part_type_a, int part_type_b,
				      double eps, double sig, double cut,
				      double shift, double offset,
				      double cap_radius, double min)
{
  IA_parameters *data = get_ia_param_safe(part_type_a, part_type_b);

  if (!data) return ES_ERROR;

  data->LJ_eps    = eps;
  data->LJ_sig    = sig;
  data->LJ_cut    = cut;
  data->LJ_shift  = shift;
  data->LJ_offset = offset;
  if (cap_radius > 0) {
    data->LJ_capradius = cap_radius;
  }
  if (min > 0) {
    data->LJ_min = min;
  }
  /* broadcast interaction parameters */
  mpi_bcast_ia_params(part_type_a, part_type_b);

  mpi_cap_forces(force_cap);

  return ES_OK;
}
Exemplo n.º 3
0
int ljgen_set_params(int part_type_a, int part_type_b,
			       double eps, double sig, double cut,
			       double shift, double offset,
			       int a1, int a2, double b1, double b2,
			       double cap_radius
#ifdef LJGEN_SOFTCORE
             , double lambda, double softrad
#endif
             )
{
  IA_parameters *data = get_ia_param_safe(part_type_a, part_type_b);

  if (!data) return ES_ERROR;

  data->LJGEN_eps    = eps;
  data->LJGEN_sig    = sig;
  data->LJGEN_cut    = cut;
  data->LJGEN_shift  = shift;
  data->LJGEN_offset = offset;
  data->LJGEN_a1     = a1;
  data->LJGEN_a2     = a2;
  data->LJGEN_b1     = b1;
  data->LJGEN_b2     = b2;
  if (cap_radius > 0) 
    data->LJGEN_capradius = cap_radius;
#ifdef LJGEN_SOFTCORE
  if (lambda >= 0.0 && lambda <= 1.0)
    data->LJGEN_lambda  = lambda;
  if (softrad >=0.0)
    data->LJGEN_softrad = softrad;  
#endif

  /* broadcast interaction parameters */
  mpi_bcast_ia_params(part_type_a, part_type_b);

  mpi_cap_forces(force_cap);

  return ES_OK;
}
Exemplo n.º 4
0
int ljangle_set_params(int part_type_a, int part_type_b,
				double eps, double sig, double cut,
				int b1p, int b1n, int b2p, int b2n,
				double cap_radius, double z0, double dz, 
				double kappa, double epsprime)
{
  IA_parameters *data = get_ia_param_safe(part_type_a, part_type_b);

  if (!data) return ES_ERROR;

  data->LJANGLE_eps         = eps;
  data->LJANGLE_sig         = sig;
  data->LJANGLE_cut         = cut;
  data->LJANGLE_bonded1pos  = b1p;
  data->LJANGLE_bonded1neg  = b1n;
  data->LJANGLE_bonded2pos  = b2p;
  data->LJANGLE_bonded2neg  = b2n;
  
  data->LJANGLE_bonded1type = part_type_a;

  if (cap_radius > 0) {
    data->LJANGLE_capradius = cap_radius;
  }

  if (dz > 0.) {
    data->LJANGLE_z0       = z0;
    data->LJANGLE_dz       = dz;
    data->LJANGLE_kappa    = kappa;
    data->LJANGLE_epsprime = epsprime;
  }

  /* broadcast interaction parameters */
  mpi_bcast_ia_params(part_type_a, part_type_b);

  mpi_cap_forces(force_cap);
    
  return ES_OK;
}
Exemplo n.º 5
0
int buckingham_set_params(int part_type_a, int part_type_b,
                          double A, double B, double C, double D, double cut,
                          double discont, double shift, double cap_radius,
                          double F1, double F2)
{
    IA_parameters *data = get_ia_param_safe(part_type_a, part_type_b);

    if (!data) return ES_ERROR;

    data->BUCK_A       = A;
    data->BUCK_B       = B;
    data->BUCK_C       = C;
    data->BUCK_D       = D;
    data->BUCK_cut     = cut;
    data->BUCK_discont = discont;
    data->BUCK_shift   = shift;
    if (cap_radius > 0.0) {
        data->BUCK_capradius = cap_radius;
    }

    /* Replace the buckingham potential for interatomic dist. less
       than or equal to discontinuity by a straight line (F1+F2*r) */
    F1 = buck_energy_r(A, B, C, D, shift, discont) +
         discont*buck_force_r(A, B, C, D, discont);
    F2 = -buck_force_r(A, B, C, D, discont);

    data->BUCK_F1 = F1;
    data->BUCK_F2 = F2;

    /* broadcast interaction parameters */
    mpi_bcast_ia_params(part_type_a, part_type_b);

    mpi_cap_forces(force_cap);

    return ES_OK;
}
Exemplo n.º 6
0
int ljcos2_set_params(int part_type_a, int part_type_b,
				      double eps, double sig, double offset,
				      double w)
{
  IA_parameters *data = get_ia_param_safe(part_type_a, part_type_b);

  if (!data) return ES_ERROR;

  data->LJCOS2_eps    = eps;
  data->LJCOS2_sig    = sig;
  data->LJCOS2_offset = offset;
  data->LJCOS2_w      = w;

  /* calculate dependent parameters */
  data->LJCOS2_rchange = pow(2,1/6.)*sig;
  data->LJCOS2_cut     = w + data->LJCOS2_rchange;

  /* broadcast interaction parameters */
  mpi_bcast_ia_params(part_type_a, part_type_b);

  mpi_cap_forces(force_cap);

  return ES_OK;
}
Exemplo n.º 7
0
/** set the force cap for the LJ interaction.
    @param ljforcecap the maximal force, 0 to disable, -1 for individual cutoff
    for each of the interactions.
*/
int ljforcecap_set_params(double ljforcecap)
{
  mpi_cap_forces(ljforcecap);
  
  return ES_OK;
}
Exemplo n.º 8
0
int tabulated_set_params(int part_type_a, int part_type_b, char* filename)
{
  IA_parameters *data;
  FILE* fp;
  int npoints;
  double minval, maxval;
  int i, newsize;
  int token;
  double dummr;
  token = 0;

  data = get_ia_param_safe(part_type_a, part_type_b);

  if (!data)
    return 1;

  if (strlen(filename) > MAXLENGTH_TABFILE_NAME-1 )
    return 2;

  /* Open the file containing force and energy tables */
  fp = fopen( filename , "r");
  if ( !fp )
    return 3;

  /* Look for a line starting with # */
  while ( token != EOF) {
    token = fgetc(fp);
    if ( token == '#' ) { break; }
  }
  if ( token == EOF ) {
    fclose(fp);
    return 4;
  }

  /* First read two important parameters we read in the data later*/
  if (fscanf( fp , "%d %lf %lf", &npoints, &minval, &maxval) != 3) return 5;

  // Set the newsize to the same as old size : only changed if a new force table is being added.
  newsize = tabulated_forces.max;

  if ( data->TAB_npoints == 0){
    // A new potential will be added so set the number of points, the startindex and newsize
    data->TAB_npoints    = npoints;
    data->TAB_startindex = tabulated_forces.max;
    newsize += npoints;
  } else {
    // We have existing data for this pair of monomer types check array sizing
    if ( data->TAB_npoints != npoints ) {
      fclose(fp);
      return 6;
    }
  }

  /* Update parameters symmetrically */
  data->TAB_maxval    = maxval;
  data->TAB_minval    = minval;
  strcpy(data->TAB_filename,filename);

  /* Calculate dependent parameters */
  data->TAB_stepsize = (maxval-minval)/(double)(data->TAB_npoints - 1);

  /* Allocate space for new data */
  realloc_doublelist(&tabulated_forces,newsize);
  realloc_doublelist(&tabulated_energies,newsize);

  /* Read in the new force and energy table data */
  for (i =0 ; i < npoints ; i++)
    {
      if (fscanf(fp,"%lf %lf %lf",&dummr,
		 &(tabulated_forces.e[i+data->TAB_startindex]),
		 &(tabulated_energies.e[i+data->TAB_startindex])) != 3) return 5;
    }

  fclose(fp);

  /* broadcast interaction parameters including force and energy tables*/
  mpi_bcast_ia_params(part_type_a, part_type_b);

  mpi_cap_forces(force_cap);
  return 0;
}