mirror of
https://github.com/triqs/dft_tools
synced 2024-11-18 03:53:48 +01:00
[fix] update mpi.all_reduce calls 52bccac
This commit is contained in:
parent
b2271d578e
commit
89f72dee02
@ -78,8 +78,7 @@ for ik in mpi.slice_array(ikarray):
|
|||||||
add_g_ik << SK.downfold(ik, 0, bname, G_latt_KS[bname], gf, shells='csc', ir=None)
|
add_g_ik << SK.downfold(ik, 0, bname, G_latt_KS[bname], gf, shells='csc', ir=None)
|
||||||
gf << gf + add_g_ik
|
gf << gf + add_g_ik
|
||||||
|
|
||||||
G_latt_orb << mpi.all_reduce(
|
G_latt_orb << mpi.all_reduce(G_latt_orb)
|
||||||
mpi.world, G_latt_orb, lambda x, y: x + y)
|
|
||||||
|
|
||||||
mpi.barrier()
|
mpi.barrier()
|
||||||
|
|
||||||
|
@ -787,8 +787,7 @@ class SumkDFT(object):
|
|||||||
|
|
||||||
# Collect data from mpi
|
# Collect data from mpi
|
||||||
for icrsh in range(self.n_corr_shells):
|
for icrsh in range(self.n_corr_shells):
|
||||||
G_loc[icrsh] << mpi.all_reduce(
|
G_loc[icrsh] << mpi.all_reduce(G_loc[icrsh])
|
||||||
mpi.world, G_loc[icrsh], lambda x, y: x + y)
|
|
||||||
mpi.barrier()
|
mpi.barrier()
|
||||||
|
|
||||||
# G_loc[:] is now the sum over k projected to the local orbitals.
|
# G_loc[:] is now the sum over k projected to the local orbitals.
|
||||||
@ -1530,8 +1529,7 @@ class SumkDFT(object):
|
|||||||
# get data from nodes:
|
# get data from nodes:
|
||||||
for icrsh in range(self.n_corr_shells):
|
for icrsh in range(self.n_corr_shells):
|
||||||
for sp in dens_mat[icrsh]:
|
for sp in dens_mat[icrsh]:
|
||||||
dens_mat[icrsh][sp] = mpi.all_reduce(
|
dens_mat[icrsh][sp] = mpi.all_reduce(dens_mat[icrsh][sp])
|
||||||
mpi.world, dens_mat[icrsh][sp], lambda x, y: x + y)
|
|
||||||
mpi.barrier()
|
mpi.barrier()
|
||||||
|
|
||||||
if self.symm_op != 0:
|
if self.symm_op != 0:
|
||||||
@ -1910,7 +1908,7 @@ class SumkDFT(object):
|
|||||||
ik=ik, mu=mu, with_Sigma=with_Sigma, with_dc=with_dc, broadening=broadening)
|
ik=ik, mu=mu, with_Sigma=with_Sigma, with_dc=with_dc, broadening=broadening)
|
||||||
dens += self.bz_weights[ik] * G_latt.total_density()
|
dens += self.bz_weights[ik] * G_latt.total_density()
|
||||||
# collect data from mpi:
|
# collect data from mpi:
|
||||||
dens = mpi.all_reduce(mpi.world, dens, lambda x, y: x + y)
|
dens = mpi.all_reduce(dens)
|
||||||
mpi.barrier()
|
mpi.barrier()
|
||||||
|
|
||||||
if abs(dens.imag) > 1e-20:
|
if abs(dens.imag) > 1e-20:
|
||||||
@ -2168,16 +2166,14 @@ class SumkDFT(object):
|
|||||||
# mpi reduce:
|
# mpi reduce:
|
||||||
for bname in deltaN:
|
for bname in deltaN:
|
||||||
for ik in range(self.n_k):
|
for ik in range(self.n_k):
|
||||||
deltaN[bname][ik] = mpi.all_reduce(
|
deltaN[bname][ik] = mpi.all_reduce(deltaN[bname][ik])
|
||||||
mpi.world, deltaN[bname][ik], lambda x, y: x + y)
|
dens[bname] = mpi.all_reduce(dens[bname])
|
||||||
dens[bname] = mpi.all_reduce(
|
|
||||||
mpi.world, dens[bname], lambda x, y: x + y)
|
|
||||||
self.deltaNOld = copy.copy(deltaN)
|
self.deltaNOld = copy.copy(deltaN)
|
||||||
mpi.barrier()
|
mpi.barrier()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
band_en_correction = mpi.all_reduce(mpi.world, band_en_correction, lambda x,y : x+y)
|
band_en_correction = mpi.all_reduce(band_en_correction)
|
||||||
|
|
||||||
# now save to file:
|
# now save to file:
|
||||||
if dm_type == 'wien2k':
|
if dm_type == 'wien2k':
|
||||||
@ -2335,7 +2331,7 @@ class SumkDFT(object):
|
|||||||
hop_slice = mpi.slice_array(hop)
|
hop_slice = mpi.slice_array(hop)
|
||||||
diag_hop_slice = mpi.slice_array(diag_hop)
|
diag_hop_slice = mpi.slice_array(diag_hop)
|
||||||
diag_hop_slice[:] = np.linalg.eigvalsh(hop_slice)
|
diag_hop_slice[:] = np.linalg.eigvalsh(hop_slice)
|
||||||
diag_hop = mpi.all_reduce(mpi.world, diag_hop, lambda x, y: x + y)
|
diag_hop = mpi.all_reduce(diag_hop)
|
||||||
min_band_energy = diag_hop.min().real
|
min_band_energy = diag_hop.min().real
|
||||||
max_band_energy = diag_hop.max().real
|
max_band_energy = diag_hop.max().real
|
||||||
self.min_band_energy = min_band_energy
|
self.min_band_energy = min_band_energy
|
||||||
|
@ -137,11 +137,9 @@ class SumkDFTTools(SumkDFT):
|
|||||||
|
|
||||||
# Collect data from mpi:
|
# Collect data from mpi:
|
||||||
for bname in DOS:
|
for bname in DOS:
|
||||||
DOS[bname] = mpi.all_reduce(
|
DOS[bname] = mpi.all_reduce(DOS[bname])
|
||||||
mpi.world, DOS[bname], lambda x, y: x + y)
|
|
||||||
for icrsh in range(self.n_corr_shells):
|
for icrsh in range(self.n_corr_shells):
|
||||||
G_loc[icrsh] << mpi.all_reduce(
|
G_loc[icrsh] << mpi.all_reduce(G_loc[icrsh])
|
||||||
mpi.world, G_loc[icrsh], lambda x, y: x + y)
|
|
||||||
mpi.barrier()
|
mpi.barrier()
|
||||||
|
|
||||||
# Symmetrize and rotate to local coord. system if needed:
|
# Symmetrize and rotate to local coord. system if needed:
|
||||||
@ -267,10 +265,8 @@ class SumkDFTTools(SumkDFT):
|
|||||||
G_loc_all[bname] << self.downfold(ik, 0, bname, gf, G_loc_all[bname], shells='csc')
|
G_loc_all[bname] << self.downfold(ik, 0, bname, gf, G_loc_all[bname], shells='csc')
|
||||||
# Collect data from mpi:
|
# Collect data from mpi:
|
||||||
for bname in DOS:
|
for bname in DOS:
|
||||||
DOS[bname] = mpi.all_reduce(
|
DOS[bname] = mpi.all_reduce(DOS[bname])
|
||||||
mpi.world, DOS[bname], lambda x, y: x + y)
|
G_loc_all[bname] << mpi.all_reduce(G_loc_all[bname])
|
||||||
G_loc_all[bname] << mpi.all_reduce(
|
|
||||||
mpi.world, G_loc_all[bname], lambda x, y: x + y)
|
|
||||||
mpi.barrier()
|
mpi.barrier()
|
||||||
|
|
||||||
# Symmetrize and rotate to local coord. system if needed:
|
# Symmetrize and rotate to local coord. system if needed:
|
||||||
@ -405,11 +401,9 @@ class SumkDFTTools(SumkDFT):
|
|||||||
|
|
||||||
# Collect data from mpi:
|
# Collect data from mpi:
|
||||||
for bname in DOS:
|
for bname in DOS:
|
||||||
DOS[bname] = mpi.all_reduce(
|
DOS[bname] = mpi.all_reduce(DOS[bname])
|
||||||
mpi.world, DOS[bname], lambda x, y: x + y)
|
|
||||||
for ish in range(self.n_shells):
|
for ish in range(self.n_shells):
|
||||||
G_loc[ish] << mpi.all_reduce(
|
G_loc[ish] << mpi.all_reduce(G_loc[ish])
|
||||||
mpi.world, G_loc[ish], lambda x, y: x + y)
|
|
||||||
mpi.barrier()
|
mpi.barrier()
|
||||||
|
|
||||||
# Symmetrize and rotate to local coord. system if needed:
|
# Symmetrize and rotate to local coord. system if needed:
|
||||||
@ -562,14 +556,12 @@ class SumkDFTTools(SumkDFT):
|
|||||||
mpi.barrier()
|
mpi.barrier()
|
||||||
# Collect data from mpi:
|
# Collect data from mpi:
|
||||||
for bname in DOS:
|
for bname in DOS:
|
||||||
DOS[bname] = mpi.all_reduce(
|
DOS[bname] = mpi.all_reduce(DOS[bname])
|
||||||
mpi.world, DOS[bname], lambda x, y: x + y)
|
|
||||||
if (pdos):
|
if (pdos):
|
||||||
for bname in pDOS:
|
for bname in pDOS:
|
||||||
for iatom in range(self.n_atoms):
|
for iatom in range(self.n_atoms):
|
||||||
for lm in range(self.maxlm):
|
for lm in range(self.maxlm):
|
||||||
pDOS[bname][iatom,lm,:] = mpi.all_reduce(
|
pDOS[bname][iatom,lm,:] = mpi.all_reduce(pDOS[bname][iatom,lm,:])
|
||||||
mpi.world, pDOS[bname][iatom,lm,:], lambda x, y: x + y)
|
|
||||||
|
|
||||||
|
|
||||||
# Write to files
|
# Write to files
|
||||||
@ -731,7 +723,7 @@ class SumkDFTTools(SumkDFT):
|
|||||||
|
|
||||||
# Collect data from mpi:
|
# Collect data from mpi:
|
||||||
for sp in spn:
|
for sp in spn:
|
||||||
Akw[sp] = mpi.all_reduce(mpi.world, Akw[sp], lambda x, y: x + y)
|
Akw[sp] = mpi.all_reduce(Akw[sp])
|
||||||
mpi.barrier()
|
mpi.barrier()
|
||||||
|
|
||||||
#fold out the IBZ k-points using the lattice vectors and symmetries
|
#fold out the IBZ k-points using the lattice vectors and symmetries
|
||||||
@ -907,7 +899,7 @@ class SumkDFTTools(SumkDFT):
|
|||||||
Akw[sp][ish, ik] = -G_loc[sp].data[numpy.where((mesh > om_minplot)&(mesh < om_maxplot)),ish,ish].imag/numpy.pi
|
Akw[sp][ish, ik] = -G_loc[sp].data[numpy.where((mesh > om_minplot)&(mesh < om_maxplot)),ish,ish].imag/numpy.pi
|
||||||
# Collect data from mpi
|
# Collect data from mpi
|
||||||
for sp in spn:
|
for sp in spn:
|
||||||
Akw[sp] = mpi.all_reduce(mpi.world, Akw[sp], lambda x, y: x + y)
|
Akw[sp] = mpi.all_reduce( Akw[sp])
|
||||||
mpi.barrier()
|
mpi.barrier()
|
||||||
|
|
||||||
if save_to_file and mpi.is_master_node():
|
if save_to_file and mpi.is_master_node():
|
||||||
@ -1010,8 +1002,7 @@ class SumkDFTTools(SumkDFT):
|
|||||||
|
|
||||||
# Collect data from mpi:
|
# Collect data from mpi:
|
||||||
for ish in range(self.n_shells):
|
for ish in range(self.n_shells):
|
||||||
G_loc[ish] << mpi.all_reduce(
|
G_loc[ish] << mpi.all_reduce(G_loc[ish])
|
||||||
mpi.world, G_loc[ish], lambda x, y: x + y)
|
|
||||||
mpi.barrier()
|
mpi.barrier()
|
||||||
|
|
||||||
# Symmetrize and rotate to local coord. system if needed:
|
# Symmetrize and rotate to local coord. system if needed:
|
||||||
|
@ -674,8 +674,7 @@ def transport_distribution(sum_k, beta, directions=['xx'], energy_window=None, O
|
|||||||
vel_R[v_i, v_i, dir_to_int[direction[1]]]), A_kw[isp][A_i, A_i, iw]).trace().real * sum_k.bz_weights[ik])
|
vel_R[v_i, v_i, dir_to_int[direction[1]]]), A_kw[isp][A_i, A_i, iw]).trace().real * sum_k.bz_weights[ik])
|
||||||
|
|
||||||
for direction in directions:
|
for direction in directions:
|
||||||
Gamma_w[direction] = (mpi.all_reduce(mpi.world, Gamma_w[direction],
|
Gamma_w[direction] = (mpi.all_reduce(Gamma_w[direction]) / sum_k.cell_vol / sum_k.n_symmetries)
|
||||||
lambda x, y: x + y) / sum_k.cell_vol / sum_k.n_symmetries)
|
|
||||||
|
|
||||||
return Gamma_w, omega, temp_Om_mesh
|
return Gamma_w, omega, temp_Om_mesh
|
||||||
|
|
||||||
@ -778,7 +777,7 @@ def transport_coefficient(Gamma_w, omega, Om_mesh, spin_polarization, direction,
|
|||||||
from scipy.integrate import simps, quad
|
from scipy.integrate import simps, quad
|
||||||
|
|
||||||
if not (mpi.is_master_node()):
|
if not (mpi.is_master_node()):
|
||||||
return
|
return None
|
||||||
|
|
||||||
if (Om_mesh[iq] == 0.0 or n == 0.0):
|
if (Om_mesh[iq] == 0.0 or n == 0.0):
|
||||||
A = 0.0
|
A = 0.0
|
||||||
@ -854,7 +853,7 @@ def conductivity_and_seebeck(Gamma_w, omega, Om_mesh, SP, directions, beta, meth
|
|||||||
mpi.report('Computing optical conductivity and kinetic coefficients...')
|
mpi.report('Computing optical conductivity and kinetic coefficients...')
|
||||||
|
|
||||||
if not (mpi.is_master_node()):
|
if not (mpi.is_master_node()):
|
||||||
return
|
return None, None, None
|
||||||
|
|
||||||
n_q = Gamma_w[directions[0]].shape[0]
|
n_q = Gamma_w[directions[0]].shape[0]
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ Converter = Wien2kConverter(filename='SrVO3', repacking=True)
|
|||||||
Converter.convert_dft_input()
|
Converter.convert_dft_input()
|
||||||
Converter.convert_transport_input()
|
Converter.convert_transport_input()
|
||||||
|
|
||||||
with HDFArchive('SrVO3_Sigma_transport.h5', 'a') as ar:
|
with HDFArchive('SrVO3_Sigma_transport.h5', 'r') as ar:
|
||||||
Sigma = ar['dmft_transp_input']['Sigma_w']
|
Sigma = ar['dmft_transp_input']['Sigma_w']
|
||||||
SK = SumkDFTTools(hdf_file='SrVO3.ref.h5', mesh=Sigma.mesh, use_dft_blocks=True)
|
SK = SumkDFTTools(hdf_file='SrVO3.ref.h5', mesh=Sigma.mesh, use_dft_blocks=True)
|
||||||
SK.set_Sigma([Sigma])
|
SK.set_Sigma([Sigma])
|
||||||
@ -47,14 +47,14 @@ SK = init_spectroscopy(SK, code='wien2k')
|
|||||||
Gamma_w, omega, Om_mesh = transport_distribution(SK, directions=['xx'], broadening=0.0, energy_window=[-0.3,0.3],
|
Gamma_w, omega, Om_mesh = transport_distribution(SK, directions=['xx'], broadening=0.0, energy_window=[-0.3,0.3],
|
||||||
Om_mesh=[0.00, 0.02], beta=beta, with_Sigma=True, code='wien2k')
|
Om_mesh=[0.00, 0.02], beta=beta, with_Sigma=True, code='wien2k')
|
||||||
|
|
||||||
#SK.save(['Gamma_w','Om_meshr','omega','directions'])
|
# SK.save(['Gamma_w','Om_meshr','omega','directions'])
|
||||||
#SK.load(['Gamma_w','Om_meshr','omega','directions'])
|
# SK.load(['Gamma_w','Om_meshr','omega','directions'])
|
||||||
optic_cond, seebeck, kappa = conductivity_and_seebeck(Gamma_w, omega, Om_mesh, SK.SP, ['xx'], beta=beta)
|
optic_cond, seebeck, kappa = conductivity_and_seebeck(Gamma_w, omega, Om_mesh, SK.SP, ['xx'], beta=beta)
|
||||||
output_dict = {'seebeck': seebeck, 'optic_cond': optic_cond, 'kappa': kappa}
|
output_dict = {'seebeck': seebeck, 'optic_cond': optic_cond, 'kappa': kappa}
|
||||||
write_output_to_hdf(SK, output_dict, 'transp_output')
|
|
||||||
|
|
||||||
# comparison of the output transport data
|
# comparison of the output transport data
|
||||||
if mpi.is_master_node():
|
if mpi.is_master_node():
|
||||||
|
write_output_to_hdf(SK, output_dict, 'transp_output')
|
||||||
out = HDFArchive('SrVO3.ref.h5','r')
|
out = HDFArchive('SrVO3.ref.h5','r')
|
||||||
ref = HDFArchive('srvo3_transp.ref.h5', 'r')
|
ref = HDFArchive('srvo3_transp.ref.h5', 'r')
|
||||||
h5diff.compare('', out['transp_output'], ref['transp_output'], 0, 1e-8)
|
h5diff.compare('', out['transp_output'], ref['transp_output'], 0, 1e-8)
|
Loading…
Reference in New Issue
Block a user