Skip to content

Commit 45fa397

Browse files
Merge branch 'master' into fix/test-aiida-sssp
2 parents b174b3b + a048fa8 commit 45fa397

8 files changed

Lines changed: 399 additions & 360 deletions

File tree

.github/workflows/python-testsuite.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ jobs:
1313
build:
1414

1515
runs-on: ubuntu-latest
16-
16+
1717
strategy:
1818
matrix:
1919
python-version: [3.8]
20-
20+
2121
services:
2222
rabbitmq:
2323
image: rabbitmq:latest
@@ -38,6 +38,7 @@ jobs:
3838
pip install flake8 pytest~=6.0 pgtest~=1.3 aiida-core~=2.3 aiida-quantumespresso~=4.3
3939
if [ ${{matrix.python-version}} -eq 2.7 ]; then pip install -r requirements2.txt;
4040
else pip install -r requirements.txt; fi
41+
aiida-pseudo install
4142
4243
- name: Lint with flake8
4344
run: |
@@ -54,7 +55,7 @@ jobs:
5455
cd CellConstructor
5556
python setup.py install --user
5657
cd ..
57-
58+
5859
python setup.py install --user
5960
6061
# Install julia requirements

Modules/AdvancedCalculations.py

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
This module contains useful functions to do post-processing analysis of the SSCHA.
1212
1313
For example, it implements custom cluster calculators to compute the electron-phonon effect on
14-
absorbption and the bandgap.
14+
absorption and the bandgap.
1515
1616
'''
1717

@@ -23,7 +23,7 @@ class OpticalQECluster(sscha.Cluster.Cluster):
2323
'''
2424

2525
def __init__(self, new_k_grid = None, random_offset = True, epsilon_data = None,
26-
epsilon_binary = 'epsilon.x -npool NPOOL -i PREFIX.pwi > PREFIX.pwo',
26+
epsilon_binary = 'epsilon.x -npool NPOOL -i PREFIX.pwi > PREFIX.pwo',
2727
**kwargs):
2828
'''
2929
Initialize the cluster object.
@@ -40,7 +40,7 @@ def __init__(self, new_k_grid = None, random_offset = True, epsilon_data = None,
4040
epsilon.x file
4141
epsilon_binary : string
4242
The path to the epsilon.x binary inside the cluster.
43-
**kwargs :
43+
**kwargs :
4444
All other arguments to be passed to the cluster.
4545
4646
'''
@@ -67,7 +67,7 @@ def __init__(self, new_k_grid = None, random_offset = True, epsilon_data = None,
6767
'wmax' : 40,
6868
'nw' : 10000,
6969
'temperature' : 300
70-
}
70+
}
7171
}
7272
if epsilon_data is not None:
7373
self.epsilon_data = epsilon_data
@@ -79,10 +79,10 @@ def __setattr__(self, __name, __value):
7979
super().__setattr__(__name, __value)
8080

8181
# Always regenerate the kpts
82-
if __name == 'new_k_grid' and not __value is None:
82+
if __name == 'new_k_grid' and not __value is None:
8383
assert len(__value) == 3, 'Error, new_k_grid must be a tuple with 3 elements'
8484
self.generate_kpts()
85-
85+
8686

