Description: Update esp++ spce tutorial to python3
 Cherry-pick upstream commit 613916e to update the last remaining Python 2
 script.
Origin: https://github.com/votca/votca/commit/613916ee15edbcde44ee6b30d9a42031d3a7e219
Bug: https://github.com/votca/votca/issues/969
Last-Update: 2022-10-15
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
Index: votca/csg-tutorials/CMakeLists.txt
===================================================================
--- votca.orig/csg-tutorials/CMakeLists.txt
+++ votca/csg-tutorials/CMakeLists.txt
@@ -34,6 +34,8 @@ if(ENABLE_REGRESSION_TESTING)
   endif()
   find_package(ESPRESSO)
   set_package_properties(ESPRESSO PROPERTIES TYPE OPTIONAL PURPOSE "ESPResSo MD python module needed to run ESPResSo MD regression tests")
+  find_package(ESPRESSOPP)
+  set_package_properties(ESPRESSOPP PROPERTIES TYPE OPTIONAL PURPOSE "ESPResSo++ MD python module needed to run ESPResSo++ MD regression tests")
   find_package(CMA)
   set_package_properties(CMA PROPERTIES TYPE OPTIONAL PURPOSE "CMA python module needed to run CMA regression tests")
   find_package(Gnuplot)
@@ -66,7 +68,7 @@ if(ENABLE_REGRESSION_TESTING)
   get_target_property(VOTCA_CSG_DEFAULTS VOTCA::csg_inverse VOTCA_CSG_DEFAULTS)
   file(GLOB_RECURSE FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} settings.xml)
   foreach(DIR ${FILES})
-    if(DIR MATCHES "(espressopp|dlpoly|hoomd|atomistic|single_chain)")
+    if(DIR MATCHES "(dlpoly|hoomd|atomistic|single_chain)")
       continue()
     elseif(DIR MATCHES "gromacs-(multi|remd)")
       if(NOT MDRUN_MPI_FOUND OR NOT MPIEXEC OR NOT GROMACS_FOUND)
@@ -82,6 +84,10 @@ if(ENABLE_REGRESSION_TESTING)
       if(NOT ESPRESSO_FOUND)
         continue()
       endif()
+    elseif(DIR MATCHES "espressopp/")
+      if(NOT ESPRESSOPP_FOUND)
+        continue()
+      endif()
     elseif(DIR MATCHES "cma/")
       if(NOT CMA_FOUND OR NOT Gnuplot_FOUND OR NOT GROMACS_FOUND)
         continue()
Index: votca/csg-tutorials/CMakeModules/FindESPRESSOPP.cmake
===================================================================
--- /dev/null
+++ votca/csg-tutorials/CMakeModules/FindESPRESSOPP.cmake
@@ -0,0 +1,36 @@
+# - this module looks for ESPRESSOPP
+#
+# Once done this will define
+#
+#  ESPRESSO_FOUND      - system has espressomd
+#
+# Copyright 2009-2022 The VOTCA Development Team (http://www.votca.org)
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+find_package(Python COMPONENTS Interpreter)
+
+set(IMPORT_ESPRESSOPP_SUCCESS FALSE)
+if(Python_EXECUTABLE)
+  execute_process(COMMAND ${Python_EXECUTABLE} -c "import espressopp"
+    RESULT_VARIABLE IMPORT_ESPRESSOPP)
+  if(IMPORT_ESPRESSOPP EQUAL 0)
+    set(IMPORT_ESPRESSOPP_SUCCESS TRUE)
+  endif()
+endif()
+
+# handle the QUIETLY and REQUIRED arguments and set LMP_FOUND to TRUE if
+# all listed variables are TRUE
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(ESPRESSOPP DEFAULT_MSG IMPORT_ESPRESSOPP_SUCCESS)
Index: votca/csg-tutorials/spce/ibi_espressopp/spce.py
===================================================================
--- votca.orig/csg-tutorials/spce/ibi_espressopp/spce.py
+++ votca/csg-tutorials/spce/ibi_espressopp/spce.py
@@ -1,13 +1,15 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
 
 # DON'T RUN THIS MANUALLY
 # RUN "csg_inverse --options settings.xml" instead
 
 import sys
-import espresso
+import espressopp
 import mpi4py.MPI as MPI
