diff --git a/phono3py/phonon3/displacement_fc3.py b/phono3py/phonon3/displacement_fc3.py index 7fcfd721..f1bdb7be 100644 --- a/phono3py/phonon3/displacement_fc3.py +++ b/phono3py/phonon3/displacement_fc3.py @@ -76,7 +76,9 @@ def direction_to_displacement(direction_dataset, lattice = supercell.cell.T new_dataset = {} new_dataset['natom'] = len(supercell) - new_dataset['duplicates'] = duplicates + + if duplicates: + new_dataset['duplicates'] = duplicates if cutoff_distance is not None: new_dataset['cutoff_distance'] = cutoff_distance @@ -333,28 +335,73 @@ def _get_orbits(atom_index, cell, site_symmetry, symprec=1e-5): def _find_duplicates(direction_dataset): - direction_sets = [] - id_offset = len(direction_dataset) + 1 + direction_sets = {} + idx = len(direction_dataset) + 1 + pair_idx = {} # (List index of direction_sets + id_offset + 1) gives the displacement id. # This id is stamped in direction_to_displacement by the sequence of # the loops. Therefore the same system of the loops should be used here. for direction1 in direction_dataset: - number1 = direction1['number'] + n1 = direction1['number'] d1 = direction1['direction'] for directions2 in direction1['second_atoms']: - number2 = directions2['number'] - for d2 in directions2['directions']: - direction_sets.append([number1, number2] + d1 + d2) - - direction_sets = np.array(direction_sets) - flip_sets = direction_sets[:, [1, 0, 5, 6, 7, 2, 3, 4]] - _duplucates = [] - for i, dset in enumerate(direction_sets): - eq_indices = np.where(np.abs(flip_sets - dset).sum(axis=1) == 0)[0] + n2 = directions2['number'] + if (n1, n2) not in direction_sets: + direction_sets[(n1, n2)] = [] + pair_idx[(n1, n2)] = [] + for i, d2 in enumerate(directions2['directions']): + direction_sets[(n1, n2)].append(d1 + d2) + pair_idx[(n1, n2)].append(idx + i) + idx += len(directions2['directions']) + + duplucates = [] + done = [] + for i, direction1 in enumerate(direction_dataset): + n1 = direction1['number'] + for directions2 in direction1['second_atoms']: + n2 = directions2['number'] + if (n2 > n1 and (n2, n1) not in done and + (n2, n1) in direction_sets): + done.append((n2, n1)) + duplucates += _compare( + n1, n2, + direction_sets[(n1, n2)], direction_sets[(n2, n1)], + pair_idx[(n1, n2)], pair_idx[(n2, n1)]) + + done = [] + for i, direction1 in enumerate(direction_dataset): + n1 = direction1['number'] + for directions2 in direction1['second_atoms']: + n2 = directions2['number'] + if n1 == n2 and n1 not in done: + done.append(n1) + duplucates += _compare_opposite( + n1, + direction_sets[(n1, n1)], + pair_idx[(n1, n1)]) + + return duplucates + + +def _compare(n1, n2, dset1, dset2, pidx1, pidx2): + flip_sets = np.array(dset2)[:, [3, 4, 5, 0, 1, 2]] + duplucates = [] + + for i, d1 in enumerate(dset1): + eq_indices = np.where(np.abs(flip_sets - d1).sum(axis=1) == 0)[0] + if len(eq_indices) > 0: + duplucates += [[pidx2[j], pidx1[i]] for j in eq_indices] + + return [[i, j] for (i, j) in duplucates if i > j] + + +def _compare_opposite(n1, dset1, pidx1): + flip_sets = np.array(dset1)[:, [3, 4, 5, 0, 1, 2]] + duplucates = [] + for i, d1 in enumerate(dset1): + eq_indices = np.where(np.abs(flip_sets + d1).sum(axis=1) == 0)[0] if len(eq_indices) > 0: - _duplucates += [[i + id_offset, j] for j in eq_indices + id_offset] - if dset[0] == dset[1] and (dset[2:5] + dset[5:8] == 0).all(): - _duplucates.append([i + id_offset, 0]) + duplucates += [[pidx1[j], 0] for j in eq_indices] - return [[i, j] for (i, j) in _duplucates if i > j] + return [[i, j] for (i, j) in duplucates if i > j] diff --git a/test/AgNO2_cell.yaml b/test/AgNO2_cell.yaml index e1190658..6adfe8c9 100644 --- a/test/AgNO2_cell.yaml +++ b/test/AgNO2_cell.yaml @@ -1,200 +1,32 @@ lattice: -- [ 9.8130133395493626, 0.0000000000000000, 0.0000000000000000 ] # a -- [ 0.0000000000000000, 12.9607729652407464, 0.0000000000000000 ] # b -- [ 0.0000000000000000, 0.0000000000000000, 9.9776294309342557 ] # c +- [ 3.2918783299999999, 0.0000000000000000, 0.0000000000000000 ] # a +- [ 0.0000000000000000, 6.4164678799999999, 0.0000000000000000 ] # b +- [ 0.0000000000000000, 0.0000000000000000, 4.9969270100000003 ] # c points: -- symbol: N # 1 -> 1 - coordinates: [ 0.0010190549685383, 0.2500000000000000, 0.1952475607335603 ] -- symbol: N # 2 -> 2 - coordinates: [ 0.3333333333333333, 0.2500000000000000, 0.1952475607335603 ] -- symbol: N # 3 -> 3 - coordinates: [ 0.6666666666666666, 0.2500000000000000, 0.1952475607335603 ] -- symbol: N # 4 -> 4 - coordinates: [ 0.0000000000000000, 0.7500000000000000, 0.1952475607335603 ] -- symbol: N # 5 -> 5 - coordinates: [ 0.3333333333333333, 0.7500000000000000, 0.1952475607335603 ] -- symbol: N # 6 -> 6 - coordinates: [ 0.6666666666666666, 0.7500000000000000, 0.1952475607335603 ] -- symbol: N # 7 -> 7 - coordinates: [ 0.0000000000000000, 0.2500000000000000, 0.6952475607335603 ] -- symbol: N # 8 -> 8 - coordinates: [ 0.3333333333333333, 0.2500000000000000, 0.6952475607335603 ] -- symbol: N # 9 -> 9 - coordinates: [ 0.6666666666666666, 0.2500000000000000, 0.6952475607335603 ] -- symbol: N # 10 -> 10 - coordinates: [ 0.0000000000000000, 0.7500000000000000, 0.6952475607335603 ] -- symbol: N # 11 -> 11 - coordinates: [ 0.3333333333333333, 0.7500000000000000, 0.6952475607335603 ] -- symbol: N # 12 -> 12 - coordinates: [ 0.6666666666666666, 0.7500000000000000, 0.6952475607335603 ] -- symbol: O # 13 -> 25 - coordinates: [ 0.0000000000000000, 0.3318936741729317, 0.2635067655175194 ] -- symbol: O # 14 -> 26 - coordinates: [ 0.3333333333333333, 0.3318936741729317, 0.2635067655175194 ] -- symbol: O # 15 -> 27 - coordinates: [ 0.6666666666666666, 0.3318936741729317, 0.2635067655175194 ] -- symbol: O # 16 -> 28 - coordinates: [ 0.0000000000000000, 0.8318936741729317, 0.2635067655175194 ] -- symbol: O # 17 -> 29 - coordinates: [ 0.3333333333333333, 0.8318936741729317, 0.2635067655175194 ] -- symbol: O # 18 -> 30 - coordinates: [ 0.6666666666666666, 0.8318936741729317, 0.2635067655175194 ] -- symbol: O # 19 -> 31 - coordinates: [ 0.0000000000000000, 0.3318936741729317, 0.7635067655175194 ] -- symbol: O # 20 -> 32 - coordinates: [ 0.3333333333333333, 0.3318936741729317, 0.7635067655175194 ] -- symbol: O # 21 -> 33 - coordinates: [ 0.6666666666666666, 0.3318936741729317, 0.7635067655175194 ] -- symbol: O # 22 -> 34 - coordinates: [ 0.0000000000000000, 0.8318936741729317, 0.7635067655175194 ] -- symbol: O # 23 -> 35 - coordinates: [ 0.3333333333333333, 0.8318936741729317, 0.7635067655175194 ] -- symbol: O # 24 -> 36 - coordinates: [ 0.6666666666666666, 0.8318936741729317, 0.7635067655175194 ] -- symbol: O # 25 -> 37 - coordinates: [ 0.0000000000000000, 0.1681063258270684, 0.2635067655175194 ] -- symbol: O # 26 -> 38 - coordinates: [ 0.3333333333333333, 0.1681063258270684, 0.2635067655175194 ] -- symbol: O # 27 -> 39 - coordinates: [ 0.6666666666666666, 0.1681063258270684, 0.2635067655175194 ] -- symbol: O # 28 -> 40 - coordinates: [ 0.0000000000000000, 0.6681063258270684, 0.2635067655175194 ] -- symbol: O # 29 -> 41 - coordinates: [ 0.3333333333333333, 0.6681063258270684, 0.2635067655175194 ] -- symbol: O # 30 -> 42 - coordinates: [ 0.6666666666666666, 0.6681063258270684, 0.2635067655175194 ] -- symbol: O # 31 -> 43 - coordinates: [ 0.0000000000000000, 0.1681063258270684, 0.7635067655175194 ] -- symbol: O # 32 -> 44 - coordinates: [ 0.3333333333333333, 0.1681063258270684, 0.7635067655175194 ] -- symbol: O # 33 -> 45 - coordinates: [ 0.6666666666666666, 0.1681063258270684, 0.7635067655175194 ] -- symbol: O # 34 -> 46 - coordinates: [ 0.0000000000000000, 0.6681063258270684, 0.7635067655175194 ] -- symbol: O # 35 -> 47 - coordinates: [ 0.3333333333333333, 0.6681063258270684, 0.7635067655175194 ] -- symbol: O # 36 -> 48 - coordinates: [ 0.6666666666666666, 0.6681063258270684, 0.7635067655175194 ] -- symbol: Ag # 37 -> 73 - coordinates: [ 0.0000000000000000, 0.2500000000000000, 0.4777389082314037 ] -- symbol: Ag # 38 -> 74 - coordinates: [ 0.3333333333333333, 0.2500000000000000, 0.4777389082314037 ] -- symbol: Ag # 39 -> 75 - coordinates: [ 0.6666666666666666, 0.2500000000000000, 0.4777389082314037 ] -- symbol: Ag # 40 -> 76 - coordinates: [ 0.0000000000000000, 0.7500000000000000, 0.4777389082314037 ] -- symbol: Ag # 41 -> 77 - coordinates: [ 0.3333333333333333, 0.7500000000000000, 0.4777389082314037 ] -- symbol: Ag # 42 -> 78 - coordinates: [ 0.6666666666666666, 0.7500000000000000, 0.4777389082314037 ] -- symbol: Ag # 43 -> 79 - coordinates: [ 0.0000000000000000, 0.2500000000000000, 0.9777389082314037 ] -- symbol: Ag # 44 -> 80 - coordinates: [ 0.3333333333333333, 0.2500000000000000, 0.9777389082314037 ] -- symbol: Ag # 45 -> 81 - coordinates: [ 0.6666666666666666, 0.2500000000000000, 0.9777389082314037 ] -- symbol: Ag # 46 -> 82 - coordinates: [ 0.0000000000000000, 0.7500000000000000, 0.9777389082314037 ] -- symbol: Ag # 47 -> 83 - coordinates: [ 0.3333333333333333, 0.7500000000000000, 0.9777389082314037 ] -- symbol: Ag # 48 -> 84 - coordinates: [ 0.6666666666666666, 0.7500000000000000, 0.9777389082314037 ] -- symbol: N # 49 -> 13 - coordinates: [ 0.1666666666666667, 0.0000000000000000, 0.4452475607335603 ] -- symbol: N # 50 -> 14 - coordinates: [ 0.5000000000000000, 0.0000000000000000, 0.4452475607335603 ] -- symbol: N # 51 -> 15 - coordinates: [ 0.8333333333333334, 0.0000000000000000, 0.4452475607335603 ] -- symbol: N # 52 -> 16 - coordinates: [ 0.1666666666666667, 0.5000000000000000, 0.4452475607335603 ] -- symbol: N # 53 -> 17 - coordinates: [ 0.5000000000000000, 0.5000000000000000, 0.4452475607335603 ] -- symbol: N # 54 -> 18 - coordinates: [ 0.8333333333333334, 0.5000000000000000, 0.4452475607335603 ] -- symbol: N # 55 -> 19 - coordinates: [ 0.1666666666666667, 0.0000000000000000, 0.9452475607335603 ] -- symbol: N # 56 -> 20 - coordinates: [ 0.5000000000000000, 0.0000000000000000, 0.9452475607335603 ] -- symbol: N # 57 -> 21 - coordinates: [ 0.8333333333333334, 0.0000000000000000, 0.9452475607335603 ] -- symbol: N # 58 -> 22 - coordinates: [ 0.1666666666666667, 0.5000000000000000, 0.9452475607335603 ] -- symbol: N # 59 -> 23 - coordinates: [ 0.5000000000000000, 0.5000000000000000, 0.9452475607335603 ] -- symbol: N # 60 -> 24 - coordinates: [ 0.8333333333333334, 0.5000000000000000, 0.9452475607335603 ] -- symbol: O # 61 -> 49 - coordinates: [ 0.1666666666666667, 0.0818936741729317, 0.0135067655175194 ] -- symbol: O # 62 -> 50 - coordinates: [ 0.5000000000000000, 0.0818936741729317, 0.0135067655175194 ] -- symbol: O # 63 -> 51 - coordinates: [ 0.8333333333333334, 0.0818936741729317, 0.0135067655175194 ] -- symbol: O # 64 -> 52 - coordinates: [ 0.1666666666666667, 0.5818936741729317, 0.0135067655175194 ] -- symbol: O # 65 -> 53 - coordinates: [ 0.5000000000000000, 0.5818936741729317, 0.0135067655175194 ] -- symbol: O # 66 -> 54 - coordinates: [ 0.8333333333333334, 0.5818936741729317, 0.0135067655175194 ] -- symbol: O # 67 -> 55 - coordinates: [ 0.1666666666666667, 0.0818936741729317, 0.5135067655175194 ] -- symbol: O # 68 -> 56 - coordinates: [ 0.5000000000000000, 0.0818936741729317, 0.5135067655175194 ] -- symbol: O # 69 -> 57 - coordinates: [ 0.8333333333333334, 0.0818936741729317, 0.5135067655175194 ] -- symbol: O # 70 -> 58 - coordinates: [ 0.1666666666666667, 0.5818936741729317, 0.5135067655175194 ] -- symbol: O # 71 -> 59 - coordinates: [ 0.5000000000000000, 0.5818936741729317, 0.5135067655175194 ] -- symbol: O # 72 -> 60 - coordinates: [ 0.8333333333333334, 0.5818936741729317, 0.5135067655175194 ] -- symbol: O # 73 -> 61 - coordinates: [ 0.1666666666666667, 0.4181063258270684, 0.0135067655175194 ] -- symbol: O # 74 -> 62 - coordinates: [ 0.5000000000000000, 0.4181063258270684, 0.0135067655175194 ] -- symbol: O # 75 -> 63 - coordinates: [ 0.8333333333333334, 0.4181063258270684, 0.0135067655175194 ] -- symbol: O # 76 -> 64 - coordinates: [ 0.1666666666666667, 0.9181063258270683, 0.0135067655175194 ] -- symbol: O # 77 -> 65 - coordinates: [ 0.5000000000000000, 0.9181063258270683, 0.0135067655175194 ] -- symbol: O # 78 -> 66 - coordinates: [ 0.8333333333333334, 0.9181063258270683, 0.0135067655175194 ] -- symbol: O # 79 -> 67 - coordinates: [ 0.1666666666666667, 0.4181063258270684, 0.5135067655175194 ] -- symbol: O # 80 -> 68 - coordinates: [ 0.5000000000000000, 0.4181063258270684, 0.5135067655175194 ] -- symbol: O # 81 -> 69 - coordinates: [ 0.8333333333333334, 0.4181063258270684, 0.5135067655175194 ] -- symbol: O # 82 -> 70 - coordinates: [ 0.1666666666666667, 0.9181063258270683, 0.5135067655175194 ] -- symbol: O # 83 -> 71 - coordinates: [ 0.5000000000000000, 0.9181063258270683, 0.5135067655175194 ] -- symbol: O # 84 -> 72 - coordinates: [ 0.8333333333333334, 0.9181063258270683, 0.5135067655175194 ] -- symbol: Ag # 85 -> 85 - coordinates: [ 0.1666666666666667, 0.0000000000000000, 0.2277389082314037 ] -- symbol: Ag # 86 -> 86 - coordinates: [ 0.5000000000000000, 0.0000000000000000, 0.2277389082314037 ] -- symbol: Ag # 87 -> 87 - coordinates: [ 0.8333333333333334, 0.0000000000000000, 0.2277389082314037 ] -- symbol: Ag # 88 -> 88 - coordinates: [ 0.1666666666666667, 0.5000000000000000, 0.2277389082314037 ] -- symbol: Ag # 89 -> 89 - coordinates: [ 0.5000000000000000, 0.5000000000000000, 0.2277389082314037 ] -- symbol: Ag # 90 -> 90 - coordinates: [ 0.8333333333333334, 0.5000000000000000, 0.2277389082314037 ] -- symbol: Ag # 91 -> 91 - coordinates: [ 0.1666666666666667, 0.0000000000000000, 0.7277389082314037 ] -- symbol: Ag # 92 -> 92 - coordinates: [ 0.5000000000000000, 0.0000000000000000, 0.7277389082314037 ] -- symbol: Ag # 93 -> 93 - coordinates: [ 0.8333333333333334, 0.0000000000000000, 0.7277389082314037 ] -- symbol: Ag # 94 -> 94 - coordinates: [ 0.1666666666666667, 0.5000000000000000, 0.7277389082314037 ] -- symbol: Ag # 95 -> 95 - coordinates: [ 0.5000000000000000, 0.5000000000000000, 0.7277389082314037 ] -- symbol: Ag # 96 -> 96 - coordinates: [ 0.8333333333333334, 0.5000000000000000, 0.7277389082314037 ] +- symbol: N # 1 + coordinates: [ 0.5000000000000000, 0.5000000000000000, 0.1095444300000000 ] + mass: 14.006700 +- symbol: N # 2 + coordinates: [ 0.0000000000000000, 0.0000000000000000, 0.6095444300000000 ] + mass: 14.006700 +- symbol: O # 3 + coordinates: [ 0.5000000000000000, 0.6654353800000000, 0.9730617300000000 ] + mass: 15.999400 +- symbol: O # 4 + coordinates: [ 0.5000000000000000, 0.3345646200000000, 0.9730617300000000 ] + mass: 15.999400 +- symbol: O # 5 + coordinates: [ 0.0000000000000000, 0.1654353800000000, 0.4730617300000000 ] + mass: 15.999400 +- symbol: O # 6 + coordinates: [ 0.0000000000000000, 0.8345646200000000, 0.4730617300000000 ] + mass: 15.999400 +- symbol: Ag # 7 + coordinates: [ 0.5000000000000000, 0.5000000000000000, 0.5443321400000000 ] + mass: 107.868200 +- symbol: Ag # 8 + coordinates: [ 0.0000000000000000, 0.0000000000000000, 0.0443321400000000 ] + mass: 107.868200 poscar_order: - 1 - 2 @@ -204,91 +36,3 @@ poscar_order: - 6 - 7 - 8 -- 9 -- 10 -- 11 -- 12 -- 49 -- 50 -- 51 -- 52 -- 53 -- 54 -- 55 -- 56 -- 57 -- 58 -- 59 -- 60 -- 13 -- 14 -- 15 -- 16 -- 17 -- 18 -- 19 -- 20 -- 21 -- 22 -- 23 -- 24 -- 25 -- 26 -- 27 -- 28 -- 29 -- 30 -- 31 -- 32 -- 33 -- 34 -- 35 -- 36 -- 61 -- 62 -- 63 -- 64 -- 65 -- 66 -- 67 -- 68 -- 69 -- 70 -- 71 -- 72 -- 73 -- 74 -- 75 -- 76 -- 77 -- 78 -- 79 -- 80 -- 81 -- 82 -- 83 -- 84 -- 37 -- 38 -- 39 -- 40 -- 41 -- 42 -- 43 -- 44 -- 45 -- 46 -- 47 -- 48 -- 85 -- 86 -- 87 -- 88 -- 89 -- 90 -- 91 -- 92 -- 93 -- 94 -- 95 -- 96 \ No newline at end of file