Skip to content
Permalink
Browse files

Merge #2888

2888: Refactor Python tests r=fweik a=jngrad

Description of changes:
- combined duplicated tests (closes #2874)
- added tests for benchmarks (fixes #2882)
- replaced `@ut.skipIf` for missing features/GPU with dedicated decorators
- removed unused code, reduced code complexity, cleaned up comments

Co-authored-by: Jean-Noël Grad <jgrad@icp.uni-stuttgart.de>
  • Loading branch information...
bors and jngrad committed Jun 8, 2019
2 parents 67655dd + 0da71aa commit 5b88304daccbeb546063c721e522356d5f065ab4
Showing with 2,122 additions and 2,912 deletions.
  1. +8 −4 .gitlab-ci.yml
  2. +4 −4 doc/tutorials/11-ferrofluid/11-ferrofluid_part1.ipynb
  3. +2 −2 doc/tutorials/11-ferrofluid/11-ferrofluid_part2.ipynb
  4. +4 −4 doc/tutorials/11-ferrofluid/11-ferrofluid_part3.ipynb
  5. +8 −2 maintainer/CI/build_cmake.sh
  6. +4 −3 maintainer/benchmarks/lj.py
  7. +4 −2 maintainer/benchmarks/p3m.py
  8. +2 −3 testsuite/python/CMakeLists.txt
  9. +4 −4 testsuite/python/accumulator.py
  10. +21 −22 testsuite/python/analyze_chains.py
  11. +2 −3 testsuite/python/analyze_distance.py
  12. +11 −18 testsuite/python/analyze_distribution.py
  13. +12 −16 testsuite/python/analyze_energy.py
  14. +14 −16 testsuite/python/analyze_gyration_tensor.py
  15. +9 −10 testsuite/python/analyze_itensor.py
  16. +10 −18 testsuite/python/array_properties.py
  17. +2 −3 testsuite/python/auto_exclusions.py
  18. +0 −3 testsuite/python/cellsystem.py
  19. +7 −8 testsuite/python/cluster_analysis.py
  20. +17 −18 testsuite/python/collision_detection.py
  21. +6 −10 testsuite/python/constant_pH.py
  22. +8 −11 testsuite/python/constraint_homogeneous_magnetic_field.py
  23. +89 −139 testsuite/python/constraint_shape_based.py
  24. +2 −5 testsuite/python/correlation.py
  25. +65 −68 testsuite/python/coulomb_cloud_wall.py
  26. +82 −87 testsuite/python/coulomb_cloud_wall_duplicated.py
  27. +49 −51 testsuite/python/coulomb_mixed_periodicity.py
  28. +20 −29 testsuite/python/coulomb_tuning.py
  29. +33 −36 testsuite/python/dawaanr-and-bh-gpu.py
  30. +23 −36 testsuite/python/dawaanr-and-dds-gpu.py
  31. +0 −188 testsuite/python/dds-and-bh-gpu-perf.py
  32. +28 −32 testsuite/python/dds-and-bh-gpu.py
  33. +23 −31 testsuite/python/dipolar_mdlc_p3m_scafacos_p2nfft.py
  34. +1 −5 testsuite/python/domain_decomposition.py
  35. +6 −5 testsuite/python/dpd.py
  36. +78 −60 testsuite/python/drude.py
  37. +44 −53 testsuite/python/ek_charged_plate.py
  38. +16 −16 testsuite/python/ek_eof_one_species_base.py
  39. +2 −0 testsuite/python/ek_eof_one_species_x.py
  40. +2 −0 testsuite/python/ek_eof_one_species_y.py
  41. +2 −0 testsuite/python/ek_eof_one_species_z.py
  42. +28 −36 testsuite/python/ek_fluctuations.py
  43. +21 −10 testsuite/python/elc_vs_mmm2d_neutral.py
  44. +17 −8 testsuite/python/elc_vs_mmm2d_nonneutral.py
  45. +13 −45 testsuite/python/electrostaticInteractions.py
  46. +2 −3 testsuite/python/engine_langevin.py
  47. +83 −75 testsuite/python/engine_lb.py
  48. +0 −126 testsuite/python/engine_lbgpu.py
  49. +21 −23 testsuite/python/exclusions.py
  50. +27 −36 testsuite/python/field_test.py
  51. +4 −9 testsuite/python/force_cap.py
  52. +18 −0 testsuite/python/galilei.py
  53. +4 −7 testsuite/python/gpu_availability.py
  54. +10 −28 testsuite/python/h5md.py
  55. +2 −3 testsuite/python/hat.py
  56. +3 −7 testsuite/python/icc.py
  57. +0 −1 testsuite/python/integrate.py
  58. +2 −3 testsuite/python/interactions_bond_angle.py
  59. +12 −19 testsuite/python/interactions_bonded.py
  60. +6 −10 testsuite/python/interactions_bonded_interface.py
  61. +3 −5 testsuite/python/interactions_dihedral.py
  62. +94 −88 testsuite/python/interactions_non-bonded.py
  63. +14 −17 testsuite/python/interactions_non-bonded_interface.py
  64. +51 −49 testsuite/python/langevin_thermostat.py
  65. +1 −5 testsuite/python/layered.py
  66. +21 −44 testsuite/python/lb.py
  67. +4 −7 testsuite/python/lb_boundary.py
  68. +4 −5 testsuite/python/lb_boundary_velocity.py
  69. +0 −2 testsuite/python/lb_density.py
  70. +3 −4 testsuite/python/lb_electrohydrodynamics.py
  71. +2 −1 testsuite/python/lb_get_u_at_pos.py
  72. +0 −63 testsuite/python/lb_gpu_viscous.py
  73. +10 −12 testsuite/python/lb_interpolation.py
  74. +6 −7 testsuite/python/lb_poiseuille.py
  75. +14 −16 testsuite/python/lb_poiseuille_cylinder.py
  76. +5 −5 testsuite/python/lb_shear.py
  77. +12 −26 testsuite/python/lb_stokes_sphere.py
  78. +3 −6 testsuite/python/lb_streaming.py
  79. +4 −8 testsuite/python/lb_switch.py
  80. +8 −11 testsuite/python/lb_thermo_virtual.py
  81. +6 −5 testsuite/python/lb_thermostat.py
  82. +2 −1 testsuite/python/lbgpu_remove_total_momentum.py
  83. +5 −7 testsuite/python/lj.py
  84. +10 −13 testsuite/python/magnetostaticInteractions.py
  85. +53 −62 testsuite/python/mass-and-rinertia_per_particle.py
  86. +7 −10 testsuite/python/minimize_energy.py
  87. +9 −53 testsuite/python/mmm1d.py
  88. +2 −3 testsuite/python/mpiio.py
  89. +5 −6 testsuite/python/npt.py
  90. +2 −5 testsuite/python/nsquare.py
  91. +20 −32 testsuite/python/observable_cylindrical.py
  92. +29 −36 testsuite/python/observable_cylindricalLB.py
  93. +10 −17 testsuite/python/observable_profile.py
  94. +2 −2 testsuite/python/observable_profileLB.py
  95. +13 −12 testsuite/python/observables.py
  96. +10 −11 testsuite/python/oif_volume_conservation.py
  97. +25 −23 testsuite/python/p3m_electrostatic_pressure.py
  98. +6 −11 testsuite/python/p3m_gpu.py
  99. +11 −15 testsuite/python/pair_criteria.py
  100. +12 −16 testsuite/python/pairs.py
  101. +23 −22 testsuite/python/particle.py
  102. +80 −96 testsuite/python/particle_slice.py
  103. +19 −27 testsuite/python/polymer.py
  104. +2 −3 testsuite/python/random_pairs.py
  105. +3 −3 testsuite/python/rdf.py
  106. +4 −14 testsuite/python/reaction_ensemble.py
  107. +0 −1 testsuite/python/rescale.py
  108. +3 −6 testsuite/python/rigid_bond.py
  109. +11 −15 testsuite/python/rotation_per_particle.py
  110. +74 −71 testsuite/python/rotational-diffusion-aniso.py
  111. +27 −48 testsuite/python/rotational_inertia.py
  112. +11 −15 testsuite/python/scafacos_dipoles_1d_2d.py
  113. +19 −2 testsuite/python/sigint.py
  114. +18 −1 testsuite/python/sigint_child.py
  115. +17 −12 testsuite/python/simple_pore.py
  116. +3 −7 testsuite/python/stress.py
  117. +2 −2 testsuite/python/subt_lj.py
  118. +7 −7 testsuite/python/swimmer_reaction.py
  119. +2 −3 testsuite/python/tabulated.py
  120. +14 −29 testsuite/python/test_checkpoint.py
  121. +26 −81 testsuite/python/tests_common.py
  122. +23 −16 testsuite/python/thermalized_bond.py
  123. +10 −13 testsuite/python/thole.py
  124. +59 −0 testsuite/python/unittest_decorators.py
  125. +0 −107 testsuite/python/variant_conversion.py
  126. +22 −26 testsuite/python/virtual_sites_relative.py
  127. +4 −12 testsuite/python/virtual_sites_tracers.py
  128. +21 −25 testsuite/python/virtual_sites_tracers_common.py
  129. +4 −14 testsuite/python/virtual_sites_tracers_gpu.py
  130. +11 −11 testsuite/python/wang_landau_reaction_ensemble.py
  131. +15 −21 testsuite/python/widom_insertion.py
  132. +4 −7 testsuite/python/writevtf.py
  133. +1 −0 testsuite/scripts/CMakeLists.txt
  134. +24 −0 testsuite/scripts/benchmarks/CMakeLists.txt
  135. +32 −0 testsuite/scripts/benchmarks/test_lj.py
  136. +32 −0 testsuite/scripts/benchmarks/test_p3m.py
@@ -209,7 +209,8 @@ tutorials-samples-maxset:
stage: build
image: gitlab.icp.uni-stuttgart.de:4567/espressomd/docker/cuda:tutorials
script:
- export myconfig=maxset with_coverage=false python_version=3 make_check=false make_check_tutorials=true make_check_samples=true test_timeout=1200
- export myconfig=maxset with_coverage=false python_version=3 make_check=false
- export make_check_tutorials=true make_check_samples=true make_check_benchmarks=true test_timeout=1200
- bash maintainer/CI/build_cmake.sh
tags:
- docker
@@ -221,7 +222,8 @@ tutorials-samples-default:
stage: build
image: gitlab.icp.uni-stuttgart.de:4567/espressomd/docker/cuda:tutorials
script:
- export myconfig=default with_coverage=false python_version=3 make_check=false make_check_tutorials=true make_check_samples=true test_timeout=1200
- export myconfig=default with_coverage=false python_version=3 make_check=false
- export make_check_tutorials=true make_check_samples=true make_check_benchmarks=true test_timeout=1200
- bash maintainer/CI/build_cmake.sh
tags:
- docker
@@ -235,7 +237,8 @@ tutorials-samples-empty:
stage: build
image: gitlab.icp.uni-stuttgart.de:4567/espressomd/docker/cuda:tutorials
script:
- export myconfig=empty with_coverage=false python_version=3 make_check=false make_check_tutorials=true make_check_samples=true test_timeout=1200
- export myconfig=empty with_coverage=false python_version=3 make_check=false
- export make_check_tutorials=true make_check_samples=true make_check_benchmarks=true test_timeout=1200
- bash maintainer/CI/build_cmake.sh
tags:
- docker
@@ -249,7 +252,8 @@ tutorials-samples-no-gpu:
stage: build
image: gitlab.icp.uni-stuttgart.de:4567/espressomd/docker/cuda:tutorials
script:
- export myconfig=maxset with_coverage=false python_version=3 make_check=false make_check_tutorials=true make_check_samples=true test_timeout=1200 hide_gpu=true
- export myconfig=maxset with_coverage=false python_version=3 make_check=false
- export make_check_tutorials=true make_check_samples=true make_check_benchmarks=true test_timeout=1200 hide_gpu=true
- bash maintainer/CI/build_cmake.sh
tags:
- docker
@@ -151,7 +151,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The aim of this tutorial is to introduce the basic features of **ESPResSo** for ferrofluids or dipolar fluids in general. In **part I** and **part II** we will do this for a monolayer-ferrofluid, in **part III** for a three dimensional system. In **part I** we will examine the clusters which are present in all interesting ferrofluid systems. In **part II** we will examine the influence of the dipole-dipole-interaction on the magnetization curve of a ferrofluid. In **part III** we calculate estimatiors for the initial susceptibility using fluctuation formulas and sample the magnetization curve.\n",
"The aim of this tutorial is to introduce the basic features of **ESPResSo** for ferrofluids or dipolar fluids in general. In **part I** and **part II** we will do this for a monolayer-ferrofluid, in **part III** for a three dimensional system. In **part I** we will examine the clusters which are present in all interesting ferrofluid systems. In **part II** we will examine the influence of the dipole-dipole-interaction on the magnetization curve of a ferrofluid. In **part III** we calculate estimators for the initial susceptibility using fluctuation formulas and sample the magnetization curve.\n",
"\n",
"We assume the reader is familiar with the basic concepts of Python and MD simulations."
]
@@ -274,7 +274,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we setting up all simulation parameters. "
"Now we set up all simulation parameters. "
]
},
{
@@ -800,8 +800,8 @@
"metadata": {},
"source": [
"<a id='[1]'></a>[1] Juan J. Cerdà, V. Ballenegger, O. Lenz, and Ch. Holm. *P3M algorithm for dipolar interactions. *Journal of Chemical Physics, 129:234104, 2008. \n",
"<a id='[2]'></a>[2] A. Bródka. “Ewald summation method with electrostatic layer correction for in-\n",
"teractions of point dipoles in slab geometry”. In: Chemical Physics Letters 400.1\n",
"<a id='[2]'></a>[2] A. Bródka. “Ewald summation method with electrostatic layer correction for\n",
"interactions of point dipoles in slab geometry”. In: Chemical Physics Letters 400.1\n",
"(2004), pp. 62–67. issn: 0009-2614. doi: https://doi.org/10.1016/j.cplett.\n",
"2004.10.086. url: http://www.sciencedirect.com/science/article/pii/S0009261404016847."
]
@@ -115,7 +115,7 @@
"Now we set up the system, where we, as we did in **part I**, only commit the orientation of the dipole moment to the particles and take the magnitude into account in the prefactor of Dipolar P3M (for more details see **part I**). \n",
"\n",
"**Hint:**\n",
"It should be noted that we seed both the Langevin thermostat and the random number generator of numpy. Latter means that the initial configuration of our system is the same every time this script will be executed. As the time evolution of the system depends not solely on the Langevin thermostat but also on the numeric accuracy and DP3M as well as DLC (the tuned parameters are slightly different every time) it is only partly predefined. You can change the seeds to simulate with a different initial configuration and a guaranteed different time evolution."
"It should be noted that we seed both the Langevin thermostat and the random number generator of numpy. The latter means that the initial configuration of our system is the same every time this script will be executed. As the time evolution of the system depends not solely on the Langevin thermostat but also on the numeric accuracy and DP3M as well as DLC (the tuned parameters are slightly different every time) it is only partly predefined. You can change the seeds to simulate with a different initial configuration and a guaranteed different time evolution."
]
},
{
@@ -566,7 +566,7 @@
"loops = 500\n",
"\n",
"for alpha in alphas:\n",
" print(\"Sample for alpha = {}\".format(alpha))\n",
" print(\"Sampling for alpha = {}\".format(alpha))\n",
" H_dipm = (alpha*kT)\n",
" H_field = [0,0,H_dipm]\n",
" print(\"Set magnetic field constraint...\")\n",
@@ -85,7 +85,7 @@
" \\chi = \\frac{\\beta\\mu_0}{V} \\left \\lbrack \\frac{1}{Z_c}\\sum_{\\alpha} \\mu_{\\alpha}^2~ e^{ -\\beta E_{\\alpha}(H=0) + \\beta\\mu_0\\mu_{\\boldsymbol{H},\\alpha}H } - \\frac{1}{Z_c}\\sum_{\\alpha} \\mu_{\\alpha}~ e^{ -\\beta E_{\\alpha}(H=0) + \\beta\\mu_0\\mu_{\\boldsymbol{H},\\alpha}H }~~ \\frac{1}{Z_c}\\sum_{\\alpha'}\\mu_{\\alpha'}~ e^{ -\\beta E_{\\alpha'}(H=0) + \\beta\\mu_0\\mu_{\\boldsymbol{H},\\alpha}H }\\right \\rbrack = \\frac{\\beta\\mu_0}{V} \\left \\lbrack \\langle \\mu_{\\boldsymbol{H}}^2 \\rangle - \\langle \\mu_{\\boldsymbol{H}} \\rangle^2 \\right \\rbrack = \\frac{\\beta\\mu_0}{V} \\left(\\Delta \\mu_{\\boldsymbol{H}}\\right)^2\n",
"\\end{equation}\n",
"\n",
"At zero external magentic field ($H = 0$) there is no distinct direction for the system, so we can take the fluctuations $\\Delta \\mu$ in all directions and divide it by the dimension. Thus we can use more data points of our simulation for the average and get a more precise estimatior for the susceptibility. Thus finally the fluctuation formular for the initial susceptibility in three dimensions reads\n",
"At zero external magentic field ($H = 0$) there is no distinct direction for the system, so we can take the fluctuations $\\Delta \\mu$ in all directions and divide it by the dimension. Thus we can use more data points of our simulation for the average and get a more precise estimator for the susceptibility. Thus finally the fluctuation formula for the initial susceptibility in three dimensions reads\n",
"\n",
"\\begin{equation}\n",
" \\chi_{init} = \\frac{\\beta\\mu_0}{3V} \\left \\lbrack \\langle \\boldsymbol{\\mu}^2 \\rangle - \\langle \\boldsymbol{\\mu} \\rangle^2 \\right \\rbrack = \\frac{V\\beta\\mu_0}{3} \\left \\lbrack \\langle \\boldsymbol{M}^2 \\rangle - \\langle \\boldsymbol{M} \\rangle^2 \\right \\rbrack\n",
@@ -2813,14 +2813,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Copared with the value $\\chi = 0.822 \\pm 0.017$ of Ref. <a href='#[1]'>[1]</a> (see table 1) it should be very similar."
"Compared with the value $\\chi = 0.822 \\pm 0.017$ of Ref. <a href='#[1]'>[1]</a> (see table 1) it should be very similar."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we want to compare the result with the theoretically expectations.\n",
"Now we want to compare the result with the theoretical expectations.\n",
"At first with the simple Langevin susceptibility"
]
},
@@ -3034,7 +3034,7 @@
" \\frac{\\partial M^*}{\\partial \\alpha} = \\frac{1}{M_{sat}}\\frac{\\partial M}{\\partial \\left( \\frac{\\mu_0\\mu}{k_BT} H\\right)} = \\frac{k_BT~V}{\\mu_0\\mu^2N}\\frac{\\partial M}{\\partial H} = \\frac{k_BT~V}{\\mu_0\\mu^2N}~\\chi\n",
"\\end{equation}\n",
"\n",
"we have to scale our calculated initial susceptibilit $\\chi_{init}$ by a factor to get it in our dimensionless units.\n",
"we have to scale our calculated initial susceptibility $\\chi_{init}$ by a factor to get it in our dimensionless units.\n",
"\n",
"Now we plot the resulting curves together with our simulation results and the linear approximation"
]
@@ -60,14 +60,15 @@ function end {
[ -z "$check_skip_long" ] && check_skip_long="false"
[ -z "$make_check_tutorials" ] && make_check_tutorials="false"
[ -z "$make_check_samples" ] && make_check_samples="false"
[ -z "$make_check_benchmarks" ] && make_check_benchmarks="false"
[ -z "$python_version" ] && python_version="2"
[ -z "$with_cuda" ] && with_cuda="true"
[ -z "$build_type" ] && build_type="Debug"
[ -z "$with_ccache" ] && with_ccache="false"
[ -z "$test_timeout" ] && test_timeout="300"
[ -z "$hide_gpu" ] && hide_gpu="false"

if [ $make_check ] || [ $make_check_tutorials ] || [ $make_check_samples ]; then
if [ $make_check ] || [ $make_check_tutorials ] || [ $make_check_samples ] || [ $make_check_benchmarks ]; then
run_checks="true"
fi

@@ -114,7 +115,7 @@ elif [ -z "$builddir" ]; then
fi

outp insource srcdir builddir \
make_check make_check_tutorials make_check_samples \
make_check make_check_tutorials make_check_samples make_check_benchmarks \
cmake_params with_fftw \
with_python_interface with_coverage \
with_ubsan with_asan \
@@ -293,6 +294,11 @@ if $run_checks; then
make -j${build_procs} check_samples $make_params || exit 1
fi

# benchmark tests
if $make_check_benchmarks; then
make -j${build_procs} check_benchmarks $make_params || exit 1
fi

# installation tests
make check_cmake_install $make_params || exit 1

@@ -45,6 +45,7 @@
n_proc = int(os.environ.get("OMPI_COMM_WORLD_SIZE", 1))
n_part = n_proc * args.particles_per_core
measurement_steps = int(np.round(5e6 / args.particles_per_core, -2))
n_iterations = 30
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)"
@@ -127,9 +128,9 @@
print()
system.integrator.set_vv()

