Exemple #1
0
def test_generate_initial_coordinates_random_error(method, options, error):
    """
    Test failure for generate initial state - we are not giving specific directions for how to do this, so they may write several functions.
    """
    with pytest.raises(error):
        mc.generate_initial_coordinates(method=method,
                                        num_particles=options["num_particles"],
                                        box_length=options["box_length"])
Exemple #2
0
def nist_file():
    current_directory = os.path.dirname(os.path.abspath(__file__))
    nist_file = os.path.join(current_directory, '..', 'data',
                             'nist_sample_config1.txt')
    coordinates = mc.generate_initial_coordinates(method='file',
                                                  fname=nist_file)
    return coordinates, nist_file
Exemple #3
0
def test_generate_initial_coordinates_random():
    test_particles = 100
    box_length = 10
    coords, box_length = mc.generate_initial_coordinates(
        method='random', num_particles=test_particles, box_length=box_length)
    assert test_particles == len(coords)
    assert box_length == 10

    # Check that coords are within bounds
    max_coord = np.max(coords)
    assert box_length / 2 > max_coord, "Coordinates found outside box."

    min_coord = np.min(coords)
    assert -box_length / 2 < min_coord
Exemple #4
0
def test_generate_initial_state_file_error(method, filename, error):
    """
    Test failure for generate initial state - we are not giving specific directions for how to do this, so they may write several functions.
    """
    with pytest.raises(error):
        mc.generate_initial_coordinates(method=method, fname=filename)