diff --git a/doc/sphinx/installation.rst b/doc/sphinx/installation.rst index c94796004ef..6641da052f6 100644 --- a/doc/sphinx/installation.rst +++ b/doc/sphinx/installation.rst @@ -491,13 +491,9 @@ using a CMake flag (see :ref:`Options and Variables`). - ``GSL`` Enables features relying on the GNU Scientific Library, e.g. :meth:`espressomd.cluster_analysis.Cluster.fractal_dimension`. -- ``STOKESIAN_DYNAMICS`` Enables the Stokesian Dynamics feature for CPU +- ``STOKESIAN_DYNAMICS`` Enables the Stokesian Dynamics feature (see :ref:`Stokesian Dynamics`). Requires BLAS and LAPACK. -- ``STOKESIAN_DYNAMICS_GPU`` Enables the Stokesian Dynamics feature for GPU - (see :ref:`Stokesian Dynamics`). Requires thrust/cuBLAS/cuSolver. - Requires ``EXPERIMENTAL_FEATURES``. - .. _Configuring: diff --git a/samples/dancing.py b/samples/dancing.py index 67c0b5390b9..7429784c9e9 100644 --- a/samples/dancing.py +++ b/samples/dancing.py @@ -31,24 +31,10 @@ parser = argparse.ArgumentParser(epilog=__doc__) group = parser.add_mutually_exclusive_group() -group.add_argument('--cpu', action='store_true', help='Use CPU implementation') -group.add_argument('--gpu', action='store_true', help='Use GPU implementation') -group = parser.add_mutually_exclusive_group() group.add_argument('--ft', action='store_true', help='Use FT approximation') group.add_argument('--fts', action='store_true', help='Use FTS approximation') args = parser.parse_args() -required_features = ["STOKESIAN_DYNAMICS"] - -if args.gpu: - print("Using GPU implementation") - required_features.append("CUDA") - required_features.append("STOKESIAN_DYNAMICS_GPU") - sd_device = "gpu" -else: - print("Using CPU implementation") - sd_device = "cpu" - if args.ft: print("Using FT approximation method") sd_method = "ft" @@ -56,7 +42,7 @@ print("Using FTS approximation method") sd_method = "fts" -espressomd.assert_features(required_features) +espressomd.assert_features("STOKESIAN_DYNAMICS") system = espressomd.System(box_l=[10, 10, 10]) system.time_step = 1.5 @@ -64,8 +50,7 @@ system.periodicity = [False, False, False] system.integrator.set_stokesian_dynamics( - viscosity=1.0, radii={0: 1.0}, device=sd_device, - approximation_method=sd_method) + viscosity=1.0, radii={0: 1.0}, approximation_method=sd_method) system.part.add(pos=[-5, 0, 0], rotation=[1, 1, 1]) system.part.add(pos=[0, 0, 0], rotation=[1, 1, 1]) @@ -94,8 +79,7 @@ plt.plot(data[:, i], data[:, i + 1], linestyle='dashed') plt.title("Trajectory of sedimenting spheres\nsolid line: simulation " - "({} on {}), dashed line: paper (FTS)" - .format(sd_method.upper(), sd_device.upper())) + "({}), dashed line: paper (FTS)".format(sd_method.upper())) plt.xlabel("x") plt.ylabel("y") plt.show() diff --git a/src/config/features.def b/src/config/features.def index a18167fafa2..d3dd8e4c5db 100644 --- a/src/config/features.def +++ b/src/config/features.def @@ -26,10 +26,6 @@ ENGINE implies ROTATION, EXTERNAL_FORCES PARTICLE_ANISOTROPY implies ROTATION STOKESIAN_DYNAMICS requires BLAS and LAPACK STOKESIAN_DYNAMICS implies ROTATION -# Needs cuBLAS, which is expected to be included with CUDA -STOKESIAN_DYNAMICS_GPU requires CUDA -STOKESIAN_DYNAMICS_GPU implies ROTATION -STOKESIAN_DYNAMICS_GPU requires EXPERIMENTAL_FEATURES /* Rotation */ ROTATION @@ -111,4 +107,3 @@ GSL external BLAS external LAPACK external STOKESIAN_DYNAMICS external -STOKESIAN_DYNAMICS_GPU external diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 6e04e7906bc..f56d4b158de 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -108,12 +108,7 @@ if(WITH_UNIT_TESTS) add_subdirectory(unit_tests) endif(WITH_UNIT_TESTS) -if(STOKESIAN_DYNAMICS OR STOKESIAN_DYNAMICS_GPU) +if(STOKESIAN_DYNAMICS) add_subdirectory(stokesian_dynamics) - if(STOKESIAN_DYNAMICS) - target_link_libraries(EspressoCore PRIVATE StokesianDynamics::sd_cpu) - endif() - if(STOKESIAN_DYNAMICS_GPU) - target_link_libraries(EspressoCore PRIVATE StokesianDynamics::sd_gpu) - endif() + target_link_libraries(EspressoCore PRIVATE StokesianDynamics::sd_cpu) endif() diff --git a/src/core/stokesian_dynamics/sd_interface.cpp b/src/core/stokesian_dynamics/sd_interface.cpp index 28859312beb..e5f9dce9b5a 100644 --- a/src/core/stokesian_dynamics/sd_interface.cpp +++ b/src/core/stokesian_dynamics/sd_interface.cpp @@ -19,14 +19,8 @@ #include "sd_interface.hpp" -#if defined(STOKESIAN_DYNAMICS) || defined(STOKESIAN_DYNAMICS_GPU) #ifdef STOKESIAN_DYNAMICS #include "stokesian_dynamics/sd_cpu.hpp" -#endif - -#ifdef STOKESIAN_DYNAMICS_GPU -#include "stokesian_dynamics/sd_gpu.hpp" -#endif #include "thermostat.hpp" @@ -37,6 +31,7 @@ #include #include +#include #include namespace { @@ -63,8 +58,6 @@ struct SD_particle_data { double sd_viscosity = -1.0; -enum { CPU, GPU, INVALID } device = INVALID; - std::unordered_map radius_dict; double sd_kT = 0.0; @@ -118,35 +111,6 @@ void set_sd_viscosity(double eta) { double get_sd_viscosity() { return sd_viscosity; } -void set_sd_device(std::string const &dev) { -#ifdef STOKESIAN_DYNAMICS - if (dev == "cpu") { - device = CPU; - return; - } -#endif -#ifdef STOKESIAN_DYNAMICS_GPU - if (dev == "gpu") { - device = GPU; - - return; - } -#endif - - throw std::runtime_error("Invalid device " + dev); -} - -std::string get_sd_device() { - switch (device) { - case CPU: - return "cpu"; - case GPU: - return "gpu"; - default: - return "invalid"; - } -} - void set_sd_radius_dict(std::unordered_map const &x) { /* Check that radii are positive */ for (auto const &kv : x) { @@ -224,27 +188,10 @@ void propagate_vel_pos_sd(const ParticleRange &particles, ++i; } - switch (device) { -#ifdef STOKESIAN_DYNAMICS - case CPU: - v_sd = sd_cpu(x_host, f_host, a_host, n_part, sd_viscosity, - std::sqrt(sd_kT / time_step), - static_cast(stokesian.rng_counter()), - static_cast(stokesian.rng_seed()), sd_flags); - break; -#endif - -#ifdef STOKESIAN_DYNAMICS_GPU - case GPU: - v_sd = sd_gpu(x_host, f_host, a_host, n_part, sd_viscosity, - std::sqrt(sd_kT / time_step), - static_cast(stokesian.rng_counter()), - static_cast(stokesian.rng_seed()), sd_flags); - break; -#endif - default: - throw std::runtime_error("Stokesian dynamics device not set."); - } + v_sd = sd_cpu(x_host, f_host, a_host, n_part, sd_viscosity, + std::sqrt(sd_kT / time_step), + static_cast(stokesian.rng_counter()), + static_cast(stokesian.rng_seed()), sd_flags); } else { // if (this_node == 0) v_sd.resize(particles.size() * 6); } // if (this_node == 0) {...} else diff --git a/src/core/stokesian_dynamics/sd_interface.hpp b/src/core/stokesian_dynamics/sd_interface.hpp index 241ed5265b9..01219147538 100644 --- a/src/core/stokesian_dynamics/sd_interface.hpp +++ b/src/core/stokesian_dynamics/sd_interface.hpp @@ -32,15 +32,11 @@ #include -#include #include void set_sd_viscosity(double eta); double get_sd_viscosity(); -void set_sd_device(std::string const &dev); -std::string get_sd_device(); - void set_sd_radius_dict(std::unordered_map const &x); std::unordered_map get_sd_radius_dict(); diff --git a/src/core/thermostat.cpp b/src/core/thermostat.cpp index d6e67d7905c..3641cda0912 100644 --- a/src/core/thermostat.cpp +++ b/src/core/thermostat.cpp @@ -74,7 +74,7 @@ ThermalizedBondThermostat thermalized_bond = {}; #ifdef DPD DPDThermostat dpd = {}; #endif -#if defined(STOKESIAN_DYNAMICS) || defined(STOKESIAN_DYNAMICS_GPU) +#ifdef STOKESIAN_DYNAMICS StokesianThermostat stokesian = {}; #endif @@ -85,7 +85,7 @@ REGISTER_THERMOSTAT_CALLBACKS(thermalized_bond) #ifdef DPD REGISTER_THERMOSTAT_CALLBACKS(dpd) #endif -#if defined(STOKESIAN_DYNAMICS) || defined(STOKESIAN_DYNAMICS_GPU) +#ifdef STOKESIAN_DYNAMICS REGISTER_THERMOSTAT_CALLBACKS(stokesian) #endif @@ -133,7 +133,7 @@ void philox_counter_increment() { dpd.rng_increment(); } #endif -#if defined(STOKESIAN_DYNAMICS) || defined(STOKESIAN_DYNAMICS_GPU) +#ifdef STOKESIAN_DYNAMICS if (thermo_switch & THERMO_SD) { stokesian.rng_increment(); } diff --git a/src/core/thermostat.hpp b/src/core/thermostat.hpp index e36fed17224..a594fd3e519 100644 --- a/src/core/thermostat.hpp +++ b/src/core/thermostat.hpp @@ -316,7 +316,7 @@ struct ThermalizedBondThermostat : public BaseThermostat {}; struct DPDThermostat : public BaseThermostat {}; #endif -#if defined(STOKESIAN_DYNAMICS) || defined(STOKESIAN_DYNAMICS_GPU) +#ifdef STOKESIAN_DYNAMICS /** %Thermostat for Stokesian dynamics. */ struct StokesianThermostat : public BaseThermostat { StokesianThermostat() { rng_initialize(0); } @@ -343,7 +343,7 @@ NEW_THERMOSTAT(thermalized_bond) #ifdef DPD NEW_THERMOSTAT(dpd) #endif -#if defined(STOKESIAN_DYNAMICS) || defined(STOKESIAN_DYNAMICS_GPU) +#ifdef STOKESIAN_DYNAMICS NEW_THERMOSTAT(stokesian) #endif @@ -355,7 +355,7 @@ extern ThermalizedBondThermostat thermalized_bond; #ifdef DPD extern DPDThermostat dpd; #endif -#if defined(STOKESIAN_DYNAMICS) || defined(STOKESIAN_DYNAMICS_GPU) +#ifdef STOKESIAN_DYNAMICS extern StokesianThermostat stokesian; #endif diff --git a/src/python/espressomd/integrate.pxd b/src/python/espressomd/integrate.pxd index 041d81de518..56fca0c0a3c 100644 --- a/src/python/espressomd/integrate.pxd +++ b/src/python/espressomd/integrate.pxd @@ -43,20 +43,17 @@ IF NPT: cbool zdir_rescale, cbool cubic_box) cdef extern from "stokesian_dynamics/sd_interface.hpp": - IF(STOKESIAN_DYNAMICS or STOKESIAN_DYNAMICS_GPU): + IF STOKESIAN_DYNAMICS: void set_sd_viscosity(double eta) double get_sd_viscosity() - void set_sd_device(const string & dev) - string get_sd_device() - void set_sd_radius_dict(const unordered_map[int, double] & radius_dict) unordered_map[int, double] get_sd_radius_dict() void set_sd_flags(int flg) int get_sd_flags() -IF(STOKESIAN_DYNAMICS or STOKESIAN_DYNAMICS_GPU): +IF STOKESIAN_DYNAMICS: cpdef enum flags: NONE = 0, SELF_MOBILITY = 1 << 0, diff --git a/src/python/espressomd/integrate.pyx b/src/python/espressomd/integrate.pyx index c9dc41c8aca..ee81b500d0e 100644 --- a/src/python/espressomd/integrate.pyx +++ b/src/python/espressomd/integrate.pyx @@ -406,7 +406,7 @@ cdef class BrownianDynamics(Integrator): integrate_set_bd() -IF(STOKESIAN_DYNAMICS or STOKESIAN_DYNAMICS_GPU): +IF STOKESIAN_DYNAMICS: cdef class StokesianDynamics(Integrator): """ Stokesian Dynamics integrator. @@ -417,8 +417,6 @@ IF(STOKESIAN_DYNAMICS or STOKESIAN_DYNAMICS_GPU): Bulk viscosity. radii : :obj:`dict` Dictionary that maps particle types to radii. - device : :obj:`str`, optional, \{'cpu', 'gpu'\} - Device to execute on. approximation_method : :obj:`str`, optional, \{'ft', 'fts'\} Chooses the method of the mobility approximation. ``'fts'`` is more accurate. Default is ``'fts'``. @@ -432,20 +430,15 @@ IF(STOKESIAN_DYNAMICS or STOKESIAN_DYNAMICS_GPU): """ def default_params(self): - IF STOKESIAN_DYNAMICS: - sd_device_str = "cpu" - ELIF STOKESIAN_DYNAMICS_GPU: - sd_device_str = "gpu" return {"lubrication": False, "approximation_method": "fts", - "self_mobility": True, "pair_mobility": True, - "device": sd_device_str} + "self_mobility": True, "pair_mobility": True} def valid_keys(self): """All parameters that can be set. """ - return {"radii", "viscosity", "device", "lubrication", - "approximation_method", "self_mobility", "pair_mobility"} + return {"radii", "viscosity", "lubrication", "approximation_method", + "self_mobility", "pair_mobility"} def required_keys(self): """Parameters that have to be set. @@ -457,9 +450,6 @@ IF(STOKESIAN_DYNAMICS or STOKESIAN_DYNAMICS_GPU): check_type_or_throw_except( self._params["viscosity"], 1, float, "viscosity must be a number") - check_type_or_throw_except( - self._params["device"], 1, str, - "device must be a string") check_type_or_throw_except( self._params["radii"], 1, dict, "radii must be a dictionary") @@ -486,7 +476,6 @@ IF(STOKESIAN_DYNAMICS or STOKESIAN_DYNAMICS_GPU): def _set_params_in_es_core(self): integrate_set_sd() set_sd_radius_dict(self._params["radii"]) - set_sd_device(to_char_pointer(self._params["device"].lower())) set_sd_viscosity(self._params["viscosity"]) fl = flags.NONE if self._params["lubrication"]: diff --git a/src/python/espressomd/thermostat.pxd b/src/python/espressomd/thermostat.pxd index fb083f621ff..7a049e161fd 100644 --- a/src/python/espressomd/thermostat.pxd +++ b/src/python/espressomd/thermostat.pxd @@ -61,7 +61,7 @@ cdef extern from "thermostat.hpp": IF DPD: cdef cppclass DPDThermostat(BaseThermostat): pass - IF(STOKESIAN_DYNAMICS or STOKESIAN_DYNAMICS_GPU): + IF STOKESIAN_DYNAMICS: cdef cppclass StokesianThermostat(BaseThermostat): pass @@ -71,7 +71,7 @@ cdef extern from "thermostat.hpp": ThermalizedBondThermostat thermalized_bond IF DPD: DPDThermostat dpd - IF(STOKESIAN_DYNAMICS or STOKESIAN_DYNAMICS_GPU): + IF STOKESIAN_DYNAMICS: StokesianThermostat stokesian void langevin_set_rng_seed(stdint.uint32_t seed) @@ -79,7 +79,7 @@ cdef extern from "thermostat.hpp": void npt_iso_set_rng_seed(stdint.uint32_t seed) IF DPD: void dpd_set_rng_seed(stdint.uint32_t seed) - IF(STOKESIAN_DYNAMICS or STOKESIAN_DYNAMICS_GPU): + IF STOKESIAN_DYNAMICS: void stokesian_set_rng_seed(stdint.uint32_t seed) void langevin_set_rng_counter(stdint.uint64_t counter) @@ -87,11 +87,11 @@ cdef extern from "thermostat.hpp": void npt_iso_set_rng_counter(stdint.uint64_t counter) IF DPD: void dpd_set_rng_counter(stdint.uint64_t counter) - IF(STOKESIAN_DYNAMICS or STOKESIAN_DYNAMICS_GPU): + IF STOKESIAN_DYNAMICS: void stokesian_set_rng_counter(stdint.uint64_t counter) cdef extern from "stokesian_dynamics/sd_interface.hpp": - IF(STOKESIAN_DYNAMICS or STOKESIAN_DYNAMICS_GPU): + IF STOKESIAN_DYNAMICS: void set_sd_kT(double kT) double get_sd_kT() diff --git a/src/python/espressomd/thermostat.pyx b/src/python/espressomd/thermostat.pyx index db44ba26337..cc281bc52a6 100644 --- a/src/python/espressomd/thermostat.pyx +++ b/src/python/espressomd/thermostat.pyx @@ -738,8 +738,7 @@ cdef class Thermostat: """ Sets the SD thermostat with required parameters. - This thermostat requires the feature ``STOKESIAN_DYNAMICS`` or - ``STOKESIAN_DYNAMICS_GPU``. + This thermostat requires the feature ``STOKESIAN_DYNAMICS``. Parameters ---------- diff --git a/testsuite/python/CMakeLists.txt b/testsuite/python/CMakeLists.txt index 79632f74897..fa1cc07505c 100644 --- a/testsuite/python/CMakeLists.txt +++ b/testsuite/python/CMakeLists.txt @@ -61,7 +61,7 @@ endfunction(PYTHON_TEST) # Separate features with hyphens, use a period to add an optional flag. foreach( TEST_COMBINATION - lb.cpu-p3m.cpu-lj-therm.lb;lb.gpu-p3m.cpu-lj-therm.lb;ek.gpu;lb.off-therm.npt-int.npt;lb.off-int.sd;lb.off-therm.langevin-int.nvt;lb.off-therm.dpd-int.nvt;lb.off-therm.bd-int.bd;lb.off-therm.sdm-int.sdm.cpu + lb.cpu-p3m.cpu-lj-therm.lb;lb.gpu-p3m.cpu-lj-therm.lb;ek.gpu;lb.off-therm.npt-int.npt;lb.off-int.sd;lb.off-therm.langevin-int.nvt;lb.off-therm.dpd-int.nvt;lb.off-therm.bd-int.bd;lb.off-therm.sdm-int.sdm ) if(${TEST_COMBINATION} MATCHES "\\.gpu") set(TEST_LABELS "gpu") @@ -212,7 +212,7 @@ python_test(FILE time_series.py MAX_NUM_PROC 1) python_test(FILE linear_momentum.py MAX_NUM_PROC 4) python_test(FILE linear_momentum_lb.py MAX_NUM_PROC 2 LABELS gpu) python_test(FILE mmm1d.py MAX_NUM_PROC 2 LABELS gpu) -python_test(FILE stokesian_dynamics_cpu.py MAX_NUM_PROC 2) +python_test(FILE stokesian_dynamics.py MAX_NUM_PROC 2) python_test(FILE elc.py MAX_NUM_PROC 2) python_test(FILE elc_vs_analytic.py MAX_NUM_PROC 2) python_test(FILE rotation.py MAX_NUM_PROC 1) diff --git a/testsuite/python/save_checkpoint.py b/testsuite/python/save_checkpoint.py index 828999e66c8..2cd67d44be6 100644 --- a/testsuite/python/save_checkpoint.py +++ b/testsuite/python/save_checkpoint.py @@ -157,7 +157,7 @@ system.thermostat.set_npt(kT=1.0, gamma0=2.0, gammav=0.1, seed=42) elif 'THERM.DPD' in modes and has_features('DPD'): system.thermostat.set_dpd(kT=1.0, seed=42) - elif 'THERM.SDM' in modes and (has_features('STOKESIAN_DYNAMICS') or has_features('STOKESIAN_DYNAMICS_GPU')): + elif 'THERM.SDM' in modes and has_features('STOKESIAN_DYNAMICS'): system.periodicity = [0, 0, 0] system.thermostat.set_stokesian(kT=1.0, seed=42) # set integrator @@ -171,16 +171,11 @@ system.integrator.set_nvt() elif 'INT.BD' in modes: system.integrator.set_brownian_dynamics() - elif 'INT.SDM.CPU' in modes and has_features('STOKESIAN_DYNAMICS'): + elif 'INT.SDM' in modes and has_features('STOKESIAN_DYNAMICS'): system.periodicity = [0, 0, 0] system.integrator.set_stokesian_dynamics( - approximation_method='ft', device='cpu', viscosity=0.5, - radii={0: 1.5}, pair_mobility=False, self_mobility=True) - elif 'INT.SDM.GPU' in modes and has_features('STOKESIAN_DYNAMICS_GPU') and espressomd.gpu_available(): - system.periodicity = [0, 0, 0] - system.integrator.set_stokesian_dynamics( - approximation_method='fts', device='gpu', viscosity=2.0, - radii={0: 1.0}, pair_mobility=True, self_mobility=False) + approximation_method='ft', viscosity=0.5, radii={0: 1.5}, + pair_mobility=False, self_mobility=True) if espressomd.has_features(['VIRTUAL_SITES', 'VIRTUAL_SITES_RELATIVE']): system.virtual_sites = espressomd.virtual_sites.VirtualSitesRelative( diff --git a/testsuite/python/stokesian_dynamics.py b/testsuite/python/stokesian_dynamics.py index 3f710126421..454b3f22af8 100644 --- a/testsuite/python/stokesian_dynamics.py +++ b/testsuite/python/stokesian_dynamics.py @@ -22,43 +22,39 @@ import espressomd.constraints import numpy as np import unittest as ut +import unittest_decorators as utx from tests_common import abspath s = espressomd.System(box_l=[1.0, 1.0, 1.0]) +@utx.skipIfMissingFeatures(["STOKESIAN_DYNAMICS"]) class StokesianDynamicsSetupTest(ut.TestCase): system = s - device = 'none' - def setUp(self): + def test_pbc_checks(self): self.system.box_l = [10] * 3 self.system.time_step = 1.0 self.system.cell_system.skin = 0.4 - - # unset SD integrator so we can test whether set_stokesian_dynamics() - # fails. set_nvt() is the only way to ensure that integ_switch is - # set to a different value than INTEG_METHOD_SD self.system.integrator.set_nvt() - def pbc_checks(self): self.system.periodicity = [0, 0, 1] with self.assertRaises(Exception): self.system.integrator.set_stokesian_dynamics( - viscosity=1.0, device=self.device, radii={0: 1.0}) + viscosity=1.0, radii={0: 1.0}) self.system.periodicity = [0, 0, 0] self.system.integrator.set_stokesian_dynamics( - viscosity=1.0, device=self.device, radii={0: 1.0}) + viscosity=1.0, radii={0: 1.0}) with self.assertRaises(Exception): self.system.periodicity = [0, 1, 0] +@utx.skipIfMissingFeatures(["STOKESIAN_DYNAMICS"]) class StokesianDynamicsTest(ut.TestCase): system = s - device = 'none' # Digitized reference data of Figure 5b from # Durlofsky et al., J. Fluid Mech. 180, 21 (1987) @@ -70,6 +66,10 @@ def setUp(self): self.system.periodicity = [0, 0, 0] self.system.cell_system.skin = 0.4 + def tearDown(self): + self.system.constraints.clear() + self.system.part.clear() + def falling_spheres(self, time_step, l_factor, t_factor, sd_method='fts', sd_short=False): self.system.time_step = time_step @@ -79,8 +79,7 @@ def falling_spheres(self, time_step, l_factor, t_factor, self.system.integrator.set_stokesian_dynamics( viscosity=1.0 / (t_factor * l_factor), - device=self.device, radii={0: 1.0 * l_factor}, - approximation_method=sd_method) + radii={0: 1.0 * l_factor}, approximation_method=sd_method) gravity = espressomd.constraints.Gravity( g=[0, -1.0 * l_factor / (t_factor**2), 0]) @@ -122,14 +121,22 @@ def falling_spheres(self, time_step, l_factor, t_factor, self.assertLess(idx, intsteps, msg='Insufficient sampling') np.testing.assert_allclose(dist, 0, rtol=0, atol=0.5 * l_factor) - def tearDown(self): - self.system.constraints.clear() - self.system.part.clear() + def test_default(self): + self.falling_spheres(1.0, 1.0, 1.0) + + def test_rescaled(self): + self.falling_spheres(1.0, 4.5, 2.5) + + def test_different_time_step(self): + self.falling_spheres(0.7, 1.0, 1.0) + def test_default_ft(self): + self.falling_spheres(1.0, 1.0, 1.0, 'ft') + +@utx.skipIfMissingFeatures(["STOKESIAN_DYNAMICS"]) class StokesianDiffusionTest(ut.TestCase): system = s - device = 'none' kT = 1e-4 R = 1.5 @@ -144,9 +151,14 @@ def setUp(self): self.system.part.add(pos=[0, 0, 0], rotation=[1, 1, 1]) - def check(self): + def tearDown(self): + self.system.constraints.clear() + self.system.part.clear() + self.system.thermostat.set_stokesian(kT=0) + + def test(self): self.system.integrator.set_stokesian_dynamics( - viscosity=self.eta, device=self.device, radii={0: self.R}) + viscosity=self.eta, radii={0: self.R}) self.system.thermostat.set_stokesian(kT=self.kT, seed=42) intsteps = int(100000 / self.system.time_step) @@ -197,7 +209,6 @@ def check(self): Dr_measured, delta=Dr_expected * 0.1) - def tearDown(self): - self.system.constraints.clear() - self.system.part.clear() - self.system.thermostat.set_stokesian(kT=0) + +if __name__ == '__main__': + ut.main() diff --git a/testsuite/python/stokesian_dynamics_cpu.py b/testsuite/python/stokesian_dynamics_cpu.py deleted file mode 100644 index 4959da98631..00000000000 --- a/testsuite/python/stokesian_dynamics_cpu.py +++ /dev/null @@ -1,58 +0,0 @@ -# -# Copyright (C) 2019-2020 The ESPResSo project -# -# This file is part of ESPResSo. -# -# ESPResSo is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# ESPResSo is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -import unittest as ut -import unittest_decorators as utx -import stokesian_dynamics as sd - - -@utx.skipIfMissingFeatures(["STOKESIAN_DYNAMICS"]) -class StokesianDynamicsSetupTest(sd.StokesianDynamicsSetupTest): - device = 'cpu' - - def test_pbc_checks(self): - self.pbc_checks() - - -@utx.skipIfMissingFeatures(["STOKESIAN_DYNAMICS"]) -class StokesianDynamicsTest(sd.StokesianDynamicsTest): - device = 'cpu' - - def test_default(self): - self.falling_spheres(1.0, 1.0, 1.0) - - def test_rescaled(self): - self.falling_spheres(1.0, 4.5, 2.5) - - def test_different_time_step(self): - self.falling_spheres(0.7, 1.0, 1.0) - - def test_default_ft(self): - self.falling_spheres(1.0, 1.0, 1.0, 'ft') - - -@utx.skipIfMissingFeatures(["STOKESIAN_DYNAMICS"]) -class StokesianDiffusionTest(sd.StokesianDiffusionTest): - device = 'cpu' - - def test(self): - self.check() - - -if __name__ == '__main__': - ut.main() diff --git a/testsuite/python/stokesian_dynamics_gpu.py b/testsuite/python/stokesian_dynamics_gpu.py deleted file mode 100644 index b9ca6d0a73e..00000000000 --- a/testsuite/python/stokesian_dynamics_gpu.py +++ /dev/null @@ -1,55 +0,0 @@ -# -# Copyright (C) 2019-2020 The ESPResSo project -# -# This file is part of ESPResSo. -# -# ESPResSo is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# ESPResSo is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -import unittest as ut -import unittest_decorators as utx -import stokesian_dynamics as sd - - -@utx.skipIfMissingGPU() -@utx.skipIfMissingFeatures(["STOKESIAN_DYNAMICS_GPU"]) -class StokesianDynamicsSetupTest(sd.StokesianDynamicsSetupTest): - device = 'gpu' - - def test_pbc_checks(self): - self.pbc_checks() - - -@utx.skipIfMissingGPU() -@utx.skipIfMissingFeatures(["STOKESIAN_DYNAMICS_GPU"]) -class StokesianDynamicsTest(sd.StokesianDynamicsTest): - device = 'gpu' - - def test_default_fts(self): - self.falling_spheres(1.0, 1.0, 1.0, 'fts', sd_short=True) - - def test_default_ft(self): - self.falling_spheres(1.0, 1.0, 1.0, 'ft', sd_short=True) - - -@utx.skipIfMissingGPU() -@utx.skipIfMissingFeatures(["STOKESIAN_DYNAMICS_GPU"]) -class StokesianDiffusionTest(sd.StokesianDiffusionTest): - device = 'gpu' - - def test(self): - pass - - -if __name__ == '__main__': - ut.main() diff --git a/testsuite/python/test_checkpoint.py b/testsuite/python/test_checkpoint.py index 2aaa256c8b9..b90fc388415 100644 --- a/testsuite/python/test_checkpoint.py +++ b/testsuite/python/test_checkpoint.py @@ -35,14 +35,6 @@ and espressomd.has_features('ELECTROKINETICS')) -def skipIfMissingFeatureStokesianDynamics(): - """Specialized unittest skipIf decorator for missing Stokesian Dynamics.""" - if not espressomd.has_features(["STOKESIAN_DYNAMICS"]) and (not espressomd.has_features( - ["STOKESIAN_DYNAMICS_GPU"]) or not espressomd.gpu_available()): - return ut.skip("Skipping test: feature STOKESIAN_DYNAMICS unavailable") - return utx._id - - class CheckpointTest(ut.TestCase): @classmethod @@ -203,7 +195,7 @@ def test_thermostat_NPT(self): self.assertEqual(thmst['gamma0'], 2.0) self.assertEqual(thmst['gammav'], 0.1) - @skipIfMissingFeatureStokesianDynamics() + @utx.skipIfMissingFeatures('STOKESIAN_DYNAMICS') @ut.skipIf('THERM.SDM' not in modes, 'SDM thermostat not in modes') def test_thermostat_SDM(self): thmst = system.thermostat.get_state()[0] @@ -255,27 +247,13 @@ def test_integrator_BD(self): self.assertEqual(params, {}) @utx.skipIfMissingFeatures('STOKESIAN_DYNAMICS') - @ut.skipIf('INT.SDM.CPU' not in modes, 'SDM CPU integrator not in modes') - def test_integrator_SDM_cpu(self): - integ = system.integrator.get_state() - self.assertIsInstance(integ, espressomd.integrate.StokesianDynamics) - expected_params = { - 'approximation_method': 'ft', 'device': 'cpu', 'radii': {0: 1.5}, - 'viscosity': 0.5, 'lubrication': False, 'pair_mobility': False, - 'self_mobility': True} - params = integ.get_params() - self.assertEqual(params, expected_params) - - @utx.skipIfMissingGPU() - @utx.skipIfMissingFeatures('STOKESIAN_DYNAMICS_GPU') - @ut.skipIf('INT.SDM.GPU' not in modes, 'SDM GPU integrator not in modes') - def test_integrator_SDM_gpu(self): + @ut.skipIf('INT.SDM' not in modes, 'SDM integrator not in modes') + def test_integrator_SDM(self): integ = system.integrator.get_state() self.assertIsInstance(integ, espressomd.integrate.StokesianDynamics) expected_params = { - 'approximation_method': 'fts', 'device': 'gpu', 'radii': {0: 1.0}, - 'viscosity': 2.0, 'lubrication': False, 'pair_mobility': True, - 'self_mobility': False} + 'approximation_method': 'ft', 'radii': {0: 1.5}, 'viscosity': 0.5, + 'lubrication': False, 'pair_mobility': False, 'self_mobility': True} params = integ.get_params() self.assertEqual(params, expected_params) diff --git a/testsuite/scripts/samples/CMakeLists.txt b/testsuite/scripts/samples/CMakeLists.txt index cfc70fcde2d..df75ba56b17 100644 --- a/testsuite/scripts/samples/CMakeLists.txt +++ b/testsuite/scripts/samples/CMakeLists.txt @@ -26,8 +26,6 @@ sample_test(FILE test_chamber_game.py) sample_test(FILE test_constraints.py) sample_test(FILE test_dancing.py SUFFIX cpu_ft) sample_test(FILE test_dancing.py SUFFIX cpu_fts) -sample_test(FILE test_dancing.py SUFFIX gpu_ft LABELS "gpu") -sample_test(FILE test_dancing.py SUFFIX gpu_fts LABELS "gpu") sample_test(FILE test_diffusion_coefficient.py) sample_test(FILE test_dpd.py) sample_test(FILE test_drude_bmimpf6.py SUFFIX cpu) diff --git a/testsuite/scripts/samples/test_dancing.py b/testsuite/scripts/samples/test_dancing.py index 1d322504438..562bb9344ae 100644 --- a/testsuite/scripts/samples/test_dancing.py +++ b/testsuite/scripts/samples/test_dancing.py @@ -19,9 +19,8 @@ import importlib_wrapper import numpy as np -sd_device = "--gpu" if "gpu" in "@TEST_SUFFIX@" else "--cpu" sd_method = "--fts" if "fts" in "@TEST_SUFFIX@" else "--ft" -if sd_method == "--fts" and sd_device == "--cpu": +if sd_method == "--fts": y_min = -555 intsteps = 5500 else: @@ -30,8 +29,7 @@ sample, skipIfMissingFeatures = importlib_wrapper.configure_and_import( "@SAMPLES_DIR@/dancing.py", script_suffix="@TEST_SUFFIX@", - gpu=(sd_device == "--gpu"), cmd_arguments=[sd_device, sd_method], - intsteps=intsteps, + cmd_arguments=[sd_method], intsteps=intsteps, ref_data="@CMAKE_SOURCE_DIR@/testsuite/python/data/dancing.txt")