typename DMFTBase::GFType DMFTBase::getBubblePI(MPoint in) const { GFType out(this->_S.w_grid); GFType gw_shift(_S.gw), Sigma_shift(_S.Sigma); real_type T = 1.0/_S.w_grid.beta(); if (std::abs(complex_type(in))<PI*T) { gw_shift = _S.gw.shift(in); Sigma_shift = _S.Sigma.shift(in); }; GFType iwn(this->_S.w_grid); iwn.fill(typename GFType::function_type([](complex_type w){return w;})); out = -T*(_S.gw+gw_shift)/(2*iwn+complex_type(in)+2.0*_S.mu-_S.Sigma-Sigma_shift); return out; }
// s = e^{i \pi \lambda A} const complex_matrix_type make_s( const value_type l ) const { auto A = make_new_a(); A *= complex_type(0,l); return expm(A); }
inline typename LatticeDMFTSC<LatticeT>::GFType LatticeDMFTSC<LatticeT>::getBubble(MPoint in, std::array<KPoint,_D> q) const { auto args = std::tuple_cat(std::forward_as_tuple(in),q); auto out = Diagrams::getBubble(this->getGLat(_S.w_grid),args); auto T = 1.0/_S.beta; auto w_1 = _S.w_1; auto mu = _S.mu; auto U = _S.U; out.tail_ = std::bind([T,in,w_1,mu,U](complex_type w){return -T/(w*(w+complex_type(in)))*(1.0 - (1.0/w + 1.0/((w+complex_type(in))))*(mu-w_1*U));},std::placeholders::_1); return out; }
//--------------------------------------------------------------------------- ParserComplex::complex_type ParserComplex::UnpackToComplex(double val) { float imag(0), real(0); real = *((float*)(&val)); imag = *((float*)(&val)+1); return complex_type(real, imag); }
//--------------------------------------------------------------------------- // Default value recognition callback int ParserComplex::IsVal(const char_type *a_szExpr, int *a_iPos, value_type *a_fVal) { string_type buf(a_szExpr); float real, imag; int stat, len; stat = sscanf(buf.c_str(), "{%f,%f}%n", &real, &imag, &len); if (stat!=2) return 0; *a_iPos += len; *a_fVal = PackToDouble(complex_type(real, imag)); return 1; }
const complex_matrix_type make_ug( const matrix_type& G, const matrix_type& A, const matrix_type& D ) const { assert( G.col() == 3 ); assert( A.col() == 3 ); assert( D.col() == 1 ); assert( A.row() == D.row() ); auto const M = make_matrix(); auto const S = G * ( M.inverse() ); matrix_type s( 1, S.row() ); for ( size_type i = 0; i < S.row(); ++ i ) { s[0][i] = value_type( 0.5 ) * std::sqrt( std::inner_product( S.row_begin( i ), S.row_end( i ), S.row_begin( i ), value_type( 0 ) ) ); } auto const piomega = 3.141592553590 * feng::inner_product( array_type( M[0][0], M[1][0], M[2][0] ), feng::cross_product( array_type( M[0][1], M[1][1], M[2][1] ), array_type( M[0][2], M[1][2], M[2][2] ) ) ); auto const atomcellfacte = make_gaussian_electron( s, v0 ); const complex_matrix_type dwss = D * feng::pow( s, value_type( 2 ) ); const complex_matrix_type piag = A * G.transpose(); auto fact = feng::exp( - dwss - piag * complex_type( 0, 6.2831853071796 ) ); std::transform( fact.begin(), fact.end(), atomcellfacte.begin(), fact.begin(), [piomega]( const complex_type f, const value_type a ) { return f * a / piomega; } ); complex_matrix_type Ug( fact.col(), 1 ); for ( size_type i = 0; i < fact.col(); ++i ) { Ug[i][0] = std::accumulate( fact.col_begin( i ), fact.col_end( i ), complex_type() ); //if ( std::abs(Ug[i][0].real()) < 1.0e-8 ) Ug[i][0].real(0); //if ( std::abs(Ug[i][0].imag()) < 1.0e-8 ) Ug[i][0].imag(0); } return Ug; }
//should be optimized const complex_matrix_type make_new_a() const { auto A = make_a(); auto gs = make_gscale(); auto gy = make_gyvec(); auto const gd = make_gd(make_beam_vector()); auto const Gm = make_gm(gd); auto gm = make_unique_beams(Gm); array_type gxu = scale_multiply( gx, gs ); array_type gyu = scale_multiply( gy, gs ); array_type gu = array_type( gxu.norm(), gyu.norm(), 0 ); array_vector_type gxy( gd ); std::for_each( gxy.begin(), gxy.end(), [gu](array_type& a){ a[0]*=gu[1]; a[1]*=gu[0]; a[2]=0; } ); vector_type gxy2( gxy.size() ); feng::for_each( gxy2.begin(), gxy2.end(), gxy.begin(), [](value_type& v, const array_type& a){ v = a.norm(); v*=v; } ); feng::for_each( A.diag_begin(), A.diag_end(), gxy2.begin(), [](complex_type& c, const value_type& v){ c = complex_type(-v, 0); } ); std::cout << "\nA=\n" << A; return A; }
complex_size( const complex_type& c_ = complex_type( 0, 0 ), const size_type s_ = size_type( 0 ) ) : c( c_ ), s( s_ ) {}