1import numpy as np 2 3gammas = [ 4 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 5 0.0005412, 0.0005412, 0.0008843, 0.0191694, 0.0206316, 0.0206316, 6 0.0019424, 0.0019424, 0.0067566, 0.0548967, 0.0506115, 0.0506115, 7 0.0062204, 0.0062204, 0.0088148, 0.0426150, 0.0417223, 0.0417223, 8 0.0016263, 0.0016263, 0.0017293, 0.0279509, 0.0289259, 0.0289259, 9 0.0097926, 0.0097926, 0.0170092, 0.0438828, 0.0523105, 0.0523105, 10 0.0035542, 0.0035542, 0.0135109, 0.0623533, 0.0343746, 0.0343746, 11 0.0073140, 0.0073140, 0.0289659, 0.5006760, 0.5077932, 0.5077932, 12 0.0016144, 0.0016144, 0.0126326, 0.2731933, 0.2791702, 0.2791702, 13 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 14 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 15 0.0023304, 0.0026469, 0.0052513, 0.0209641, 0.0220092, 0.0234752, 16 0.0035532, 0.0038158, 0.0087882, 0.0276654, 0.0315055, 0.0286975, 17 0.0345193, 0.0277533, 0.0495734, 0.0511798, 0.0465938, 0.0436605, 18 0.0071705, 0.0081615, 0.0139063, 0.0204058, 0.0307320, 0.0237855, 19 0.0202095, 0.0197716, 0.0316074, 0.0402461, 0.0438103, 0.0394924, 20 0.0171448, 0.0176446, 0.0567310, 0.0930479, 0.0570520, 0.0622142, 21 0.0292639, 0.0328821, 0.0667957, 0.2541887, 0.4592188, 0.4234131, 22 0.0104887, 0.0179753, 0.0827533, 0.2659557, 0.3242633, 0.3189804, 23 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000] 24gammas_sigma = [ 25 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 26 0.00046029, 0.00046029, 0.00071545, 0.02242054, 0.01975435, 0.01975435, 27 0.00143860, 0.00143860, 0.00715263, 0.05481156, 0.04396936, 0.04396936, 28 0.00826301, 0.00826301, 0.00950813, 0.04304817, 0.04400210, 0.04400210, 29 0.00203560, 0.00203560, 0.00207048, 0.02226551, 0.03531839, 0.03531839, 30 0.00746195, 0.00746195, 0.01268396, 0.02380441, 0.03074892, 0.03074892, 31 0.00389360, 0.00389360, 0.01154058, 0.05602348, 0.04034627, 0.04034627, 32 0.00642767, 0.00642767, 0.02338437, 0.43710790, 0.48306584, 0.48306584, 33 0.00291728, 0.00291728, 0.11718631, 0.84620157, 0.80881708, 0.80881708, 34 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 35 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 36 0.00224835, 0.00288498, 0.00554574, 0.02261273, 0.02349047, 0.02647988, 37 0.00330612, 0.00430468, 0.00975355, 0.02954525, 0.03242621, 0.03052183, 38 0.03210358, 0.02583317, 0.04906091, 0.04609366, 0.04064508, 0.04250035, 39 0.00888799, 0.00936948, 0.01541312, 0.02079095, 0.03001210, 0.02721119, 40 0.02593986, 0.02559304, 0.04760672, 0.04958274, 0.04942973, 0.03703768, 41 0.01005313, 0.01125217, 0.05423798, 0.10135670, 0.06021902, 0.09005459, 42 0.02358822, 0.03737522, 0.06633807, 0.22190369, 0.41562743, 0.32601504, 43 0.01240071, 0.02372173, 0.20217767, 0.49239981, 0.52883866, 0.50769018, 44 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000] 45gammas_class1 = [ 46 0.00000000, 0.00000000, 0.00000000, -0.00000000, 0.00000000, 0.00000000, 47 0.00053387, 0.00053387, 0.00086230, 0.01894313, 0.02034210, 0.02034210, 48 0.00155506, 0.00155506, 0.00260125, 0.01821681, 0.01820381, 0.01820381, 49 0.00571765, 0.00571765, 0.00544460, 0.01325570, 0.01118428, 0.01118428, 50 0.00016153, 0.00016153, 0.00032679, 0.00020002, 0.00020927, 0.00020927, 51 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 52 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 53 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 54 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 55 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 56 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 57 0.00233036, 0.00264690, 0.00525130, 0.02096414, 0.02200915, 0.02347515, 58 0.00297698, 0.00348529, 0.00638118, 0.01776255, 0.02740917, 0.02217207, 59 0.03234423, 0.02580162, 0.03682891, 0.03904463, 0.01942315, 0.02072384, 60 0.00004097, 0.00005101, 0.00007457, 0.00003508, 0.00004210, 0.00003803, 61 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 62 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 63 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 64 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 65 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000] 66gammas_class2 = [ 67 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 68 0.00000728, 0.00000728, 0.00002201, 0.00022624, 0.00028946, 0.00028946, 69 0.00038736, 0.00038736, 0.00415534, 0.03667993, 0.03240766, 0.03240766, 70 0.00050274, 0.00050274, 0.00337024, 0.02935928, 0.03053801, 0.03053801, 71 0.00146473, 0.00146473, 0.00140248, 0.02775086, 0.02871662, 0.02871662, 72 0.00979262, 0.00979262, 0.01700920, 0.04388280, 0.05231049, 0.05231049, 73 0.00355424, 0.00355424, 0.01351094, 0.06235333, 0.03437465, 0.03437465, 74 0.00731397, 0.00731397, 0.02896588, 0.50067605, 0.50779324, 0.50779324, 75 0.00161440, 0.00161440, 0.01263256, 0.27319333, 0.27917018, 0.27917018, 76 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 77 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 78 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 79 0.00057618, 0.00033051, 0.00240702, 0.00990280, 0.00409632, 0.00652547, 80 0.00217505, 0.00195163, 0.01274449, 0.01213516, 0.02717067, 0.02293662, 81 0.00712953, 0.00811051, 0.01383178, 0.02037067, 0.03068992, 0.02374747, 82 0.02020952, 0.01977157, 0.03160744, 0.04024612, 0.04381027, 0.03949241, 83 0.01714475, 0.01764459, 0.05673104, 0.09304789, 0.05705200, 0.06221421, 84 0.02926385, 0.03288210, 0.06679574, 0.25418868, 0.45921877, 0.42341309, 85 0.01048868, 0.01797532, 0.08275328, 0.26595568, 0.32426329, 0.31898043, 86 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000] 87freq_points = [0.0, 3.41024688, 6.82049376, 10.23074063, 13.64098751, 88 17.05123439, 20.46148127, 23.87172814, 27.28197502, 30.6922219] 89freq_points_sigma = [ 90 0.0, 3.45491354, 6.90982709, 10.36474063, 13.81965418, 91 17.27456772, 20.72948127, 24.18439481, 27.63930835, 31.09422190] 92 93detailed_gamma = [0.00000000, 0.00653193, 0.02492913, 0.01682092, 0.01001680, 94 0.02181888, 0.01858641, 0.16208762, 0.09598706, 0.00000000] 95 96 97def test_imag_self_energy_npoints(si_pbesol): 98 si_pbesol.mesh_numbers = [9, 9, 9] 99 si_pbesol.init_phph_interaction() 100 _fpoints, _gammas = si_pbesol.run_imag_self_energy( 101 [1, 103], 102 [300, ], 103 num_frequency_points=10) 104 np.testing.assert_allclose( 105 gammas, np.swapaxes(_gammas, -1, -2).ravel(), atol=1e-2) 106 np.testing.assert_allclose( 107 freq_points, _fpoints.ravel(), atol=1e-5) 108 109 110def test_imag_self_energy_npoints_with_sigma(si_pbesol): 111 si_pbesol.sigmas = [0.1, ] 112 si_pbesol.mesh_numbers = [9, 9, 9] 113 si_pbesol.init_phph_interaction() 114 _fpoints, _gammas = si_pbesol.run_imag_self_energy( 115 [1, 103], 116 [300, ], 117 num_frequency_points=10) 118 # for _g_line in np.swapaxes(_gammas, -1, -2).reshape(-1, 6): 119 # print("".join(["%.8f, " % g for g in _g_line])) 120 # print("".join(["%.8f, " % f for f in _fpoints])) 121 np.testing.assert_allclose( 122 gammas_sigma, np.swapaxes(_gammas, -1, -2).ravel(), atol=1e-2) 123 np.testing.assert_allclose( 124 freq_points_sigma, _fpoints.ravel(), atol=1e-5) 125 si_pbesol.sigmas = None 126 127 128def test_imag_self_energy_freq_points(si_pbesol): 129 si_pbesol.mesh_numbers = [9, 9, 9] 130 si_pbesol.init_phph_interaction() 131 _fpoints, _gammas = si_pbesol.run_imag_self_energy( 132 [1, 103], 133 [300, ], 134 frequency_points=freq_points) 135 np.testing.assert_allclose( 136 gammas, np.swapaxes(_gammas, -1, -2).ravel(), atol=1e-2) 137 np.testing.assert_allclose( 138 freq_points, _fpoints.ravel(), atol=1e-5) 139 140 141def test_imag_self_energy_detailed(si_pbesol): 142 si_pbesol.mesh_numbers = [9, 9, 9] 143 si_pbesol.init_phph_interaction() 144 _fpoints, _gammas, _detailed_gammas = si_pbesol.run_imag_self_energy( 145 [1, ], 146 [300, ], 147 frequency_points=freq_points, 148 keep_gamma_detail=True) 149 np.testing.assert_allclose( 150 detailed_gamma, 151 _detailed_gammas[0][0, 0].sum(axis=(1, 2, 3, 4)), 152 atol=1e-2) 153 154 155def test_imag_self_energy_scat_class1(si_pbesol): 156 si_pbesol.mesh_numbers = [9, 9, 9] 157 si_pbesol.init_phph_interaction() 158 _fpoints, _gammas = si_pbesol.run_imag_self_energy( 159 [1, 103], 160 [300, ], 161 frequency_points=freq_points, 162 scattering_event_class=1) 163 # for line in si_pbesol.gammas.reshape(-1, 6): 164 # print(("%10.8f, " * 6) % tuple(line)) 165 np.testing.assert_allclose( 166 gammas_class1, np.swapaxes(_gammas, -1, -2).ravel(), atol=1e-2) 167 168 169def test_imag_self_energy_scat_class2(si_pbesol): 170 si_pbesol.mesh_numbers = [9, 9, 9] 171 si_pbesol.init_phph_interaction() 172 _fpoints, _gammas = si_pbesol.run_imag_self_energy( 173 [1, 103], 174 [300, ], 175 frequency_points=freq_points, 176 scattering_event_class=2) 177 # for line in si_pbesol.gammas.reshape(-1, 6): 178 # print(("%10.8f, " * 6) % tuple(line)) 179 np.testing.assert_allclose( 180 gammas_class2, np.swapaxes(_gammas, -1, -2).ravel(), atol=1e-2) 181