Ejemplo n.º 1
0
def get_from_chain_stepwise_convergence(J,
                                        domain,
                                        nof_coefficients,
                                        disc_type='sp_quad',
                                        interval_type='log',
                                        mapping_type='sp_hes',
                                        permute=None,
                                        residual=True,
                                        low_memory=True,
                                        stable=False,
                                        min_ncap=10,
                                        max_ncap=2000,
                                        step_ncap=1,
                                        stop_rel=1e-10,
                                        stop_abs=1e-10,
                                        get_trafo=False,
                                        force_sp=False,
                                        mp_dps=30,
                                        sort_by=None,
                                        **kwargs):
    """
        Returns star coefficients, constructed from chain coefficients via diagonalization
        see chain.get_from_stepwise_convergence and convert_chain_to_star for an explanation of the arguments.
        Sort_by sorts the couplings and energies (if passed and not None), see utils.sorting.sort_star_coefficients
        for details on the parameters.
        Defaults to logarithmic intervals for the direct discretization
    :returns: gamma (couplings), xi (energies), info dict from both the conversion and the chain mapping
              if get_trafo is set True, the dict only contains the latest transformation (from chain to star here)
    """
    c0, omega, t, info = get_from_stepwise_convergence(
        J,
        domain,
        nof_coefficients,
        disc_type=disc_type,
        interval_type=interval_type,
        mapping_type=mapping_type,
        permute=permute,
        residual=residual,
        low_memory=low_memory,
        stable=stable,
        min_ncap=min_ncap,
        max_ncap=max_ncap,
        step_ncap=step_ncap,
        stop_rel=stop_rel,
        stop_abs=stop_abs,
        get_trafo=False,
        **kwargs)
    gamma, xi, trafo_info = convert_chain_to_star(c0,
                                                  omega,
                                                  t,
                                                  force_sp=force_sp,
                                                  mp_dps=mp_dps,
                                                  get_trafo=get_trafo)
    gamma, xi = sort_star_coefficients(gamma, xi, sort_by)
    return gamma, xi, info.update(trafo_info)
Ejemplo n.º 2
0
def get_from_hr_star_stepwise_convergence(discretized_bath,
                                          nof_coefficients,
                                          mapping_type='sp_hes',
                                          permute=None,
                                          residual=True,
                                          low_memory=True,
                                          stable=False,
                                          min_ncap=10,
                                          max_ncap=2000,
                                          step_ncap=1,
                                          stop_rel=1e-10,
                                          stop_abs=1e-10,
                                          get_trafo=False,
                                          force_sp=False,
                                          mp_dps=30,
                                          sort_by=None):
    """
        Returns star coefficients, constructed from chain coefficients via diagonalization using a pre-
        constructed discretized bath as 'high-resolution' star, which is mapped to chain, truncated and
        then mapped back,
        see chain.from_bath_from_stepwise_convergence and convert_chain_to_star for an explanation of the arguments.
        Sort_by sorts the couplings and energies (if passed and not None), see utils.sorting.sort_star_coefficients
        for details on the parameters.
    :returns: gamma (couplings), xi (energies), info dict from both the conversion and the chain mapping
              if get_trafo is set True, the dict only contains the latest transformation (from chain to star here)
    """
    c0, omega, t, info = from_bath_from_stepwise_convergence(
        discretized_bath,
        nof_coefficients,
        mapping_type=mapping_type,
        permute=permute,
        residual=residual,
        low_memory=low_memory,
        stable=stable,
        min_ncap=min_ncap,
        max_ncap=max_ncap,
        step_ncap=step_ncap,
        stop_rel=stop_rel,
        stop_abs=stop_abs,
        get_trafo=get_trafo)
    gamma, xi, trafo_info = convert_chain_to_star(c0,
                                                  omega,
                                                  t,
                                                  force_sp=force_sp,
                                                  mp_dps=mp_dps,
                                                  get_trafo=get_trafo)
    gamma, xi = sort_star_coefficients(gamma, xi, sort_by)
    return gamma, xi, info.update(trafo_info)
Ejemplo n.º 3
0
 def get_star_coefficients_from_chain(self,
                                      get_trafo=False,
                                      force_sp=False,
                                      mp_dps=30):
     """
         Calculates the equivalent star coefficients of the currently calculated chain coefficients.
         Returns None if none have been calculated so far
         See utils.convert.convert_chain_to_star for an explanation of the parameters
     :return: star couplings gamma, star energies xi, info dict from conversion
              (see utils.convert.convert_chain_to_star)
     """
     if self.nof_calculated_coefficients == 0:
         return None, None, None
     else:
         return convert_chain_to_star(self.c0,
                                      self.omega,
                                      self.t,
                                      get_trafo=get_trafo,
                                      force_sp=force_sp,
                                      mp_dps=mp_dps)
Ejemplo n.º 4
0
 def get_discretized_bath_from_chain(self,
                                     get_trafo=False,
                                     force_sp=False,
                                     mp_dps=30):
     """
         Calculates the equivalent discretized bath of the currently calculated chain coefficients.
         Returns None if none have been calculated so far
         See utils.convert.convert_chain_to_star for an explanation of the parameters.
     :return: discretized bath object, info dict from conversion (see utils.convert.convert_chain_to_star)
     """
     if self.nof_calculated_coefficients == 0:
         return None, None
     else:
         gamma, xi = convert_chain_to_star(self.c0,
                                           self.omega,
                                           self.t,
                                           get_trafo=get_trafo,
                                           force_sp=force_sp,
                                           mp_dps=mp_dps)
         return DiscretizedBath(gamma, xi)
Ejemplo n.º 5
0
 def __init__(self, J, domain, max_nof_coefficients=100, **kwargs):
     """
         Generates BSDO coefficients from a spectral density J, by diagonalizing the tridiagonal matrix
         of polynomial recurrence coefficients
     :param J: Spectral density. A function defined on 'domain', must be >0 in the inner part of domain
     :param domain: List/tuple of two elements for the left and right boundary of the domain of J
     :param max_nof_coefficients: Size of the buffers which hold gamma and xi coefficients (maximum number of
                      these coefficients that can be calculated)
     :param kwargs: may contain 'orthpol_ncap' to change the internal discretization of orthpol, default is 60000
                                'mp_dps' to change the number o decimals with which the diagonalization is performed
                                         defult is 30
                                'force_sp' forces scipy eigh for the diagonalization, default is False
     """
     self.J = J
     try:
         orthpol_ncap = kwargs['orthpol_ncap']
     except KeyError:
         orthpol_ncap = 60000
     try:
         mp_dps = kwargs['mp_dps']
     except KeyError:
         mp_dps = 30
     try:
         force_sp = kwargs['force_sp']
     except KeyError:
         force_sp = False
     try:
         get_trafo = kwargs['get_trafo']
     except KeyError:
         get_trafo = False
     super().__init__(self.compute_coefficients, max_nof_coefficients=max_nof_coefficients)
     # Preallocate arrays for the coefficients
     alpha, beta = self.get_monic_recurrence(max_nof_coefficients, domain, J, orthpol_ncap)
     self._eta_0 = beta[0]
     self.gamma_buf[:], self.xi_buf[:], info = \
         convert_chain_to_star(np.sqrt(beta[0]), alpha, np.sqrt(beta[1::]), force_sp=force_sp, mp_dps=mp_dps,
                               sort_by=None, get_trafo=get_trafo)
     self.info = info
     self._set_next_n(max_nof_coefficients)