Commit c1fb7c7e authored by Thorbjørn Skovhus's avatar Thorbjørn Skovhus

inserted a calculate step in get_component and renamed to get_component_array

parent cf4e21f1
Pipeline #98634671 passed with stage
in 3 minutes and 29 seconds
......@@ -123,6 +123,7 @@ class FourComponentSusceptibilityTensor:
----------
spincomponent, q_c,
frequencies : see gpaw.response.chiks, gpaw.response.kslrf
txt : see get_macroscopic_component
Returns
-------
......@@ -146,18 +147,17 @@ class FourComponentSusceptibilityTensor:
return omega_w, chiks_w, chi_w
def get_component(self, spincomponent, q_c, frequencies,
store_ecut=50, filename=None, txt=None):
"""Calculates a specific spin component of the
susceptibility tensor and writes it to a file.
def get_component_array(self, spincomponent, q_c, frequencies,
array_ecut=50, filename=None, txt=None):
"""Calculates a specific spin component of the susceptibility tensor,
collects it as a numpy array in a reduced plane wave description
and writes it to a file.
Parameters
----------
spincomponent, q_c,
frequencies : see gpaw.response.chiks, gpaw.response.kslrf
store_ecut : float
Energy cutoff for the reduced plane wave representation.
The susceptibility is returned/saved in the reduced representation.
array_ecut : see calculate_component_array
filename : str
Save chiks_w and chi_w to pickle file of given name.
Defaults to:
......@@ -169,11 +169,7 @@ class FourComponentSusceptibilityTensor:
Returns
-------
omega_w, G_Gc, chiks_wGG, chi_wGG : nd.array(s)
omega_w: frequencies in eV
G_Gc : plane wave repr. as coordinates on the reciprocal lattice
chiks_wGG: dynamic susceptibility (Kohn-Sham system)
chi_wGG: dynamic susceptibility
see calculate_component_array
"""
if filename is None:
......@@ -181,6 +177,40 @@ class FourComponentSusceptibilityTensor:
*tuple((q_c * self.calc.wfs.kd.N_c).round()))
filename = 'chi%sGG_q«%+d-%+d-%+d».pckl' % tup
(omega_w, G_Gc, chiks_wGG,
chi_wGG) = self.calculate_component_array(spincomponent,
q_c,
frequencies,
array_ecut=array_ecut,
txt=txt)
# Write susceptibilities to a pickle file
write_component(omega_w, G_Gc, chiks_wGG, chi_wGG,
filename, self.world)
return omega_w, G_Gc, chiks_wGG, chi_wGG
def calculate_component_array(self, spincomponent, q_c, frequencies,
array_ecut=50, txt=None):
"""Calculates a specific spin component of the susceptibility tensor
and collects it as a numpy array in a reduced plane wave description.
Parameters
----------
spincomponent, q_c,
frequencies : see gpaw.response.chiks, gpaw.response.kslrf
array_ecut : float
Energy cutoff for the reduced plane wave representation.
The susceptibility is returned in the reduced representation.
Returns
-------
omega_w, G_Gc, chiks_wGG, chi_wGG : nd.array(s)
omega_w: frequencies in eV
G_Gc : plane wave repr. as coordinates on the reciprocal lattice
chiks_wGG: dynamic susceptibility (Kohn-Sham system)
chi_wGG: dynamic susceptibility
"""
(pd, wd,
chiks_wGG, chi_wGG) = self.calculate_component(spincomponent, q_c,
frequencies, txt=txt)
......@@ -189,7 +219,7 @@ class FourComponentSusceptibilityTensor:
omega_w = wd.get_data() * Hartree
# Get susceptibility in a reduced plane wave representation
mask_G = get_pw_reduction_map(pd, store_ecut)
mask_G = get_pw_reduction_map(pd, array_ecut)
chiks_wGG = np.ascontiguousarray(chiks_wGG[:, mask_G, :][:, :, mask_G])
chi_wGG = np.ascontiguousarray(chi_wGG[:, mask_G, :][:, :, mask_G])
......@@ -200,10 +230,6 @@ class FourComponentSusceptibilityTensor:
chiks_wGG = self.gather(chiks_wGG, wd)
chi_wGG = self.gather(chi_wGG, wd)
# Write susceptibilities to a pickle file
write_component(omega_w, G_Gc, chiks_wGG, chi_wGG,
filename, self.world)
return omega_w, G_Gc, chiks_wGG, chi_wGG
def calculate_component(self, spincomponent, q_c, frequencies, txt=None):
......
......@@ -42,8 +42,8 @@ class TransverseMagneticSusceptibility(FCST):
frequencies, filename=filename,
txt=txt)
def get_component(self, spincomponent, q_c, frequencies,
store_ecut=50, filename=None, txt=None):
def get_component_array(self, spincomponent, q_c, frequencies,
array_ecut=50, filename=None, txt=None):
"""Calculates a specific spin component of the
transverse magnetic susceptibility and writes it to a file.
......@@ -52,7 +52,7 @@ class TransverseMagneticSusceptibility(FCST):
spincomponent : str
'+-': calculate chi+-, '-+: calculate chi-+
q_c, frequencies,
store_ecut, filename, txt : see gpaw.response.susceptibility
array_ecut, filename, txt : see gpaw.response.susceptibility
Returns
-------
......@@ -60,9 +60,9 @@ class TransverseMagneticSusceptibility(FCST):
"""
assert spincomponent in ['+-', '-+']
return FCST.get_component(self, spincomponent, q_c,
frequencies, store_ecut=store_ecut,
filename=filename, txt=txt)
return FCST.get_component_array(self, spincomponent, q_c,
frequencies, array_ecut=array_ecut,
filename=filename, txt=txt)
def _calculate_component(self, spincomponent, pd, wd):
"""Calculate a transverse magnetic susceptibility element.
......
......@@ -55,8 +55,8 @@ fcst = FourComponentSusceptibilityTensor(calc1, fxc='RPA',
disable_point_group=False,
disable_time_reversal=False)
for q, q_c in enumerate(q1_qc):
fcst.get_component('00', q_c, w, store_ecut=25,
filename='Al1_chiGG_q%d.pckl' % (q + 1))
fcst.get_component_array('00', q_c, w, array_ecut=25,
filename='Al1_chiGG_q%d.pckl' % (q + 1))
world.barrier()
t4 = time.time()
......@@ -67,8 +67,8 @@ fcst = FourComponentSusceptibilityTensor(calc2, fxc='RPA',
disable_point_group=False,
disable_time_reversal=False)
for q, q_c in enumerate(q2_qc):
fcst.get_component('00', q_c, w, store_ecut=25,
filename='Al2_chiGG_q%d.pckl' % (q + 1))
fcst.get_component_array('00', q_c, w, array_ecut=25,
filename='Al2_chiGG_q%d.pckl' % (q + 1))
world.barrier()
t5 = time.time()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment