Skip to content

Commit

Permalink
maintainer: Fix particle coupling in LB benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed May 31, 2023
1 parent e5a97fa commit 442de9f
Showing 1 changed file with 47 additions and 9 deletions.
56 changes: 47 additions & 9 deletions maintainer/benchmarks/lb.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
type=int, default=125, required=False,
help="Number of particles per core")
parser.add_argument("--box_l", action="store",
type=int, default=32, required=False,
help="Number of particles per core")
type=int, default=argparse.SUPPRESS, required=False,
help="Box length (cubic box)")
parser.add_argument("--lb_sites_per_particle", metavar="N_LB", action="store",
type=float, default=28, required=False,
help="Number of LB sites per particle")
Expand All @@ -54,10 +54,15 @@
assert args.volume_fraction > 0, "volume_fraction must be a positive number"
assert args.volume_fraction < np.pi / (3 * np.sqrt(2)), \
"volume_fraction exceeds the physical limit of sphere packing (~0.74)"
assert "box_l" not in args or args.particles_per_core == 0, \
"Argument box_l requires particles_per_core=0"

required_features = ["LENNARD_JONES", "WALBERLA"]
espressomd.assert_features(required_features)

# make simulation deterministic
np.random.seed(42)

# System
#############################################################
system = espressomd.System(box_l=[1, 1, 1])
Expand All @@ -71,12 +76,24 @@

# System parameters
#############################################################
n_proc = system.cell_system.get_state()["n_nodes"]
n_part = n_proc * args.particles_per_core
if n_part == 0:
box_l = args.box_l
agrid = 1.
measurement_steps = 80
else:
# volume of N spheres with radius r: N * (4/3*pi*r^3)
box_l = (n_part * 4. / 3. * np.pi * (lj_sig / 2.)**3
/ args.volume_fraction)**(1. / 3.)
lb_grid = (n_part * args.lb_sites_per_particle)**(1. / 3.)
lb_grid = int(2. * round(lb_grid / 2.))
agrid = box_l / lb_grid
measurement_steps = max(50, int(120**3 / lb_grid**3))
measurement_steps = 40

n_proc = system.cell_system.get_state()['n_nodes']
box_l = args.box_l
lb_grid = box_l
agrid = 1.
measurement_steps = 80
print(f"LB shape: [{lb_grid}, {lb_grid}, {lb_grid}]")
print(f"LB agrid: {agrid:.3f}")

# System
#############################################################
Expand All @@ -88,8 +105,29 @@
system.cell_system.skin = 0.5
system.thermostat.turn_off()

print(f"LB shape: [{lb_grid}, {lb_grid}, {lb_grid}]")
print(f"LB agrid: {agrid:.3f}")
# Interaction setup
#############################################################
system.non_bonded_inter[0, 0].lennard_jones.set_params(
epsilon=lj_eps, sigma=lj_sig, cutoff=lj_cut, shift="auto")

if n_part:
system.part.add(pos=np.random.random((n_part, 3)) * system.box_l)
benchmarks.minimize(system, n_part / 2.)
system.integrator.set_vv()
system.thermostat.set_langevin(kT=1.0, gamma=1.0, seed=42)

# tuning and equilibration
min_skin = 0.2
max_skin = 1.0
print("Tune skin: {:.3f}".format(system.cell_system.tune_skin(
min_skin=min_skin, max_skin=max_skin, tol=0.05, int_steps=100)))
print("Equilibration")
system.integrator.run(500)
print("Tune skin: {:.3f}".format(system.cell_system.tune_skin(
min_skin=min_skin, max_skin=max_skin, tol=0.05, int_steps=100)))
print("Equilibration")
system.integrator.run(500)
system.thermostat.turn_off()

lbf = espressomd.lb.LBFluidWalberla(agrid=agrid, tau=system.time_step,
density=1., kinematic_viscosity=1.,
Expand Down

0 comments on commit 442de9f

Please sign in to comment.