Ejemplo n.º 1
0
int main(int, char **argv) {
  int retval = 0;

  const int Nx = 20;
  const double R = 1.0, a = 2.0, kT = 1, nval = 0.1;
  const double energy = 2.72225468848892;
  printf("about to create input\n");
  WhiteBear wb(Nx, Nx, Nx);
  wb.R() = R;
  wb.a1() = a;
  wb.a2() = a;
  wb.a3() = a;
  wb.kT() = kT;
  wb.n() = nval;
  retval += check_functional_value("WhiteBear", wb, energy, 2e-11);
  printf("n0 = %g\n", wb.get_n0()[0]);
  printf("n1 = %g\n", wb.get_n1()[0]);
  printf("n2 = %g\n", wb.get_n2()[0]);
  printf("n3 = %g\n", wb.get_n3()[0]);

  for (int i=0;i<Nx*Nx*Nx/2;i++) wb.n()[i] = 0.1*nval;
  //FIXME:  the following test OUGHT to pass, but currently fails.  :(
  //retval += wb.run_finite_difference_test("WhiteBear");

  HomogeneousWhiteBear hwb;
  hwb.R() = R;
  hwb.kT() = kT;
  hwb.n() = nval;
  retval += check_functional_value("HomogeneousWhiteBear", hwb, energy/uipow(a,3), 2e-11);
  printf("n0 = %g\n", hwb.get_n0());
  printf("n1 = %g\n", hwb.get_n1());
  printf("n2 = %g\n", hwb.get_n2());
  printf("n3 = %g\n", hwb.get_n3());

  if (retval == 0) {
    printf("\n%s passes!\n", argv[0]);
  } else {
    printf("\n%s fails %d tests!\n", argv[0], retval);
    return retval;
  }
}
Ejemplo n.º 2
0
int main(int, char **argv) {
  int retval = 0;

  WhiteBear wb(1);
  const int Nx = 100;
  const double R = 1.0, a = 5.0, kT = 1, nval = 0.1;
  const double energy = 42.53522950699669281;
  Vector inp = wb.createInput(Nx, Nx, Nx, R, a, a, a, Vector(Nx*Nx*Nx), kT);
  wb.get_x(inp) = wb.get_x(inp)*0 + nval;
  retval += check_functional_value("WhiteBear", wb, inp, energy);

  if (retval == 0) {
    printf("\n%s passes!\n", argv[0]);
  } else {
    printf("\n%s fails %d tests!\n", argv[0], retval);
    return retval;
  }
}
Ejemplo n.º 3
0
int main(int, char **argv) {
  int retval = 0;

  const int Nx = 100;
  const double a = 10.0, kT = new_water_prop.kT, nval = 1.1*new_water_prop.liquid_density;
  const double energy_density = -9.350583155126999e-05; // from older code
  printf("about to create input\n");
  WaterSaft ws(Nx, Nx, Nx);

  // double lengthscale, liquid_density, critical_density, vapor_density, kT;
  // double epsilon_dispersion, lambda_dispersion, length_scaling, epsilonAB, kappaAB;

  ws.R() = new_water_prop.lengthscale;
  ws.epsilon_association() = new_water_prop.epsilonAB;
  ws.epsilon_dispersion() = new_water_prop.epsilon_dispersion;
  ws.kappa_association() = new_water_prop.kappaAB;
  ws.lambda_dispersion() = new_water_prop.lambda_dispersion;
  ws.length_scaling() = new_water_prop.length_scaling;
  ws.a1() = a;
  ws.a2() = a;
  ws.a3() = a;
  ws.kT() = kT;
  ws.n() = nval;
  retval += check_functional_value("WaterSaft", ws, energy_density*a*a*a, 1e-11);

  WaterSaftByHand wsbh(Nx, Nx, Nx);

  // double lengthscale, liquid_density, critical_density, vapor_density, kT;
  // double epsilon_dispersion, lambda_dispersion, length_scaling, epsilonAB, kappaAB;

  wsbh.R() = new_water_prop.lengthscale;
  wsbh.epsilon_association() = new_water_prop.epsilonAB;
  wsbh.epsilon_dispersion() = new_water_prop.epsilon_dispersion;
  wsbh.kappa_association() = new_water_prop.kappaAB;
  wsbh.lambda_dispersion() = new_water_prop.lambda_dispersion;
  wsbh.length_scaling() = new_water_prop.length_scaling;
  wsbh.a1() = a;
  wsbh.a2() = a;
  wsbh.a3() = a;
  wsbh.kT() = kT;
  wsbh.n() = nval;
  retval += check_functional_value("WaterSaftByHand", wsbh, energy_density*a*a*a, 1e-11);

  HomogeneousWaterSaft hws;
  hws.R() = new_water_prop.lengthscale;
  hws.epsilon_association() = new_water_prop.epsilonAB;
  hws.epsilon_dispersion() = new_water_prop.epsilon_dispersion;
  hws.kappa_association() = new_water_prop.kappaAB;
  hws.lambda_dispersion() = new_water_prop.lambda_dispersion;
  hws.kT() = kT;
  hws.n() = nval;
  retval += check_functional_value("HomogeneousWaterSaft", hws, energy_density);

  HomogeneousWaterSaftByHand hwsbh;
  hwsbh.R() = new_water_prop.lengthscale;
  hwsbh.epsilon_association() = new_water_prop.epsilonAB;
  hwsbh.epsilon_dispersion() = new_water_prop.epsilon_dispersion;
  hwsbh.kappa_association() = new_water_prop.kappaAB;
  hwsbh.lambda_dispersion() = new_water_prop.lambda_dispersion;
  hwsbh.kT() = kT;
  hwsbh.n() = nval;
  retval += check_functional_value("HomogeneousWaterSaftByHand", hwsbh, energy_density);

  if (retval == 0) {
    printf("\n%s passes!\n", argv[0]);
  } else {
    printf("\n%s fails %d tests!\n", argv[0], retval);
    return retval;
  }
}