Beispiel #1
0
def get_part_caffeine_grimme_15A():
    # Get a system and define scalings
    system = get_system_caffeine()
    nlist = NeighborList(system)
    scalings = Scalings(system, 0.0, 1.0, 0.5)
    # Initialize (random) parameters
    r0_table = {
        1: 1.001*angstrom,
        6: 1.452*angstrom,
        7: 1.397*angstrom,
        8: 1.342*angstrom,
    }
    c6_table = {
        1: 0.14*1e-3*kjmol*nanometer**6,
        6: 1.75*1e-3*kjmol*nanometer**6,
        7: 1.23*1e-3*kjmol*nanometer**6,
        8: 0.70*1e-3*kjmol*nanometer**6,
    }
    r0s = np.zeros(24, float)
    c6s = np.zeros(24, float)
    for i in xrange(system.natom):
        r0s[i] = r0_table[system.numbers[i]]
        c6s[i] = c6_table[system.numbers[i]]
    # Construct the pair potential and part
    pair_pot = PairPotGrimme(r0s, c6s, 15*angstrom)
    part_pair = ForcePartPair(system, nlist, scalings, pair_pot)
    # The pair function
    def pair_fn(i, j, d):
        r0 = (r0s[i]+r0s[j])
        c6 = np.sqrt(c6s[i]*c6s[j])
        return -1.1/(1.0 + np.exp(-20.0*(d/r0-1.0)))*c6/d**6
    return system, nlist, scalings, part_pair, pair_fn
Beispiel #2
0
def get_part_caffeine_mm3_15A():
    # Get a system and define scalings
    system = get_system_caffeine()
    nlist = NeighborList(system)
    scalings = Scalings(system, 0.0, 1.0, 0.5)
    # Initialize (random) parameters
    rminhalf_table = {
        1: 0.2245*angstrom,
        6: 1.6000*angstrom,
        7: 1.7000*angstrom,
        8: 1.7682*angstrom
    }
    epsilon_table = {
        1: -0.0460*kcalmol,
        6: -0.2357*kcalmol,
        7: -0.1970*kcalmol,
        8: -0.1521*kcalmol,
    }
    sigmas = np.zeros(24, float)
    epsilons = np.zeros(24, float)
    onlypaulis = np.zeros(24, np.int32)
    for i in xrange(system.natom):
        sigmas[i] = rminhalf_table[system.numbers[i]]*(2.0)**(5.0/6.0)
        epsilons[i] = epsilon_table[system.numbers[i]]
    # Construct the pair potential and part
    pair_pot = PairPotMM3(sigmas, epsilons, onlypaulis, 15*angstrom)
    part_pair = ForcePartPair(system, nlist, scalings, pair_pot)
    # The pair function
    def pair_fn(i, j, d):
        sigma = sigmas[i]+sigmas[j]
        epsilon = np.sqrt(epsilons[i]*epsilons[j])
        x = (sigma/d)
        return epsilon*(1.84e5*np.exp(-12.0/x)-2.25*x**6)
    return system, nlist, scalings, part_pair, pair_fn
Beispiel #3
0
def get_part_caffeine_exprep_5A(amp_mix, amp_mix_coeff, b_mix, b_mix_coeff):
    # Get a system and define scalings
    system = get_system_caffeine()
    nlist = NeighborList(system)
    scalings = Scalings(system, 0.0, 1.0, 1.0)
    # Initialize (random) parameters
    amps = np.array([2.35, 410.0, 0.0, 421.0])
    bs = np.array([4.46, 4.43, 0.0, 4.41])/angstrom
    # Allocate some arrays for the pair potential
    assert len(system.ffatypes) == 4
    amp_cross = np.zeros((4, 4), float)
    b_cross = np.zeros((4, 4), float)
    # Construct the pair potential and part
    pair_pot = PairPotExpRep(
        system.ffatype_ids, amp_cross, b_cross, 5*angstrom, None,
        amps, amp_mix, amp_mix_coeff, bs, b_mix, b_mix_coeff,
    )
    assert abs(np.diag(pair_pot.amp_cross) - amps).max() < 1e-10
    assert abs(np.diag(pair_pot.b_cross) - bs).max() < 1e-10
    part_pair = ForcePartPair(system, nlist, scalings, pair_pot)
    # The pair function
    def pair_fn(i0, i1, d):
        amp0 = amps[system.ffatype_ids[i0]]
        amp1 = amps[system.ffatype_ids[i1]]
        b0 = bs[system.ffatype_ids[i0]]
        b1 = bs[system.ffatype_ids[i1]]
        if amp_mix == 0:
            amp = np.sqrt(amp0*amp1)
        elif amp0 == 0.0 or amp1 == 0.0:
            amp = 0.0
        elif amp_mix == 1:
            cor = 1-amp_mix_coeff*abs(np.log(amp0/amp1))
            amp = np.exp( (np.log(amp0)+np.log(amp1))/2*cor )
        else:
            raise NotImplementedError
        if b_mix == 0:
            b = (b0+b1)/2
        elif amp0 == 0.0 or amp1 == 0.0:
            b = 0.0
        elif b_mix == 1:
            cor = 1-b_mix_coeff*abs(np.log(amp0/amp1))
            b = (b0+b1)/2*cor
        else:
            raise NotImplementedError
        if amp == 0.0 or b == 0.0:
            energy = 0.0
        else:
            energy = amp*np.exp(-b*d)
        return energy
    return system, nlist, scalings, part_pair, pair_fn
