Ejemplo n.º 1
0
def test_volume():
    coordinates = mc_lj_potential.generate_initial_state(method='random',
                                                         num_particles=100,
                                                         box_length=5.0)
    mcs = mc_lj_potential.Box(coordinates=coordinates, box_length=5.0)

    assert mcs.volume == 125
Ejemplo n.º 2
0
def test_generate_intial_state_length():
    """
    Test the number of coordinates generated by generate_initial_state() function is the same as required.
    """
    coordinates = mc_lj_potential.generate_initial_state("random",
                                                         num_particles=100,
                                                         box_length=10.0)
    assert len(coordinates) == 100
Ejemplo n.º 3
0
def test_generate_initial_state_coords():
    """
    Test the coordinates generated by random method, will always pass as long as generated coordinates value is acceptsble.
    """
    np.random.seed(123)
    coordinates = mc_lj_potential.generate_initial_state("random", num_particles = 100, box_length = 10.0)
    try:
        assert np.isclose(coordinates[0][0], -6.46469)
    finally:
        np.random.seed()
Ejemplo n.º 4
0
def test_num_particles():
    """
    Test if the property of num_particles is true.
    """

    coordinates = mc_lj_potential.generate_initial_state(method='random',
                                                         num_particles=100,
                                                         box_length=10.0)
    mcs = mc_lj_potential.Box(coordinates=coordinates, box_length=10.0)

    assert mcs.num_particles == 100
Ejemplo n.º 5
0
def mcs():
    """
    Set up the fixture to have a general MCState that can be callable for all tests of different energy functions.
    """ 
    current_directory = os.path.dirname(os.path.abspath(__file__))
    file_path = os.path.join(current_directory, "sample_config.xyz")
    coordinates = mc_lj_potential.generate_initial_state(method = "file", file_name=file_path)
    box_length = 10.0
    cutoff = 3.0
    box = mc_lj_potential.Box(box_length=box_length, coordinates=coordinates)
    mcs = mc_lj_potential.MCState(box, cutoff = cutoff)
    return mcs
Ejemplo n.º 6
0
import mc_lj_potential as mc
import numpy as np
np.random.seed(123)
num_particles = 100
box_length = 10.0
coordinates = mc.generate_initial_state(method='random',
                                        num_particles=num_particles,
                                        box_length=box_length)
#print(coordinates)
box = mc.Box(coordinates=coordinates, box_length=box_length)
#print(box.coordinates)
mcs = mc.MCState(box1=box, cutoff=3.0)
total_pair_energy = mcs.calculate_total_pair_energy()
#print(total_pair_energy)
#print(mcs.calculate_tail_correction())
#print(mcs.calculate_unit_energy())
#print(mcs.get_particle_energy(0))