Exemplo n.º 1
0
void CanonicalEnsembleTest::UpdateNumMoleculesSequential() {
// remove the ifndef when canonicalensemble can be tested in parallel
#ifndef ENABLE_MPI

	delete _domainDecomposition;
	// will be deleted by tearDown()
	_domainDecomposition = new DomainDecompDummy();

	// the halo is cleared for freshly initialized particle containers.
	ParticleContainer* container = initializeFromFile(ParticleContainerFactory::AdaptiveSubCell, "1clj-regular-12x12x12.inp", 1.0);
	vector<Component>& components(_domain->getComponents());
	CanonicalEnsemble ensemble(container, &components);

	ensemble.updateGlobalVariable(NUM_PARTICLES);
	// has the ensemble counted the right number of particles?
	ASSERT_EQUAL(1728ul, ensemble.N());
	// has the ensemble updated the count of particles per component right?
	ASSERT_EQUAL(1728ul, components[0].getNumMolecules());

	Molecule molecule(1729, 0, 5.5, 5.5, 5.5, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., &components);
	container->addParticle(molecule);

	ensemble.updateGlobalVariable(NUM_PARTICLES);
	// has the ensemble counted the right number of particles?
	ASSERT_EQUAL(1729ul, ensemble.N());
	// has the ensemble updated the count of particles per component right?
	ASSERT_EQUAL(1729ul, components[0].getNumMolecules());

#endif
}
Exemplo n.º 2
0
void CuboidInitializer::initialize(ParticleContainer& container) {
	double x[] = {0,0,0};
	double m = _config.getMaterialConfig().getM();
	double epsilon = _config.getMaterialConfig().getEpsilon();
	double sigma = _config.getMaterialConfig().getSigma();
	LOG4CXX_DEBUG(logger, "SphereInitializer material: m=" << m << " epsilon=" << epsilon << " sigma=" << sigma);

	const utils::Vector<double,3>& v = _config.getV();
	const utils::Vector<int, 3>& n = _config.getN();

	LOG4CXX_DEBUG(logger, "Initializing CUBE at " << _config.getX().toString());

	for (int i = 0; i < n[0]; i++) {
		for (int j = 0; j < n[1]; j++) {
			for (int k = 0; k < n[2]; k++) {
				x[0] = _config.getX()[0] + ((double)i) * _config.getH();
				x[1] = _config.getX()[1] + ((double)j) * _config.getH();
				x[2] = _config.getX()[2] + ((double)k) * _config.getH();
				LOG4CXX_TRACE(logger, "creating (x,y,z): (" << x[i] << "," << x[j] << "," << x[k] << ")");
				Particle p(x, v, m, epsilon, sigma, _type_id);
				//MaxwellBoltzmannDistribution(p, 0.1, dim);
				container.addParticle(p);
			}
		}
	}
}
Exemplo n.º 3
0
void SphereInitializer::initialize(ParticleContainer& container) {
	utils::Vector<double,3> x(0.);
	double m = _config.getMaterialConfig().getM();
	double epsilon = _config.getMaterialConfig().getEpsilon();
	double sigma = _config.getMaterialConfig().getSigma();
	LOG4CXX_DEBUG(logger, "SphereInitializer material: m=" << m << " epsilon=" << epsilon << " sigma=" << sigma);

	int n = _config.getN();
	double h = _config.getH();
	double radius = ((double)n) * h;
	const utils::Vector<double, 3>& center = _config.getX();

	utils::Vector<double,3> radius_vector = radius;
	utils::Vector<double,3> lower_left_front = center - radius_vector;
	int dim = Configuration::getInstance().getDimension();
	LOG4CXX_DEBUG(logger, "SphereINitializer dimension: " << dim );

	bool two_d = (dim == 2);
	if (two_d) {
		lower_left_front[2] = center[2];
	}

	const utils::Vector<double, 3>& v = _config.getV();

	int innerCount = two_d ? 1 : (2*n);
	LOG4CXX_DEBUG(logger, "Initializing SPHERE at " << _config.getX().toString() << " two_d==" << two_d);

	for (int i = 0; i < n*2; i++) {
		for (int j = 0; j < n*2; j++) {
			for (int k = 0; k < innerCount; k++) {
				x[0] = lower_left_front[0] + ((double)i) * h;
				x[1] = lower_left_front[1] + ((double)j) * h;
				x[2] = lower_left_front[2] + ((double)k) * h;
				LOG4CXX_TRACE(logger, "point at " << x.toString() << "has distance " << (x - center).L2Norm() << " and radius is "<< radius);
				if ((x - center).L2Norm() < radius) {
					LOG4CXX_TRACE(logger, "creating (x,y,z): (" << x[0] << "," << x[1] << "," << x[2] << ")");
					Particle p(x, v, m, epsilon, sigma, _type_id);
					//MaxwellBoltzmannDistribution(p, 0.1, dim);
					container.addParticle(p);
				}
			}
		}
	}
}