system.thermostat.set_langevin(kT=1.0, gamma=1.0)
system.thermostat.set_langevin(kT=1.0, gamma=1.0, seed=42)

# tune skin
# tuning and equilibration
print("Tune skin: {}".format(system.cell_system.tune_skin(
min_skin=0.2, max_skin=1, tol=0.05, int_steps=100)))
system.integrator.run(min(5 * measurement_steps, 60000))
@@ -148,7 +149,7 @@
print("Timing every {} steps".format(measurement_steps))
main_tick = time()
all_t = []
for i in range(30):
for i in range(n_iterations):
tick = time()
system.integrator.run(measurement_steps)
tock = time()
@@ -48,6 +48,7 @@
n_proc = int(os.environ.get("OMPI_COMM_WORLD_SIZE", 1))
n_part = n_proc * args.particles_per_core
measurement_steps = int(np.round(5e5 / args.particles_per_core, -1))
n_iterations = 30
assert args.bjerrum_length > 0, "bjerrum_length must be a positive number"
assert args.volume_fraction > 0, "volume_fraction must be a positive number"
assert args.volume_fraction < np.pi / (3 * np.sqrt(2)), \
@@ -146,8 +147,9 @@


system.integrator.set_vv()
system.thermostat.set_langevin(kT=1.0, gamma=1.0)
system.thermostat.set_langevin(kT=1.0, gamma=1.0, seed=42)

