#!/usr/bin/env python

import mirheo as mir

dt = 0.001

ranks  = (1, 1, 1)
domain = (8, 16, 8)
force = (1.0, 0, 0)

density = 4

u = mir.Mirheo(ranks, domain, dt, debug_level=3, log_filename='log', no_splash=True)

pv = mir.ParticleVectors.ParticleVector('pv', mass = 1)
ic = mir.InitialConditions.Uniform(number_density=density)
u.registerParticleVector(pv=pv, ic=ic)
    
dpd = mir.Interactions.Pairwise('dpd', rc=1.0, kind="DPD", a=10.0, gamma=50.0, kBT=1.0, power=0.5)
u.registerInteraction(dpd)

plate_lo = mir.Walls.Plane("plate_lo", (0, 0, -1), (0, 0,              1))
plate_hi = mir.Walls.Plane("plate_hi", (0, 0,  1), (0, 0,  domain[2] - 1))
u.registerWall(plate_lo, 0)
u.registerWall(plate_hi, 0)

vv = mir.Integrators.VelocityVerlet("vv")
frozen = u.makeFrozenWallParticles(pvName="plates", walls=[plate_lo, plate_hi], interactions=[dpd], integrator=vv, number_density=density)

u.setWall(plate_lo, pv)
u.setWall(plate_hi, pv)


for p in (pv, frozen):
    u.setInteraction(dpd, p, pv)

vv_dp = mir.Integrators.VelocityVerlet_withConstForce("vv_dp", force)
u.registerIntegrator(vv_dp)
u.setIntegrator(vv_dp, pv)


sample_every = 2
dump_every   = 1000
bin_size     = (1., 1., 0.5)

u.registerPlugins(mir.Plugins.createDumpAverage('field', [pv], sample_every, dump_every, bin_size, ["velocities"], 'h5/solvent-'))

u.run(7002)

# nTEST: walls.analytic.plates
# cd walls/analytic
# rm -rf h5
# mir.run --runargs "-n 2" ./plates.py
# mir.avgh5 xy velocities h5/solvent-0000[4-7].h5 | awk '{print $1}' > profile.out.txt

[((13, 4, 13, 84), 'mirheo.Mirheo', 'mir.Mirheo', (), '', True, 'import mirheo as mir\n'), ((15, 5, 15, 55), 'mirheo.ParticleVectors.ParticleVector', 'mir.ParticleVectors.ParticleVector', (), '', True, 'import mirheo as mir\n'), ((16, 5, 16, 58), 'mirheo.InitialConditions.Uniform', 'mir.InitialConditions.Uniform', (), '', True, 'import mirheo as mir\n'), ((19, 6, 19, 98), 'mirheo.Interactions.Pairwise', 'mir.Interactions.Pairwise', (), '', True, 'import mirheo as mir\n'), ((22, 11, 22, 74), 'mirheo.Walls.Plane', 'mir.Walls.Plane', ({(22, 27, 22, 37): '"""plate_lo"""', (22, 39, 22, 49): '(0, 0, -1)', (22, 51, 22, 73): '(0, 0, 1)'}, {}), "('plate_lo', (0, 0, -1), (0, 0, 1))", True, 'import mirheo as mir\n'), ((23, 11, 23, 74), 'mirheo.Walls.Plane', 'mir.Walls.Plane', ({(23, 27, 23, 37): '"""plate_hi"""', (23, 39, 23, 49): '(0, 0, 1)', (23, 51, 23, 73): '(0, 0, domain[2] - 1)'}, {}), "('plate_hi', (0, 0, 1), (0, 0, domain[2] - 1))", True, 'import mirheo as mir\n'), ((27, 5, 27, 41), 'mirheo.Integrators.VelocityVerlet', 'mir.Integrators.VelocityVerlet', ({(27, 36, 27, 40): '"""vv"""'}, {}), "('vv')", True, 'import mirheo as mir\n'), ((37, 8, 37, 69), 'mirheo.Integrators.VelocityVerlet_withConstForce', 'mir.Integrators.VelocityVerlet_withConstForce', ({(37, 54, 37, 61): '"""vv_dp"""', (37, 63, 37, 68): 'force'}, {}), "('vv_dp', force)", True, 'import mirheo as mir\n'), ((46, 18, 46, 129), 'mirheo.Plugins.createDumpAverage', 'mir.Plugins.createDumpAverage', ({(46, 48, 46, 55): '"""field"""', (46, 57, 46, 61): '[pv]', (46, 63, 46, 75): 'sample_every', (46, 77, 46, 87): 'dump_every', (46, 89, 46, 97): 'bin_size', (46, 99, 46, 113): "['velocities']", (46, 115, 46, 128): '"""h5/solvent-"""'}, {}), "('field', [pv], sample_every, dump_every,\n    bin_size, ['velocities'], 'h5/solvent-')", True, 'import mirheo as mir\n')]