File: test_rng.py

package info (click to toggle)
python-ase 3.26.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,484 kB
  • sloc: python: 148,112; xml: 2,728; makefile: 110; javascript: 47
file content (32 lines) | stat: -rw-r--r-- 696 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# fmt: off
"""Tests for legacy and modern NumPy PRNGs."""
import numpy as np
import pytest

from ase.build import bulk
from ase.calculators.emt import EMT
from ase.md import Andersen
from ase.units import fs


@pytest.fixture(name='atoms')
def _fixture_atoms():
    atoms = bulk('Cu') * (2, 2, 2)
    atoms.calc = EMT()
    return atoms


@pytest.mark.parametrize(
    'rng',
    [np.random.RandomState(0), np.random.default_rng(42)],
)
def test_andersen(atoms, rng):
    """Test legacy and modern NumPy PRNGs for `Andersen`."""
    with Andersen(
        atoms,
        timestep=1.0 / fs,
        temperature_K=1000.0,
        andersen_prob=0.01,
        rng=rng,
    ) as md:
        md.run(5)