File: MolmecSupport_test.C

package info (click to toggle)
ball 1.5.0%2Bgit20180813.37fc53c-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 239,848 kB
  • sloc: cpp: 326,149; ansic: 4,208; python: 2,303; yacc: 1,778; lex: 1,099; xml: 958; sh: 322; makefile: 93
file content (98 lines) | stat: -rw-r--r-- 3,298 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//

#include <BALL/CONCEPT/classTest.h>

///////////////////////////

#include <BALL/MOLMEC/COMMON/support.h>
#include <BALL/KERNEL/system.h>

#include <set>

///////////////////////////

namespace BALL
{
	template <>
	HashIndex Hash(const std::pair<Atom*, Atom*>& item)
	{
		return Hash(static_cast<LongSize>(reinterpret_cast<PointerSizeUInt>(item.first)) / 2
								+ static_cast<LongSize>(reinterpret_cast<PointerSizeUInt>(item.second)) / 2);
	}
}

START_TEST(class_name)

/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////

using namespace BALL;


System S;
ForceField ff;

ff.options.setVector(PeriodicBoundary::Option::PERIODIC_BOX_LOWER, Vector3(-8.0));
ff.options.setVector(PeriodicBoundary::Option::PERIODIC_BOX_UPPER, Vector3(8.0));
ff.periodic_boundary.enable();
ff.setup(S);

CHECK(calculateNonBondedAtomPairs())
	ForceField::PairVector pair_vector;
	pair_vector.reserve(2000000);
			MolmecSupport::calculateNonBondedAtomPairs
				(pair_vector, ff.getAtoms(), ff.periodic_boundary.getBox(),
				 4.0, true, MolmecSupport::HASH_GRID);

	std::cout << pair_vector.size() << std::endl;
	HashSet<ForceField::PairVector::value_type> pair_set_hash_grid;
	std::copy(pair_vector.begin(), pair_vector.end(), std::inserter(pair_set_hash_grid, pair_set_hash_grid.begin()));
	pair_vector.clear();

	MolmecSupport::calculateNonBondedAtomPairs
		(pair_vector, ff.getAtoms(), ff.periodic_boundary.getBox(),
		 4.0, true, MolmecSupport::BRUTE_FORCE);

	STATUS("first atom handle: " << ff.getAtoms()[0]->getHandle())
	STATUS("last atom handle: " << ff.getAtoms()[ff.getAtoms().size() - 1]->getHandle())

	std::cout << pair_vector.size() << std::endl;
	HashSet<ForceField::PairVector::value_type> pair_set_brute_force;
	std::copy(pair_vector.begin(), pair_vector.end(), std::inserter(pair_set_brute_force, pair_set_brute_force.begin()));
	pair_vector.clear();

	STATUS("# of pairs in hash grid set: " << pair_set_hash_grid.size())
	STATUS("# of pairs in brute force set: " << pair_set_brute_force.size())
	
	pair_set_brute_force -= pair_set_hash_grid;
	
	HashSet<ForceField::PairVector::value_type> union_set = pair_set_hash_grid + pair_set_brute_force;
	STATUS("# of pairs in union: " << union_set.size())

	STATUS("# of missing pairs: " << pair_set_brute_force.size())

	HashSet<ForceField::PairVector::value_type>::ConstIterator it = pair_set_brute_force.begin();
	for (; +it; ++it)
	{
		STATUS("pair: " << it->first->getPosition() << " / " << it->second->getPosition())
		STATUS("missing pair: " << it->first->getHandle() << " - " << it->second->getHandle())
	}
	
	MolmecSupport::calculateNonBondedAtomPairs
		(pair_vector, ff.getAtoms(), ff.periodic_boundary.getBox(),
		 4.0, false, MolmecSupport::HASH_GRID);
	std::cout << pair_vector.size() << std::endl;

	pair_vector.clear();
	MolmecSupport::calculateNonBondedAtomPairs
		(pair_vector, ff.getAtoms(), ff.periodic_boundary.getBox(),
		 4.0, false, MolmecSupport::BRUTE_FORCE);
	std::cout << pair_vector.size() << std::endl;
	std::cout << S.countAtoms() << std::endl;
RESULT											

/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
END_TEST