@@ -1923,25 +1923,26 @@ def get_preconditioned_gradient(self, subtract_sscha = True, return_error = Fals
19231923 """
19241924
19251925 t1 = time .time ()
1926- supercell_dyn = self .current_dyn .GenerateSupercellDyn (self .supercell )
1927-
1926+ super_struct = self .current_dyn .structure .generate_supercell (self .supercell )
1927+ #supercell_dyn = self.current_dyn.GenerateSupercellDyn(self.supercell)
1928+
19281929 # Dyagonalize
1929- w , pols = supercell_dyn .DyagDinQ (0 )
1930+ w , pols = self . current_dyn . DiagonalizeSupercell () # supercell_dyn.DyagDinQ(0)
19301931
19311932 if not self .ignore_small_w :
1932- trans = CC .Methods .get_translations (pols , supercell_dyn . structure .get_masses_array ())
1933+ trans = CC .Methods .get_translations (pols , super_struct .get_masses_array ())
19331934 else :
19341935 trans = np .abs (w ) < CC .Phonons .__EPSILON_W__
19351936
1936- ityp = supercell_dyn . structure .get_ityp () + 1 # Py to fortran convertion
1937- mass = np .array (list (supercell_dyn . structure .masses .values ()))
1938-
1937+ ityp = super_struct .get_ityp () + 1 # Py to fortran convertion
1938+ mass = np .array (list (super_struct .masses .values ()))
1939+
19391940 log_err = "err_yesrho"
19401941
19411942 mass *= 2
19421943 w /= 2
19431944
1944- nat = supercell_dyn . structure .N_atoms
1945+ nat = super_struct .N_atoms
19451946 eforces = np .zeros ((self .N , nat , 3 ), dtype = np .float64 , order = "F" )
19461947 u_disp = np .zeros ((self .N , nat , 3 ), dtype = np .float64 , order = "F" )
19471948 #print nat
@@ -1982,11 +1983,20 @@ def get_preconditioned_gradient(self, subtract_sscha = True, return_error = Fals
19821983
19831984 # Perform the fourier transform
19841985 if return_error :
1985- q_grad ,q_grad_err = CC .Phonons .GetDynQFromFCSupercell (grad , np .array (self .current_dyn .q_tot ),
1986- self .current_dyn .structure , supercell_dyn .structure ,fc2 = grad_err )
1986+ # Check if a multiprocessing function can be exploited
1987+ if hasattr (CC .Phonons , 'GetDynQFromFCSupercell_parallel' ) and CC .Settings .GetNProc () > 1 :
1988+ q_grad ,q_grad_err = CC .Phonons .GetDynQFromFCSupercell_parallel (grad , np .array (self .current_dyn .q_tot ),
1989+ self .current_dyn .structure , super_struct ,fc2 = grad_err )
1990+ else :
1991+ q_grad ,q_grad_err = CC .Phonons .GetDynQFromFCSupercell (grad , np .array (self .current_dyn .q_tot ),
1992+ self .current_dyn .structure , super_struct ,fc2 = grad_err )
19871993 else :
1988- q_grad = CC .Phonons .GetDynQFromFCSupercell (grad , np .array (self .current_dyn .q_tot ),
1989- self .current_dyn .structure , supercell_dyn .structure )
1994+ if hasattr (CC .Phonons , 'GetDynQFromFCSupercell_parallel' ):
1995+ q_grad = CC .Phonons .GetDynQFromFCSupercell_parallel (grad , np .array (self .current_dyn .q_tot ),
1996+ self .current_dyn .structure , super_struct )
1997+ else :
1998+ q_grad = CC .Phonons .GetDynQFromFCSupercell (grad , np .array (self .current_dyn .q_tot ),
1999+ self .current_dyn .structure , super_struct )
19902000 #q_grad_err = CC.Phonons.GetDynQFromFCSupercell(grad_err, np.array(self.current_dyn.q_tot),
19912001 # self.current_dyn.structure, supercell_dyn.structure)
19922002 else :
0 commit comments