#!/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

[((134, 219), 'mirheo.Mirheo', 'mir.Mirheo', (['ranks', 'domain', 'dt'], {'debug_level': '(3)', 'log_filename': '"""log"""', 'no_splash': '(True)'}), "(ranks, domain, dt, debug_level=3, log_filename='log', no_splash=True\n    )\n", (144, 219), True, 'import mirheo as mir\n'), ((221, 269), 'mirheo.ParticleVectors.ParticleVector', 'mir.ParticleVectors.ParticleVector', (['"""pv"""'], {'mass': '(1)'}), "('pv', mass=1)\n", (255, 269), True, 'import mirheo as mir\n'), ((277, 330), 'mirheo.InitialConditions.Uniform', 'mir.InitialConditions.Uniform', ([], {'number_density': 'density'}), '(number_density=density)\n', (306, 330), True, 'import mirheo as mir\n'), ((381, 477), 'mirheo.Interactions.Pairwise', 'mir.Interactions.Pairwise', (['"""dpd"""'], {'rc': '(1.0)', 'kind': '"""DPD"""', 'a': '(10.0)', 'gamma': '(50.0)', 'kBT': '(1.0)', 'power': '(0.5)'}), "('dpd', rc=1.0, kind='DPD', a=10.0, gamma=50.0,\n    kBT=1.0, power=0.5)\n", (406, 477), True, 'import mirheo as mir\n'), ((513, 563), 'mirheo.Walls.Plane', 'mir.Walls.Plane', (['"""plate_lo"""', '(0, 0, -1)', '(0, 0, 1)'], {}), "('plate_lo', (0, 0, -1), (0, 0, 1))\n", (528, 563), True, 'import mirheo as mir\n'), ((588, 649), 'mirheo.Walls.Plane', 'mir.Walls.Plane', (['"""plate_hi"""', '(0, 0, 1)', '(0, 0, domain[2] - 1)'], {}), "('plate_hi', (0, 0, 1), (0, 0, domain[2] - 1))\n", (603, 649), True, 'import mirheo as mir\n'), ((714, 750), 'mirheo.Integrators.VelocityVerlet', 'mir.Integrators.VelocityVerlet', (['"""vv"""'], {}), "('vv')\n", (744, 750), True, 'import mirheo as mir\n'), ((1006, 1067), 'mirheo.Integrators.VelocityVerlet_withConstForce', 'mir.Integrators.VelocityVerlet_withConstForce', (['"""vv_dp"""', 'force'], {}), "('vv_dp', force)\n", (1051, 1067), True, 'import mirheo as mir\n'), ((1210, 1325), 'mirheo.Plugins.createDumpAverage', 'mir.Plugins.createDumpAverage', (['"""field"""', '[pv]', 'sample_every', 'dump_every', 'bin_size', "['velocities']", '"""h5/solvent-"""'], {}), "('field', [pv], sample_every, dump_every,\n    bin_size, ['velocities'], 'h5/solvent-')\n", (1239, 1325), True, 'import mirheo as mir\n')]