Exemplo n.º 1
0
void Setup(){
	int i;
	int LCount = 0;
	FILE * fp;
    
    fp = fopen("LJParas.dat", "r");

    if (fp == NULL) 
    {
    fprintf(stderr, "Can't open input file!\n");
    exit(1);
    }
    
	Delta.x = Size.x / (Pts.x - 1.0);
	Delta.y = Size.y / (Pts.y - 1.0);
	Delta.z = Size.z / (Pts.z - 1.0);
	
	
	

//	Beta = 1.0 / (Kb * Na * Temperature);

    Beta = 1.0 / (Kb * Temperature);

	
	AllocMem(ThermWaveLength, NumAtomType, real);
	
	AllocMem(Atom, NumAtomType, struct PropertyAtom);
	
	while (1){
	if (feof (fp)) break;
    fscanf(fp, "%lf %lf %lf %lf %lf\n", &(Atom[LCount].mass), &(Atom[LCount].charge), &(Atom[LCount].sigma), &(Atom[LCount].epslion), &(Atom[LCount].density)); 
    if(AtomType==LJ)
		Atom[LCount].miu = P2(Atom[LCount].sigma, Atom[LCount].epslion, Atom[LCount].density,"Chemical potential");		
	else if(AtomType==HS)
	    Atom[LCount].miu = P1(Atom[LCount].sigma, Atom[LCount].density);
    ++ LCount;
	}

	for(i=0;i<NumAtomType;i++){
//		ThermWaveLength[i] = sqrt(Beta * Sqr(h) / (2.0 * M_PI * Atom[i].mass));
        ThermWaveLength[i] = 1.0;
		}
	if(AtomType==LJ){
		Radius = 0.5 *  Atom[0].sigma * (1.0+0.2977*Temperature) / (1.0+0.33163*Temperature+0.0010477*Sqr(Temperature));
	}		
	else if(AtomType==HS){
	    Radius = 0.5 *  Atom[0].sigma;
	}
	       
	AllocMem(Vext, VProd(Pts), real);	
	AllocMem(Density, VProd(Pts), real);
	
	SetVext();
	SetInitialDensity();
	Set_FFT();
	
	printf ("Setting the calculation is done\n ");	
	return;
	}
Exemplo n.º 2
0
Arquivo: pr_08_1.c Projeto: qnu/mdoch
void SetParams ()
{
  sitesMol = 4;
  VSCopy (region, 1. / pow (density, 1./3.), initUcell);
  nMol = VProd (initUcell);
  velMag = sqrt (NDIM * (1. - 1. / nMol) * temperature);
}
Exemplo n.º 3
0
void SetParams ()
{
    rCut = pow (2., 1./6.);
    VSCopy (region, 1. / sqrt (density), initUcell);
    nMol = VProd (initUcell);
    velMag = sqrt (NDIM * (1. - 1. / nMol) * temperature);
}
Exemplo n.º 4
0
Arquivo: pr_08_1.c Projeto: qnu/mdoch
void EvalRdf ()
{
  VecR dr, shift;
  real deltaR, normFac, rr;
  int j1, j2, k, m1, m2, ms1, ms2, n, rdfType, typeSum;

  if (countRdf == 0) {
    for (k = 0; k < 3; k ++) {
      for (n = 0; n < sizeHistRdf; n ++) histRdf[k][n] = 0.;
    }
  }
  deltaR = rangeRdf / sizeHistRdf;
  for (m1 = 0; m1 < nMol - 1; m1 ++) {
    for (m2 = m1 + 1; m2 < nMol; m2 ++) {
      VSub (dr, mol[m1].r, mol[m2].r);
      VZero (shift);
      VShiftAll (dr);
      VVAdd (dr, shift);
      rr = VLenSq (dr);
      if (rr < Sqr (rangeRdf)) {
        ms1 = m1 * sitesMol;
        ms2 = m2 * sitesMol;
        for (j1 = 0; j1 < sitesMol; j1 ++) {
          for (j2 = 0; j2 < sitesMol; j2 ++) {
            typeSum = mSite[j1].typeRdf + mSite[j2].typeRdf;
            if (typeSum >= 2) {
              VSub (dr, site[ms1 + j1].r, site[ms2 + j2].r);
              VVAdd (dr, shift);
              rr = VLenSq (dr);
              if (rr < Sqr (rangeRdf)) {
                n = sqrt (rr) / deltaR;
                if (typeSum == 2) rdfType = 0;
                else if (typeSum == 3) rdfType = 1;
                else rdfType = 2;
                ++ histRdf[rdfType][n];
              }
            }
          }
        }
      }
    }
  }
  ++ countRdf;
  if (countRdf == limitRdf) {
    normFac = VProd (region) / (2. * M_PI * Cube (deltaR) *
       Sqr (nMol) * countRdf);
    for (k = 0; k < 3; k ++) {
      for (n = 0; n < sizeHistRdf; n ++)
         histRdf[k][n] *= normFac / Sqr (n - 0.5);
    }
    PrintRdf (stdout);
    countRdf = 0;
  }
}
Exemplo n.º 5
0
Arquivo: pr_13_1.c Projeto: qnu/mdoch
void EvalRdf ()
{
  VecR dr;
  real deltaR, normFac, rr, sr1, sr2, ss;
  int j1, j2, k, n;

  if (countRdf == 0) {
    for (k = 0; k < 3; k ++) {
      for (n = 0; n < sizeHistRdf; n ++) histRdf[k][n] = 0.;
    }
  }
  deltaR = rangeRdf / sizeHistRdf;
  for (j1 = 0; j1 < nMol - 1; j1 ++) {
    for (j2 = j1 + 1; j2 < nMol; j2 ++) {
      VSub (dr, mol[j1].r, mol[j2].r);
      VWrapAll (dr);
      rr = VLenSq (dr);
      if (rr < Sqr (rangeRdf)) {
        ss = VDot (mol[j1].s, mol[j2].s);
        sr1 = VDot (mol[j1].s, dr);
        sr2 = VDot (mol[j2].s, dr);
        n = sqrt (rr) / deltaR;
        ++ histRdf[0][n];
        histRdf[1][n] += ss;
        histRdf[2][n] += 3. * sr1 * sr2 / rr - ss;
      }
    }
  }
  ++ countRdf;
  if (countRdf == limitRdf) {
    normFac = VProd (region) / (2. * M_PI * Cube (deltaR) *
       Sqr (nMol) * countRdf);
    for (k = 0; k < 3; k ++) {
      for (n = 0; n < sizeHistRdf; n ++)
         histRdf[k][n] *= normFac / Sqr (n - 0.5);
    }
    PrintRdf (stdout);
    countRdf = 0;
  }
}