def test_cubic_unit_cell_should_return_cubic_vertices_without_vector_calculation( ): expected_vertices = [[0.00000, 0.00000, 0.00000], [18.6400, 0.00000, 0.00000], [0.00000, 18.6400, 0.00000], [0.00000, 0.00000, 18.6400], [18.6400, 18.6400, 0.00000], [0.00000, 18.6400, 18.6400], [18.6400, 0.00000, 18.6400], [18.6400, 18.6400, 18.6400]] cell = Cell([18.6400, 18.6400, 18.6400, 90.0, 90.0, 90.0]) cell.calculate_vertices() assert np.allclose(cell.vertices, expected_vertices)
def test_triclinic_unit_cell_should_return_triclinic_vectors(): # Parameters for UVARIT_clean from CoRE database and expected results from Avogadro expected_vectors = [[8.40900, 0.00000, 0.00000], [2.09071, 13.32498, 0.00000], [1.04535, 6.66249, 12.41697]] cell = Cell([8.40900, 13.48800, 14.13020, 61.49240, 85.75740, 81.08290]) assert np.allclose(cell.vectors, expected_vectors)
def test_monoclinic_unit_cell_should_return_monoclinic_vectors(): # Parameters for OJAKOA_clean from CoRE database and expected results from Avogadro expected_vectors = [[9.01670, 0.00000, 0.00000], [-3.61984, 14.69194, 0.00000], [0.00000, 0.00000, 16.82840]] cell = Cell([9.01670, 15.13130, 16.82840, 90.00000, 90.00000, 103.84100]) assert np.allclose(cell.vectors, expected_vectors)
def test_hexagonal_unit_cell_should_return_hexagonal_vectors(): # Parameters for cm301726k_si_004_clean from CoRE database and expected results from Avogadro expected_vectors = [[12.57380, 0.00000, 0.00000], [-6.2869, 10.88923, 0.00000], [0.00000, 0.00000, 14.33400]] cell = Cell([12.57380, 12.57380, 14.33400, 90.00000, 90.00000, 120.00000]) assert np.allclose(cell.vectors, expected_vectors)
def test_tetragonal_unit_cell_should_return_tetragonal_vectors(): # Parameters for LAVTOT_clean from CoRE database and expected results from Avogadro expected_vectors = [[10.26700, 0.00000, 0.00000], [0.00000, 10.26700, 0.00000], [0.00000, 0.00000, 14.46200]] cell = Cell([10.26700, 10.26700, 14.46200, 90.0, 90.0, 90.0]) assert np.allclose(cell.vectors, expected_vectors)
def test_cubic_unit_cell_should_return_cubic_vectors(): # Parameters for ECOLEP_clean from CoRE database and expected results from Avogadro expected_vectors = [[18.64000, 0.00000, 0.00000], [0.00000, 18.64000, 0.00000], [0.00000, 0.00000, 18.64000]] cell = Cell([18.64000, 18.64000, 18.64000, 90.0, 90.0, 90.0]) assert np.allclose(cell.vectors, expected_vectors)
def test_trigonal_unit_cell_should_return_correct_cell_volume(): # Parameters for MIHHER_clean from CoRE database and expected results from Avogadro expected_volume = 23506.4 cell = Cell([32.15390, 32.15390, 32.15390, 60.0, 60.0, 60.0]) assert np.isclose(cell.volume, expected_volume) assert np.isclose(cell.frac_volume, cell.volume / (cell.a * cell.b * cell.c))
def test_orthorhombic_unit_cell_should_return_orthorhombic_vectors(): # Parameters for MOGYAI_clean from CoRE database and expected results from Avogadro expected_vectors = [[10.55690, 0.00000, 0.00000], [0.00000, 14.84590, 0.00000], [0.00000, 0.00000, 19.06630]] cell = Cell([10.55690, 14.84590, 19.06630, 90.0, 90.0, 90.0]) assert np.allclose(cell.vectors, expected_vectors)
def test_triclinic_unit_cell_should_return_correct_cell_volume(): # Parameters for UVARIT_clean from CoRE database and expected results from Avogadro expected_volume = 1391.32 cell = Cell([8.40900, 13.48800, 14.13020, 61.49240, 85.75740, 81.08290]) assert np.isclose(cell.volume, expected_volume) assert np.isclose(cell.frac_volume, cell.volume / (cell.a * cell.b * cell.c))
def test_monoclinic_unit_cell_should_return_correct_cell_volume(): # Parameters for OJAKOA_clean from CoRE database and expected results from Avogadro expected_volume = 2229.31 cell = Cell([9.01670, 15.13130, 16.82840, 90.00000, 90.00000, 103.84100]) assert np.isclose(cell.volume, expected_volume) assert np.isclose(cell.frac_volume, cell.volume / (cell.a * cell.b * cell.c))
def test_hexagonal_unit_cell_should_return_correct_cell_volume(): # Parameters for cm301726k_si_004_clean from CoRE database and expected results from Avogadro expected_volume = 1962.6 cell = Cell([12.57380, 12.57380, 14.33400, 90.00000, 90.00000, 120.00000]) assert np.isclose(cell.volume, expected_volume) assert np.isclose(cell.frac_volume, cell.volume / (cell.a * cell.b * cell.c))
def test_trigonal_unit_cell_should_return_trigonal_vectors(): # Parameters for MIHHER_clean from CoRE database and expected results from Avogadro expected_vectors = [[32.15390, 0.00000, 0.00000], [16.07695, 27.84609, 0.00000], [16.07695, 9.28203, 26.25355]] cell = Cell([32.15390, 32.15390, 32.15390, 60.0, 60.0, 60.0]) assert np.allclose(cell.vectors, expected_vectors)
def test_cubic_unit_cell_pbc(): cell = Cell([10, 10, 10, 90.0, 90.0, 90.0]) assert np.allclose([2, 2, 2], cell.car2frac([20, 20, 20])) assert np.allclose([20, 20, 20], cell.frac2car([2, 2, 2]))
def packmol_config(structure_path, gas_path, output_path, num_molecules, boundary_tolerance, a2a_tolerance, supercell): """ Two tolerances: (1) boundary_tolerance is the minimum distance between a gas molecule and one of the planes defining the boundary, (2) a2a_tolerance is the atom-to-atom tolerance defining the minimum distance between any two atoms. """ cell = Cell(supercell) cell.calculate_vertices() pts = cell.vertices # would typically use vertices of (0,1,3), (2,4,5), (0,3,2), (1,6,4), (0,1,2), (3,5,6) # but only need the second in each pair because the planes are parallel. Since the first plane # will always have d = 0, we only need the second plane to define the triclinic bounds. # We can then bound the box using each plane twice, one where the plane > 0 and one where # the plane < d. Since we are normalizing the plane coefficients so that d is equal to the # appropriate unit cell lengths, d should be in units of angstroms. We can then add a tolerance # by just using plane > 1 or plane < d - 1 (for a one angstrom tolerance). plane_coefficients = [] p = Plane(pts[2], pts[4], pts[5]) n = p.d / cell.b # normalize by length of b a, b, c, d = (p.a / n, p.b / n, p.c / n, p.d / n) print("Using plane: %+.2fx %+.2fy %+.2fz = %.2f" % (a, b, c, d)) plane_coefficients += [a, b, c, 0 + boundary_tolerance, a, b, c, d - boundary_tolerance] p = Plane(pts[1], pts[6], pts[4]) n = p.d / cell.a # normalize by length of a a, b, c, d = (p.a / n, p.b / n, p.c / n, p.d / n) print("Using plane: %+.2fx %+.2fy %+.2fz = %.2f" % (a, b, c, d)) plane_coefficients += [a, b, c, 0 + boundary_tolerance, a, b, c, d - boundary_tolerance] p = Plane(pts[3], pts[5], pts[6]) n = p.d / cell.c # normalize by length of c a, b, c, d = (p.a / n, p.b / n, p.c / n, p.d / n) print("Using plane: %+.2fx %+.2fy %+.2fz = %.2f" % (a, b, c, d)) plane_coefficients += [a, b, c, 0 + boundary_tolerance, a, b, c, d - boundary_tolerance] random_seed = random.randint(0,999999999) s = """ tolerance %10.5f seed %d output %s filetype xyz structure %s filetype xyz number 1 fixed 0 0 0 0 0 0 end structure structure %s number %d over plane %10.5f %10.5f %10.5f %10.5f below plane %10.5f %10.5f %10.5f %10.5f over plane %10.5f %10.5f %10.5f %10.5f below plane %10.5f %10.5f %10.5f %10.5f over plane %10.5f %10.5f %10.5f %10.5f below plane %10.5f %10.5f %10.5f %10.5f end structure """ % (a2a_tolerance, random_seed, output_path, structure_path, gas_path, num_molecules, *plane_coefficients) return s
def test_cubic_unit_cell_should_return_correct_cell_volume(): # Parameters for ECOLEP_clean from CoRE database and expected results from Avogadro expected_volume = 6476.46 cell = Cell([18.64000, 18.64000, 18.64000, 90.0, 90.0, 90.0]) assert np.isclose(cell.volume, expected_volume) assert np.isclose(cell.frac_volume, 1)
def test_tetragonal_unit_cell_should_return_correct_cell_volume(): # Parameters for LAVTOT_clean from CoRE database and expected results from Avogadro expected_volume = 1524.46 cell = Cell([10.26700, 10.26700, 14.46200, 90.0, 90.0, 90.0]) assert np.isclose(cell.volume, expected_volume) assert np.isclose(cell.frac_volume, 1)
def test_orthorhombic_unit_cell_should_return_correct_cell_volume(): # Parameters for MOGYAI_clean from CoRE database and expected results from Avogadro expected_volume = 2988.2 cell = Cell([10.55690, 14.84590, 19.06630, 90.0, 90.0, 90.0]) assert np.isclose(cell.volume, expected_volume) assert np.isclose(cell.frac_volume, 1)