diff --git a/doc/doxygen/bibliography.bib b/doc/doxygen/bibliography.bib index df73a90672e..cb6d95a2618 100644 --- a/doc/doxygen/bibliography.bib +++ b/doc/doxygen/bibliography.bib @@ -351,6 +351,20 @@ @Article{neumann85b doi = {10.1063/1.448553}, } +@article{panneton06a, +author = {Panneton, Fran\c{c}ois and L'Ecuyer, Pierre and Matsumoto, Makoto}, +title = {Improved long-period generators based on linear recurrences modulo 2}, +year = {2006}, +publisher = {Association for Computing Machinery}, +address = {New York, NY, USA}, +volume = {32}, +number = {1}, +issn = {0098-3500}, +doi = {10.1145/1132973.1132974}, +journal = {ACM Transactions on Mathematical Software (TOMS)}, +pages = {1-16}, +} + @Book{Pottier2010, title={{Nonequilibrium Statistical Physics}}, subtitle={{Linear Irreversible Processes}}, diff --git a/doc/tutorials/01-lennard_jones/01-lennard_jones.ipynb b/doc/tutorials/01-lennard_jones/01-lennard_jones.ipynb index ac1f2b893e2..d05d26ff0e4 100644 --- a/doc/tutorials/01-lennard_jones/01-lennard_jones.ipynb +++ b/doc/tutorials/01-lennard_jones/01-lennard_jones.ipynb @@ -168,7 +168,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The next step would be to create an instance of the System class and to seed espresso. This instance is used as a handle to the simulation system. At any time, only one instance of the System class can exist." + "The next step would be to create an instance of the System class. This instance is used as a handle to the simulation system. At any time, only one instance of the System class can exist." ] }, { @@ -177,8 +177,7 @@ "metadata": {}, "outputs": [], "source": [ - "system = espressomd.System(box_l=BOX_L)\n", - "system.seed = 42" + "system = espressomd.System(box_l=BOX_L)" ] }, { diff --git a/doc/tutorials/02-charged_system/02-charged_system-1.ipynb b/doc/tutorials/02-charged_system/02-charged_system-1.ipynb index 5673ebbf345..9b4512154d9 100644 --- a/doc/tutorials/02-charged_system/02-charged_system-1.ipynb +++ b/doc/tutorials/02-charged_system/02-charged_system-1.ipynb @@ -102,7 +102,6 @@ "# Setup System\n", "box_l = (n_part / density)**(1. / 3.)\n", "system = System(box_l=[box_l, box_l, box_l])\n", - "system.seed = 42\n", "system.periodicity = [True, True, True]\n", "system.time_step = time_step\n", "system.cell_system.skin = 0.3" diff --git a/doc/tutorials/02-charged_system/02-charged_system-2.ipynb b/doc/tutorials/02-charged_system/02-charged_system-2.ipynb index 9722acc07b1..ef2d7958224 100644 --- a/doc/tutorials/02-charged_system/02-charged_system-2.ipynb +++ b/doc/tutorials/02-charged_system/02-charged_system-2.ipynb @@ -157,7 +157,6 @@ "box_z = box_l + 2.0 * (lj_sigmas[\"Electrode\"] + wall_margin)\n", "elc_gap = box_z * 0.15\n", "system = System(box_l=[box_l, box_l, box_z + elc_gap])\n", - "system.seed = 42\n", "box_volume = numpy.prod([box_l, box_l, box_z])\n", "\n", "system.periodicity = [True, True, True]\n", diff --git a/doc/tutorials/02-charged_system/scripts/nacl.py b/doc/tutorials/02-charged_system/scripts/nacl.py index 8f0b2c4c40a..8febd4f25d8 100644 --- a/doc/tutorials/02-charged_system/scripts/nacl.py +++ b/doc/tutorials/02-charged_system/scripts/nacl.py @@ -50,7 +50,6 @@ # Setup System box_l = (n_part / density)**(1. / 3.) system = espressomd.System(box_l=[box_l] * 3) -system.seed = system.cell_system.get_state()['n_nodes'] * [1234] system.periodicity = [True, True, True] system.time_step = time_step system.cell_system.skin = 0.3 diff --git a/doc/tutorials/02-charged_system/scripts/nacl_units.py b/doc/tutorials/02-charged_system/scripts/nacl_units.py index 3795349864a..e3fff54167f 100644 --- a/doc/tutorials/02-charged_system/scripts/nacl_units.py +++ b/doc/tutorials/02-charged_system/scripts/nacl_units.py @@ -25,8 +25,7 @@ assert_features(["ELECTROSTATICS", "MASS", "LENNARD_JONES"]) system = espressomd.System(box_l=[1.0, 1.0, 1.0]) -system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -numpy.random.seed(system.seed) +numpy.random.seed(seed=42) print("\n--->Setup system") diff --git a/doc/tutorials/02-charged_system/scripts/nacl_units_confined.py b/doc/tutorials/02-charged_system/scripts/nacl_units_confined.py index aebb21af31a..3fe4cdb8350 100644 --- a/doc/tutorials/02-charged_system/scripts/nacl_units_confined.py +++ b/doc/tutorials/02-charged_system/scripts/nacl_units_confined.py @@ -27,8 +27,7 @@ assert_features(["ELECTROSTATICS", "MASS", "LENNARD_JONES"]) system = espressomd.System(box_l=[1.0, 1.0, 1.0]) -system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -numpy.random.seed(system.seed) +numpy.random.seed(seed=42) print("\n--->Setup system") diff --git a/doc/tutorials/02-charged_system/scripts/nacl_units_confined_vis.py b/doc/tutorials/02-charged_system/scripts/nacl_units_confined_vis.py index e500db7a2be..8f6b1c10a68 100644 --- a/doc/tutorials/02-charged_system/scripts/nacl_units_confined_vis.py +++ b/doc/tutorials/02-charged_system/scripts/nacl_units_confined_vis.py @@ -29,8 +29,7 @@ assert_features(["ELECTROSTATICS", "MASS", "LENNARD_JONES"]) system = espressomd.System(box_l=[1.0, 1.0, 1.0]) -system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -numpy.random.seed(system.seed) +numpy.random.seed(seed=42) print("\n--->Setup system") diff --git a/doc/tutorials/02-charged_system/scripts/nacl_units_vis.py b/doc/tutorials/02-charged_system/scripts/nacl_units_vis.py index c00ec2d95c6..99a64e5d3b1 100644 --- a/doc/tutorials/02-charged_system/scripts/nacl_units_vis.py +++ b/doc/tutorials/02-charged_system/scripts/nacl_units_vis.py @@ -27,8 +27,7 @@ assert_features(["ELECTROSTATICS", "MASS", "LENNARD_JONES"]) system = espressomd.System(box_l=[1.0, 1.0, 1.0]) -system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -numpy.random.seed(system.seed) +numpy.random.seed(seed=42) visualizer = visualization_opengl.openGLLive( system, diff --git a/doc/tutorials/05-raspberry_electrophoresis/05-raspberry_electrophoresis.ipynb b/doc/tutorials/05-raspberry_electrophoresis/05-raspberry_electrophoresis.ipynb index a9c38e7efd1..d10ff376b34 100644 --- a/doc/tutorials/05-raspberry_electrophoresis/05-raspberry_electrophoresis.ipynb +++ b/doc/tutorials/05-raspberry_electrophoresis/05-raspberry_electrophoresis.ipynb @@ -93,7 +93,6 @@ "# System setup\n", "#############################################################\n", "system = espressomd.System(box_l=[box_l] * 3)\n", - "system.set_random_state_PRNG()\n", "system.time_step = time_step" ] }, diff --git a/doc/tutorials/06-active_matter/EXERCISES/flow_field.py b/doc/tutorials/06-active_matter/EXERCISES/flow_field.py index 1bca345b716..51f51b6f7cb 100644 --- a/doc/tutorials/06-active_matter/EXERCISES/flow_field.py +++ b/doc/tutorials/06-active_matter/EXERCISES/flow_field.py @@ -60,7 +60,6 @@ TIME_STEP = 0.01 system = espressomd.System(box_l=[LENGTH, LENGTH, LENGTH]) -system.seed = system.cell_system.get_state()['n_nodes'] * [1234] system.cell_system.skin = 0.3 system.time_step = TIME_STEP system.min_global_cut = 1.0 diff --git a/doc/tutorials/08-visualization/08-visualization.ipynb b/doc/tutorials/08-visualization/08-visualization.ipynb index f8090eab473..4a7684a5d18 100644 --- a/doc/tutorials/08-visualization/08-visualization.ipynb +++ b/doc/tutorials/08-visualization/08-visualization.ipynb @@ -59,7 +59,6 @@ "\n", "# integration parameters\n", "system = espressomd.System(box_l=[box_l, box_l, box_l])\n", - "system.seed = system.cell_system.get_state()['n_nodes'] * [1234]\n", "system.time_step = 0.0001\n", "system.cell_system.skin = 0.4\n", "system.thermostat.set_langevin(kT=1.0, gamma=1.0, seed=42)\n", diff --git a/maintainer/benchmarks/ferrofluid.py b/maintainer/benchmarks/ferrofluid.py index 3c6a2af8c39..56df3c1f5a2 100644 --- a/maintainer/benchmarks/ferrofluid.py +++ b/maintainer/benchmarks/ferrofluid.py @@ -93,9 +93,8 @@ # PRNG seeds ############################################################# -system.random_number_generator_state = list(range( - n_proc * (system._get_PRNG_state_size() + 1))) # np.random.seed(1) + # Integration parameters ############################################################# system.time_step = 0.01 diff --git a/maintainer/benchmarks/lj.py b/maintainer/benchmarks/lj.py index 8d38dc95f30..c442381cc9c 100644 --- a/maintainer/benchmarks/lj.py +++ b/maintainer/benchmarks/lj.py @@ -91,8 +91,6 @@ # PRNG seeds ############################################################# -system.random_number_generator_state = list(range( - n_proc * (system._get_PRNG_state_size() + 1))) # np.random.seed(1) # Integration parameters diff --git a/maintainer/benchmarks/p3m.py b/maintainer/benchmarks/p3m.py index a981c28a9c8..43fe781596d 100644 --- a/maintainer/benchmarks/p3m.py +++ b/maintainer/benchmarks/p3m.py @@ -99,8 +99,8 @@ # PRNG seeds ############################################################# -system.random_number_generator_state = list(range( - n_proc * (system._get_PRNG_state_size() + 1))) +# np.random.seed(1) + # Integration parameters ############################################################# system.time_step = 0.01 diff --git a/samples/MDAnalysisIntegration.py b/samples/MDAnalysisIntegration.py index a870854cda0..ac7f4e0eb98 100644 --- a/samples/MDAnalysisIntegration.py +++ b/samples/MDAnalysisIntegration.py @@ -28,9 +28,7 @@ # set up a minimal sample system system = espressomd.System(box_l=[10.0, 10.0, 10.0]) -system.set_random_state_PRNG() -#system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -np.random.seed(seed=system.seed) +np.random.seed(seed=42) system.time_step = 0.001 system.cell_system.skin = 0.1 diff --git a/samples/billiard.py b/samples/billiard.py index 1d3cca7c640..6b5617f3971 100644 --- a/samples/billiard.py +++ b/samples/billiard.py @@ -38,7 +38,6 @@ # ESPRESSO system = espressomd.System(box_l=[1.0, 1.0, 1.0]) -system.seed = system.cell_system.get_state()['n_nodes'] * [1234] table_dim = [2.24, 1.12] system.box_l = [table_dim[0], 3, table_dim[1]] diff --git a/samples/chamber_game.py b/samples/chamber_game.py index be9f92207c3..034dffd55c7 100644 --- a/samples/chamber_game.py +++ b/samples/chamber_game.py @@ -58,7 +58,6 @@ box = np.array([1500.0, 500.0, 150.0]) system = espressomd.System(box_l=box) -system.set_random_state_PRNG() # PARAMETERS diff --git a/samples/constraints.py b/samples/constraints.py index 227f284363d..add17a534a7 100644 --- a/samples/constraints.py +++ b/samples/constraints.py @@ -34,10 +34,7 @@ box_l = 50.0 system = espressomd.System(box_l=[box_l] * 3) -system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -np.random.seed(seed=system.seed) - -# if no seed is provided espresso generates a seed +np.random.seed(seed=42) system.time_step = 0.01 system.cell_system.skin = 10.0 diff --git a/samples/diffusion_coefficient.py b/samples/diffusion_coefficient.py index e66159ccf3c..e590e0917b8 100644 --- a/samples/diffusion_coefficient.py +++ b/samples/diffusion_coefficient.py @@ -31,9 +31,7 @@ dt = 0.05 system = espressomd.System(box_l=[1.0, 1.0, 1.0]) -system.set_random_state_PRNG() -#system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -np.random.seed(seed=system.seed) +np.random.seed(seed=42) p = system.part.add(pos=(0, 0, 0), id=0) system.time_step = dt diff --git a/samples/dpd.py b/samples/dpd.py index fccc41371cf..9b34bbdb165 100644 --- a/samples/dpd.py +++ b/samples/dpd.py @@ -41,9 +41,7 @@ # Activate the thermostat system.thermostat.set_dpd(kT=kT, seed=123) -system.set_random_state_PRNG() -np.random.seed(seed=system.seed) -#system.seed = system.cell_system.get_state()['n_nodes'] * [1234] +np.random.seed(seed=42) # Set up the DPD friction interaction system.non_bonded_inter[0, 0].dpd.set_params( diff --git a/samples/drude_bmimpf6.py b/samples/drude_bmimpf6.py index 99e71f5f669..b0714d7c752 100644 --- a/samples/drude_bmimpf6.py +++ b/samples/drude_bmimpf6.py @@ -76,7 +76,6 @@ system = espressomd.System(box_l=[box_l, box_l, box_l]) system.virtual_sites = VirtualSitesRelative(have_velocity=True) -system.set_random_state_PRNG() if args.visu: d_scale = 0.988 * 0.5 diff --git a/samples/ekboundaries.py b/samples/ekboundaries.py index 7505121567e..9ee941037fe 100644 --- a/samples/ekboundaries.py +++ b/samples/ekboundaries.py @@ -27,8 +27,6 @@ import os system = System(box_l=[10, 10, 10]) -system.set_random_state_PRNG() -#system.seed = system.cell_system.get_state()['n_nodes'] * [1234] system.cell_system.skin = 0.4 system.time_step = 0.1 diff --git a/samples/espresso_logo.py b/samples/espresso_logo.py index 03c93c9e7b3..1143e693ba7 100644 --- a/samples/espresso_logo.py +++ b/samples/espresso_logo.py @@ -27,9 +27,7 @@ box_l = 50 system = espressomd.System(box_l=[box_l, 15, box_l]) -system.set_random_state_PRNG() -#system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -np.random.seed(seed=system.seed) +np.random.seed(seed=42) yoff = 3 diff --git a/samples/grand_canonical.py b/samples/grand_canonical.py index 573a6f79caf..bc5fa32f57a 100644 --- a/samples/grand_canonical.py +++ b/samples/grand_canonical.py @@ -59,9 +59,7 @@ # Integration parameters ############################################################# system = espressomd.System(box_l=[box_l, box_l, box_l]) -system.set_random_state_PRNG() -#system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -np.random.seed(seed=system.seed) +np.random.seed(seed=42) system.time_step = 0.01 system.cell_system.skin = 0.4 diff --git a/samples/h5md.py b/samples/h5md.py index 623543368dd..48da2e3b794 100644 --- a/samples/h5md.py +++ b/samples/h5md.py @@ -24,8 +24,6 @@ from espressomd import interactions system = espressomd.System(box_l=[100.0, 100.0, 100.0]) -system.set_random_state_PRNG() -#system.seed = system.cell_system.get_state()['n_nodes'] * [1234] system.time_step = 0.01 system.thermostat.set_langevin(kT=1.0, gamma=1.0, seed=42) diff --git a/samples/lbf.py b/samples/lbf.py index 6968adf181b..c13da38b92a 100644 --- a/samples/lbf.py +++ b/samples/lbf.py @@ -52,7 +52,6 @@ box_l = 50 system = espressomd.System(box_l=[box_l] * 3) -system.set_random_state_PRNG() system.time_step = 0.01 system.cell_system.skin = 0.1 diff --git a/samples/lj-demo.py b/samples/lj-demo.py index 9bcfc625681..74b04f73554 100644 --- a/samples/lj-demo.py +++ b/samples/lj-demo.py @@ -95,8 +95,6 @@ # Integration parameters ############################################################# system = espressomd.System(box_l=[box_l, box_l, box_l]) -system.set_random_state_PRNG() -#system.seed = system.cell_system.get_state()['n_nodes'] * [1234] system.time_step = 0.01 system.cell_system.skin = 0.4 diff --git a/samples/lj_liquid.py b/samples/lj_liquid.py index 423d28321cb..7c1c3b99b5a 100644 --- a/samples/lj_liquid.py +++ b/samples/lj_liquid.py @@ -57,9 +57,7 @@ # Integration parameters ############################################################# system = espressomd.System(box_l=[box_l] * 3) -system.set_random_state_PRNG() -#system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -np.random.seed(seed=system.seed) +np.random.seed(seed=42) system.time_step = 0.01 system.cell_system.skin = 0.4 diff --git a/samples/lj_liquid_distribution.py b/samples/lj_liquid_distribution.py index 8294276a81c..072af3b5428 100644 --- a/samples/lj_liquid_distribution.py +++ b/samples/lj_liquid_distribution.py @@ -54,9 +54,7 @@ # Integration parameters ############################################################# system = espressomd.System(box_l=[box_l] * 3) -system.set_random_state_PRNG() -#system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -np.random.seed(seed=system.seed) +np.random.seed(seed=42) system.time_step = 0.01 system.cell_system.skin = 0.4 diff --git a/samples/lj_liquid_structurefactor.py b/samples/lj_liquid_structurefactor.py index b07ef8b9222..6881d56c90a 100644 --- a/samples/lj_liquid_structurefactor.py +++ b/samples/lj_liquid_structurefactor.py @@ -54,9 +54,7 @@ # Integration parameters ############################################################# system = espressomd.System(box_l=[box_l] * 3) -system.set_random_state_PRNG() -#system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -np.random.seed(seed=system.seed) +np.random.seed(seed=42) system.time_step = 0.01 system.cell_system.skin = 0.4 diff --git a/samples/load_checkpoint.py b/samples/load_checkpoint.py index c10bffaae43..f00107ce4f4 100644 --- a/samples/load_checkpoint.py +++ b/samples/load_checkpoint.py @@ -81,8 +81,6 @@ print("\n### Integrate until user presses ctrl+c ###") print("Integrating...") -system.set_random_state_PRNG() -#system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -np.random.seed(seed=system.seed) +np.random.seed(seed=42) while True: system.integrator.run(1000) diff --git a/samples/minimal-charged-particles.py b/samples/minimal-charged-particles.py index 57a9461f0af..74013f6eadf 100644 --- a/samples/minimal-charged-particles.py +++ b/samples/minimal-charged-particles.py @@ -44,9 +44,7 @@ # Integration parameters ############################################################# system = espressomd.System(box_l=[box_l] * 3) -system.set_random_state_PRNG() -#system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -np.random.seed(seed=system.seed) +np.random.seed(seed=42) system.time_step = 0.01 system.cell_system.skin = 0.4 diff --git a/samples/minimal-diamond.py b/samples/minimal-diamond.py index 3b923c4a8c2..9923841ab8a 100644 --- a/samples/minimal-diamond.py +++ b/samples/minimal-diamond.py @@ -30,9 +30,7 @@ ############################################################# system = espressomd.System(box_l=[1.0, 1.0, 1.0]) -system.set_random_state_PRNG() -system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -np.seed = system.seed +np.random.seed(seed=42) system.time_step = 0.01 system.cell_system.skin = 0.4 system.cell_system.set_n_square(use_verlet_lists=False) diff --git a/samples/minimal-polymer.py b/samples/minimal-polymer.py index e1ab72c8da8..bdb28fc2622 100644 --- a/samples/minimal-polymer.py +++ b/samples/minimal-polymer.py @@ -30,9 +30,7 @@ ############################################################# system = espressomd.System(box_l=[100, 100, 100]) -system.set_random_state_PRNG() -#system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -np.random.seed(seed=system.seed) +np.random.seed(seed=42) system.time_step = 0.01 system.cell_system.skin = 0.4 diff --git a/samples/observables_correlators.py b/samples/observables_correlators.py index 24743898e01..3e53268bc5d 100644 --- a/samples/observables_correlators.py +++ b/samples/observables_correlators.py @@ -26,9 +26,7 @@ # System setup system = espressomd.System(box_l=[1.0, 1.0, 1.0]) -system.set_random_state_PRNG() -#system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -np.random.seed(seed=system.seed) +np.random.seed(seed=42) system.part.add(pos=(0, 0, 0), v=(1, 2, 3)) system.time_step = 0.01 diff --git a/samples/p3m.py b/samples/p3m.py index 0f83ed5df55..05b5d43e24d 100644 --- a/samples/p3m.py +++ b/samples/p3m.py @@ -59,9 +59,7 @@ # Integration parameters ############################################################# system = espressomd.System(box_l=[box_l] * 3) -system.set_random_state_PRNG() -#system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -np.random.seed(seed=system.seed) +np.random.seed(seed=42) system.time_step = 0.01 system.cell_system.skin = 0.4 diff --git a/samples/reaction_ensemble.py b/samples/reaction_ensemble.py index 4a41c893505..79d1a644bda 100644 --- a/samples/reaction_ensemble.py +++ b/samples/reaction_ensemble.py @@ -48,9 +48,7 @@ # Integration parameters ############################################################# system = espressomd.System(box_l=[box_l] * 3) -system.set_random_state_PRNG() -#system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -np.random.seed(seed=system.seed) +np.random.seed(seed=42) system.time_step = 0.02 system.cell_system.skin = 0.4 diff --git a/samples/save_checkpoint.py b/samples/save_checkpoint.py index 620aed203bd..3fa6ac8a40f 100644 --- a/samples/save_checkpoint.py +++ b/samples/save_checkpoint.py @@ -49,9 +49,7 @@ box_l = 10.7437 system = espressomd.System(box_l=[box_l] * 3) -system.set_random_state_PRNG() -#system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -np.random.seed(seed=system.seed) +np.random.seed(seed=42) system.time_step = 0.01 system.cell_system.skin = 0.4 diff --git a/samples/slice_input.py b/samples/slice_input.py index f0bbdf6ca59..6b7367ad165 100644 --- a/samples/slice_input.py +++ b/samples/slice_input.py @@ -37,9 +37,7 @@ ############################################################# system = espressomd.System(box_l=[box_l] * 3) -system.set_random_state_PRNG() -#system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -np.random.seed(seed=system.seed) +np.random.seed(seed=42) system.time_step = 0.01 system.cell_system.skin = 0.4 diff --git a/samples/visualization_bonded.py b/samples/visualization_bonded.py index deca36aff7c..064f4615cc8 100644 --- a/samples/visualization_bonded.py +++ b/samples/visualization_bonded.py @@ -40,8 +40,7 @@ n_part = 200 system = espressomd.System(box_l=[box_l] * 3) -system.set_random_state_PRNG() -np.random.seed(seed=system.seed) +np.random.seed(seed=42) system.time_step = 0.01 system.cell_system.skin = 0.4 diff --git a/samples/visualization_cellsystem.py b/samples/visualization_cellsystem.py index a6872e6954e..ac43049db46 100644 --- a/samples/visualization_cellsystem.py +++ b/samples/visualization_cellsystem.py @@ -29,7 +29,6 @@ box = [40, 30, 20] system = espressomd.System(box_l=box) -system.set_random_state_PRNG() visualizer = openGLLive( system, window_size=[800, 800], diff --git a/samples/visualization_charged.py b/samples/visualization_charged.py index 35fc3bab2ca..7bad987b0e4 100644 --- a/samples/visualization_charged.py +++ b/samples/visualization_charged.py @@ -34,7 +34,6 @@ visualizer = openGLLive(system, background_color=[1, 1, 1], drag_enabled=True, drag_force=10) -system.set_random_state_PRNG() # TIMESTEP time_step_fs = 1.0 diff --git a/samples/visualization_constraints.py b/samples/visualization_constraints.py index db531fc9d33..51ada9ab1cc 100644 --- a/samples/visualization_constraints.py +++ b/samples/visualization_constraints.py @@ -43,8 +43,7 @@ box_l = 50.0 system = espressomd.System(box_l=[box_l] * 3) -system.set_random_state_PRNG() -np.random.seed(seed=system.seed) +np.random.seed(seed=42) system.time_step = 0.0001 system.cell_system.skin = 0.3 diff --git a/samples/visualization_elc.py b/samples/visualization_elc.py index 933a338ea0d..6d26710afd2 100644 --- a/samples/visualization_elc.py +++ b/samples/visualization_elc.py @@ -38,8 +38,7 @@ elc_gap = 10 potential_diff = -3. system = espressomd.System(box_l=[box_l, box_l, box_l + elc_gap]) -system.set_random_state_PRNG() -np.random.seed(seed=system.seed) +np.random.seed(seed=42) visualizer = visualization.openGLLive( system, background_color=[1, 1, 1], diff --git a/samples/visualization_interactive.py b/samples/visualization_interactive.py index 24748d5698a..b7459cdfa57 100644 --- a/samples/visualization_interactive.py +++ b/samples/visualization_interactive.py @@ -31,7 +31,6 @@ box_l = 10.0 system = espressomd.System(box_l=[box_l] * 3) -system.set_random_state_PRNG() visualizer = visualization_opengl.openGLLive( system, drag_enabled=True, drag_force=100) diff --git a/samples/visualization_lbboundaries.py b/samples/visualization_lbboundaries.py index 4ff4bc19658..085a88a0408 100644 --- a/samples/visualization_lbboundaries.py +++ b/samples/visualization_lbboundaries.py @@ -28,7 +28,6 @@ espressomd.assert_features(required_features) system = espressomd.System(box_l=[10.0, 10.0, 5.0]) -system.set_random_state_PRNG() system.time_step = 0.01 system.cell_system.skin = 0.4 diff --git a/samples/visualization_ljliquid.py b/samples/visualization_ljliquid.py index 10dc0dcb40d..5be7abb02e8 100644 --- a/samples/visualization_ljliquid.py +++ b/samples/visualization_ljliquid.py @@ -61,9 +61,7 @@ # Integration parameters ############################################################# system = espressomd.System(box_l=[box_l] * 3) -system.set_random_state_PRNG() -#system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -np.random.seed(seed=system.seed) +np.random.seed(seed=42) system.time_step = 0.001 system.cell_system.skin = 0.4 diff --git a/samples/visualization_npt.py b/samples/visualization_npt.py index 6edb69fb33c..c45c075bfad 100644 --- a/samples/visualization_npt.py +++ b/samples/visualization_npt.py @@ -31,8 +31,7 @@ espressomd.assert_features(required_features) system = espressomd.System(box_l=3 * [10]) -system.set_random_state_PRNG() -np.random.seed(seed=system.seed) +np.random.seed(seed=42) visualizer = espressomd.visualization_opengl.openGLLive( system, background_color=[1, 1, 1], bond_type_radius=[0.2]) diff --git a/samples/visualization_poiseuille.py b/samples/visualization_poiseuille.py index ce32a8e03aa..ef87fc856a4 100644 --- a/samples/visualization_poiseuille.py +++ b/samples/visualization_poiseuille.py @@ -29,8 +29,7 @@ # System setup box_l = 16 system = System(box_l=[box_l] * 3) -system.set_random_state_PRNG() -np.random.seed(seed=system.seed) +np.random.seed(seed=42) system.time_step = 0.01 system.cell_system.skin = 0.2 diff --git a/samples/wang_landau_reaction_ensemble.py b/samples/wang_landau_reaction_ensemble.py index 15d6c441264..61c6e621fc7 100644 --- a/samples/wang_landau_reaction_ensemble.py +++ b/samples/wang_landau_reaction_ensemble.py @@ -53,9 +53,7 @@ # Integration parameters ############################################################# system = espressomd.System(box_l=[box_l] * 3) -system.set_random_state_PRNG() -#system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -np.random.seed(seed=system.seed) +np.random.seed(seed=42) system.time_step = 0.02 system.cell_system.skin = 0.4 diff --git a/samples/widom_insertion.py b/samples/widom_insertion.py index 7e052fbc32c..e44b4701d73 100644 --- a/samples/widom_insertion.py +++ b/samples/widom_insertion.py @@ -44,9 +44,7 @@ # Integration parameters ############################################################# system = espressomd.System(box_l=[box_l, box_l, box_l]) -system.set_random_state_PRNG() -#system.seed = system.cell_system.get_state()['n_nodes'] * [1234] -np.random.seed(seed=system.seed) +np.random.seed(seed=42) system.time_step = 0.01 system.cell_system.skin = 0.4 temperature = 1.0 diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 39153450bc5..f738a66f2d2 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -31,7 +31,6 @@ set(EspressoCore_SRC polymer.cpp polynom.cpp pressure.cpp - random.cpp rattle.cpp reaction_ensemble.cpp rotate_system.cpp diff --git a/src/core/actor/DipolarBarnesHut.hpp b/src/core/actor/DipolarBarnesHut.hpp index 19686917a52..ba7f4a79faa 100644 --- a/src/core/actor/DipolarBarnesHut.hpp +++ b/src/core/actor/DipolarBarnesHut.hpp @@ -30,8 +30,6 @@ #include "errorhandling.hpp" #include "grid.hpp" -#include - #ifndef ACTOR_DIPOLARBARNESHUT_HPP #define ACTOR_DIPOLARBARNESHUT_HPP diff --git a/src/core/actor/DipolarBarnesHut_cuda.cuh b/src/core/actor/DipolarBarnesHut_cuda.cuh index 1d857923e2c..3a09682bd30 100644 --- a/src/core/actor/DipolarBarnesHut_cuda.cuh +++ b/src/core/actor/DipolarBarnesHut_cuda.cuh @@ -25,9 +25,6 @@ #ifdef DIPOLAR_BARNES_HUT -#include -#include - typedef float dds_float; typedef struct { diff --git a/src/core/actor/Mmm1dgpuForce.hpp b/src/core/actor/Mmm1dgpuForce.hpp index ca6d3d4e93b..31233a5a698 100644 --- a/src/core/actor/Mmm1dgpuForce.hpp +++ b/src/core/actor/Mmm1dgpuForce.hpp @@ -22,7 +22,6 @@ #include "Actor.hpp" #include "SystemInterface.hpp" -#include typedef float mmm1dgpu_real; diff --git a/src/core/actor/Mmm1dgpuForce_cuda.cu b/src/core/actor/Mmm1dgpuForce_cuda.cu index 456129f12de..c5b8dd869c5 100644 --- a/src/core/actor/Mmm1dgpuForce_cuda.cu +++ b/src/core/actor/Mmm1dgpuForce_cuda.cu @@ -22,6 +22,8 @@ #include "actor/Mmm1dgpuForce.hpp" #include "cuda_utils.hpp" +#include + #if defined(OMPI_MPI_H) || defined(_MPI_H) #error CU-file includes mpi.h! This should not happen! #endif diff --git a/src/core/electrostatics_magnetostatics/scafacos.cpp b/src/core/electrostatics_magnetostatics/scafacos.cpp index 3db47347e53..0202e4fcfc2 100644 --- a/src/core/electrostatics_magnetostatics/scafacos.cpp +++ b/src/core/electrostatics_magnetostatics/scafacos.cpp @@ -27,7 +27,6 @@ #include #include -#include #include #include #include diff --git a/src/core/event.cpp b/src/core/event.cpp index 2e1bfd6ca60..7408cf57559 100644 --- a/src/core/event.cpp +++ b/src/core/event.cpp @@ -92,11 +92,6 @@ void on_program_start() { cuda_init(); #endif - /* - call the initialization of the modules here - */ - Random::init_random(); - init_node_grid(); /* initially go for domain decomposition */ diff --git a/src/core/forces_inline.hpp b/src/core/forces_inline.hpp index 2d155394dae..14428930d17 100644 --- a/src/core/forces_inline.hpp +++ b/src/core/forces_inline.hpp @@ -35,6 +35,7 @@ #include "bonded_interactions/subt_lj.hpp" #include "bonded_interactions/thermalized_bond.hpp" #include "bonded_interactions/umbrella.hpp" +#include "errorhandling.hpp" #include "forces.hpp" #include "immersed_boundary/ibm_tribend.hpp" #include "immersed_boundary/ibm_triel.hpp" diff --git a/src/core/grid_based_algorithms/electrokinetics_cuda.cu b/src/core/grid_based_algorithms/electrokinetics_cuda.cu index 3a24f714687..96609d060a8 100644 --- a/src/core/grid_based_algorithms/electrokinetics_cuda.cu +++ b/src/core/grid_based_algorithms/electrokinetics_cuda.cu @@ -27,7 +27,6 @@ #include #include #include -#include #include #include diff --git a/src/core/grid_based_algorithms/lb.cpp b/src/core/grid_based_algorithms/lb.cpp index c240bdcfa35..68c4d0e672e 100644 --- a/src/core/grid_based_algorithms/lb.cpp +++ b/src/core/grid_based_algorithms/lb.cpp @@ -59,8 +59,6 @@ using Utils::get_linear_index; #include #include -#include -#include namespace { /** Basis of the mode space as described in @cite dunweg07a */ diff --git a/src/core/grid_based_algorithms/lb_particle_coupling.cpp b/src/core/grid_based_algorithms/lb_particle_coupling.cpp index 35e1b74200b..28baaadaeec 100644 --- a/src/core/grid_based_algorithms/lb_particle_coupling.cpp +++ b/src/core/grid_based_algorithms/lb_particle_coupling.cpp @@ -20,6 +20,7 @@ #include "cells.hpp" #include "communication.hpp" #include "config.hpp" +#include "errorhandling.hpp" #include "global.hpp" #include "grid.hpp" #include "grid_based_algorithms/lattice.hpp" diff --git a/src/core/grid_based_algorithms/lbgpu.cpp b/src/core/grid_based_algorithms/lbgpu.cpp index 7b729aa753b..7131ebc06d8 100644 --- a/src/core/grid_based_algorithms/lbgpu.cpp +++ b/src/core/grid_based_algorithms/lbgpu.cpp @@ -42,7 +42,6 @@ #include #include -#include LB_particle_allocation_state lb_reinit_particles_gpu; diff --git a/src/core/integrate.cpp b/src/core/integrate.cpp index 58ee3d52328..ab69bb7ee23 100644 --- a/src/core/integrate.cpp +++ b/src/core/integrate.cpp @@ -69,7 +69,6 @@ #include #include -#include #include #ifdef VALGRIND_INSTRUMENTATION diff --git a/src/core/integrators/velocity_verlet_npt.cpp b/src/core/integrators/velocity_verlet_npt.cpp index c5b295c697c..74b8bc448b1 100644 --- a/src/core/integrators/velocity_verlet_npt.cpp +++ b/src/core/integrators/velocity_verlet_npt.cpp @@ -23,6 +23,7 @@ #include "ParticleRange.hpp" #include "cells.hpp" #include "communication.hpp" +#include "errorhandling.hpp" #include "grid.hpp" #include "integrate.hpp" #include "nonbonded_interactions/nonbonded_interaction_data.hpp" diff --git a/src/core/io/writer/h5md_core.cpp b/src/core/io/writer/h5md_core.cpp index fb9cf48cf98..69294efcccf 100644 --- a/src/core/io/writer/h5md_core.cpp +++ b/src/core/io/writer/h5md_core.cpp @@ -26,6 +26,7 @@ #include "integrate.hpp" #include "version.hpp" +#include #include namespace Writer { diff --git a/src/core/io/writer/h5md_core.hpp b/src/core/io/writer/h5md_core.hpp index 6d09025ec07..c934d403863 100644 --- a/src/core/io/writer/h5md_core.hpp +++ b/src/core/io/writer/h5md_core.hpp @@ -24,9 +24,7 @@ #include #include -#include #include -#include #include #include #include diff --git a/src/core/polymer.cpp b/src/core/polymer.cpp index b836a3a60b8..c6884d59ed4 100644 --- a/src/core/polymer.cpp +++ b/src/core/polymer.cpp @@ -32,13 +32,13 @@ #include "bonded_interactions/bonded_interaction_data.hpp" #include "constraints.hpp" #include "constraints/ShapeBasedConstraint.hpp" +#include "random.hpp" #include #include #include #include -#include #include template static Utils::Vector3d random_position(RNG &rng) { @@ -119,7 +119,7 @@ draw_polymer_positions(PartCfg &partCfg, int const n_polymers, double const min_distance, int const max_tries, int const use_bond_angle, double const bond_angle, int const respect_constraints, int const seed) { - auto rng = [mt = std::mt19937{static_cast(seed)}, + auto rng = [mt = Random::mt19937(static_cast(seed)), dist = std::uniform_real_distribution( 0.0, 1.0)]() mutable { return dist(mt); }; diff --git a/src/core/random.cpp b/src/core/random.cpp deleted file mode 100644 index 4d880dfff1c..00000000000 --- a/src/core/random.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (C) 2010-2019 The ESPResSo project - * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 - * - * Max-Planck-Institute for Polymer Research, Theory Group - * - * 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 . - */ - -#include "random.hpp" -#include "communication.hpp" - -#include - -namespace Random { -using std::istringstream; -using std::ostringstream; -using std::string; -using std::vector; - -using Communication::mpiCallbacks; - -std::mt19937 generator; -std::uniform_real_distribution uniform_real_distribution(0, 1); - -bool user_has_seeded = false; - -/* Local functions */ - -/** - * @brief Get a string representation of the state of the PRNG. - */ -string get_state() { - ostringstream os; - os << generator; - - return os.str(); -} - -/** - * @brief Set the state of the PRNG from a string representation. - */ -void set_state(const string &s) { - istringstream is(s); - is >> generator; -} - -/** - * @brief Get the state size of the PRNG - */ -int get_state_size_of_generator() { - return std::mt19937::state_size; // this only works for the Mersenne twister - // generator, other generators do not provide - // this member variable -} - -/* Communication */ - -void mpi_random_seed_slave(int, int) { - int this_seed; - user_has_seeded = true; - - MPI_Scatter(nullptr, 1, MPI_INT, &this_seed, 1, MPI_INT, 0, comm_cart); - - init_random_seed(this_seed); -} - -void mpi_random_seed(int cnt, vector &seeds) { - int this_seed; - user_has_seeded = true; - mpi_call(mpi_random_seed_slave, -1, cnt); - - MPI_Scatter(&seeds[0], 1, MPI_INT, &this_seed, 1, MPI_INT, 0, comm_cart); - - init_random_seed(this_seed); -} - -void mpi_random_set_stat_slave(int, int) { - user_has_seeded = true; - string msg; - mpiCallbacks().comm().recv(0, SOME_TAG, msg); - - set_state(msg); -} - -void mpi_random_set_stat(const vector &stat) { - user_has_seeded = true; - mpi_call(mpi_random_set_stat_slave, 0, 0); - - for (int i = 1; i < n_nodes; i++) { - mpiCallbacks().comm().send(i, SOME_TAG, stat[i]); - } - - set_state(stat[0]); -} - -void mpi_random_get_stat_slave(int, int) { - string state = get_state(); - - mpiCallbacks().comm().send(0, SOME_TAG, state); -} - -string mpi_random_get_stat() { - string res = get_state(); - - mpi_call(mpi_random_get_stat_slave, 0, 0); - - for (int i = 1; i < n_nodes; i++) { - string tmp; - mpiCallbacks().comm().recv(i, SOME_TAG, tmp); - res.append(" "); - res.append(tmp); - } - - return res; -} - -void init_random() { - /** Set the initial seed */ - init_random_seed(1 + this_node); -} - -REGISTER_CALLBACK(mpi_random_seed_slave) -REGISTER_CALLBACK(mpi_random_set_stat_slave) -REGISTER_CALLBACK(mpi_random_get_stat_slave) - -void init_random_seed(int seed) { - std::seed_seq seeder{ - seed}; // come up with "sane" initialization to avoid too many zeros in - // the internal state of the Mersenne twister - generator.seed(seeder); - generator.discard(1'000'000); // discard the first 1e6 random numbers to warm - // up the Mersenne-Twister PRNG -} - -} // namespace Random diff --git a/src/core/random.hpp b/src/core/random.hpp index 12c04f92035..e720d59ff8f 100644 --- a/src/core/random.hpp +++ b/src/core/random.hpp @@ -26,8 +26,6 @@ * Random number generation using Philox. */ -#include "errorhandling.hpp" - #include #include #include @@ -35,8 +33,6 @@ #include #include -#include -#include #include /* @@ -138,7 +134,7 @@ auto noise_uniform(uint64_t counter, int key1, int key2 = 0) { * @param counter counter for the random number generation * @param key1 key for random number generation * @param key2 key for random number generation - * @tparam salt (decorrelates different thermostat types) + * @tparam salt decorrelates different thermostat types * * @return Vector of Gaussian random numbers. * @@ -181,73 +177,19 @@ auto noise_gaussian(uint64_t counter, int key1, int key2 = 0) { return noise; } -extern std::mt19937 generator; -extern std::uniform_real_distribution uniform_real_distribution; -extern bool user_has_seeded; -inline void unseeded_error() { - runtimeErrorMsg() << "Please seed the random number generator.\nESPResSo " - "can choose one for you with set_random_state_PRNG()."; -} - -/** - * @brief checks the seeded state and throws error if unseeded - */ -inline void check_user_has_seeded() { - static bool unseeded_error_thrown = false; - if (!user_has_seeded && !unseeded_error_thrown) { - unseeded_error_thrown = true; - unseeded_error(); - } -} - -/** - * @brief Set seed of random number generators on each node. - * - * @param cnt Unused. - * @param seeds A vector of seeds, must be at least n_nodes long. - */ -void mpi_random_seed(int cnt, std::vector &seeds); - -/** - * @brief Gets a string representation of the state of all the nodes. - */ -std::string mpi_random_get_stat(); - -/** - * @brief Set the seeds on all the node to the state represented - * by the string. - * The string representation must be one that was returned by - * @ref mpi_random_get_stat. - */ -void mpi_random_set_stat(const std::vector &stat); - -/** - * @brief Get the state size of the random number generator - */ -int get_state_size_of_generator(); - -/** - * @brief Initialize PRNG with MPI rank as seed. - */ -void init_random(); - -/** - * @brief Initialize PRNG with user-provided seed. +/** Mersenne Twister with warmup. + * The first 100'000 values of Mersenne Twister generators are often heavily + * correlated @cite panneton06a. This utility function discards the first + * 1'000'000 values. * - * @param seed seed + * @param seed RNG seed */ -void init_random_seed(int seed); +template std::mt19937 mt19937(T &&seed) { + std::mt19937 generator(seed); + generator.discard(1'000'000); + return generator; +} } // namespace Random -/** - * @brief Draws a random real number from the uniform distribution in the - * range [0,1) using the Mersenne twister. - */ -inline double d_random() { - using namespace Random; - check_user_has_seeded(); - return uniform_real_distribution(generator); -} - #endif diff --git a/src/core/reaction_ensemble.hpp b/src/core/reaction_ensemble.hpp index 7847aca44c3..6a8ca2cd36f 100644 --- a/src/core/reaction_ensemble.hpp +++ b/src/core/reaction_ensemble.hpp @@ -20,8 +20,8 @@ #define REACTION_ENSEMBLE_H #include "energy.hpp" +#include "random.hpp" #include -#include #include #include @@ -111,9 +111,8 @@ class ReactionAlgorithm { public: ReactionAlgorithm(int seed) - : m_seeder({seed, seed, seed}), m_generator(m_seeder), + : m_generator(Random::mt19937(std::seed_seq({seed, seed, seed}))), m_normal_distribution(0.0, 1.0), m_uniform_real_distribution(0.0, 1.0) { - m_generator.discard(1'000'000); } virtual ~ReactionAlgorithm() = default; @@ -198,7 +197,6 @@ class ReactionAlgorithm { bool all_reactant_particles_exist(int reaction_id); private: - std::seed_seq m_seeder; std::mt19937 m_generator; std::normal_distribution m_normal_distribution; std::uniform_real_distribution m_uniform_real_distribution; diff --git a/src/core/unit_tests/CMakeLists.txt b/src/core/unit_tests/CMakeLists.txt index 6703afd0c46..d6b6e8c43e2 100644 --- a/src/core/unit_tests/CMakeLists.txt +++ b/src/core/unit_tests/CMakeLists.txt @@ -33,7 +33,7 @@ unit_test(NAME Variant_test SRC Variant_test.cpp DEPENDS EspressoScriptInterface unit_test(NAME ParticleIterator_test SRC ParticleIterator_test.cpp) unit_test(NAME link_cell_test SRC link_cell_test.cpp DEPENDS utils) unit_test(NAME verlet_ia_test SRC verlet_ia_test.cpp DEPENDS utils) -unit_test(NAME ParticleCache_test SRC ParticleCache_test.cpp DEPENDS utils Boost::mpi MPI::MPI_CXX Boost::serialization NUM_PROC 2) +unit_test(NAME ParticleCache_test SRC ParticleCache_test.cpp DEPENDS utils Boost::mpi MPI::MPI_CXX Boost::serialization Random123 NUM_PROC 2) unit_test(NAME Particle_test SRC Particle_test.cpp DEPENDS utils Boost::serialization) unit_test(NAME get_value SRC get_value_test.cpp DEPENDS EspressoScriptInterface) unit_test(NAME field_coupling_couplings SRC field_coupling_couplings_test.cpp DEPENDS utils) @@ -45,5 +45,5 @@ unit_test(NAME grid_test SRC grid_test.cpp DEPENDS EspressoCore) unit_test(NAME BoxGeometry_test SRC BoxGeometry_test.cpp DEPENDS EspressoCore) unit_test(NAME LocalBox_test SRC LocalBox_test.cpp DEPENDS EspressoCore) unit_test(NAME thermostats_test SRC thermostats_test.cpp DEPENDS EspressoCore) -unit_test(NAME random_test SRC random_test.cpp DEPENDS EspressoCore) +unit_test(NAME random_test SRC random_test.cpp DEPENDS utils Random123) diff --git a/src/core/unit_tests/ParticleCache_test.cpp b/src/core/unit_tests/ParticleCache_test.cpp index a951cae5e1c..ef9907c6880 100644 --- a/src/core/unit_tests/ParticleCache_test.cpp +++ b/src/core/unit_tests/ParticleCache_test.cpp @@ -20,10 +20,10 @@ /* Unit tests for the MpiCallbacks class. */ -#include #include #include "ParticleCache.hpp" +#include "random.hpp" #include #include @@ -64,7 +64,7 @@ void check_merge(unsigned size, unsigned split) { boost::container::flat_set u, v; using value_type = typename boost::container::flat_set::value_type; - std::mt19937 mersenne_engine(size); + auto mersenne_engine = Random::mt19937(size); std::uniform_int_distribution dist; for (int i = 0; i < size; i++) { diff --git a/src/core/unit_tests/RuntimeErrorCollector_test.cpp b/src/core/unit_tests/RuntimeErrorCollector_test.cpp index 87c6af8cb9e..3202f49942b 100644 --- a/src/core/unit_tests/RuntimeErrorCollector_test.cpp +++ b/src/core/unit_tests/RuntimeErrorCollector_test.cpp @@ -22,7 +22,6 @@ /* Unit tests for the ErrorHandling::RuntimeErrorCollector class. */ #include -#include #include #include diff --git a/src/core/unit_tests/link_cell_test.cpp b/src/core/unit_tests/link_cell_test.cpp index 0c26dd08b5e..dcf4d4fc268 100644 --- a/src/core/unit_tests/link_cell_test.cpp +++ b/src/core/unit_tests/link_cell_test.cpp @@ -18,7 +18,6 @@ */ #include #include -#include #include #define BOOST_TEST_MODULE link_cell test diff --git a/src/core/unit_tests/verlet_ia_test.cpp b/src/core/unit_tests/verlet_ia_test.cpp index d0cdadecc42..528638ebeaa 100644 --- a/src/core/unit_tests/verlet_ia_test.cpp +++ b/src/core/unit_tests/verlet_ia_test.cpp @@ -18,7 +18,6 @@ */ #include #include -#include #include #define BOOST_TEST_MODULE link_cell test diff --git a/src/python/espressomd/system.pxd b/src/python/espressomd/system.pxd index 0c3b48cdc4e..e03939cd95e 100644 --- a/src/python/espressomd/system.pxd +++ b/src/python/espressomd/system.pxd @@ -24,17 +24,10 @@ from libcpp cimport bool cdef extern from "grid.hpp": cdef void rescale_boxl(int dir, double d_new) -cdef extern from "communication.hpp" namespace "Random": - void mpi_random_seed(int cnt, vector[int] & seed) - from libcpp.string cimport string # import std::string as string from libcpp.vector cimport vector # import std::vector as vector ctypedef vector[string] string_vec -cdef extern from "random.hpp" namespace "Random": - string mpi_random_get_stat() - void mpi_random_set_stat(const vector[string] & stat) - int get_state_size_of_generator() cdef extern from "rotate_system.hpp": void rotate_system(double phi, double theta, double alpha) diff --git a/src/python/espressomd/system.pyx b/src/python/espressomd/system.pyx index 116dc4410ba..09afab3154c 100644 --- a/src/python/espressomd/system.pyx +++ b/src/python/espressomd/system.pyx @@ -118,7 +118,6 @@ cdef class System: lbboundaries ekboundaries collision_detection - __seed cuda_init_handle comfixed _active_virtual_sites_handle @@ -300,82 +299,6 @@ cdef class System: def __get__(self): return self.globals.min_global_cut - def _get_PRNG_state_size(self): - """ - Returns the state size of the pseudo random number generator. - """ - - return get_state_size_of_generator() - - def set_random_state_PRNG(self): - """ - Sets the state of the pseudo random number generator using real random numbers. - """ - - _state_size_plus_one = self._get_PRNG_state_size() + 1 - states = string_vec(n_nodes) - rng = random.SystemRandom() # true RNG that uses os.urandom() - for i in range(n_nodes): - states_on_node_i = [] - for j in range(_state_size_plus_one + 1): - states_on_node_i.append( - rng.randint(0, numeric_limits[int].max())) - states[i] = (" ".join(map(str, states_on_node_i))).encode('utf-8') - mpi_random_set_stat(states) - - property seed: - """ - Sets the seed of the pseudo random number with a list of seeds which is - as long as the number of used nodes. - """ - - def __set__(self, _seed): - cdef vector[int] seed_array - self.__seed = _seed - if(is_valid_type(_seed, int) and n_nodes == 1): - seed_array.resize(1) - seed_array[0] = int(_seed) - mpi_random_seed(0, seed_array) - elif(hasattr(_seed, "__iter__")): - if(len(_seed) < n_nodes or len(_seed) > n_nodes): - raise ValueError( - "The list needs to contain one seed value per node") - seed_array.resize(len(_seed)) - for i in range(len(_seed)): - seed_array[i] = int(_seed[i]) - mpi_random_seed(n_nodes, seed_array) - else: - raise ValueError( - "The seed has to be an integer or a list of integers with one integer per node") - - def __get__(self): - return self.__seed - - property random_number_generator_state: - """Sets the random number generator state in the core. This is of - interest for deterministic checkpointing. - """ - - def __set__(self, rng_state): - _state_size_plus_one = self._get_PRNG_state_size() + 1 - if(len(rng_state) == n_nodes * _state_size_plus_one): - states = string_vec(n_nodes) - for i in range(n_nodes): - states[i] = (" ".join(map(str, - rng_state[i * _state_size_plus_one:(i + 1) * _state_size_plus_one]) - )).encode('utf-8') - mpi_random_set_stat(states) - else: - raise ValueError( - "Wrong number of arguments: Usage: 'system.random_number_generator_state = " - "[, ..., ], where each " - "is an integer. The state size of the PRNG can be obtained by calling " - "system._get_PRNG_state_size().") - - def __get__(self): - rng_state = list(map(int, (mpi_random_get_stat().c_str()).split())) - return rng_state - IF VIRTUAL_SITES: property virtual_sites: def __set__(self, v): diff --git a/src/utils/include/utils/Factory.hpp b/src/utils/include/utils/Factory.hpp index d38feefacc1..ae2c21ae266 100644 --- a/src/utils/include/utils/Factory.hpp +++ b/src/utils/include/utils/Factory.hpp @@ -30,8 +30,6 @@ #include #include -#include - namespace Utils { /** diff --git a/src/utils/tests/RunningAverage_test.cpp b/src/utils/tests/RunningAverage_test.cpp index b8694905e9e..68d50edb912 100644 --- a/src/utils/tests/RunningAverage_test.cpp +++ b/src/utils/tests/RunningAverage_test.cpp @@ -20,7 +20,6 @@ */ #include -#include #include #include diff --git a/testsuite/python/analyze_chains.py b/testsuite/python/analyze_chains.py index f135c560cf2..39738edf709 100644 --- a/testsuite/python/analyze_chains.py +++ b/testsuite/python/analyze_chains.py @@ -26,7 +26,6 @@ class AnalyzeChain(ut.TestCase): system = espressomd.System(box_l=[1.0, 1.0, 1.0]) np.random.seed(1234) - system.set_random_state_PRNG() num_poly = 2 num_mono = 5 diff --git a/testsuite/python/analyze_distance.py b/testsuite/python/analyze_distance.py index c26b3cafa88..d9436cfcba0 100644 --- a/testsuite/python/analyze_distance.py +++ b/testsuite/python/analyze_distance.py @@ -25,7 +25,6 @@ @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] np.random.seed(1234) def setUp(self): diff --git a/testsuite/python/brownian_dynamics.py b/testsuite/python/brownian_dynamics.py index 8988f9c5e36..530cf2f4061 100644 --- a/testsuite/python/brownian_dynamics.py +++ b/testsuite/python/brownian_dynamics.py @@ -31,7 +31,6 @@ class BrownianDynamics(ut.TestCase): system = espressomd.System(box_l=[1.0, 1.0, 1.0]) system.cell_system.set_domain_decomposition(use_verlet_lists=True) system.cell_system.skin = 0 - system.seed = range(system.cell_system.get_state()["n_nodes"]) system.periodicity = [0, 0, 0] system.integrator.set_brownian_dynamics() diff --git a/testsuite/python/collision_detection.py b/testsuite/python/collision_detection.py index 89b69b9f86a..f10c974d423 100644 --- a/testsuite/python/collision_detection.py +++ b/testsuite/python/collision_detection.py @@ -30,8 +30,7 @@ class CollisionDetection(ut.TestCase): """Tests interface and functionality of the collision detection / dynamic binding""" s = espressomd.System(box_l=[1.0, 1.0, 1.0]) - s.seed = s.cell_system.get_state()['n_nodes'] * [1234] - np.random.seed(seed=s.seed) + np.random.seed(seed=42) if espressomd.has_features("VIRTUAL_SITES_RELATIVE"): from espressomd.virtual_sites import VirtualSitesRelative s.virtual_sites = VirtualSitesRelative() diff --git a/testsuite/python/comfixed.py b/testsuite/python/comfixed.py index 00e4df99d29..a001cfaba73 100644 --- a/testsuite/python/comfixed.py +++ b/testsuite/python/comfixed.py @@ -31,8 +31,7 @@ def test(self): skin = 0.4 s = espressomd.System(box_l=[1.0, 1.0, 1.0]) - s.seed = s.cell_system.get_state()['n_nodes'] * [1234] - np.random.seed(seed=s.seed) + np.random.seed(seed=42) s.box_l = [10, 10, 10] s.time_step = dt diff --git a/testsuite/python/constant_pH.py b/testsuite/python/constant_pH.py index 6c98bd8312e..c4b7e538b8c 100644 --- a/testsuite/python/constant_pH.py +++ b/testsuite/python/constant_pH.py @@ -44,7 +44,6 @@ class ReactionEnsembleTest(ut.TestCase): Ka = 10**(-pKa) box_l = (N0 / c0)**(1.0 / 3.0) system = espressomd.System(box_l=[box_l, box_l, box_l]) - system.seed = system.cell_system.get_state()['n_nodes'] * [2] np.random.seed(69) # make reaction code fully deterministic system.cell_system.skin = 0.4 system.time_step = 0.01 diff --git a/testsuite/python/constraint_homogeneous_magnetic_field.py b/testsuite/python/constraint_homogeneous_magnetic_field.py index 6f1333bf921..683c31a5a3b 100644 --- a/testsuite/python/constraint_homogeneous_magnetic_field.py +++ b/testsuite/python/constraint_homogeneous_magnetic_field.py @@ -24,8 +24,7 @@ class HomogeneousMagneticFieldTest(ut.TestCase): S = espressomd.System(box_l=[1.0, 1.0, 1.0]) - S.seed = S.cell_system.get_state()['n_nodes'] * [1234] - np.random.seed(S.seed) + np.random.seed(seed=42) def setUp(self): self.S.box_l = [3.0, 3.0, 3.0] diff --git a/testsuite/python/coulomb_cloud_wall.py b/testsuite/python/coulomb_cloud_wall.py index 74e80b668d7..e2fa89e9053 100644 --- a/testsuite/python/coulomb_cloud_wall.py +++ b/testsuite/python/coulomb_cloud_wall.py @@ -36,7 +36,6 @@ class CoulombCloudWall(ut.TestCase): """ S = espressomd.System(box_l=[1.0, 1.0, 1.0]) - S.seed = S.cell_system.get_state()['n_nodes'] * [1234] forces = {} tolerance = 1E-3 diff --git a/testsuite/python/coulomb_cloud_wall_duplicated.py b/testsuite/python/coulomb_cloud_wall_duplicated.py index ff367c4a26c..84a78a84031 100644 --- a/testsuite/python/coulomb_cloud_wall_duplicated.py +++ b/testsuite/python/coulomb_cloud_wall_duplicated.py @@ -32,8 +32,7 @@ class CoulombCloudWall(ut.TestCase): """This compares p3m, p3m_gpu electrostatic forces and energy against stored data.""" S = espressomd.System(box_l=[1.0, 1.0, 1.0]) - S.seed = S.cell_system.get_state()['n_nodes'] * [1234] - np.random.seed(S.seed) + np.random.seed(seed=42) forces = {} tolerance = 1E-3 diff --git a/testsuite/python/coulomb_tuning.py b/testsuite/python/coulomb_tuning.py index 2250356f72d..d689e5fa97a 100644 --- a/testsuite/python/coulomb_tuning.py +++ b/testsuite/python/coulomb_tuning.py @@ -31,7 +31,6 @@ class CoulombCloudWallTune(ut.TestCase): """This compares p3m, p3m_gpu electrostatic forces against stored data.""" system = espressomd.System(box_l=[1.0, 1.0, 1.0]) - system.seed = system.cell_system.get_state()['n_nodes'] * [1234] tolerance = 1E-3 diff --git a/testsuite/python/dawaanr-and-bh-gpu.py b/testsuite/python/dawaanr-and-bh-gpu.py index e9f3f8e2303..9be6a09c992 100644 --- a/testsuite/python/dawaanr-and-bh-gpu.py +++ b/testsuite/python/dawaanr-and-bh-gpu.py @@ -33,8 +33,7 @@ def stopAll(system): @utx.skipIfMissingFeatures(["DIPOLAR_BARNES_HUT", "LENNARD_JONES"]) class BHGPUTest(ut.TestCase): system = espressomd.System(box_l=[1, 1, 1]) - system.seed = system.cell_system.get_state()['n_nodes'] * [1234] - np.random.seed(system.seed) + np.random.seed(seed=42) def vectorsTheSame(self, a, b): tol = 5E-2 diff --git a/testsuite/python/dawaanr-and-dds-gpu.py b/testsuite/python/dawaanr-and-dds-gpu.py index fdc30e519ac..d8a6fabdcaf 100644 --- a/testsuite/python/dawaanr-and-dds-gpu.py +++ b/testsuite/python/dawaanr-and-dds-gpu.py @@ -30,7 +30,6 @@ class DDSGPUTest(ut.TestCase): # Handle for espresso system es = espressomd.System(box_l=[1.0, 1.0, 1.0]) - es.seed = es.cell_system.get_state()['n_nodes'] * [1234] def stopAll(self): for i in range(len(self.es.part)): diff --git a/testsuite/python/dds-and-bh-gpu.py b/testsuite/python/dds-and-bh-gpu.py index 85478bc504f..e473e35b818 100644 --- a/testsuite/python/dds-and-bh-gpu.py +++ b/testsuite/python/dds-and-bh-gpu.py @@ -34,10 +34,6 @@ def stopAll(system): @utx.skipIfMissingFeatures(["DIPOLAR_BARNES_HUT", "LENNARD_JONES"]) class BH_DDS_gpu_multCPU_test(ut.TestCase): system = espressomd.System(box_l=[1, 1, 1]) - # just some seeding based on 14 - system.seed = [s * 14 for s in range( - system.cell_system.get_state()["n_nodes"])] - # just some seeding different from the previous one np.random.seed(71) def vectorsTheSame(self, a, b): diff --git a/testsuite/python/dipolar_mdlc_p3m_scafacos_p2nfft.py b/testsuite/python/dipolar_mdlc_p3m_scafacos_p2nfft.py index 6e65468402f..ab27519cde3 100644 --- a/testsuite/python/dipolar_mdlc_p3m_scafacos_p2nfft.py +++ b/testsuite/python/dipolar_mdlc_p3m_scafacos_p2nfft.py @@ -39,7 +39,6 @@ class Dipolar_p3m_mdlc_p2nfft(ut.TestCase): 3d: as long as the independently written p3m and p2nfft agree, we are safe. """ s = espressomd.System(box_l=[1.0, 1.0, 1.0]) - s.seed = s.cell_system.get_state()['n_nodes'] * [1234] s.time_step = 0.01 s.cell_system.skin = .4 s.periodicity = [1, 1, 1] diff --git a/testsuite/python/dpd.py b/testsuite/python/dpd.py index 7acf8391cc0..2e255abeffe 100644 --- a/testsuite/python/dpd.py +++ b/testsuite/python/dpd.py @@ -37,7 +37,6 @@ class DPDThermostat(ut.TestCase): s.cell_system.skin = 0.4 def setUp(self): - self.s.seed = range(self.s.cell_system.get_state()["n_nodes"]) np.random.seed(16) def tearDown(self): diff --git a/testsuite/python/drude.py b/testsuite/python/drude.py index 96adbc7e8ad..bcd41de687b 100644 --- a/testsuite/python/drude.py +++ b/testsuite/python/drude.py @@ -41,7 +41,6 @@ def test(self): box_l = 50 system = espressomd.System(box_l=[box_l, box_l, box_l]) - system.seed = system.cell_system.get_state()['n_nodes'] * [12] np.random.seed(12) # Reference Results, reproduced with LAMMPS diff --git a/testsuite/python/ek_eof_one_species_base.py b/testsuite/python/ek_eof_one_species_base.py index ba8f7d7382e..a419a8596c2 100644 --- a/testsuite/python/ek_eof_one_species_base.py +++ b/testsuite/python/ek_eof_one_species_base.py @@ -108,7 +108,6 @@ def bisection(): @utx.skipIfMissingFeatures(["ELECTROKINETICS", "EK_BOUNDARIES"]) class ek_eof_one_species(ut.TestCase): system = espressomd.System(box_l=[1.0, 1.0, 1.0]) - system.seed = system.cell_system.get_state()['n_nodes'] * [1234] xi = bisection() def run_test(self, params): diff --git a/testsuite/python/engine_langevin.py b/testsuite/python/engine_langevin.py index 2691f4ca43e..5b3f9cf9eb5 100644 --- a/testsuite/python/engine_langevin.py +++ b/testsuite/python/engine_langevin.py @@ -45,7 +45,6 @@ def z_v(t, z0): np.exp(-gamma * t)) + z0 S = espressomd.System(box_l=[1.0, 1.0, 1.0]) - S.seed = S.cell_system.get_state()['n_nodes'] * [1234] S.box_l = [boxl, boxl, boxl] S.cell_system.skin = 0.1 diff --git a/testsuite/python/exclusions.py b/testsuite/python/exclusions.py index 023ca82b26f..a4267e94f83 100644 --- a/testsuite/python/exclusions.py +++ b/testsuite/python/exclusions.py @@ -25,7 +25,6 @@ @utx.skipIfMissingFeatures(['EXCLUSIONS']) class Exclusions(ut.TestCase): s = espressomd.System(box_l=[1.0, 1.0, 1.0]) - s.seed = s.cell_system.get_state()['n_nodes'] * [1234] def setUp(self): self.s.part.clear() diff --git a/testsuite/python/force_cap.py b/testsuite/python/force_cap.py index caa2a74bb2f..c2bc792f6c3 100644 --- a/testsuite/python/force_cap.py +++ b/testsuite/python/force_cap.py @@ -31,7 +31,6 @@ class ForceCap(ut.TestCase): s = espressomd.System(box_l=[1.0, 1.0, 1.0]) s.cell_system.skin = 0.0 - s.seed = range(s.cell_system.get_state()["n_nodes"]) np.random.seed(42) diff --git a/testsuite/python/hat.py b/testsuite/python/hat.py index aa82a650675..77f33ad2f85 100644 --- a/testsuite/python/hat.py +++ b/testsuite/python/hat.py @@ -38,7 +38,6 @@ def pot(self, F_max, r_cut, r): def test(self): s = espressomd.System(box_l=[1.0, 1.0, 1.0]) - s.seed = s.cell_system.get_state()['n_nodes'] * [1234] s.box_l = 3 * [10] s.time_step = 0.01 s.cell_system.skin = 0.4 diff --git a/testsuite/python/icc.py b/testsuite/python/icc.py index 9f1d39b2972..7e98d658cfa 100644 --- a/testsuite/python/icc.py +++ b/testsuite/python/icc.py @@ -27,7 +27,6 @@ def runTest(self): from espressomd.electrostatic_extensions import ICC S = espressomd.System(box_l=[1.0, 1.0, 1.0]) - S.seed = S.cell_system.get_state()['n_nodes'] * [1234] # Parameters box_l = 20.0 nicc = 10 diff --git a/testsuite/python/interactions_bonded.py b/testsuite/python/interactions_bonded.py index 71434eb13be..a73fee31219 100644 --- a/testsuite/python/interactions_bonded.py +++ b/testsuite/python/interactions_bonded.py @@ -27,7 +27,7 @@ class InteractionsBondedTest(ut.TestCase): system = espressomd.System(box_l=[17.0, 9.0, 8.0]) - np.random.seed(seed=system.seed) + np.random.seed(seed=42) box_l = 10. diff --git a/testsuite/python/interactions_dihedral.py b/testsuite/python/interactions_dihedral.py index 3013d6804a5..207398bb608 100644 --- a/testsuite/python/interactions_dihedral.py +++ b/testsuite/python/interactions_dihedral.py @@ -75,7 +75,7 @@ def dihedral_force(k, n, phase, p1, p2, p3, p4): class InteractionsBondedTest(ut.TestCase): system = espressomd.System(box_l=[1.0, 1.0, 1.0]) - np.random.seed(seed=system.seed) + np.random.seed(seed=42) box_l = 10. diff --git a/testsuite/python/langevin_thermostat.py b/testsuite/python/langevin_thermostat.py index f75296b5f09..ac9188e94f6 100644 --- a/testsuite/python/langevin_thermostat.py +++ b/testsuite/python/langevin_thermostat.py @@ -33,7 +33,6 @@ class LangevinThermostat(ut.TestCase): system = espressomd.System(box_l=[1.0, 1.0, 1.0]) system.cell_system.set_domain_decomposition(use_verlet_lists=True) system.cell_system.skin = 0 - system.seed = range(system.cell_system.get_state()["n_nodes"]) system.periodicity = [0, 0, 0] @classmethod diff --git a/testsuite/python/layered.py b/testsuite/python/layered.py index 9632828cf18..a3ff9b91913 100644 --- a/testsuite/python/layered.py +++ b/testsuite/python/layered.py @@ -23,7 +23,6 @@ class Layered(ut.TestCase): S = espressomd.System(box_l=[1.0, 1.0, 1.0]) - S.seed = S.cell_system.get_state()['n_nodes'] * [1234] def setUp(self): self.S.part.clear() diff --git a/testsuite/python/lb.py b/testsuite/python/lb.py index b2f8d5c408d..9aaf353cb91 100644 --- a/testsuite/python/lb.py +++ b/testsuite/python/lb.py @@ -37,7 +37,6 @@ class TestLB: """ system = espressomd.System(box_l=[1.0, 1.0, 1.0]) - n_nodes = system.cell_system.get_state()["n_nodes"] np.random.seed(1) params = {'int_steps': 15, 'int_times': 20, diff --git a/testsuite/python/lb_density.py b/testsuite/python/lb_density.py index 41bb42121d7..d0a5c0ecde1 100644 --- a/testsuite/python/lb_density.py +++ b/testsuite/python/lb_density.py @@ -46,7 +46,6 @@ class LBMassCommon: system.cell_system.skin = 0.4 * AGRID def prepare(self): - self.system.set_random_state_PRNG() self.system.actors.clear() self.system.actors.add(self.lbf) self.system.thermostat.set_lb(LB_fluid=self.lbf, seed=3, gamma=2.0) diff --git a/testsuite/python/lb_electrohydrodynamics.py b/testsuite/python/lb_electrohydrodynamics.py index 0137bde69c3..55b132b5338 100644 --- a/testsuite/python/lb_electrohydrodynamics.py +++ b/testsuite/python/lb_electrohydrodynamics.py @@ -24,7 +24,6 @@ class LBEHTest(ut.TestCase): from espressomd import lb s = espressomd.System(box_l=[6.0, 6.0, 6.0]) - s.seed = s.cell_system.get_state()['n_nodes'] * [1234] def setUp(self): self.params = {'time_step': 0.01, diff --git a/testsuite/python/mass-and-rinertia_per_particle.py b/testsuite/python/mass-and-rinertia_per_particle.py index 036877bc0cf..38bd60a07f2 100644 --- a/testsuite/python/mass-and-rinertia_per_particle.py +++ b/testsuite/python/mass-and-rinertia_per_particle.py @@ -60,13 +60,7 @@ class ThermoTest(ut.TestCase): @classmethod def setUpClass(cls): - # Handle a random generator seeding - seed1 = 15 - np.random.seed(seed1) - seed2 = 42 - # The Espresso system configuration - cls.system.seed = [ - s * seed2 for s in range(cls.system.cell_system.get_state()["n_nodes"])] + np.random.seed(seed=15) cls.system.cell_system.set_domain_decomposition(use_verlet_lists=True) cls.system.cell_system.skin = 5.0 diff --git a/testsuite/python/nsquare.py b/testsuite/python/nsquare.py index 00987092aec..0d2327c243c 100644 --- a/testsuite/python/nsquare.py +++ b/testsuite/python/nsquare.py @@ -23,7 +23,6 @@ class NSquare(ut.TestCase): S = espressomd.System(box_l=[1.0, 1.0, 1.0]) - S.seed = S.cell_system.get_state()['n_nodes'] * [1234] def setUp(self): self.S.part.clear() diff --git a/testsuite/python/observable_chain.py b/testsuite/python/observable_chain.py index 217da4420b1..ef248ac0206 100644 --- a/testsuite/python/observable_chain.py +++ b/testsuite/python/observable_chain.py @@ -44,7 +44,6 @@ class ObservableTests(ut.TestCase): n_parts = 5 box_l = 5. system = espressomd.System(box_l=3 * [box_l]) - system.seed = system.cell_system.get_state()['n_nodes'] * [1234] system.periodicity = [1, 1, 1] system.time_step = 0.01 system.cell_system.skin = 0.2 * box_l diff --git a/testsuite/python/p3m_gpu.py b/testsuite/python/p3m_gpu.py index 8da8f1b2295..5dfce06cd77 100644 --- a/testsuite/python/p3m_gpu.py +++ b/testsuite/python/p3m_gpu.py @@ -30,7 +30,6 @@ def test(self): from espressomd.electrostatics import P3MGPU es = espressomd.System(box_l=[10.0, 10.0, 10.0]) - es.seed = es.cell_system.get_state()['n_nodes'] * [1234] test_params = {} test_params["prefactor"] = 2 test_params["cao"] = 2 diff --git a/testsuite/python/pairs.py b/testsuite/python/pairs.py index ad93290a664..b8a58003428 100644 --- a/testsuite/python/pairs.py +++ b/testsuite/python/pairs.py @@ -22,7 +22,6 @@ @utx.skipIfMissingFeatures(["LENNARD_JONES"]) class PairTest(ut.TestCase): s = espressomd.System(box_l=[1.0, 1.0, 1.0]) - s.seed = s.cell_system.get_state()['n_nodes'] * [1234] def setUp(self): self.s.time_step = 0.1 diff --git a/testsuite/python/polymer_linear.py b/testsuite/python/polymer_linear.py index 88707e33390..e8c293dbda3 100644 --- a/testsuite/python/polymer_linear.py +++ b/testsuite/python/polymer_linear.py @@ -37,7 +37,6 @@ class LinearPolymerPositions(ut.TestCase): system = espressomd.System(box_l=[box_l, box_l, box_l]) np.random.seed(1234) - system.set_random_state_PRNG() def assertShape(self, positions, n_poly, n_mono): """ diff --git a/testsuite/python/rdf.py b/testsuite/python/rdf.py index ffc21a3edb7..bda17fcddc8 100644 --- a/testsuite/python/rdf.py +++ b/testsuite/python/rdf.py @@ -24,7 +24,6 @@ class RdfTest(ut.TestCase): s = espressomd.System(box_l=[1.0, 1.0, 1.0]) - s.seed = s.cell_system.get_state()['n_nodes'] * [1234] def setUp(self): self.s.box_l = 3 * [10] diff --git a/testsuite/python/reaction_ensemble.py b/testsuite/python/reaction_ensemble.py index bc88ad42813..4b4992ec93e 100644 --- a/testsuite/python/reaction_ensemble.py +++ b/testsuite/python/reaction_ensemble.py @@ -52,7 +52,6 @@ class ReactionEnsembleTest(ut.TestCase): product_coefficients = [1, 1] nubar = 1 system = espressomd.System(box_l=np.ones(3) * (N0 / c0)**(1.0 / 3.0)) - system.seed = system.cell_system.get_state()['n_nodes'] * [67] np.random.seed(69) # make reaction code fully deterministic system.cell_system.skin = 0.4 volume = np.prod(system.box_l) # cuboid box diff --git a/testsuite/python/rescale.py b/testsuite/python/rescale.py index d22b0a7514d..66639946a1a 100644 --- a/testsuite/python/rescale.py +++ b/testsuite/python/rescale.py @@ -27,7 +27,6 @@ class RescaleTest(ut.TestCase): """ s = espressomd.System(box_l=[1.0, 1.0, 1.0]) - s.seed = s.cell_system.get_state()['n_nodes'] * [1234] s.cell_system.skin = 0.0 s.time_step = 0.01 diff --git a/testsuite/python/rigid_bond.py b/testsuite/python/rigid_bond.py index a711a690661..c4f62490a9a 100644 --- a/testsuite/python/rigid_bond.py +++ b/testsuite/python/rigid_bond.py @@ -30,7 +30,6 @@ def test(self): target_acc = 1E-3 tol = 1.2 * target_acc s = espressomd.System(box_l=[1.0, 1.0, 1.0]) - s.seed = s.cell_system.get_state()['n_nodes'] * [1234] s.box_l = [10, 10, 10] s.cell_system.skin = 0.4 s.time_step = 0.01 diff --git a/testsuite/python/rotate_system.py b/testsuite/python/rotate_system.py index b06cd66c301..f2d739edd84 100644 --- a/testsuite/python/rotate_system.py +++ b/testsuite/python/rotate_system.py @@ -28,7 +28,6 @@ class RotateSystemTest(ut.TestCase): s = espressomd.System(box_l=3 * [10.]) - s.seed = s.cell_system.get_state()['n_nodes'] * [1234] def tearDown(self): self.s.part.clear() diff --git a/testsuite/python/rotation_per_particle.py b/testsuite/python/rotation_per_particle.py index 17b6d070432..20d3dbaa0dd 100644 --- a/testsuite/python/rotation_per_particle.py +++ b/testsuite/python/rotation_per_particle.py @@ -25,7 +25,6 @@ @utx.skipIfMissingFeatures("ROTATION") class Rotation(ut.TestCase): s = espressomd.System(box_l=[1.0, 1.0, 1.0]) - s.seed = s.cell_system.get_state()['n_nodes'] * [1234] s.cell_system.skin = 0 s.time_step = 0.01 diff --git a/testsuite/python/rotational-diffusion-aniso.py b/testsuite/python/rotational-diffusion-aniso.py index 9492e87248b..533b545668b 100644 --- a/testsuite/python/rotational-diffusion-aniso.py +++ b/testsuite/python/rotational-diffusion-aniso.py @@ -30,7 +30,6 @@ class RotDiffAniso(ut.TestCase): # Handle for espresso system system = espressomd.System(box_l=[1.0, 1.0, 1.0]) system.cell_system.skin = 5.0 - system.seed = range(system.cell_system.get_state()["n_nodes"]) # The NVT thermostat parameters kT = 0.0 diff --git a/testsuite/python/rotational_inertia.py b/testsuite/python/rotational_inertia.py index 31779801d42..247f6591e36 100644 --- a/testsuite/python/rotational_inertia.py +++ b/testsuite/python/rotational_inertia.py @@ -27,7 +27,6 @@ class RotationalInertia(ut.TestCase): # Handle for espresso system system = espressomd.System(box_l=[1.0, 1.0, 1.0]) system.cell_system.skin = 0 - system.seed = system.cell_system.get_state()['n_nodes'] * [1234] # Particle's angular momentum: initial and ongoing L_0_lab = np.zeros((3)) L_lab = np.zeros((3)) diff --git a/testsuite/python/save_checkpoint.py b/testsuite/python/save_checkpoint.py index c14c8b0a83f..c2c9b7253ab 100644 --- a/testsuite/python/save_checkpoint.py +++ b/testsuite/python/save_checkpoint.py @@ -40,7 +40,6 @@ # use a box with 3 different dimensions system = espressomd.System(box_l=[12.0, 14.0, 16.0]) system.cell_system.skin = 0.1 -system.seed = system.cell_system.get_state()["n_nodes"] * [1234] system.time_step = 0.01 system.min_global_cut = 2.0 diff --git a/testsuite/python/scafacos_dipoles_1d_2d.py b/testsuite/python/scafacos_dipoles_1d_2d.py index a2697d3c747..23ec027c79e 100644 --- a/testsuite/python/scafacos_dipoles_1d_2d.py +++ b/testsuite/python/scafacos_dipoles_1d_2d.py @@ -47,7 +47,6 @@ def test_scafacos(self): skin = 0.5 s = espressomd.System(box_l=[1.0, 1.0, 1.0]) - s.seed = s.cell_system.get_state()['n_nodes'] * [1234] # give Espresso some parameters s.time_step = 0.01 s.cell_system.skin = skin diff --git a/testsuite/python/simple_pore.py b/testsuite/python/simple_pore.py index b21963ca269..f8e06814a59 100644 --- a/testsuite/python/simple_pore.py +++ b/testsuite/python/simple_pore.py @@ -42,7 +42,6 @@ def test_orientation(self): def test_stability(self): s = espressomd.System(box_l=[1.0, 1.0, 1.0]) - s.seed = s.cell_system.get_state()['n_nodes'] * [1234] box_yz = 15. box_x = 20. s.box_l = [box_x, box_yz, box_yz] diff --git a/testsuite/python/tabulated.py b/testsuite/python/tabulated.py index 48f5eb9faeb..535d90b0ac9 100644 --- a/testsuite/python/tabulated.py +++ b/testsuite/python/tabulated.py @@ -24,7 +24,6 @@ class TabulatedTest(ut.TestCase): s = espressomd.System(box_l=[1.0, 1.0, 1.0]) - s.seed = s.cell_system.get_state()['n_nodes'] * [1234] s.box_l = 3 * [10] s.time_step = 0.01 s.cell_system.skin = 0.4 diff --git a/testsuite/python/thermalized_bond.py b/testsuite/python/thermalized_bond.py index 88199361b67..6113bc85bf2 100644 --- a/testsuite/python/thermalized_bond.py +++ b/testsuite/python/thermalized_bond.py @@ -35,7 +35,6 @@ class ThermalizedBond(ut.TestCase): system = espressomd.System(box_l=[box_l] * 3) system.cell_system.set_n_square() system.cell_system.skin = 0.3 - system.seed = range(system.cell_system.get_state()["n_nodes"]) @classmethod def setUpClass(cls): diff --git a/testsuite/python/virtual_sites_relative.py b/testsuite/python/virtual_sites_relative.py index 25a5d37078f..b7a125c7ed7 100644 --- a/testsuite/python/virtual_sites_relative.py +++ b/testsuite/python/virtual_sites_relative.py @@ -30,7 +30,6 @@ @utx.skipIfMissingFeatures("VIRTUAL_SITES_RELATIVE") class VirtualSites(ut.TestCase): system = espressomd.System(box_l=[1.0, 1.0, 1.0]) - system.seed = range(system.cell_system.get_state()["n_nodes"]) np.random.seed(42) diff --git a/testsuite/python/wang_landau_reaction_ensemble.py b/testsuite/python/wang_landau_reaction_ensemble.py index 66ab5452343..6a61f048ffd 100644 --- a/testsuite/python/wang_landau_reaction_ensemble.py +++ b/testsuite/python/wang_landau_reaction_ensemble.py @@ -45,8 +45,7 @@ class ReactionEnsembleTest(ut.TestCase): # Integration parameters # system = espressomd.System(box_l=[box_l, box_l, box_l]) - system.seed = system.cell_system.get_state()['n_nodes'] * [1234] - np.random.seed(seed=system.seed) + np.random.seed(seed=42) system.time_step = 0.01 system.cell_system.skin = 0 system.cell_system.set_n_square(use_verlet_lists=False) diff --git a/testsuite/python/widom_insertion.py b/testsuite/python/widom_insertion.py index 21ba39a4989..4730426c285 100644 --- a/testsuite/python/widom_insertion.py +++ b/testsuite/python/widom_insertion.py @@ -67,7 +67,6 @@ class WidomInsertionTest(ut.TestCase): system = espressomd.System(box_l=np.ones(3) * BOX_L) system.cell_system.set_n_square() - system.seed = system.cell_system.get_state()['n_nodes'] * [2] np.random.seed(69) # make reaction code fully deterministic system.cell_system.skin = 0.4 volume = np.prod(system.box_l) # cuboid box @@ -91,27 +90,21 @@ def setUp(self): default_charges={self.TYPE_HA: self.CHARGE_HA}) def test_widom_insertion(self): - system = WidomInsertionTest.system - Widom = WidomInsertionTest.Widom - target_mu_ex = WidomInsertionTest.target_mu_ex - - system.seed = system.cell_system.get_state()[ - 'n_nodes'] * [np.random.randint(5)] num_samples = 100000 for _ in range(num_samples): # 0 for insertion reaction - Widom.measure_excess_chemical_potential(0) - mu_ex = Widom.measure_excess_chemical_potential(0) - deviation_mu_ex = abs(mu_ex[0] - target_mu_ex) + self.Widom.measure_excess_chemical_potential(0) + mu_ex = self.Widom.measure_excess_chemical_potential(0) + deviation_mu_ex = abs(mu_ex[0] - self.target_mu_ex) # error self.assertLess( deviation_mu_ex - 1e-3, 0.0, - msg="\nExcess chemical potential for single LJ-particle computed via widom insertion gives a wrong value.\n" + msg="\nExcess chemical potential for single LJ-particle computed via Widom insertion gives a wrong value.\n" + " average mu_ex: " + str(mu_ex[0]) + " mu_ex_std_err: " + str(mu_ex[1]) - + " target_mu_ex: " + str(target_mu_ex) + + " target_mu_ex: " + str(self.target_mu_ex) ) diff --git a/testsuite/scripts/importlib_wrapper.py b/testsuite/scripts/importlib_wrapper.py index 6fd77fdd136..12465f941d6 100644 --- a/testsuite/scripts/importlib_wrapper.py +++ b/testsuite/scripts/importlib_wrapper.py @@ -52,7 +52,7 @@ def configure_and_import(filepath, - pass command line arguments during import to emulate shell execution - disable the OpenGL/Mayavi modules if they are not compiled - disable the matplotlib GUI using a text-based backend - - use random seeds for the RNG in NumPy and ESPResSo + - use random seeds for the RNG in NumPy - temporarily move to the directory where the script is located Parameters @@ -112,7 +112,7 @@ def configure_and_import(filepath, # disable OpenGL/Mayavi GUI using MagicMock() if mock_visualizers: code = mock_es_visualization(code) - # use random seeds for ES and NumPy RNGs + # use random seeds for NumPy RNG if random_seeds: code = set_random_seeds(code) # save changes to a new file @@ -261,14 +261,13 @@ class GetPrngSeedEspressomdSystem(ast.NodeVisitor): """ Find all assignments of :class:`espressomd.system.System` in the global namespace. Assignments made in classes or function raise an error. Detect - random seed setup in the numpy and :class:`espressomd.system.System` PRNGs. + random seed setup of the numpy PRNG. """ def __init__(self): self.numpy_random_aliases = set() self.es_system_aliases = set() self.variable_system_aliases = set() - self.system_seeds = [] self.numpy_seeds = [] self.abort_message = None self.error_msg_multi_assign = "Cannot parse {} in a multiple assignment (line {})" @@ -357,33 +356,6 @@ def detect_es_system_instances(self, node): "Cannot process espressomd.System assignments in " + self.abort_message self.variable_system_aliases.add(varname) - def detect_es_system_assign_seed(self, node): - def is_seed(target): - if isinstance(target, ast.Attribute) \ - and hasattr(target.value, "id") \ - and target.value.id in self.variable_system_aliases \ - and target.attr in ("seed", "random_number_generator_state"): - return True - for target in node.targets: - if is_seed(target): - assert len(node.targets) == 1, self.error_msg_multi_assign.format( - "espressomd.System.seed", node.lineno) - assert self.abort_message is None, \ - "Cannot process espressomd.System assignments in " + self.abort_message - self.system_seeds.append( - (node.lineno, target.value.id, target.attr)) - elif isinstance(target, ast.Tuple) and any(map(is_seed, target.elts)): - raise AssertionError(self.error_msg_multi_assign.format( - "espressomd.System.seed", node.lineno)) - - def detect_es_system_expr_seed(self, node): - if hasattr(node.value, "func") and hasattr(node.value.func, "value") \ - and hasattr(node.value.func.value, "id") \ - and node.value.func.value.id in self.variable_system_aliases \ - and node.value.func.attr == "set_random_state_PRNG": - self.system_seeds.append((node.lineno, node.value.func.value.id, - node.value.func.attr)) - def detect_np_random_expr_seed(self, node): if hasattr(node.value, "func") and hasattr(node.value.func, "value") \ and (hasattr(node.value.func.value, "id") and node.value.func.value.id in self.numpy_random_aliases @@ -397,10 +369,8 @@ def detect_np_random_expr_seed(self, node): def visit_Assign(self, node): self.detect_es_system_instances(node) - self.detect_es_system_assign_seed(node) def visit_Expr(self, node): - self.detect_es_system_expr_seed(node) self.detect_np_random_expr_seed(node) def visit_ClassDef(self, node): @@ -421,7 +391,7 @@ def visit_AsyncFunctionDef(self, node): def set_random_seeds(code): """ - Remove random number generator seeds (ESPResSo + numpy), such that + Remove numpy random number generator seeds, such that the sample/tutorial always starts with different random seeds. """ code = protect_ipython_magics(code) @@ -429,13 +399,6 @@ def set_random_seeds(code): visitor = GetPrngSeedEspressomdSystem() visitor.visit(tree) lines = code.split("\n") - # delete ESPResSo system seed - for lineno, varname, seed_attribute in visitor.system_seeds: - old_stmt = varname + "." + seed_attribute - new_stmt = varname + ".set_random_state_PRNG(); _random_seed_es__original" - if seed_attribute == "set_random_state_PRNG": - new_stmt += " = " - lines[lineno - 1] = lines[lineno - 1].replace(old_stmt, new_stmt, 1) # delete explicit NumPy seed for lineno in visitor.numpy_seeds: old_stmt = ".seed" diff --git a/testsuite/scripts/test_importlib_wrapper.py b/testsuite/scripts/test_importlib_wrapper.py index be97c16c2e2..84414349a35 100644 --- a/testsuite/scripts/test_importlib_wrapper.py +++ b/testsuite/scripts/test_importlib_wrapper.py @@ -83,28 +83,12 @@ def test_disable_matplotlib_gui(self): self.assertEqual(str_out, str_exp) def test_set_random_seeds(self): - # ESPResSo seed - str_es_sys = "import espressomd.System as S\nsystem = S(box_l=[1]*3)\n" - str_inp = str_es_sys + "system.set_random_state_PRNG()" - str_exp = str_es_sys + "system.set_random_state_PRNG(); _random_seed_es__original = ()" - str_out = iw.set_random_seeds(str_inp) - self.assertEqual(str_out, str_exp) - str_inp = str_es_sys + "system.random_number_generator_state = 7 * [0]" - str_exp = str_es_sys + "system.set_random_state_PRNG();" + \ - " _random_seed_es__original = 7 * [0]" - str_out = iw.set_random_seeds(str_inp) - self.assertEqual(str_out, str_exp) - str_inp = str_es_sys + "system.seed = 42" - str_exp = str_es_sys + "system.set_random_state_PRNG();" + \ - " _random_seed_es__original = 42" - str_out = iw.set_random_seeds(str_inp) - self.assertEqual(str_out, str_exp) # NumPy seed str_np = "import numpy as np\n" str_lambda = "(lambda *args, **kwargs: None)" - str_inp = str_np + "np.random.seed(seed=system.seed)" + str_inp = str_np + "np.random.seed(seed=42)" str_exp = str_np + "np.random.seed;_random_seed_np = " + \ - str_lambda + "(seed=system.seed)" + str_lambda + "(seed=42)" str_out = iw.set_random_seeds(str_inp) self.assertEqual(str_out, str_exp) str_np = "import numpy.random as npr\n" @@ -349,9 +333,6 @@ def test_prng_seed_espressomd_system_visitor(self): 'sys5 = s2()', 'sys6 = s3()', 'sys7 = s4()', - 'sys3.seed = 5', - 'sys5.random_number_generator_state = 5', - 'sys7.set_random_state_PRNG(5)', 'import numpy as np', 'import numpy.random as npr1', 'from numpy import random as npr2', @@ -370,13 +351,7 @@ def test_prng_seed_espressomd_system_visitor(self): expected_es_sys_objs = set('sys' + str(i) for i in range(1, 8)) self.assertEqual(v.variable_system_aliases, expected_es_sys_objs) # find all seeds setup - expected_es_sys_seeds = [ - (14, 'sys3', 'seed'), - (15, 'sys5', 'random_number_generator_state'), - (16, 'sys7', 'set_random_state_PRNG'), - ] - self.assertEqual(v.system_seeds, expected_es_sys_seeds) - self.assertEqual(v.numpy_seeds, [20, 21, 22]) + self.assertEqual(v.numpy_seeds, [17, 18, 19]) # test exceptions str_es_sys_list = [ 'import espressomd.System', @@ -388,7 +363,6 @@ def test_prng_seed_espressomd_system_visitor(self): 's, var = System(), 5', 'class A:\n\ts = System()', 'def A():\n\ts = System()', - 's = System()\ns.seed, var = 1, 5', ] for str_es_sys in str_es_sys_list: for str_stmt in exception_stmt: