Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diego thermodynamic fix #189

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
929e328
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Jun 10, 2022
a602d52
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Jul 27, 2022
22dc054
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Aug 30, 2022
967b13c
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Sep 1, 2022
dd60a1b
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Sep 7, 2022
5be1f0b
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Sep 12, 2022
4f4885d
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Sep 15, 2022
77235bd
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Sep 21, 2022
a7228c9
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Sep 21, 2022
cc2037e
Fix Typo
diegomartinez2 Sep 22, 2022
7432a96
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Nov 17, 2022
c6152ed
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Nov 30, 2022
73669a0
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Dec 19, 2022
3a83ac1
Quick fix on the q_stars call for the Symmetrization.
diegomartinez2 Feb 23, 2023
60adc5d
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Feb 23, 2023
ebed02b
Merge branch 'master' of github.com:diegomartinez2/python-sscha
diegomartinez2 May 15, 2023
6b812eb
Merge branch 'master' of github.com:diegomartinez2/python-sscha
diegomartinez2 Jun 6, 2023
041bc62
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Jun 12, 2023
d76ca82
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Jun 13, 2023
76232cc
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Jun 18, 2023
f951de6
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Jul 24, 2023
c50fce8
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Aug 1, 2023
3b4bb3b
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Aug 8, 2023
cfe6a53
Merge branch 'master' of github.com:diegomartinez2/python-sscha
diegomartinez2 Oct 18, 2023
1a7bc46
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Oct 19, 2023
9449725
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Oct 26, 2023
0d99780
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Oct 30, 2023
bf842bc
Checking for 'init_q_opposite()' calls without julia installed.
diegomartinez2 Nov 3, 2023
0e55f1e
Quickfix for the 'init_q_opposite()' call in __init__ of Ensemble
diegomartinez2 Nov 3, 2023
99cc083
Merge branch 'master' of github.com:diegomartinez2/python-sscha
diegomartinez2 Nov 10, 2023
218194a
Fix typo
diegomartinez2 Nov 14, 2023
3ace31e
Added comments
diegomartinez2 Nov 17, 2023
c6de26a
More comments
diegomartinez2 Nov 17, 2023
6d243f3
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Dec 13, 2023
d39d427
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Dec 21, 2023
94a351f
Merge branch 'SSCHAcode:master' into master
diegomartinez2 Jan 17, 2024
a5f846a
Fix for the Thermodymamic
diegomartinez2 Feb 7, 2024
ddbafaa
Fix import from scipy.special: tanh, sinh, cosh
diegomartinez2 Feb 7, 2024
01bce44
Use numpy.tanh()
diegomartinez2 Feb 7, 2024
0d05a18
Stupid missing 'self' fixed
diegomartinez2 Feb 7, 2024
447818d
spglib error fix
diegomartinez2 Feb 7, 2024
89d1273
Added the "aiida-pseudo install" into github testsuite
diegomartinez2 Feb 7, 2024
113600c
Test, undo later.
diegomartinez2 Feb 7, 2024
eef1fcb
Undo the test.
diegomartinez2 Feb 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/python-testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.8]

services:
rabbitmq:
image: rabbitmq:latest
Expand All @@ -38,6 +38,7 @@ jobs:
pip install flake8 pytest~=6.0 pgtest~=1.3 aiida-core~=2.3 aiida-quantumespresso~=4.3
if [ ${{matrix.python-version}} -eq 2.7 ]; then pip install -r requirements2.txt;
else pip install -r requirements.txt; fi
aiida-pseudo install

- name: Lint with flake8
run: |
Expand All @@ -54,7 +55,7 @@ jobs:
cd CellConstructor
python setup.py install --user
cd ..

python setup.py install --user

# Install julia requirements
Expand Down
74 changes: 54 additions & 20 deletions Modules/AdvancedCalculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
This module contains useful functions to do post-processing analysis of the SSCHA.

For example, it implements custom cluster calculators to compute the electron-phonon effect on
absorbption and the bandgap.
absorption and the bandgap.

'''

Expand All @@ -23,7 +23,7 @@ class OpticalQECluster(sscha.Cluster.Cluster):
'''

def __init__(self, new_k_grid = None, random_offset = True, epsilon_data = None,
epsilon_binary = 'epsilon.x -npool NPOOL -i PREFIX.pwi > PREFIX.pwo',
epsilon_binary = 'epsilon.x -npool NPOOL -i PREFIX.pwi > PREFIX.pwo',
**kwargs):
'''
Initialize the cluster object.
Expand All @@ -40,7 +40,7 @@ def __init__(self, new_k_grid = None, random_offset = True, epsilon_data = None,
epsilon.x file
epsilon_binary : string
The path to the epsilon.x binary inside the cluster.
**kwargs :
**kwargs :
All other arguments to be passed to the cluster.

'''
Expand All @@ -67,7 +67,7 @@ def __init__(self, new_k_grid = None, random_offset = True, epsilon_data = None,
'wmax' : 40,
'nw' : 10000,
'temperature' : 300
}
}
}
if epsilon_data is not None:
self.epsilon_data = epsilon_data
Expand All @@ -79,10 +79,10 @@ def __setattr__(self, __name, __value):
super().__setattr__(__name, __value)

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


def generate_kpts(self):
'''
Expand Down Expand Up @@ -119,7 +119,7 @@ def get_execution_command(self, label):

# Get the MPI command replacing NPROC
new_mpicmd = self.mpi_cmd.replace("NPROC", str(self.n_cpu))

# Replace the NPOOL variable and the PREFIX in the binary
binary = self.binary.replace("NPOOL", str(self.n_pool)).replace("PREFIX", label)
binary_nscf = self.binary.replace("NPOOL", str(self.n_pool)).replace("PREFIX", label + '_nscf')
Expand Down Expand Up @@ -147,6 +147,18 @@ def get_execution_command(self, label):
def read_results(self, calc, label):
'''
Get the results

Parameters
----------
calc : the ASE or CellConstructor calculator.
In this case, it works with quantum espresso
labels : List of strings
The unique name of this calculation
Returns
-------
results : array
An array containing the real part of epsilon,
and the mean of the real and imaginary parst of epsilon.
'''

results = super().read_results(calc, label)
Expand Down Expand Up @@ -176,7 +188,31 @@ def read_results(self, calc, label):
def prepare_input_file(self, structures, calc, labels):
'''
Prepare the input files for the cluster
'''

This is specific for quantum espresso and must be inherit and replaced for
other calculators.

This crates the input files in the local working directory
self.local_workdir and it returns the list of all the files generated.


Parameters
----------
structures : List of cellconstructor.Structure.Structure
The atomic structures.
calc : the ASE or CellConstructor calculator.
In this case, it works with quantum espresso
labels : List of strings
The unique name of this calculation

Returns
-------
List_of_input : list
List of strings containing all the input files
List_of_output : list
List of strings containing the output files expected
for the calculation
'''


# Prepare the input file
Expand All @@ -185,7 +221,7 @@ def prepare_input_file(self, structures, calc, labels):
for i, (label, structure) in enumerate(zip(labels, structures)):
# Avoid thread conflict
self.lock.acquire()

try:
calc.set_directory(self.local_workdir)
PREFIX = label
Expand All @@ -204,7 +240,7 @@ def prepare_input_file(self, structures, calc, labels):
input_file = '{}.pwi'.format(label)
output_file = '{}.pwo'.format(label)

list_of_inputs.append(input_file)
list_of_inputs.append(input_file)
list_of_outputs.append(output_file)

# prepare the nscf calculation
Expand All @@ -218,7 +254,7 @@ def prepare_input_file(self, structures, calc, labels):
calc.write_input(structure)
input_file = '{}.pwi'.format(new_label)
output_file = '{}.pwo'.format(new_label)
list_of_inputs.append(input_file)
list_of_inputs.append(input_file)
list_of_outputs.append(output_file)


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


list_of_inputs.append(input_file)

list_of_inputs.append(input_file)
list_of_outputs.append(output_file)

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

# Release the lock on the threads
self.lock.release()
self.lock.release()

print('THREAD: {} inputs: {} outputs: {}'.format(threading.get_native_id(), list_of_inputs, list_of_outputs))


return list_of_inputs, list_of_outputs


Expand Down Expand Up @@ -306,7 +342,7 @@ def get_optical_spectrum(ensemble, w_array = None):
Error, the configuration {} has no 'epsilon' data.
""".format(i)
raise ValueError(ERR)

data = np.array(ensemble.all_properties[i]['epsilon'])

if w_data is None:
Expand All @@ -330,13 +366,11 @@ def get_optical_spectrum(ensemble, w_array = None):
kind = 'cubic', bounds_error = False, fill_value = 'extrapolate')
eps_imag = f_imag(w_array)
w_data = w_array

# Build the complex epsilon
epsilon = eps_real + 1j * eps_imag

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

return w_data, n


Loading
Loading