Skip to content

Commit 0bc1875

Browse files
committed
Remove unused q_start and current_q arrays from Ensemble
These two arrays (N_configs x 3*nat_sc float64 each) were allocated in Ensemble.__init__ but never read anywhere in the active codebase. All usages were commented out after the weight-update code was refactored to use the uYu direct computation instead of the old get_gaussian_weight Fortran path. For a typical simulation (N=20000, nat_sc=320, 4x4x4 supercell), this saves ~293 MB of persistent memory per ensemble.
1 parent ae48d6e commit 0bc1875

1 file changed

Lines changed: 1 addition & 35 deletions

File tree

Modules/Ensemble.py

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,6 @@ def __init__(self, dyn0, T0, supercell = None, **kwargs):
235235
self.supercell_structure = super_struct
236236
self.itau = itau + 1
237237

238-
# To avoid to recompute each time the same variables store something usefull here
239-
self.q_start = np.zeros( (self.N, Nsc * 3))
240-
self.current_q = np.zeros( (self.N, Nsc * 3))
241-
242238
self.q_opposite_index = None
243239

244240
# Store also the displacements
@@ -709,11 +705,6 @@ def load(self, data_dir, population, N, verbose = False, load_displacements = Tr
709705
self.rho = np.ones(self.N, dtype = np.float64)
710706

711707

712-
t1 = time.time()
713-
#self.q_start = CC.Manipulate.GetQ_vectors(self.structures, dyn_supercell, self.u_disps)
714-
t2 = time.time()
715-
#self.current_q = self.q_start.copy()
716-
717708
p_count = np.sum(self.stress_computed.astype(int))
718709
if p_count > 0:
719710
self.has_stress = True
@@ -832,11 +823,6 @@ def load_from_calculator_output(self, directory, out_ext = ".pwo", timer=None):
832823

833824
self.rho = np.ones(self.N, dtype = np.float64)
834825

835-
t1 = time.time()
836-
# self.q_start = CC.Manipulate.GetQ_vectors(self.structures, dyn_supercell, self.u_disps)
837-
t2 = time.time()
838-
# self.current_q = self.q_start.copy()
839-
840826
if count_stress == self.N:
841827
self.has_stress = True
842828
else:
@@ -1797,21 +1783,13 @@ def update_weights_fourier(self, new_dynamical_matrix, newT, timer=None):
17971783

17981784

17991785

1800-
# Convert the q vectors in the Hartree units
1801-
#old_q = self.q_start * np.sqrt(np.float64(2)) * __A_TO_BOHR__
1802-
#new_q = self.current_q * np.sqrt(np.float64(2)) * __A_TO_BOHR__
1803-
1804-
1805-
#t1 = time.time()
1806-
#self.rho = SCHAModules.stochastic.get_gaussian_weight(new_q, old_q, new_a, old_a)
1807-
#t2 = time.time()
1808-
18091786
if __DEBUG_RHO__:
18101787
print( " ==== [UPDATE RHO DEBUGGING] ==== ")
18111788
print( " INPUT INFO: ")
18121789
np.savetxt("rho_%05d.dat" % self.__debug_index__, self.rho)
18131790
print( " rho saved in ", "rho_%05d.dat" % self.__debug_index__)
18141791

1792+
18151793
# Get the two covariance matrix
18161794
t1 = time.time()
18171795
Y_qspace_new = julia.Main.get_upsilon_fourier(
@@ -2020,15 +1998,6 @@ def update_weights(self, new_dynamical_matrix, newT, update_q = False, timer=Non
20201998

20211999

20222000

2023-
# Convert the q vectors in the Hartree units
2024-
#old_q = self.q_start * np.sqrt(np.float64(2)) * __A_TO_BOHR__
2025-
#new_q = self.current_q * np.sqrt(np.float64(2)) * __A_TO_BOHR__
2026-
2027-
2028-
#t1 = time.time()
2029-
#self.rho = SCHAModules.stochastic.get_gaussian_weight(new_q, old_q, new_a, old_a)
2030-
#t2 = time.time()
2031-
20322001
if __DEBUG_RHO__:
20332002
print( " ==== [UPDATE RHO DEBUGGING] ==== ")
20342003
print( " INPUT INFO: ")
@@ -3121,9 +3090,6 @@ def get_average_stress(self):
31213090

31223091
# #n_modes = len(w)
31233092

3124-
# # Convert the q vector into Ha units
3125-
# q_new = np.array(self.current_q, dtype = np.float64) * np.sqrt(2) * __A_TO_BOHR__
3126-
31273093
# # Get the ityp variable
31283094
# #ityp = self.current_dyn.structure.get_atomic_types()
31293095

0 commit comments

Comments
 (0)