@@ -4230,7 +4230,57 @@ def w_to_a(self,w, T):
42304230 a [:] = np .sqrt ((1.0 / np .tanh (0.5 * w * 315774.65221921849 / T )) / (2.0 * w ))
42314231 return a
42324232
4233+
4234+
4235+
4236+ # ------------------------------------------------------------------------------
4237+ def load_ensemble_bin (directory , population , temperature , nqirr = - 1 ):
4238+ """
4239+ Load the ensemble from the given directory. This subroutine automatically initializes the ensemble
4240+ and avoids the hursle of having to define and initialize a dynamical matrix before loading the ensemble.
4241+
4242+
4243+ Parameters
4244+ ----------
4245+ - directory : string
4246+ Path to the directory where the ensemble is located
4247+ - population : Int
4248+ The index of the ensemble
4249+ - temperature : Float
4250+ The temperature for the ensemble
4251+ - nqirr : Int
4252+ The number of irreducible points of the dynamical matrix.
4253+ If not provided (or negative), it is inferred from the files.
4254+
4255+ Returns
4256+ -------
4257+ - ensemble : Ensemble()
4258+ The Ensemble object.
4259+ """
4260+
4261+ # Get the generated dyn
4262+ generated_name = os .path .join (directory , "dyn_gen_pop%d_" % population )
4263+
4264+ # Infer the nqirr if not provided
4265+ if nqirr < 0 :
4266+ nqirr = len ([x for x in os .listdir (directory ) if x .startswith ("dyn_gen_pop%d_" % population )])
4267+ if os .path .exists (generated_name + "0" ):
4268+ nqirr -= 1
4269+
4270+ # Load the dynamical matrix
4271+ dyn = CC .Phonons .Phonons (generated_name , nqirr )
4272+
4273+ # Check if nqirr was correct
4274+ assert np .prod (dyn .GetSupercell ()) == len (dyn .dynmats ), "Error, the value of nqirr = {} is wrong. Check wether you specified the correct value." .format (nqirr )
4275+
4276+ ensemble = Ensemble (dyn , temperature )
4277+ ensemble .load_bin (directory , population )
4278+
4279+ return ensemble
4280+
4281+
42334282#-------------------------------------------------------------------------------
4283+
42344284def _wrapper_julia_get_upsilon_q (* args , ** kwargs ):
42354285 """Worker function, just for testing"""
42364286 return julia .Main .get_upsilon_fourier (* args , ** kwargs )
0 commit comments