File: test_h2o_xas_xes.py

package info (click to toggle)
python-ase 3.21.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,936 kB
  • sloc: python: 122,428; xml: 946; makefile: 111; javascript: 47
file content (193 lines) | stat: -rw-r--r-- 4,930 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
def test_h2o_xas_xes():
    import ase.calculators.demon as demon
    from ase import Atoms
    #from ase.optimize import BFGS
    import numpy as np

    # d = 0.9575
    d = 0.9775
    # t = np.pi / 180 * 104.51
    t = np.pi / 180 * 110.51
    atoms = Atoms('H2O',
                  positions=[(d, 0, 0),
                             (d * np.cos(t), d * np.sin(t), 0),
                             (0, 0, 0)])

    # set up deMon calculator
    basis = {'all': 'aug-cc-pvdz'}
    auxis = {'all': 'GEN-A2*'}


    # XAS hch
    input_arguments = {'GRID': 'FINE',
                       'MOMODIFY': [[1,0],
                                    [1,0.5]], 
                       'CHARGE':0,
                       'XRAY':'XAS'}

    calc = demon.Demon(basis=basis,
                       auxis=auxis,
                       scftype='UKS TOL=1.0E-6 CDF=1.0E-5',
                       guess='TB',
                       xc=['BLYP', 'BASIS'],
                       input_arguments=input_arguments)

    atoms.calc = calc

    # energy
    print('XAS hch')
    print('energy')
    energy = atoms.get_potential_energy()
    print(energy)
    ref = -1815.44708987 #-469.604737006
    error = np.sqrt(np.sum((energy - ref)**2))
    print('diff from reference:')
    print(error)

    tol = 1.0e-4
    assert(error < tol)

    # check xas
    results = calc.results

    print('xray, first transition, energy')
    value =results['xray']['E_trans'][0]
    print(value)
    ref = 539.410015646
    error = np.sqrt(np.sum((value- ref)**2))
    print('diff from reference:')
    print(error)

    tol = 1.0e-4
    assert(error < tol)

    print('xray, first transition, transition dipole moments')
    value = results['xray']['trans_dip'][0]
    print(value)
    ref = np.array([1.11921906e-02, 1.61393975e-02, 1.70983631e-07])
    error = np.sqrt(np.sum((value- ref)**2))
    print('diff from reference:')
    print(error)

    tol = 1.0e-4
    assert(error < tol)


    # XES
    input_arguments = {'GRID': 'FINE',
                       'CHARGE':0,
                       'XRAY':'XES ALPHA=1-1'}

    calc = demon.Demon(basis=basis,
                       auxis=auxis,
                       scftype='UKS TOL=1.0E-6 CDF=1.0E-5',
                       guess='TB',
                       xc=['BLYP', 'BASIS'],
                       input_arguments=input_arguments)

    atoms.calc = calc

    # energy
    print('')
    print('XES')
    print('energy')
    energy = atoms.get_potential_energy()
    print(energy)
    ref = -2079.6635944 
    error = np.sqrt(np.sum((energy - ref)**2))
    print('diff from reference:')
    print(error)

    tol = 1.0e-4
    assert(error < tol)

    # check xes
    results = calc.results

    print('xray, first transition, energy')
    value =results['xray']['E_trans'][0]
    print(value)
    ref = 486.862715888 #539.410015646
    error = np.sqrt(np.sum((value- ref)**2))
    print('diff from reference:')
    print(error)

    tol = 1.0e-4
    assert(error < tol)

    print('xray, first transition, transition dipole moments')
    value = results['xray']['trans_dip'][0]
    print(value)
    ref = np.array([6.50528073e-03, 9.37895253e-03, 6.99433480e-09])
    error = np.sqrt(np.sum((value- ref)**2))
    print('diff from reference:')
    print(error)

    tol = 1.0e-4
    assert(error < tol)

    # and XPS
    input_arguments = {'GRID': 'FINE',
                       'MOMODIFY': [[1,0],
                                    [1,0.0]], 
                       'CHARGE':0,
                       'XRAY':'XAS'}

    calc = demon.Demon(basis=basis,
                       auxis=auxis,
                       scftype='UKS TOL=1.0E-6 CDF=1.0E-5',
                       guess='TB',
                       xc=['BLYP', 'BASIS'],
                       input_arguments=input_arguments)

    atoms.calc = calc


    # energy
    print('')
    print('XPS')
    print('energy')
    energy = atoms.get_potential_energy()
    print(energy)
    ref = -1536.9295935
    error = np.sqrt(np.sum((energy - ref)**2))
    print('diff from reference:')
    print(error)

    tol = 1.0e-4
    assert(error < tol)

    # First excited state
    input_arguments = {'GRID': 'FINE',
                       'MOMODIFY': [[1,0],
                                    [1,0.0]], 
                       'CHARGE':-1}

    calc = demon.Demon(basis=basis,
                       auxis=auxis,
                       scftype='UKS TOL=1.0E-6 CDF=1.0E-5',
                       guess='TB',
                       xc=['BLYP', 'BASIS'],
                       input_arguments=input_arguments)

    atoms.calc = calc


    # energy
    print('')
    print('EXC')
    print('energy')
    energy = atoms.get_potential_energy()
    print(energy)
    ref = -1543.18092135
    error = np.sqrt(np.sum((energy - ref)**2))
    print('diff from reference:')
    print(error)

    tol = 1.0e-4
    assert(error < tol)


    print('tests passed')