Skip to content

Commit

Permalink
Merge pull request espressomd#2360 from RudolfWeeber/lb_test_stability
Browse files Browse the repository at this point in the history
Testsuite: Better averaging in lb test
  • Loading branch information
KaiSzuttor authored and RudolfWeeber committed Nov 8, 2018
1 parent bb48200 commit 6e1bd7a
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions testsuite/python/lb.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ class TestLB(object):
system = espressomd.System(box_l=[1.0, 1.0, 1.0])
n_nodes = system.cell_system.get_state()["n_nodes"]
system.seed = range(n_nodes)
params = {'int_steps': 25,
'int_times': 10,
np.random.seed = 1
params = {'int_steps': 15,
'int_times': 30,
'time_step': 0.01,
'tau': 0.02,
'agrid': 0.5,
Expand Down Expand Up @@ -122,16 +123,20 @@ def test_mass_momentum_thermostat(self):
# Integration
for i in range(self.params['int_times']):
self.system.integrator.run(self.params['int_steps'])
fluidmass_sim = 0.0
fluid_temp_sim = 0.0
node_v_list = []
node_dens_list = []
n_nodes = int(self.params['box_l'] / self.params['agrid'])
for i in range(n_nodes):
for j in range(n_nodes):
for k in range(n_nodes):
node_v_list.append(self.lbf[i, j, k].velocity)
node_dens_list.append(self.lbf[i, j, k].density[0])

# Summation vars
fluid_mass = 0.0
fluid_temp = 0.0

# Go over lb lattice
for lb_node in lb_nodes:
dens = lb_node.density[0]
fluid_mass += dens
fluid_temp += np.sum(lb_node.velocity**2) * dens

# Normalize
fluid_mass /= len(lb_nodes)
fluid_temp *= self.system.volume() / (3. * len(lb_nodes)**2)

# check mass conversation
fluidmass_sim = sum(node_dens_list) / len(node_dens_list)
Expand Down Expand Up @@ -286,7 +291,7 @@ def setUp(self):
@ut.skipIf(
not espressomd.has_features(
["LB_GPU"]) or espressomd.has_features('SHANCHEN'),
"Features not available, skipping test!")
"Features not available, skipping test!")
class TestLBGPU(TestLB, ut.TestCase):

def setUp(self):
Expand Down

0 comments on commit 6e1bd7a

Please sign in to comment.