# tuning and equilibration
system.integrator.run(min(3 * measurement_steps, 1000))
print("Tune skin: {}".format(system.cell_system.tune_skin(
min_skin=0.4, max_skin=1.6, tol=0.05, int_steps=100)))
@@ -169,7 +171,7 @@
print("Timing every {} steps".format(measurement_steps))
main_tick = time()
all_t = []
for i in range(30):
for i in range(n_iterations):
tick = time()
system.integrator.run(measurement_steps)
tock = time()
@@ -88,8 +88,7 @@ python_test(FILE dawaanr-and-bh-gpu.py MAX_NUM_PROC 1 LABELS gpu)
python_test(FILE dds-and-bh-gpu.py MAX_NUM_PROC 4 LABELS gpu)
python_test(FILE electrostaticInteractions.py MAX_NUM_PROC 2)
python_test(FILE engine_langevin.py MAX_NUM_PROC 4)
python_test(FILE engine_lb.py MAX_NUM_PROC 2)
python_test(FILE engine_lbgpu.py MAX_NUM_PROC 2 LABELS gpu)
python_test(FILE engine_lb.py MAX_NUM_PROC 2 LABELS gpu)
python_test(FILE icc.py MAX_NUM_PROC 4)
python_test(FILE magnetostaticInteractions.py MAX_NUM_PROC 1)
python_test(FILE mass-and-rinertia_per_particle.py MAX_NUM_PROC 2)
@@ -136,7 +135,6 @@ python_test(FILE minimize_energy.py MAX_NUM_PROC 4)
python_test(FILE mmm1d.py MAX_NUM_PROC 4)
python_test(FILE dipolar_mdlc_p3m_scafacos_p2nfft.py MAX_NUM_PROC 1 LABELS long)
python_test(FILE lb.py MAX_NUM_PROC 2 LABELS gpu)
python_test(FILE lb_gpu_viscous.py MAX_NUM_PROC 2 LABELS gpu)
python_test(FILE force_cap.py MAX_NUM_PROC 2)
python_test(FILE dpd.py MAX_NUM_PROC 4)
python_test(FILE hat.py MAX_NUM_PROC 4)
@@ -207,6 +205,7 @@ endif(PY_H5PY)
add_custom_target(python_test_data
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_CURRENT_BINARY_DIR}/data
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/tests_common.py ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/unittest_decorators.py ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/virtual_sites_tracers_common.py ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/ek_common.py ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/ek_eof_one_species_base.py ${CMAKE_CURRENT_BINARY_DIR}
@@ -58,11 +58,11 @@ def test_accumulator(self):
self.system.integrator.run(1)
self.assertEqual(self.pos_obs, self.pos_obs_acc.get_params()['obs'])
np.testing.assert_allclose(
self.pos_obs_acc.get_mean(), np.mean(
self.positions, axis=0), atol=1e-4)
self.pos_obs_acc.get_mean(),
np.mean(self.positions, axis=0), atol=1e-4)
np.testing.assert_allclose(
self.pos_obs_acc.get_variance(), np.var(
self.positions, axis=0, ddof=1), atol=1e-4)
self.pos_obs_acc.get_variance(),
np.var(self.positions, axis=0, ddof=1), atol=1e-4)


if __name__ == "__main__":
@@ -15,15 +15,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import sys
import unittest as ut
import unittest_decorators as utx
import numpy as np
import espressomd
from espressomd.interactions import FeneBond
from espressomd import polymer


@ut.skipIf(not espressomd.has_features("LENNARD_JONES"), "Skipped because LENNARD_JONES turned off.")
@utx.skipIfMissingFeatures("LENNARD_JONES")
class AnalyzeChain(ut.TestCase):
system = espressomd.System(box_l=[1.0, 1.0, 1.0])
np.random.seed(1234)
@@ -33,34 +33,34 @@ class AnalyzeChain(ut.TestCase):
num_mono = 5

@classmethod
def setUpClass(self):
def setUpClass(cls):
box_l = 20.0
# start with a small bo
self.system.box_l = np.array([box_l, box_l, box_l])
self.system.cell_system.set_n_square(use_verlet_lists=False)
# start with a small box
cls.system.box_l = np.array([box_l, box_l, box_l])
cls.system.cell_system.set_n_square(use_verlet_lists=False)
fene = FeneBond(k=30, d_r_max=2)
self.system.bonded_inter.add(fene)
positions = polymer.positions(n_polymers=self.num_poly,
cls.system.bonded_inter.add(fene)
positions = polymer.positions(n_polymers=cls.num_poly,
bond_length=0.9,
beads_per_chain=self.num_mono,
beads_per_chain=cls.num_mono,
seed=42)
for p in positions:
for ndx, m in enumerate(p):
part_id = len(self.system.part)
self.system.part.add(id=part_id, pos=m)
part_id = len(cls.system.part)
cls.system.part.add(id=part_id, pos=m)
if ndx > 0:
self.system.part[part_id].add_bond((fene, part_id - 1))
cls.system.part[part_id].add_bond((fene, part_id - 1))
# bring two polymers to opposite corners:
# far in centre cell, but mirror images are close
# far in cell centre, but mirror images are close
head_id = 0
tail_id = head_id + self.num_mono
cm = np.mean(self.system.part[head_id:tail_id].pos, axis=0)
self.system.part[head_id:tail_id].pos = self.system.part[
head_id:tail_id].pos - cm + self.system.box_l
head_id = self.num_mono + 1
tail_id = head_id + self.num_mono
cm = np.mean(self.system.part[head_id:tail_id].pos, axis=0)
self.system.part[head_id:tail_id].pos -= cm
tail_id = head_id + cls.num_mono
cm = np.mean(cls.system.part[head_id:tail_id].pos, axis=0)
cls.system.part[head_id:tail_id].pos = cls.system.part[
head_id:tail_id].pos - cm + cls.system.box_l
head_id = cls.num_mono + 1
tail_id = head_id + cls.num_mono
cm = np.mean(cls.system.part[head_id:tail_id].pos, axis=0)
cls.system.part[head_id:tail_id].pos -= cm

# python version of the espresso core function,
# does not check mirror distances
@@ -130,5 +130,4 @@ def test_radii(self):
self.system.part[:].pos = old_pos

if __name__ == "__main__":
print("Features: ", espressomd.features())
ut.main()
@@ -15,15 +15,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import sys
import unittest as ut
import unittest_decorators as utx
import numpy as np
import espressomd

BOX_L = 50.


@ut.skipIf(not espressomd.has_features("LENNARD_JONES"), "Skipped because LENNARD_JONES turned off.")
@utx.skipIfMissingFeatures("LENNARD_JONES")
class AnalyzeDistance(ut.TestCase):
system = espressomd.System(box_l=3 * [BOX_L])
system.seed = system.cell_system.get_state()['n_nodes'] * [1234]
@@ -115,5 +115,4 @@ def test_dist_to_id(self):
self.dist_to_id(i))

if __name__ == "__main__":
print("Features: ", espressomd.features())
ut.main()

0 comments on commit 5b88304

Please sign in to comment.
You can’t perform that action at this time.