Esempio n. 1
0
def test_head_correction():
    dr = 0.05
    cutoff = 8
    r = np.arange(0, 2.5, dr)
    V_prev = mie(r, 1, 1)
    V = mie(r, 2, 1)
    V[:cutoff] = np.inf

    linear_V = head_correction(r, np.copy(V), V_prev, "linear")
    assert not np.isnan(linear_V).any() and not np.isinf(linear_V).any()
    assert all(linear_V[cutoff:] == V[cutoff:])

    exp_V = head_correction(r, np.copy(V), V_prev, "exponential")
    assert not np.isnan(exp_V).any() and not np.isinf(exp_V).any()
    assert all(exp_V[cutoff:] == V[cutoff:])
    assert exp_V[0] > linear_V[0]
Esempio n. 2
0
def test_select_pairs():
    """Test selecting pairs with exclusions"""
    pair = Pair('tail', 'tail', potential=mie(r, 1.0, 1.0))
    alpha = 0.5
    state_dir = get_fn('state0/')
    state = State(k_B*T, state_dir=state_dir,
                  top_file=get_fn('2chains.hoomdxml'), name='state0')
    rdf_filename = get_fn('state0/target-rdf.txt')
    rdf = np.loadtxt(rdf_filename)
    pair.add_state(state, rdf, alpha)
    pair.select_pairs(state, exclude_up_to=3)
    assert pair.states[state]['pair_indices'].shape[0] == 162
Esempio n. 3
0
def init_state(state_number):
    pair = Pair('0', '1', potential=mie(r, 1.0, 1.0))
    topology_filename = get_fn('final.hoomdxml')
    traj_filename = get_fn('state{0}/query.dcd'.format(state_number))
    t = md.load(traj_filename, top=topology_filename)
    pair_list = t.top.select_pairs('name "0"', 'name "1"')
    rdf_filename = get_fn('state{0}/target-rdf.txt'.format(state_number))
    rdf = np.loadtxt(rdf_filename)
    alpha = 0.5
    state_dir = get_fn('state{0}/'.format(state_number))
    state = State(k_B*T, state_dir=state_dir,
                  top_file='sys.hoomdxml', name='state0')
    pair.add_state(state, rdf, alpha, pair_list)
    return pair, state, rdf
Esempio n. 4
0
def test_select_pairs():
    """Test selecting pairs with exclusions"""
    pair = Pair('tail', 'tail', potential=mie(r, 1.0, 1.0))
    alpha = 0.5
    state_dir = get_fn('state0/')
    state = State(k_B * T,
                  state_dir=state_dir,
                  top_file=get_fn('2chains.hoomdxml'),
                  name='state0')
    rdf_filename = get_fn('state0/target-rdf.txt')
    rdf = np.loadtxt(rdf_filename)
    pair.add_state(state, rdf, alpha)
    pair.select_pairs(state, exclude_up_to=3)
    assert pair.states[state]['pair_indices'].shape[0] == 162
Esempio n. 5
0
def init_state(state_number):
    pair = Pair('0', '1', potential=mie(r, 1.0, 1.0))
    topology_filename = get_fn('final.hoomdxml')
    traj_filename = get_fn('state{0}/query.dcd'.format(state_number))
    t = md.load(traj_filename, top=topology_filename)
    pair_list = t.top.select_pairs('name "0"', 'name "1"')
    rdf_filename = get_fn('state{0}/target-rdf.txt'.format(state_number))
    rdf = np.loadtxt(rdf_filename)
    alpha = 0.5
    state_dir = get_fn('state{0}/'.format(state_number))
    state = State(k_B * T,
                  state_dir=state_dir,
                  top_file='sys.hoomdxml',
                  name='state0')
    pair.add_state(state, rdf, alpha, pair_list)
    return pair, state, rdf
Esempio n. 6
0
 def init_state(self, state_number):
     pair = Pair("0", "1", potential=mie(r, 1.0, 1.0))
     topology_filename = get_fn("final.hoomdxml")
     traj_filename = get_fn(f"state{state_number}/query.dcd")
     t = md.load(traj_filename, top=topology_filename)
     pair_list = t.top.select_pairs('name "0"', 'name "1"')
     rdf_filename = get_fn(f"state{state_number}/target-rdf.txt")
     rdf = np.loadtxt(rdf_filename)
     alpha = 0.5
     state_dir = get_fn(f"state{state_number}/")
     state = State(k_B * T,
                   state_dir=state_dir,
                   traj_file=traj_filename,
                   top_file="sys.hoomdxml",
                   name="state0")
     pair.add_state(state, rdf, alpha, pair_list)
     return pair, state, rdf
Esempio n. 7
0
 def test_select_pairs(self):
     """Test selecting pairs with exclusions"""
     pair = Pair("tail", "tail", potential=mie(r, 1.0, 1.0))
     alpha = 0.5
     state_dir = get_fn("state0/")
     state = State(
         k_B * T,
         state_dir=state_dir,
         top_file=get_fn("2chains.hoomdxml"),
         traj_file="query.dcd",
         name="state0",
     )
     rdf_filename = get_fn("state0/target-rdf.txt")
     rdf = np.loadtxt(rdf_filename)
     pair.add_state(state, rdf, alpha)
     pair.select_pairs(state, exclude_up_to=3)
     assert pair.states[state]["pair_indices"].shape[0] == 162
Esempio n. 8
0
 def test_save_table_potential(self):
     pair = Pair("A", "B", potential=mie(r, 1.0, 1.0))
     pair.potential_file = tempfile.mkstemp()[1]
     pair.save_table_potential(r, dr)
     assert os.path.isfile(pair.potential_file)
Esempio n. 9
0
def test_save_table_potential():
    pair = Pair('A', 'B', potential=mie(r, 1.0, 1.0))
    pair.potential_file = tempfile.mkstemp()[1]
    pair.save_table_potential(r, dr)
    assert os.path.isfile(pair.potential_file)
Esempio n. 10
0
def test_tail_correction():
    dr = 0.05
    r = np.arange(0, 2.5, dr)
    V = mie(r, 1, 1)
    smooth_V = tail_correction(r, V, r_switch=2.25)
    assert smooth_V[-1] == 0.0
Esempio n. 11
0
def test_tail_correction():
    dr = 0.05
    r = np.arange(0, 2.5, dr)
    V = mie(r, 1, 1)
    smooth_V = tail_correction(r, V, r_switch=2.25)
    assert smooth_V[-1] == 0.0