-
-from espresso.tools import decomp
+from espressopp import Real3D
+from espressopp.tools import gromacs
+from espressopp.tools import decomp
+#from espressopp.tools import timers
 
 '''
 2180 Particles
@@ -21,10 +23,16 @@ rc   = 0.9
 skin = 0.3
 timestep = 0.002
 
-x, y, z, Lx, Ly, Lz = espresso.tools.convert.gromacs.read('conf.gro')
+grofile = "conf.gro"
+#topfile = "topol.top"
+
+# this calls the gromacs parser for processing the top file (and included files) and the conf file
+# The variables at the beginning defaults, types, etc... can be found by calling
+# gromacs.read(grofile,topfile) without return values. It then prints out the variables to be unpacked
+x, y, z, resname, resid, Lx, Ly, Lz =gromacs.read(grofile)
 num_particles = len(x)
 
-print 'number of particles: ', num_particles
+print('number of particles: ', num_particles)
 
 ######################################################################
 
@@ -32,69 +40,75 @@ print 'number of particles: ', num_parti
 sys.stdout.write('Setting up simulation ...\n')
 density = num_particles / (Lx * Ly * Lz)
 box = (Lx, Ly, Lz)
-system = espresso.System()
-system.rng = espresso.esutil.RNG()
-system.bc = espresso.bc.OrthorhombicBC(system.rng, box)
+system = espressopp.System()
+system.rng = espressopp.esutil.RNG()
+system.bc = espressopp.bc.OrthorhombicBC(system.rng, box)
 system.skin = skin
 
 comm = MPI.COMM_WORLD
-nodeGrid = decomp.nodeGrid(comm.size)
+nodeGrid = decomp.nodeGrid(comm.size,box, rc, skin)
 cellGrid = decomp.cellGrid(box, nodeGrid, rc, skin)
 
-system.storage = espresso.storage.DomainDecomposition(system, nodeGrid, cellGrid)
+system.storage = espressopp.storage.DomainDecomposition(system, nodeGrid, cellGrid)
 
 ######################################################################
 
 # adding particles
-props = ['id', 'type', 'pos', 'v', 'mass']
+props = ['id', 'pos', 'v', 'type', 'mass']#, 'q']
 new_particles = []
 mass = 1.0
 type = 0
 for pid in range(num_particles):
-  pos  = espresso.Real3D(x[pid],y[pid],z[pid])
-  vel  = espresso.Real3D(0,0,0)
-  part = [pid, type, pos, vel, mass]
-  new_particles.append(part)
-  
+    part = [pid + 1, Real3D(x[pid], y[pid], z[pid]),
+           Real3D(.0,.0,.0), type, mass]
+           #Real3D(vx[pid], vy[pid], vz[pid]), types[pid], masses[pid], charges[pid]]
+    new_particles.append(part)
+
 system.storage.addParticles(new_particles, *props)
 system.storage.decompose()
 
 ##########################################################################################
 
 # interaction
-vl = espresso.VerletList(system, cutoff=rc)
-tabP = espresso.interaction.Tabulated(itype=1, filename='CG_CG.tab', cutoff=rc)
-tabI = espresso.interaction.VerletListTabulated(vl)
+vl = espressopp.VerletList(system, cutoff=rc)
+tabP = espressopp.interaction.Tabulated(itype=1, filename='CG_CG.tab', cutoff=rc)
+tabI = espressopp.interaction.VerletListTabulated(vl)
 tabI.setPotential(type1=0, type2=0, potential=tabP)
 system.addInteraction(tabI)
 
 ##########################################################################################
 
 # integrator
-integrator = espresso.integrator.VelocityVerlet(system)
+integrator = espressopp.integrator.VelocityVerlet(system)
 integrator.dt = timestep
 
 # thermostat
-lT = espresso.integrator.LangevinThermostat(system)
+lT = espressopp.integrator.LangevinThermostat(system)
 lT.gamma = 5.0
 lT.temperature = 2.5
 integrator.addExtension(lT)
 
+# set system properties
+int_steps = 900
+eq_steps = 100
+steps_per_int = 100
+
 ##########################################################################################
 
-print "equilibrating ..."
-for step in range(100):
-  integrator.run(100)
-  espresso.tools.info(system, integrator)
-
-print "runing ..."
-
-espresso.tools.info(system, integrator)
-for step in range(900):
-  integrator.run(100)
-  espresso.tools.info(system, integrator)
-  print 'writing .xyz trajectory...'
+print("equilibrating ...")
+espressopp.tools.analyse.info(system, integrator)
+for step in range(eq_steps):
+  integrator.run(steps_per_int)
+  espressopp.tools.analyse.info(system, integrator)
+
+print("runing ...")
+
+espressopp.tools.analyse.info(system, integrator)
+for step in range(int_steps):
+  integrator.run(steps_per_int)
+  espressopp.tools.analyse.info(system, integrator)
+  print('writing .xyz trajectory...')
   # we are simulating in nm, but xyz files are in angstroms! -> scale= 10.0
-  espresso.tools.DumpConfigurations.fastwritexyz('traj.xyz', system, unfolded = False, append = True, velocities = False, scale = 10.0)
-  
-print "finished"
+  espressopp.tools.fastwritexyz('traj.xyz', system, velocities = False, unfolded = False, append = True, scale = 10.0)
+
+print("finished")