Beispiel #4
0
def get_part_caffeine_ei2_10A():
    # Get a system and define scalings
    system = get_system_caffeine()
    nlist = NeighborList(system)
    scalings = Scalings(system, 0.0, 1.0, 0.5)
    dielectric = 1.0
    # Initialize (random) parameters
    system.charges = np.random.uniform(0, 1, system.natom)
    system.charges -= system.charges.sum()
    # Construct the pair potential and part
    rcut = 10*angstrom
    alpha = 0.0
    pair_pot = PairPotEI(system.charges, alpha, rcut, dielectric=dielectric)
    part_pair = ForcePartPair(system, nlist, scalings, pair_pot)
    # The pair function
    def pair_fn(i, j, d):
        return system.charges[i]*system.charges[j]*erfc(alpha*d)/d
    return system, nlist, scalings, part_pair, pair_fn
Beispiel #5
0
def test_atselect_caffeine():
    system = get_system_caffeine()
    assert (system.get_indexes('C&=3%H')==np.array([11, 12, 13])).all()
    assert (system.get_indexes('C&=2%N')==np.array([7, 9, 10])).all()
    assert (system.get_indexes('O')==np.array([0, 1])).all()
    assert (system.get_indexes('O&=1')==np.array([0, 1])).all()
    assert (system.get_indexes('O&=1%C')==np.array([0, 1])).all()
    assert (system.get_indexes('O&=1%(C&=3)')==np.array([0, 1])).all()
    assert (system.get_indexes('O&=1%(C&=2%N)')==np.array([1])).all()
    assert (system.get_indexes('O&=1%(C&=1%C)')==np.array([0])).all()
    assert (system.get_indexes('C&=3')==np.array([6, 7, 8, 9, 10])).all()
    assert (system.get_indexes('C&=1%C')==np.array([7, 8])).all()
    assert (system.get_indexes('C&>1%C')==np.array([6])).all()
    assert (system.get_indexes('C&<2%C')==np.array([7, 8, 9, 10, 11, 12, 13])).all()
    assert (system.get_indexes('N&=2%C&=2')==np.array([5])).all()
    assert (system.get_indexes('N&!=2')==np.array([2, 3, 4])).all()
    assert (system.get_indexes('N|O')==np.array([0, 1, 2, 3, 4, 5])).all()
    assert (system.get_indexes('N|8')==np.array([0, 1, 2, 3, 4, 5])).all()
    assert (system.get_indexes('!0')==np.arange(system.natom)).all()
Beispiel #6
0
def test_atselect_caffeine():
    system = get_system_caffeine()
    assert (system.get_indexes('C&=3%H')==np.array([11, 12, 13])).all()
    assert (system.get_indexes('C&=2%N')==np.array([7, 9, 10])).all()
    assert (system.get_indexes('O')==np.array([0, 1])).all()
    assert (system.get_indexes('O&=1')==np.array([0, 1])).all()
    assert (system.get_indexes('O&=1%C')==np.array([0, 1])).all()
    assert (system.get_indexes('O&=1%(C&=3)')==np.array([0, 1])).all()
    assert (system.get_indexes('O&=1%(C&=2%N)')==np.array([1])).all()
    assert (system.get_indexes('O&=1%(C&=1%C)')==np.array([0])).all()
    assert (system.get_indexes('C&=3')==np.array([6, 7, 8, 9, 10])).all()
    assert (system.get_indexes('C&=1%C')==np.array([7, 8])).all()
    assert (system.get_indexes('C&>1%C')==np.array([6])).all()
    assert (system.get_indexes('C&<2%C')==np.array([7, 8, 9, 10, 11, 12, 13])).all()
    assert (system.get_indexes('N&=2%C&=2')==np.array([5])).all()
    assert (system.get_indexes('N&!=2')==np.array([2, 3, 4])).all()
    assert (system.get_indexes('N|O')==np.array([0, 1, 2, 3, 4, 5])).all()
    assert (system.get_indexes('N|8')==np.array([0, 1, 2, 3, 4, 5])).all()
    assert (system.get_indexes('!0')==np.arange(system.natom)).all()
