@@ -1916,25 +1916,26 @@ def get_preconditioned_gradient(self, subtract_sscha = True, return_error = Fals
19161916 """
19171917
19181918 t1 = time .time ()
1919- supercell_dyn = self .current_dyn .GenerateSupercellDyn (self .supercell )
1919+ super_struct = self .current_dyn .structure .generate_supercell (self .supercell )
1920+ #supercell_dyn = self.current_dyn.GenerateSupercellDyn(self.supercell)
19201921
19211922 # Dyagonalize
1922- w , pols = supercell_dyn .DyagDinQ (0 )
1923+ w , pols = self . current_dyn . DiagonalizeSupercell () # supercell_dyn.DyagDinQ(0)
19231924
19241925 if not self .ignore_small_w :
1925- trans = CC .Methods .get_translations (pols , supercell_dyn . structure .get_masses_array ())
1926+ trans = CC .Methods .get_translations (pols , super_struct .get_masses_array ())
19261927 else :
19271928 trans = np .abs (w ) < CC .Phonons .__EPSILON_W__
19281929
1929- ityp = supercell_dyn . structure .get_ityp () + 1 # Py to fortran convertion
1930- mass = np .array (list (supercell_dyn . structure .masses .values ()))
1930+ ityp = super_struct .get_ityp () + 1 # Py to fortran convertion
1931+ mass = np .array (list (super_struct .masses .values ()))
19311932
19321933 log_err = "err_yesrho"
19331934
19341935 mass *= 2
19351936 w /= 2
19361937
1937- nat = supercell_dyn . structure .N_atoms
1938+ nat = super_struct .N_atoms
19381939 eforces = np .zeros ((self .N , nat , 3 ), dtype = np .float64 , order = "F" )
19391940 u_disp = np .zeros ((self .N , nat , 3 ), dtype = np .float64 , order = "F" )
19401941 #print nat
@@ -1975,11 +1976,20 @@ def get_preconditioned_gradient(self, subtract_sscha = True, return_error = Fals
19751976
19761977 # Perform the fourier transform
19771978 if return_error :
1978- q_grad ,q_grad_err = CC .Phonons .GetDynQFromFCSupercell (grad , np .array (self .current_dyn .q_tot ),
1979- self .current_dyn .structure , supercell_dyn .structure ,fc2 = grad_err )
1979+ # Check if a multiprocessing function can be exploited
1980+ if hasattr (CC .Phonons , 'GetDynQFromFCSupercell_parallel' ) and CC .Settings .GetNProc () > 1 :
1981+ q_grad ,q_grad_err = CC .Phonons .GetDynQFromFCSupercell_parallel (grad , np .array (self .current_dyn .q_tot ),
1982+ self .current_dyn .structure , super_struct ,fc2 = grad_err )
1983+ else :
1984+ q_grad ,q_grad_err = CC .Phonons .GetDynQFromFCSupercell (grad , np .array (self .current_dyn .q_tot ),
1985+ self .current_dyn .structure , super_struct ,fc2 = grad_err )
19801986 else :
1981- q_grad = CC .Phonons .GetDynQFromFCSupercell (grad , np .array (self .current_dyn .q_tot ),
1982- self .current_dyn .structure , supercell_dyn .structure )
1987+ if hasattr (CC .Phonons , 'GetDynQFromFCSupercell_parallel' ):
1988+ q_grad = CC .Phonons .GetDynQFromFCSupercell_parallel (grad , np .array (self .current_dyn .q_tot ),
1989+ self .current_dyn .structure , super_struct )
1990+ else :
1991+ q_grad = CC .Phonons .GetDynQFromFCSupercell (grad , np .array (self .current_dyn .q_tot ),
1992+ self .current_dyn .structure , super_struct )
19831993 #q_grad_err = CC.Phonons.GetDynQFromFCSupercell(grad_err, np.array(self.current_dyn.q_tot),
19841994 # self.current_dyn.structure, supercell_dyn.structure)
19851995 else :
0 commit comments