diff --git a/src/hwave/qlmsio/read_input_k.py b/src/hwave/qlmsio/read_input_k.py index fd5ae51..daebe95 100644 --- a/src/hwave/qlmsio/read_input_k.py +++ b/src/hwave/qlmsio/read_input_k.py @@ -78,6 +78,10 @@ def __init__(self, info_inputfile, solver_type="UHFk"): logger.info("QLMSkInput: read initial_uhf from {}".format(file_name)) self.green["initial_uhf"] = self._read_data(file_name, "complex") + #- how to set initial green function when file is not given + if "initial_mode" in info_inputfile: + self.green["initial_mode"] = info_inputfile["initial_mode"] + #- geometry.dat is required to handle data in coordinate space if "geometry_uhf" in info_inputfile: file_name = os.path.join(input_file_dir, info_inputfile["geometry_uhf"]) diff --git a/src/hwave/solver/uhfk.py b/src/hwave/solver/uhfk.py index ffbbdc7..cc4159a 100644 --- a/src/hwave/solver/uhfk.py +++ b/src/hwave/solver/uhfk.py @@ -624,14 +624,57 @@ def _initial_green(self, green_info): exit(1) logger.info("load initial green function in coord space from file") _data = self._initial_green_uhf(green_info["initial_uhf"], green_info["geometry_uhf"]) - - if _data is None: + elif "initial_mode" in green_info: + if green_info["initial_mode"] == "zero": + logger.info("initialize green function with zeros") + _data = self._initial_green_zero() + elif green_info["initial_mode"] in ["one", "unity"]: + logger.info("initialize green function with identity") + _data = self._initial_green_one() + elif green_info["initial_mode"] == "conventional_random": + logger.info("initialize green function with random numbers (conventional)") + _data = self._initial_green_random_conv() + #_data = self._initial_green_random_conv_reshape() + elif green_info["initial_mode"] == "random": + pass # default + + if _data is None: # default logger.info("initialize green function with random numbers") - _data = self._initial_green_random() - # _data = self._initial_green_random_reshape() + _data = self._initial_green_random_simple() return _data - def _initial_green_random_reshape(self): + def _initial_green_zero(self): + nvol = self.nvol + norb = self.norb + ns = self.ns + nd = ns * norb + + green = np.zeros((nvol,ns,norb,ns,norb), dtype=np.complex128) + return green + + def _initial_green_one(self): + nvol = self.nvol + norb = self.norb + ns = self.ns + nd = ns * norb + + green = np.zeros((nvol,ns,norb,ns,norb), dtype=np.complex128) + green[0] = np.einsum('ab,st->satb', np.identity(norb), np.identity(ns)) + return green + + def _initial_green_random_simple(self): + nvol = self.nvol + norb = self.norb + ns = self.ns + nd = ns * norb + + np.random.seed(self.param_mod["RndSeed"]) + rand = np.random.rand(nvol * nd * nd).reshape(nvol,ns,norb,ns,norb) + green = 0.01 * (rand - 0.5) + + return green + + def _initial_green_random_conv_reshape(self): lx,ly,lz = self.cellshape lvol = self.cellvol norb = self.norb_orig if self.has_sublattice else self.norb @@ -654,7 +697,7 @@ def _initial_green_random_reshape(self): else: return green - def _initial_green_random(self): + def _initial_green_random_conv(self): nvol = self.nvol norb = self.norb ns = self.ns