Beispiel #7
0
def get_part_caffeine_ei3_10A():
    # Get a system and define scalings
    system = get_system_caffeine()
    nlist = NeighborList(system)
    scalings = Scalings(system, 0.0, 1.0, 0.5)
    # Initialize (random) parameters
    system.charges = np.random.uniform(0, 1, system.natom)
    system.charges -= system.charges.sum()
    #Set the atomic radii
    radii = np.random.uniform(0,1,system.natom)
    # Construct the pair potential and part
    rcut = 10*angstrom
    alpha = 0.0
    pair_pot = PairPotEI(system.charges, alpha, rcut, radii=radii)
    part_pair = ForcePartPair(system, nlist, scalings, pair_pot)
    # The pair function
    def pair_fn(i, j, d):
        r_ij = np.sqrt( pair_pot.radii[i]**2 + pair_pot.radii[j]**2 )
        return system.charges[i]*system.charges[j]*erf(d/r_ij)/d
    return system, nlist, scalings, part_pair, pair_fn
Beispiel #8
0
def get_part_caffeine_dampdisp_9A():
    # Get a system and define scalings
    system = get_system_caffeine()
    nlist = NeighborList(system)
    scalings = Scalings(system, 0.0, 1.0, 1.0)
    # Initialize (very random) parameters
    c6s = np.array([2.5, 27.0, 18.0, 13.0])
    bs = np.array([2.5, 2.0, 0.0, 1.8])
    vols = np.array([5, 3, 4, 5])*angstrom**3
    # Allocate some arrays
    assert system.nffatype == 4
    c6_cross = np.zeros((4, 4), float)
    b_cross = np.zeros((4, 4), float)
    # Construct the pair potential and part
    pair_pot = PairPotDampDisp(system.ffatype_ids, c6_cross, b_cross, 9*angstrom, None, c6s, bs, vols)
    part_pair = ForcePartPair(system, nlist, scalings, pair_pot)
    # The pair function
    def pair_fn(i0, i1, d):
        c60 = c6s[system.ffatype_ids[i0]]
        c61 = c6s[system.ffatype_ids[i1]]
        b0 = bs[system.ffatype_ids[i0]]
        b1 = bs[system.ffatype_ids[i1]]
        vol0 = vols[system.ffatype_ids[i0]]
        vol1 = vols[system.ffatype_ids[i1]]
        ratio = vol0/vol1
        c6 = 2*c60*c61/(c60/ratio+c61*ratio)
        if b0 != 0 and b1 != 0:
            b = 0.5*(b0+b1)
            damp = 0
            fac = 1
            for k in xrange(7):
                damp += (b*d)**k/fac
                fac *= k+1
            damp = 1 - np.exp(-b*d)*damp
            return -c6/d**6*damp
        else:
            damp = 1
            return -c6/d**6
    return system, nlist, scalings, part_pair, pair_fn
Beispiel #9
0
def test_iter_paths3():
    system = get_system_caffeine()
    paths = set(iter_paths(system, 18, 19, 2))
    assert all(len(path) == 3 for path in paths)
    assert len(paths) == 1
    assert paths == set([(18, 12, 19)])
Beispiel #10
0
def test_iter_paths2():
    system = get_system_caffeine()
    paths = set(iter_paths(system, 13, 5, 5))
    assert all(len(path) == 6 for path in paths)
    assert len(paths) == 2
    assert paths == set([(13, 4, 8, 6, 7, 5), (13, 4, 9, 2, 7, 5)])
Beispiel #11
0
def test_iter_paths1():
    system = get_system_caffeine()
    paths = set(iter_paths(system, 2, 8, 3))
    assert all(len(path) == 4 for path in paths)
    assert len(paths) == 2
    assert paths == set([(2, 7, 6, 8), (2, 9, 4, 8)])
Beispiel #12
0
def test_topology_caffeine():
    system = get_system_caffeine()
    check_topology_slow(system)
Beispiel #13
0
def test_iter_paths3():
    system = get_system_caffeine()
    paths = set(iter_paths(system, 18, 19, 2))
    assert all(len(path) == 3 for path in paths)
    assert len(paths) == 1
    assert paths == set([(18, 12, 19)])
Beispiel #14
0
def test_iter_paths2():
    system = get_system_caffeine()
    paths = set(iter_paths(system, 13, 5, 5))
    assert all(len(path) == 6 for path in paths)
    assert len(paths) == 2
    assert paths == set([(13, 4, 8, 6, 7, 5), (13, 4, 9, 2, 7, 5)])
Beispiel #15
0
def test_iter_paths1():
    system = get_system_caffeine()
    paths = set(iter_paths(system, 2, 8, 3))
    assert all(len(path) == 4 for path in paths)
    assert len(paths) == 2
    assert paths == set([(2, 7, 6, 8), (2, 9, 4, 8)])
Beispiel #16
0
def test_topology_caffeine():
    system = get_system_caffeine()
    check_topology_slow(system)