From d40edcac22dada225d7926dfcb315f4e2081e87a Mon Sep 17 00:00:00 2001 From: Hideki Kobayashi Date: Fri, 10 Jan 2025 14:23:31 +0100 Subject: [PATCH] Formatting codes --- src/walberla_bridge/CMakeLists.txt | 8 +- src/walberla_bridge/tests/CMakeLists.txt | 2 +- testsuite/python/lb_force_interpolation.py | 242 --------------------- 3 files changed, 5 insertions(+), 247 deletions(-) delete mode 100644 testsuite/python/lb_force_interpolation.py diff --git a/src/walberla_bridge/CMakeLists.txt b/src/walberla_bridge/CMakeLists.txt index bc66f3a490..af18b4ddc9 100644 --- a/src/walberla_bridge/CMakeLists.txt +++ b/src/walberla_bridge/CMakeLists.txt @@ -51,11 +51,11 @@ espresso_configure_walberla_target(espresso_walberla_codegen) target_link_libraries( espresso_walberla PUBLIC MPI::MPI_CXX espresso::utils - PRIVATE espresso::walberla::cpp_flags espresso::walberla_codegen espresso::config espresso::profiler) + PRIVATE espresso::walberla::cpp_flags espresso::walberla_codegen + espresso::config espresso::profiler) target_link_libraries(espresso_walberla_codegen PRIVATE espresso::walberla::cpp_flags) - if(WALBERLA_BUILD_WITH_CUDA) espresso_add_gpu_library(espresso_walberla_cuda SHARED) espresso_add_gpu_library(espresso_walberla_codegen_cuda SHARED) @@ -66,8 +66,8 @@ if(WALBERLA_BUILD_WITH_CUDA) espresso_configure_walberla_target(espresso_walberla_codegen_cuda) target_link_libraries( espresso_walberla_cuda PUBLIC espresso::utils - PRIVATE CUDA::cuda_driver CUDA::cudart espresso::walberla_codegen_cuda espresso::config espresso::profiler - ) + PRIVATE CUDA::cuda_driver CUDA::cudart espresso::walberla_codegen_cuda + espresso::config espresso::profiler) target_link_libraries(espresso_walberla_codegen_cuda PRIVATE CUDA::cuda_driver CUDA::cudart) endif() diff --git a/src/walberla_bridge/tests/CMakeLists.txt b/src/walberla_bridge/tests/CMakeLists.txt index f2f3d6dc6b..05d3979eeb 100644 --- a/src/walberla_bridge/tests/CMakeLists.txt +++ b/src/walberla_bridge/tests/CMakeLists.txt @@ -33,7 +33,7 @@ function(ESPRESSO_ADD_TEST) target_link_libraries( ${TEST_NAME} PRIVATE espresso::walberla::cuda_flags espresso::walberla_cuda - espresso::config espresso::profiler) + espresso::config espresso::profiler) else() target_link_libraries( ${TEST_NAME} PRIVATE espresso::walberla::cpp_flags espresso::config diff --git a/testsuite/python/lb_force_interpolation.py b/testsuite/python/lb_force_interpolation.py deleted file mode 100644 index 27cc39d729..0000000000 --- a/testsuite/python/lb_force_interpolation.py +++ /dev/null @@ -1,242 +0,0 @@ -# -# Copyright (C) 2010-2022 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 numpy as np -import itertools - -import espressomd -import espressomd.lb -import espressomd.utils -import espressomd.observables -import espressomd.electrostatics -import tests_common - - -class LBTest: - - """ - Basic tests of the lattice-Boltzmann implementation - - * temperature - * particle viscous coupling - * application of external force densities - * setting and retrieving lb node velocities - - """ - system = espressomd.System(box_l=3 * [6.0]) - np.random.seed(1) - gamma = 2.0 - params = {'tau': 0.01, - 'agrid': 0.5, - 'density': 0.85, - 'kinematic_viscosity': 3.0} - - system.periodicity = [True, True, True] - system.time_step = params['tau'] - system.cell_system.skin = 1.0 - if espressomd.gpu_available(): - system.cuda_init_handle.call_method("set_device_id_per_rank") - interpolation = False - n_nodes = system.cell_system.get_state()["n_nodes"] - - def setUp(self): - self.system.box_l = 3 * [6.0] - - def tearDown(self): - self.system.lb = None - self.system.part.clear() - self.system.thermostat.turn_off() - self.system.time_step = self.params['tau'] - - def test_force_interpolation_on_the_lattice_grid(self): - lbf = self.lb_class(**self.params, **self.lb_params) - - self.system.lb = lbf - self.system.thermostat.set_lb(LB_fluid=lbf, seed=3, gamma=self.gamma) - - position = np.array([1.25, 2.25, 3.25]) - position_lb_units = position / lbf.agrid - force = np.array([4., -5., 6.]) - lbf.add_force_at_pos(pos=position, force=force) - - self.system.integrator.run(1) - - # the force should be split across the 8 nearest vertices - n_couplings = 0 - for n in lbf[:, :, :]: - if np.sum(np.abs(n.last_applied_force)): - fluid_force = np.copy(n.last_applied_force) - distance = np.linalg.norm(n.index - position_lb_units) - n_couplings += 1 - self.assertEqual(n_couplings, 1) - - def test_force_interpolation_far_from_boundary(self): - lbf = self.lb_class(**self.params, **self.lb_params) - - self.system.lb = lbf - self.system.thermostat.set_lb(LB_fluid=lbf, seed=3, gamma=self.gamma) - - position = np.array([1.2, 2.2, 3.2]) - position_lb_units = position / lbf.agrid - force = np.array([4., -5., 6.]) - lbf.add_force_at_pos(pos=position, force=force) - - self.system.integrator.run(1) - - # the force should be split across the 8 nearest vertices - n_couplings = 0 - for n in lbf[:, :, :]: - if np.sum(np.abs(n.last_applied_force)): - fluid_force = np.copy(n.last_applied_force) - distance = np.linalg.norm(n.index - position_lb_units) - n_couplings += 1 - self.assertEqual(n_couplings, 8) - - def test_force_interpolation_near_upper_boundary_x(self): - lbf = self.lb_class(**self.params, **self.lb_params) - - self.system.lb = lbf - self.system.thermostat.set_lb(LB_fluid=lbf, seed=3, gamma=self.gamma) - - position = np.array([5.8, 5.2, 3.]) #X - position_lb_units = position / lbf.agrid - force = np.array([4., -5., 6.]) - lbf.add_force_at_pos(pos=position, force=force) - - self.system.integrator.run(1) - - # the force should be split across the 8 nearest vertices - n_couplings = 0 - for n in lbf[:, :, :]: - if np.sum(np.abs(n.last_applied_force)): - fluid_force = np.copy(n.last_applied_force) - distance = np.linalg.norm(n.index - position_lb_units) - n_couplings += 1 - self.assertEqual(n_couplings, 8) - - def test_force_interpolation_near_lower_boundary_x(self): - lbf = self.lb_class(**self.params, **self.lb_params) - - self.system.lb = lbf - self.system.thermostat.set_lb(LB_fluid=lbf, seed=3, gamma=self.gamma) - - position = np.array([0.1, 2., 3.]) #X - position_lb_units = position / lbf.agrid - force = np.array([4., -5., 6.]) - lbf.add_force_at_pos(pos=position, force=force) - - self.system.integrator.run(1) - - # the force should be split across the 8 nearest vertices - n_couplings = 0 - for n in lbf[:, :, :]: - if np.sum(np.abs(n.last_applied_force)): - fluid_force = np.copy(n.last_applied_force) - distance = np.linalg.norm(n.index - position_lb_units) - n_couplings += 1 - self.assertEqual(n_couplings, 8) - - def test_force_interpolation_near_upper_boundary_xy(self): - lbf = self.lb_class(**self.params, **self.lb_params) - - self.system.lb = lbf - self.system.thermostat.set_lb(LB_fluid=lbf, seed=3, gamma=self.gamma) - - position = np.array([5.8, 5.8, 3.]) #X - position_lb_units = position / lbf.agrid - force = np.array([4., -5., 6.]) - lbf.add_force_at_pos(pos=position, force=force) - - self.system.integrator.run(1) - - # the force should be split across the 8 nearest vertices - n_couplings = 0 - for n in lbf[:, :, :]: - if np.sum(np.abs(n.last_applied_force)): - fluid_force = np.copy(n.last_applied_force) - distance = np.linalg.norm(n.index - position_lb_units) - n_couplings += 1 - self.assertEqual(n_couplings, 8) - - def test_force_interpolation_near_lower_boundary_xyz(self): - lbf = self.lb_class(**self.params, **self.lb_params) - - self.system.lb = lbf - self.system.thermostat.set_lb(LB_fluid=lbf, seed=3, gamma=self.gamma) - - position = np.array([5.8, 5.8, 5.8]) #X - position_lb_units = position / lbf.agrid - force = np.array([4., -5., 6.]) - lbf.add_force_at_pos(pos=position, force=force) - - self.system.integrator.run(1) - - # the force should be split across the 8 nearest vertices - n_couplings = 0 - for n in lbf[:, :, :]: - if np.sum(np.abs(n.last_applied_force)): - fluid_force = np.copy(n.last_applied_force) - distance = np.linalg.norm(n.index - position_lb_units) - n_couplings += 1 - self.assertEqual(n_couplings, 8) - - -@utx.skipIfMissingFeatures("WALBERLA") -@utx.skipIfMissingFeatures("WALBERLA") -class LBTestWalberlaDoublePrecisionCPU(LBTest, ut.TestCase): - lb_class = espressomd.lb.LBFluidWalberla - lb_lattice_class = espressomd.lb.LatticeWalberla - lb_params = {"single_precision": False} - atol = 1e-10 - rtol = 1e-7 - - -@utx.skipIfMissingFeatures("WALBERLA") -class LBTestWalberlaSinglePrecisionCPU(LBTest, ut.TestCase): - lb_class = espressomd.lb.LBFluidWalberla - lb_lattice_class = espressomd.lb.LatticeWalberla - lb_params = {"single_precision": True} - atol = 1e-7 - rtol = 5e-5 - - -@utx.skipIfMissingGPU() -@utx.skipIfMissingFeatures(["WALBERLA", "CUDA"]) -class LBTestWalberlaDoublePrecisionGPU(LBTest, ut.TestCase): - lb_class = espressomd.lb.LBFluidWalberlaGPU - lb_lattice_class = espressomd.lb.LatticeWalberla - lb_params = {"single_precision": False} - atol = 1e-10 - rtol = 1e-7 - - -@utx.skipIfMissingGPU() -@utx.skipIfMissingFeatures(["WALBERLA", "CUDA"]) -class LBTestWalberlaSinglePrecisionGPU(LBTest, ut.TestCase): - lb_class = espressomd.lb.LBFluidWalberlaGPU - lb_lattice_class = espressomd.lb.LatticeWalberla - lb_params = {"single_precision": True} - atol = 1e-6 - rtol = 2e-4 - - -if __name__ == "__main__": - ut.main()