コード例 #1
0
ファイル: test_dof.py プロジェクト: molmod/yaff
def test_strain_3d():
    check_ff(get_ff_bks(), StrainCellDOF, 6, {})
コード例 #2
0
ファイル: test_harmonic.py プロジェクト: molmod/yaff
def test_bulk_elastic_bks():
    ff = get_ff_bks(smooth_ei=True, reci_ei='ignore')
    system = ff.system
    lcs = np.array([
        [1, 1, 0],
        [0, 0, 1],
    ])
    system.align_cell(lcs)
    ff.update_rvecs(system.cell.rvecs)
    opt = QNOptimizer(FullCellDOF(ff, gpos_rms=1e-6, grvecs_rms=1e-6))
    opt.run()
    rvecs0 = system.cell.rvecs.copy()
    vol0 = system.cell.volume
    pos0 = system.pos.copy()
    e0 = ff.compute()
    elastic = estimate_elastic(ff)
    assert abs(pos0 - system.pos).max() < 1e-10
    assert abs(rvecs0 - system.cell.rvecs).max() < 1e-10
    assert abs(vol0 - system.cell.volume) < 1e-10
    assert elastic.shape == (6, 6)
    # Make estimates of the same matrix elements with a simplistic approach
    eps = 1e-3

    from nose.plugins.skip import SkipTest
    raise SkipTest('Double check elastic constant implementation')

    # A) stretch in the Z direction
    deform = np.array([1, 1, 1-eps])
    rvecs1 = rvecs0*deform
    pos1 = pos0*deform
    ff.update_rvecs(rvecs1)
    ff.update_pos(pos1)
    opt = QNOptimizer(CartesianDOF(ff, gpos_rms=1e-6))
    opt.run()
    e1 = ff.compute()
    deform = np.array([1, 1, 1+eps])
    rvecs2 = rvecs0*deform
    pos2 = pos0*deform
    ff.update_rvecs(rvecs2)
    ff.update_pos(pos2)
    opt = QNOptimizer(CartesianDOF(ff, gpos_rms=1e-6))
    opt.run()
    e2 = ff.compute()
    C = (e1 + e2 - 2*e0)/(eps**2)/vol0
    assert abs(C - elastic[2,2]) < C*0.02

    # B) stretch in the X direction
    deform = np.array([1-eps, 1, 1])
    rvecs1 = rvecs0*deform
    pos1 = pos0*deform
    ff.update_rvecs(rvecs1)
    ff.update_pos(pos1)
    opt = QNOptimizer(CartesianDOF(ff, gpos_rms=1e-6))
    opt.run()
    e1 = ff.compute()
    deform = np.array([1+eps, 1, 1])
    rvecs2 = rvecs0*deform
    pos2 = pos0*deform
    ff.update_rvecs(rvecs2)
    ff.update_pos(pos2)
    opt = QNOptimizer(CartesianDOF(ff, gpos_rms=1e-6))
    opt.run()
    e2 = ff.compute()
    C = (e1 + e2 - 2*e0)/(eps**2)/vol0
    assert abs(C - elastic[0,0]) < C*0.02
コード例 #3
0
ファイル: test_dof.py プロジェクト: molmod/yaff
def test_delta_cartesian_partial():
    dof = CartesianDOF(get_ff_bks(), select=[0, 1, 2])
    dof.check_delta()
コード例 #4
0
ファイル: test_dof.py プロジェクト: molmod/yaff
def test_full_3d():
    check_ff(get_ff_bks(), FullCellDOF, 9, {})
コード例 #5
0
ファイル: test_dof.py プロジェクト: molmod/yaff
def test_fixedbc_3d():
    check_ff(get_ff_bks(align_ax=True), FixedBCDOF, 1, {})
コード例 #6
0
ファイル: test_dof.py プロジェクト: molmod/yaff
def test_delta_cartesian():
    dof = CartesianDOF(get_ff_bks())
    dof.check_delta()
コード例 #7
0
ファイル: test_dof.py プロジェクト: molmod/yaff
def test_iso_3d():
    check_ff(get_ff_bks(), IsoCellDOF, 1, {})
コード例 #8
0
ファイル: test_dof.py プロジェクト: molmod/yaff
def test_aniso_3d():
    check_ff(get_ff_bks(), AnisoCellDOF, 3, {})
コード例 #9
0
ファイル: test_dof.py プロジェクト: boegel/yaff
def test_fixedbc_3d():
    check_ff(get_ff_bks(align_ax=True), FixedBCDOF, 1, {})
コード例 #10
0
ファイル: test_dof.py プロジェクト: boegel/yaff
def test_iso_3d():
    check_ff(get_ff_bks(), IsoCellDOF, 1, {})
コード例 #11
0
ファイル: test_dof.py プロジェクト: boegel/yaff
def test_aniso_3d():
    check_ff(get_ff_bks(), AnisoCellDOF, 3, {})