8787
def generate_kpts(self):
8888
'''
@@ -119,7 +119,7 @@ def get_execution_command(self, label):
119119

120120
# Get the MPI command replacing NPROC
121121
new_mpicmd = self.mpi_cmd.replace("NPROC", str(self.n_cpu))
122-
122+
123123
# Replace the NPOOL variable and the PREFIX in the binary
124124
binary = self.binary.replace("NPOOL", str(self.n_pool)).replace("PREFIX", label)
125125
binary_nscf = self.binary.replace("NPOOL", str(self.n_pool)).replace("PREFIX", label + '_nscf')
@@ -147,6 +147,18 @@ def get_execution_command(self, label):
147147
def read_results(self, calc, label):
148148
'''
149149
Get the results
150+
151+
Parameters
152+
----------
153+
calc : the ASE or CellConstructor calculator.
154+
In this case, it works with quantum espresso
155+
labels : List of strings
156+
The unique name of this calculation
157+
Returns
158+
-------
159+
results : array
160+
An array containing the real part of epsilon,
161+
and the mean of the real and imaginary parst of epsilon.
150162
'''
151163

152164
results = super().read_results(calc, label)
@@ -176,7 +188,31 @@ def read_results(self, calc, label):
176188
def prepare_input_file(self, structures, calc, labels):
177189
'''
178190
Prepare the input files for the cluster
179-
'''
191+
192+
This is specific for quantum espresso and must be inherit and replaced for
193+
other calculators.
194+
195+
This crates the input files in the local working directory
196+
self.local_workdir and it returns the list of all the files generated.
197+
198+
199+
Parameters
200+
----------
201+
structures : List of cellconstructor.Structure.Structure
202+
The atomic structures.
203+
calc : the ASE or CellConstructor calculator.
204+
In this case, it works with quantum espresso
205+
labels : List of strings
206+
The unique name of this calculation
207+
208+
Returns
209+
-------
210+
List_of_input : list
211+
List of strings containing all the input files
212+
List_of_output : list
213+
List of strings containing the output files expected
214+
for the calculation
215+
'''
180216

181217

182218
# Prepare the input file
@@ -185,7 +221,7 @@ def prepare_input_file(self, structures, calc, labels):
185221
for i, (label, structure) in enumerate(zip(labels, structures)):
186222
# Avoid thread conflict
187223
self.lock.acquire()
188-
224+
189225
try:
190226
calc.set_directory(self.local_workdir)
191227
PREFIX = label
@@ -204,7 +240,7 @@ def prepare_input_file(self, structures, calc, labels):
204240
input_file = '{}.pwi'.format(label)
205241
output_file = '{}.pwo'.format(label)
206242

207-
list_of_inputs.append(input_file)
243+
list_of_inputs.append(input_file)
208244
list_of_outputs.append(output_file)
209245

210246
# prepare the nscf calculation
@@ -218,7 +254,7 @@ def prepare_input_file(self, structures, calc, labels):
218254
calc.write_input(structure)
219255
input_file = '{}.pwi'.format(new_label)
220256
output_file = '{}.pwo'.format(new_label)
221-
list_of_inputs.append(input_file)
257+
list_of_inputs.append(input_file)
222258
list_of_outputs.append(output_file)
223259

224260

@@ -239,8 +275,8 @@ def prepare_input_file(self, structures, calc, labels):
239275
print('fname: {} prepared'.format(eps_in_filename))
240276

241277

242-
243-
list_of_inputs.append(input_file)
278+
279+
list_of_inputs.append(input_file)
244280
list_of_outputs.append(output_file)
245281

246282
# Append also the imaginary and real part of epsilon and sigma
@@ -263,11 +299,11 @@ def prepare_input_file(self, structures, calc, labels):
263299
print(e)
264300

265301
# Release the lock on the threads
266-
self.lock.release()
302+
self.lock.release()
267303

268304
print('THREAD: {} inputs: {} outputs: {}'.format(threading.get_native_id(), list_of_inputs, list_of_outputs))
269-
270-
305+
306+
271307
return list_of_inputs, list_of_outputs
272308

273309

@@ -306,7 +342,7 @@ def get_optical_spectrum(ensemble, w_array = None):
306342
Error, the configuration {} has no 'epsilon' data.
307343
""".format(i)
308344
raise ValueError(ERR)
309-
345+
310346
data = np.array(ensemble.all_properties[i]['epsilon'])
311347

312348
if w_data is None:
@@ -330,13 +366,11 @@ def get_optical_spectrum(ensemble, w_array = None):
330366
kind = 'cubic', bounds_error = False, fill_value = 'extrapolate')
331367
eps_imag = f_imag(w_array)
332368
w_data = w_array
333-
369+
334370
# Build the complex epsilon
335371
epsilon = eps_real + 1j * eps_imag
336372

337373
# Build the refractive index
338374
n = np.sqrt(epsilon)
339375

340376
return w_data, n
341-
342-

0 commit comments

Comments
 (0)