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: ...@@ -123,6 +123,7 @@ class FourComponentSusceptibilityTensor:
---------- ----------
spincomponent, q_c, spincomponent, q_c,
frequencies : see gpaw.response.chiks, gpaw.response.kslrf frequencies : see gpaw.response.chiks, gpaw.response.kslrf
txt : see get_macroscopic_component
Returns Returns
------- -------
...@@ -146,18 +147,17 @@ class FourComponentSusceptibilityTensor: ...@@ -146,18 +147,17 @@ class FourComponentSusceptibilityTensor:
return omega_w, chiks_w, chi_w return omega_w, chiks_w, chi_w
def get_component(self, spincomponent, q_c, frequencies, def get_component_array(self, spincomponent, q_c, frequencies,
store_ecut=50, filename=None, txt=None): array_ecut=50, filename=None, txt=None):
"""Calculates a specific spin component of the """Calculates a specific spin component of the susceptibility tensor,
susceptibility tensor and writes it to a file. collects it as a numpy array in a reduced plane wave description
and writes it to a file.
Parameters Parameters
---------- ----------
spincomponent, q_c, spincomponent, q_c,
frequencies : see gpaw.response.chiks, gpaw.response.kslrf frequencies : see gpaw.response.chiks, gpaw.response.kslrf
store_ecut : float array_ecut : see calculate_component_array
Energy cutoff for the reduced plane wave representation.
The susceptibility is returned/saved in the reduced representation.
filename : str filename : str
Save chiks_w and chi_w to pickle file of given name. Save chiks_w and chi_w to pickle file of given name.
Defaults to: Defaults to:
...@@ -169,11 +169,7 @@ class FourComponentSusceptibilityTensor: ...@@ -169,11 +169,7 @@ class FourComponentSusceptibilityTensor:
Returns Returns
------- -------
omega_w, G_Gc, chiks_wGG, chi_wGG : nd.array(s) see calculate_component_array
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
""" """
if filename is None: if filename is None:
...@@ -181,6 +177,40 @@ class FourComponentSusceptibilityTensor: ...@@ -181,6 +177,40 @@ class FourComponentSusceptibilityTensor:
*tuple((q_c * self.calc.wfs.kd.N_c).round())) *tuple((q_c * self.calc.wfs.kd.N_c).round()))
filename = 'chi%sGG_q«%+d-%+d-%+d».pckl' % tup 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, (pd, wd,
chiks_wGG, chi_wGG) = self.calculate_component(spincomponent, q_c, chiks_wGG, chi_wGG) = self.calculate_component(spincomponent, q_c,
frequencies, txt=txt) frequencies, txt=txt)
...@@ -189,7 +219,7 @@ class FourComponentSusceptibilityTensor: ...@@ -189,7 +219,7 @@ class FourComponentSusceptibilityTensor:
omega_w = wd.get_data() * Hartree omega_w = wd.get_data() * Hartree
# Get susceptibility in a reduced plane wave representation # 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]) chiks_wGG = np.ascontiguousarray(chiks_wGG[:, mask_G, :][:, :, mask_G])
chi_wGG = np.ascontiguousarray(chi_wGG[:, mask_G, :][:, :, mask_G]) chi_wGG = np.ascontiguousarray(chi_wGG[:, mask_G, :][:, :, mask_G])
...@@ -200,10 +230,6 @@ class FourComponentSusceptibilityTensor: ...@@ -200,10 +230,6 @@ class FourComponentSusceptibilityTensor:
chiks_wGG = self.gather(chiks_wGG, wd) chiks_wGG = self.gather(chiks_wGG, wd)
chi_wGG = self.gather(chi_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 return omega_w, G_Gc, chiks_wGG, chi_wGG
def calculate_component(self, spincomponent, q_c, frequencies, txt=None): def calculate_component(self, spincomponent, q_c, frequencies, txt=None):
......
...@@ -42,8 +42,8 @@ class TransverseMagneticSusceptibility(FCST): ...@@ -42,8 +42,8 @@ class TransverseMagneticSusceptibility(FCST):
frequencies, filename=filename, frequencies, filename=filename,
txt=txt) txt=txt)
def get_component(self, spincomponent, q_c, frequencies, def get_component_array(self, spincomponent, q_c, frequencies,
store_ecut=50, filename=None, txt=None): array_ecut=50, filename=None, txt=None):
"""Calculates a specific spin component of the """Calculates a specific spin component of the
transverse magnetic susceptibility and writes it to a file. transverse magnetic susceptibility and writes it to a file.
...@@ -52,7 +52,7 @@ class TransverseMagneticSusceptibility(FCST): ...@@ -52,7 +52,7 @@ class TransverseMagneticSusceptibility(FCST):
spincomponent : str spincomponent : str
'+-': calculate chi+-, '-+: calculate chi-+ '+-': calculate chi+-, '-+: calculate chi-+
q_c, frequencies, q_c, frequencies,
store_ecut, filename, txt : see gpaw.response.susceptibility array_ecut, filename, txt : see gpaw.response.susceptibility
Returns Returns
------- -------
...@@ -60,9 +60,9 @@ class TransverseMagneticSusceptibility(FCST): ...@@ -60,9 +60,9 @@ class TransverseMagneticSusceptibility(FCST):
""" """
assert spincomponent in ['+-', '-+'] assert spincomponent in ['+-', '-+']
return FCST.get_component(self, spincomponent, q_c, return FCST.get_component_array(self, spincomponent, q_c,
frequencies, store_ecut=store_ecut, frequencies, array_ecut=array_ecut,
filename=filename, txt=txt) filename=filename, txt=txt)
def _calculate_component(self, spincomponent, pd, wd): def _calculate_component(self, spincomponent, pd, wd):
"""Calculate a transverse magnetic susceptibility element. """Calculate a transverse magnetic susceptibility element.
......
...@@ -55,8 +55,8 @@ fcst = FourComponentSusceptibilityTensor(calc1, fxc='RPA', ...@@ -55,8 +55,8 @@ fcst = FourComponentSusceptibilityTensor(calc1, fxc='RPA',
disable_point_group=False, disable_point_group=False,
disable_time_reversal=False) disable_time_reversal=False)
for q, q_c in enumerate(q1_qc): for q, q_c in enumerate(q1_qc):
fcst.get_component('00', q_c, w, store_ecut=25, fcst.get_component_array('00', q_c, w, array_ecut=25,
filename='Al1_chiGG_q%d.pckl' % (q + 1)) filename='Al1_chiGG_q%d.pckl' % (q + 1))
world.barrier() world.barrier()
t4 = time.time() t4 = time.time()
...@@ -67,8 +67,8 @@ fcst = FourComponentSusceptibilityTensor(calc2, fxc='RPA', ...@@ -67,8 +67,8 @@ fcst = FourComponentSusceptibilityTensor(calc2, fxc='RPA',
disable_point_group=False, disable_point_group=False,
disable_time_reversal=False) disable_time_reversal=False)
for q, q_c in enumerate(q2_qc): for q, q_c in enumerate(q2_qc):
fcst.get_component('00', q_c, w, store_ecut=25, fcst.get_component_array('00', q_c, w, array_ecut=25,
filename='Al2_chiGG_q%d.pckl' % (q + 1)) filename='Al2_chiGG_q%d.pckl' % (q + 1))
world.barrier() world.barrier()
t5 = time.time() 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