示例#1
0
def init(inidic):

    try:
        q_cl = inidic['q_cl']
        exbe = inidic['exbe']
    except:
        q_cl = 'q'
        exbe = 0

    npsd = inidic['npsd']
    pade = inidic['pade']
    temp = inidic['temp']
    jomg = inidic['jomg']
    nmod = len(jomg)

    nind = 0
    mode = []
    for m in xrange(nmod):
        try:
            ndru = len(jomg[m]['jdru'])
        except:
            ndru = 0
        try:
            nsdr = len(jomg[m]['jsdr'])
        except:
            nsdr = 0
        try:
            nqdr = len(jomg[m]['jqdr'])
        except:
            nqdr = 0
        nper = ndru + 2 * nsdr + 3 * nqdr + npsd
        nind += nper
        mode.extend([m for i in xrange(nper)])
    mode = np.array(mode)
    delr = np.zeros(nmod, dtype=float)
    expn = np.zeros(nind, dtype=complex)
    etal = np.zeros(nind, dtype=complex)
    etar = np.zeros(nind, dtype=complex)
    etaa = np.zeros(nind, dtype=float)
    bdip = np.zeros(nind, dtype=float)

    pole, resi, rn, tn = PSD(npsd, BoseFermi=1, pade=pade)

    iind = 0

    for m in xrange(nmod):
        # Dru
        try:
            jdru = jomg[m]['jdru']
        except:
            jdru = []
        # Sdr
        try:
            jsdr = jomg[m]['jsdr']
        except:
            jsdr = []
        # Qdr
        try:
            jqdr = jomg[m]['jqdr']
        except:
            jqdr = []
        # Num
        ndru = len(jdru)
        nsdr = len(jsdr)
        nqdr = len(jqdr)

        for idru in xrange(ndru):

            if len(jdru[idru]) != 2:
                raise ValueError('Invalid drude input')

            lamd, gamd = jdru[idru][0], jdru[idru][1]
            expn[iind] = gamd
            etal[iind] = -2.J * lamd * gamd * fBose(-1.J * gamd / temp, pole,
                                                    resi, rn, tn, exbe)
            if q_cl == 'cl':
                etal[iind] = etal[iind].real
            etar[iind] = etal[iind].conj()
            etaa[iind] = abs(etal[iind])
            delr[m] += 2. * lamd * gamd / temp * rn

            iind += 1

        for isdr in xrange(nsdr):

            if len(jsdr[isdr]) != 3:
                raise ValueError('Invalid BO input')

            lams, omgs, gams = jsdr[isdr][0], jsdr[isdr][1], jsdr[isdr][2]
            jind = iind + 1
            etaBO = 2. * lams * omgs * omgs * gams
            Delta = omgs * omgs - gams * gams / 4.0
            delr[m] += etaBO * tn / (temp**3)
            if Delta > 0:
                OmgB = sqrt(Delta)
                expn[iind] = 0.5 * gams + 1.J * OmgB
                expn[jind] = 0.5 * gams - 1.J * OmgB
            elif Delta < 0:
                OmgB = sqrt(-Delta)
                expn[iind] = 0.5 * gams + OmgB
                expn[jind] = 0.5 * gams - OmgB
            else:
                raise ValueError("Not prepared for Delta=0")
            z1, z2 = -1.J * expn[iind], -1.J * expn[jind]

            etal[iind] = -2.J * etaBO * z1 / (
                2. * z1 * (z1 + z2) *
                (z1 - z2)) * fBose(z1 / temp, pole, resi, rn, tn, exbe)
            etal[jind] = -2.J * etaBO * z2 / (
                2. * z2 * (z2 + z1) *
                (z2 - z1)) * fBose(z2 / temp, pole, resi, rn, tn, exbe)
            if Delta > 0:
                if q_cl == 'cl':
                    etal[iind], etal[jind] = 0.5*(etal[iind]+etal[jind].conj()), \
                            0.5*(etal[jind]+etal[iind].conj())
                etar[iind] = etal[jind].conj()
                etar[jind] = etal[iind].conj()
                etaa[iind] = etaa[jind] = sqrt(
                    abs(etal[iind]) * abs(etal[jind]))
            elif Delta < 0:
                if q_cl == 'cl':
                    etal[iind], etal[jind] = etal[iind].real, etal[jind].real
                etar[iind] = etal[iind].conj()
                etar[jind] = etal[jind].conj()
                etaa[iind] = abs(etal[iind])
                etaa[jind] = abs(etal[jind])
            else:
                raise ValueError("Not prepared for Delta=0")

            iind += 2

        for iqdr in xrange(nqdr):

            if len(jqdr[iqdr]) != 4:
                raise ValueError('Invalid Jw input')

            lams, omgs, lamt, gamt = jqdr[iqdr][0], jqdr[iqdr][1], jqdr[iqdr][
                2], jqdr[iqdr][3]
            jind = iind + 1
            kind = iind + 2
            expn[iind], expn[jind], expn[kind] = qdrgm(jqdr[iqdr])
            etaBO = 2.0 * lams * lamt * (omgs * gamt)**2
            z0, z1, z2 = -1.J * expn[iind], -1.J * expn[jind], -1.J * expn[kind]

            etal[iind] = -1.J * etaBO / (
                (z0**2 - z1**2) *
                (z0**2 - z2**2)) * fBose(z0 / temp, pole, resi, rn, tn, exbe)
            etal[jind] = -1.J * etaBO / (
                (z1**2 - z0**2) *
                (z1**2 - z2**2)) * fBose(z1 / temp, pole, resi, rn, tn, exbe)
            etal[kind] = -1.J * etaBO / (
                (z2**2 - z0**2) *
                (z2**2 - z1**2)) * fBose(z2 / temp, pole, resi, rn, tn, exbe)

            if (all(abs(expn[iind:kind + 1].imag) < 1.0e-10)):
                etar[iind:kind + 1] = etal[iind:kind + 1].conj()
                etaa[iind:kind + 1] = abs(etal[iind:kind + 1])

                if q_cl == 'cl':
                    etal[iind:kind + 1] = etal[iind:kind + 1].real
                    etar[iind:kind + 1] = etal[iind:kind + 1].conj()
                    etaa[iind:kind + 1] = abs(etal[iind:kind + 1])
            else:
                etar[iind] = etal[iind].conj()
                etar[jind] = etal[kind].conj()
                etar[kind] = etal[jind].conj()
                etaa[iind] = abs(etal[iind])
                etaa[jind] = etaa[kind] = sqrt(
                    abs(etal[jind]) * abs(etal[kind]))

                if q_cl == 'cl':
                    etal[iind] = etal[iind].real
                    etar[iind] = etal[iind].conj()
                    etaa[iind] = abs(etal[iind])
                    etal[jind], etal[kind] = 0.5*(etal[jind]+etal[kind].conj()), \
                                0.5*(etal[kind]+etal[jind].conj())
                    etar[jind] = etal[kind].conj()
                    etar[kind] = etal[jind].conj()
                    etaa[jind] = etaa[kind] = sqrt(
                        abs(etal[jind]) * abs(etal[kind]))

            iind += 3

        for ipsd in xrange(npsd):
            zomg = -1.J * pole[ipsd] * temp
            jsmd = sum(jwdru(zomg, x) for x in jdru)
            jsms = sum(jwsdr(zomg, x) for x in jsdr)
            jsmq = sum(jwqdr(zomg, x) for x in jqdr)
            jsum = jsmd + jsms + jsmq
            expn[iind] = pole[ipsd] * temp
            etal[iind] = -2.J * resi[ipsd] * temp * jsum
            etar[iind] = etal[iind].conj()
            etaa[iind] = abs(etal[iind])

            iind += 1

    arma.save(mode, inidic['modeFile'])
    arma.save(etal, inidic['etalFile'])
    arma.save(etar, inidic['etarFile'])
    arma.save(etaa, inidic['etaaFile'])
    arma.save(expn, inidic['expnFile'])
    arma.save(delr, inidic['delrFile'])
    try:
        arma.save(bdip, inidic['bdipFile'])
    except:
        print 'bdipFile not provided!'
        pass

    return etal, expn
示例#2
0
文件: syst.py 项目: hou-dao/raman
def init (inidic,hams,qmds):
        
    arma.save (hams,inidic['hamsFile'])
    arma.save (qmds,inidic['qmdsFile'])
示例#3
0
def init (inidic):
        
    try:
        q_cl = inidic['q_cl']
        exbe = inidic['exbe']
    except:
        q_cl = 'q'
        exbe = 0

    npsd = inidic['npsd']
    pade = inidic['pade']
    temp = inidic['temp']
    jomg = inidic['jomg']
    nmod = len(jomg)

    nind = 0
    mode = []
    for m in xrange(nmod):
        try:
            nsdr = len(jomg[m]['jsdr'])
        except:
            nsdr = 0
        nper = 2*nsdr+npsd
        nind += nper
        mode.extend([m for i in xrange(nper)])
    mode = np.array(mode)
    delr = np.zeros(nmod,dtype=float)
    expn = np.zeros(nind,dtype=complex)
    etal = np.zeros(nind,dtype=complex)
    etar = np.zeros(nind,dtype=complex)
    etaa = np.zeros(nind,dtype=float)

    pole, resi, rn, tn = PSD (npsd,BoseFermi=1,pade=pade)

    iind = 0

    for m in xrange(nmod):

        try:
            jsdr = jomg[m]['jsdr']
        except:
            jsdr = []

        nsdr = len(jsdr)
    
        for isdr in xrange(nsdr):

            if len(jsdr[isdr]) != 3:
                raise ValueError('Invalid BO input')

            lams, omgs, gams = jsdr[isdr][0], jsdr[isdr][1], jsdr[isdr][2]
            jind = iind+1
            etaBO = omgs*gams
            Delta = omgs*omgs-gams*gams/4.0
            delr[m] +=  etaBO*tn/(temp**3)
            if Delta > 0:
                OmgB = sqrt(Delta)
                expn[iind] = 0.5*gams+1.J*OmgB
                expn[jind] = 0.5*gams-1.J*OmgB
            elif Delta < 0:
                OmgB = sqrt(-Delta)
                expn[iind] = 0.5*gams+OmgB
                expn[jind] = 0.5*gams-OmgB           
            else:
                raise ValueError("Not prepared for Delta=0")
            z1, z2 = -1.J*expn[iind], -1.J*expn[jind]

            etal[iind] = -2.J*etaBO*z1/(2.*z1*(z1+z2)*(z1-z2))*fBose(z1/temp,pole,resi,rn,tn,exbe)
            etal[jind] = -2.J*etaBO*z2/(2.*z2*(z2+z1)*(z2-z1))*fBose(z2/temp,pole,resi,rn,tn,exbe)
            if Delta > 0:
                if q_cl == 'cl':
                    etal[iind], etal[jind] = 0.5*(etal[iind]+etal[jind].conj()), \
                            0.5*(etal[jind]+etal[iind].conj())
                etar[iind] = etal[jind].conj()
                etar[jind] = etal[iind].conj()
                etaa[iind] = etaa[jind] = sqrt(abs(etal[iind])*abs(etal[jind]))
            elif Delta < 0:
                if q_cl == 'cl':
                    etal[iind], etal[jind] = etal[iind].real, etal[jind].real
                etar[iind] = etal[iind].conj()
                etar[jind] = etal[jind].conj()
                etaa[iind] = abs(etal[iind])
                etaa[jind] = abs(etal[jind])
            else:
                raise ValueError("Not prepared for Delta=0")

            iind += 2

        for ipsd in xrange(npsd):
            zomg = -1.J*pole[ipsd]*temp
            jsum = sum(jwsdr(zomg,x) for x in jsdr)
            expn[iind] = pole[ipsd]*temp
            etal[iind] = -2.J*resi[ipsd]*temp*jsum   
            etar[iind] = etal[iind].conj()
            etaa[iind] = abs(etal[iind])  

            iind += 1
                            
    arma.save (mode,inidic['modeFile'])
    arma.save (etal,inidic['etalFile'])
    arma.save (etar,inidic['etarFile'])
    arma.save (etaa,inidic['etaaFile'])
    arma.save (expn,inidic['expnFile'])
    arma.save (delr,inidic['delrFile'])

    return etal, expn
示例#4
0
def init(inidic):

    try:
        q_cl = inidic['q_cl']
        exbe = inidic['exbe']
    except:
        q_cl = 'q'
        exbe = 0

    npsd = inidic['npsd']
    pade = inidic['pade']
    temp = inidic['temp']
    jomg = inidic['jomg']
    nmod = len(jomg)

    nind = 0
    mode = []
    for m in xrange(nmod):
        try:
            ndru = len(jomg[m]['jdru'])
        except:
            ndru = 0
        try:
            nsdr = len(jomg[m]['jsdr'])
        except:
            nsdr = 0
        nper = ndru + 2 * nsdr + npsd
        nind += nper
        mode.extend([m for i in xrange(nper)])
    mode = np.array(mode)
    delr = np.zeros(nmod, dtype=float)
    expn = np.zeros(nind, dtype=complex)
    etal = np.zeros(nind, dtype=complex)
    etar = np.zeros(nind, dtype=complex)
    etaa = np.zeros(nind, dtype=float)
    bdip = np.zeros(nind, dtype=float)

    #try:
    #    amod = inidic['amod'] # array of dru, sdr or all
    #    fmod = inidic['fmod'] # array of mode strength
    #except:
    #    print 'amod and/or fmod are not provided!'

    pole, resi, rn, tn = PSD(npsd, BoseFermi=1, pade=pade)
    """
    !TEST
    """
    #print 'pole', pole
    #print 'resi', resi
    #print 'rn = %16.6e'%rn, 'tn = %16.6e'%tn

    iind = 0

    for m in xrange(nmod):

        try:
            jdru = jomg[m]['jdru']
        except:
            jdru = []

        try:
            jsdr = jomg[m]['jsdr']
        except:
            jsdr = []

        ndru = len(jdru)
        nsdr = len(jsdr)

        for idru in xrange(ndru):

            if len(jdru[idru]) != 2:
                raise ValueError('Invalid drude input')

            lamd, gamd = jdru[idru][0], jdru[idru][1]
            expn[iind] = gamd
            etal[iind] = -2.J * lamd * gamd * fBose(-1.J * gamd / temp, pole,
                                                    resi, rn, tn, exbe)
            if q_cl == 'cl':
                etal[iind] = etal[iind].real
            etar[iind] = etal[iind].conj()
            etaa[iind] = abs(etal[iind])
            delr[m] += 2. * lamd * gamd / temp * rn

            try:
                if amod[m] == 'dru' or amod[m] == 'all':
                    bdip[iind] = fmod[m]
            except:
                pass

            iind += 1

        for isdr in xrange(nsdr):

            if len(jsdr[isdr]) != 3:
                raise ValueError('Invalid BO input')

            lams, omgs, gams = jsdr[isdr][0], jsdr[isdr][1], jsdr[isdr][2]
            jind = iind + 1
            etaBO = 2. * lams * omgs * omgs * gams
            Delta = omgs * omgs - gams * gams / 4.0
            delr[m] += etaBO * tn / (temp**3)
            if Delta > 0:
                OmgB = sqrt(Delta)
                expn[iind] = 0.5 * gams + 1.J * OmgB
                expn[jind] = 0.5 * gams - 1.J * OmgB
            elif Delta < 0:
                OmgB = sqrt(-Delta)
                expn[iind] = 0.5 * gams + OmgB
                expn[jind] = 0.5 * gams - OmgB
            else:
                raise ValueError("Not prepared for Delta=0")
            z1, z2 = -1.J * expn[iind], -1.J * expn[jind]

            etal[iind] = -2.J * etaBO * z1 / (
                2. * z1 * (z1 + z2) *
                (z1 - z2)) * fBose(z1 / temp, pole, resi, rn, tn, exbe)
            etal[jind] = -2.J * etaBO * z2 / (
                2. * z2 * (z2 + z1) *
                (z2 - z1)) * fBose(z2 / temp, pole, resi, rn, tn, exbe)
            if Delta > 0:
                if q_cl == 'cl':
                    etal[iind], etal[jind] = 0.5*(etal[iind]+etal[jind].conj()), \
                            0.5*(etal[jind]+etal[iind].conj())
                etar[iind] = etal[jind].conj()
                etar[jind] = etal[iind].conj()
                etaa[iind] = etaa[jind] = sqrt(
                    abs(etal[iind]) * abs(etal[jind]))
            elif Delta < 0:
                if q_cl == 'cl':
                    etal[iind], etal[jind] = etal[iind].real, etal[jind].real
                etar[iind] = etal[iind].conj()
                etar[jind] = etal[jind].conj()
                etaa[iind] = abs(etal[iind])
                etaa[jind] = abs(etal[jind])
            else:
                raise ValueError("Not prepared for Delta=0")

            try:
                if amod[m] == 'sdr' or amod[m] == 'all':
                    bdip[iind] = fmod[m]
                    bdip[jind] = fmod[m]
            except:
                pass

            iind += 2

        for ipsd in xrange(npsd):
            zomg = -1.J * pole[ipsd] * temp
            jsmd = sum(jwdru(zomg, x) for x in jdru)
            jsms = sum(jwsdr(zomg, x) for x in jsdr)
            jsum = jsmd + jsms
            expn[iind] = pole[ipsd] * temp
            etal[iind] = -2.J * resi[ipsd] * temp * jsum
            etar[iind] = etal[iind].conj()
            etaa[iind] = abs(etal[iind])

            try:
                if amod[m] == 'all':
                    #print 'all:', jsmd, jsms, jsum
                    bdip[iind] = fmod[m]
                #print bdip[iind]
                elif amod[m] == 'dru':
                    #print 'dru:', jsmd, jsum
                    bdip[iind] = (jsmd / jsum).real * fmod[m]
                #print bdip[iind]
                elif amod[m] == 'sdr':
                    #print 'sdr:', jsms, jsum
                    bdip[iind] = (jsms / jsum).real * fmod[m]
                #print bdip[iind]
            except:
                pass

            iind += 1
    """
    !! Test
    """
    #x2 = sum(etal).real
    #xp = sum(etal/expn)
    #print 'npsd =', npsd
    #print 'sum ck/gk =', xp
    #lams, omgs, gams = jsdr[0][0], jsdr[0][1], jsdr[0][2]
    #print 'ti_c(w0) = ', 2.0*lams*omgs*(gams*temp/omgs**3-0.5J/omgs)
    #eta1 = (expn[0]*x2-omgs**2*xp)/(expn[0]-expn[1])
    #eta2 = (expn[1]*x2-omgs**2*xp)/(expn[1]-expn[0])
    #print 'eta1 = ', eta1
    #print 'eta2 = ', eta2
    #print 'delta_2 =', eta1*expn[0]+eta2*expn[1]
    #print (x2-2.0*lams*omgs*temp/omgs)*gams+0.5J*omgs*2.0*lams*omgs

    arma.save(mode, inidic['modeFile'])
    arma.save(etal, inidic['etalFile'])
    arma.save(etar, inidic['etarFile'])
    arma.save(etaa, inidic['etaaFile'])
    arma.save(expn, inidic['expnFile'])
    arma.save(delr, inidic['delrFile'])
示例#5
0
def init(inidic, hams, qmds):

    arma.save(hams, inidic['hamsFile'])
    arma.save(qmds, inidic['qmdsFile'])
示例#6
0
文件: bath.py 项目: dupl10/raman
def init(inidic):

    nmod = inidic['nmod']
    npsd = inidic['npsd']
    pade = inidic['pade']
    temp = inidic['temp']

    ndru = max([len(m['jdru']) for m in inidic['mode']])
    nsdr = max([len(m['jsdr']) for m in inidic['mode']])
    nper = ndru + 2 * nsdr + npsd

    delr = np.zeros(nmod, dtype=float)
    expn = np.zeros((nmod, nper), dtype=complex)
    etal = np.zeros((nmod, nper), dtype=complex)
    etar = np.zeros((nmod, nper), dtype=complex)
    etaa = np.zeros((nmod, nper), dtype=float)

    pole, resi, rn, tn = PSD(npsd, BoseFermi=1, pade=pade)

    for m in xrange(nmod):

        jdru = inidic['mode'][m]['jdru']

        for idru in xrange(len(jdru)):
            lamd, gamd = jdru[idru]['lamd'], jdru[idru]['gamd']
            iper = idru
            expn[m, iper] = gamd
            etal[m, iper] = -2.J * lamd * gamd * fBose(-1.J * gamd / temp,
                                                       pole, resi, rn, tn)
            etar[m, iper] = etal[m, iper].conj()
            etaa[m, iper] = abs(etal[m, iper])
            delr[m] += 2. * lamd * gamd / temp * rn

        jsdr = inidic['mode'][m]['jsdr']

        for isdr in xrange(len(jsdr)):
            lams, omgs, gams = jsdr[isdr]['lams'], jsdr[isdr]['omgs'], jsdr[
                isdr]['gams']
            iper, jper = ndru + isdr * 2, ndru + isdr * 2 + 1
            etaBO = 2. * lams * omgs * omgs * gams
            Delta = omgs * omgs - gams * gams / 4.0
            delr[m] += etaBO * tn / (temp**3)
            if Delta > 0:
                OmgB = sqrt(Delta)
                expn[m, iper] = 0.5 * gams + 1.J * OmgB
                expn[m, jper] = 0.5 * gams - 1.J * OmgB
            elif Delta < 0:
                OmgB = sqrt(-Delta)
                expn[m, iper] = 0.5 * gams + OmgB
                expn[m, jper] = 0.5 * gams - OmgB
            else:
                raise ValueError("Not prepared for Delta=0")
            z1, z2 = -1.J * expn[m, iper], -1.J * expn[m, jper]
            etal[m, iper] = -2.J * etaBO * z1 / (
                2. * z1 * (z1 + z2) *
                (z1 - z2)) * fBose(z1 / temp, pole, resi, rn, tn)
            etal[m, jper] = -2.J * etaBO * z2 / (
                2. * z2 * (z2 + z1) *
                (z2 - z1)) * fBose(z2 / temp, pole, resi, rn, tn)
            if Delta > 0:
                etar[m, iper] = etal[m, jper].conj()
                etar[m, jper] = etal[m, iper].conj()
                etaa[m, iper] = etaa[m, jper] = sqrt(
                    abs(etal[m, iper]) * abs(etal[m, jper]))
            elif Delta < 0:
                etar[m, iper] = etal[m, iper].conj()
                etar[m, jper] = etal[m, jper].conj()
                etaa[m, iper] = abs(etal[m, iper])
                etaa[m, jper] = abs(etal[m, jper])
            else:
                raise ValueError("Not prepared for Delta=0")

        for ipsd in xrange(npsd):

            iper = ndru + nsdr * 2 + ipsd
            zomg = -1.J * pole[ipsd] * temp
            jsum = sum(jwdru(zomg, x)
                       for x in jdru) + sum(jwsdr(zomg, x) for x in jsdr)
            expn[m, iper] = pole[ipsd] * temp
            etal[m, iper] = -2.J * resi[ipsd] * temp * jsum
            etar[m, iper] = etal[m, iper].conj()
            etaa[m, iper] = abs(etal[m, iper])

    arma.save(etal, inidic['etalFile'])
    arma.save(etar, inidic['etarFile'])
    arma.save(etaa, inidic['etaaFile'])
    arma.save(expn, inidic['expnFile'])
    arma.save(delr, inidic['delrFile'])
示例#7
0
def init(inidic):

    try:
        exbe = inidic['exbe']
    except:
        exbe = 0

    npsd = inidic['npsd']
    pade = inidic['pade']
    temp = inidic['temp']
    jomg = inidic['jomg']
    nmod = len(jomg)

    nind = 0
    mode = []
    for m in xrange(nmod):
        try:
            ndru = len(jomg[m]['jdru'])
        except:
            ndru = 0
        try:
            nsdr = len(jomg[m]['jsdr'])
        except:
            nsdr = 0
        nper = ndru + 2 * nsdr + npsd
        nind += nper
        mode.extend([m for i in xrange(nper)])
    mode = np.array(mode)
    delr = np.zeros(nmod, dtype=float)
    expn = np.zeros(nind, dtype=complex)
    etal = np.zeros(nind, dtype=complex)
    etar = np.zeros(nind, dtype=complex)
    etaa = np.zeros(nind, dtype=float)

    pole, resi, rn, tn = PSD(npsd, BoseFermi=1, pade=pade)

    iind = 0

    for m in xrange(nmod):

        try:
            jdru = jomg[m]['jdru']
        except:
            jdru = []

        try:
            jsdr = jomg[m]['jsdr']
        except:
            jsdr = []

        ndru = len(jdru)
        nsdr = len(jsdr)

        for idru in xrange(ndru):

            if len(jdru[idru]) != 2:
                raise ValueError('Invalid drude input')

            lamd, gamd = jdru[idru][0], jdru[idru][1]
            expn[iind] = gamd
            etal[iind] = -2.J * lamd * gamd * fBose(-1.J * gamd / temp, pole,
                                                    resi, rn, tn, exbe)
            etar[iind] = etal[iind].conj()
            etaa[iind] = abs(etal[iind])
            delr[m] += 2. * lamd * gamd / temp * rn

            iind += 1

        for isdr in xrange(nsdr):

            if len(jsdr[isdr]) != 3:
                raise ValueError('Invalid BO input')

            lams, omgs, gams = jsdr[isdr][0], jsdr[isdr][1], jsdr[isdr][2]
            jind = iind + 1
            etaBO = 2. * lams * omgs * omgs * gams
            Delta = omgs * omgs - gams * gams / 4.0
            delr[m] += etaBO * tn / (temp**3)
            if Delta > 0:
                OmgB = sqrt(Delta)
                expn[iind] = 0.5 * gams + 1.J * OmgB
                expn[jind] = 0.5 * gams - 1.J * OmgB
            elif Delta < 0:
                OmgB = sqrt(-Delta)
                expn[iind] = 0.5 * gams + OmgB
                expn[jind] = 0.5 * gams - OmgB
            else:
                raise ValueError("Not prepared for Delta=0")
            z1, z2 = -1.J * expn[iind], -1.J * expn[jind]

            etal[iind] = -2.J * etaBO * z1 / (
                2. * z1 * (z1 + z2) *
                (z1 - z2)) * fBose(z1 / temp, pole, resi, rn, tn, exbe)
            etal[jind] = -2.J * etaBO * z2 / (
                2. * z2 * (z2 + z1) *
                (z2 - z1)) * fBose(z2 / temp, pole, resi, rn, tn, exbe)
            if Delta > 0:
                etar[iind] = etal[jind].conj()
                etar[jind] = etal[iind].conj()
                etaa[iind] = etaa[jind] = sqrt(
                    abs(etal[iind]) * abs(etal[jind]))
            elif Delta < 0:
                etar[iind] = etal[iind].conj()
                etar[jind] = etal[jind].conj()
                etaa[iind] = abs(etal[iind])
                etaa[jind] = abs(etal[jind])
            else:
                raise ValueError("Not prepared for Delta=0")

            iind += 2

        for ipsd in xrange(npsd):
            zomg = -1.J * pole[ipsd] * temp
            jsmd = sum(jwdru(zomg, x) for x in jdru)
            jsms = sum(jwsdr(zomg, x) for x in jsdr)
            jsum = jsmd + jsms
            expn[iind] = pole[ipsd] * temp
            etal[iind] = -2.J * resi[ipsd] * temp * jsum
            etar[iind] = etal[iind].conj()
            etaa[iind] = abs(etal[iind])

            iind += 1

    delr_img = delr
    mode_img = np.zeros(2 * nind, dtype=int)
    expn_img = np.zeros(2 * nind, dtype=complex)
    etal_img = np.zeros(2 * nind, dtype=complex)
    etar_img = np.zeros(2 * nind, dtype=complex)
    etaa_img = np.zeros(2 * nind, dtype=float)
    for i in xrange(nind):
        mode_img[2 * i] = mode_img[2 * i + 1] = mode[i]
        expn_img[2 * i] = expn[i]
        expn_img[2 * i + 1] = -expn[i]
        etal_img[2 * i] = 0.5 * etal[i]
        etal_img[2 * i + 1] = 0.5 * etal[i] * cexp(1.J * expn[i] / temp)
        etar_img[2 * i] = 0.5 * etar[i]
        etar_img[2 * i + 1] = 0.5 * etar[i] * cexp(-1.J * expn[i] / temp)
        etaa_img[2 * i] = etaa_img[2 * i + 1] = etaa[i] * 0.5

    arma.save(mode_img, inidic['modeFile'])
    arma.save(etal_img, inidic['etalFile'])
    arma.save(etar_img, inidic['etarFile'])
    arma.save(etaa_img, inidic['etaaFile'])
    arma.save(expn_img, inidic['expnFile'])
    arma.save(delr_img, inidic['delrFile'])

    return etal, expn
示例#8
0
文件: bath.py 项目: hou-dao/raman
def init (inidic):
        
    nmod = inidic['nmod']
    npsd = inidic['npsd']
    pade = inidic['pade']
    temp = inidic['temp']

    ndru = max([len(m['jdru']) for m in inidic['mode']])
    nsdr = max([len(m['jsdr']) for m in inidic['mode']])
    nper = ndru+2*nsdr+npsd

    delr = np.zeros(nmod,dtype=float)
    expn = np.zeros((nmod,nper),dtype=complex)
    etal = np.zeros((nmod,nper),dtype=complex)
    etar = np.zeros((nmod,nper),dtype=complex)
    etaa = np.zeros((nmod,nper),dtype=float)

    pole, resi, rn, tn = PSD (npsd,BoseFermi=1,pade=pade)
    
    for m in xrange(nmod):

        jdru = inidic['mode'][m]['jdru']
    
        for idru in xrange(len(jdru)):
            lamd, gamd = jdru[idru]['lamd'], jdru[idru]['gamd']
            iper = idru
            expn[m,iper] = gamd
            etal[m,iper] = -2.J*lamd*gamd*fBose(-1.J*gamd/temp,pole,resi,rn,tn)
            etar[m,iper] = etal[m,iper].conj()
            etaa[m,iper] = abs(etal[m,iper])
            delr[m] += 2.*lamd*gamd/temp*rn
        
        jsdr = inidic['mode'][m]['jsdr']

        for isdr in xrange(len(jsdr)):
            lams, omgs, gams = jsdr[isdr]['lams'], jsdr[isdr]['omgs'], jsdr[isdr]['gams']
            iper, jper = ndru+isdr*2, ndru+isdr*2+1
            etaBO = 2.*lams*omgs*omgs*gams
            Delta = omgs*omgs-gams*gams/4.0
            delr[m] +=  etaBO*tn/(temp**3)
            if Delta > 0:
                OmgB = sqrt(Delta)
                expn[m,iper] = 0.5*gams+1.J*OmgB
                expn[m,jper] = 0.5*gams-1.J*OmgB
            elif Delta < 0:
                OmgB = sqrt(-Delta)
                expn[m,iper] = 0.5*gams+OmgB
                expn[m,jper] = 0.5*gams-OmgB           
            else:
                raise ValueError("Not prepared for Delta=0")
            z1, z2 = -1.J*expn[m,iper], -1.J*expn[m,jper]
            etal[m,iper] = -2.J*etaBO*z1/(2.*z1*(z1+z2)*(z1-z2))*fBose(z1/temp,pole,resi,rn,tn)
            etal[m,jper] = -2.J*etaBO*z2/(2.*z2*(z2+z1)*(z2-z1))*fBose(z2/temp,pole,resi,rn,tn)
            if Delta > 0:
                etar[m,iper] = etal[m,jper].conj()
                etar[m,jper] = etal[m,iper].conj()
                etaa[m,iper] = etaa[m,jper] = sqrt(abs(etal[m,iper])*abs(etal[m,jper]))
            elif Delta < 0:
                etar[m,iper] = etal[m,iper].conj()
                etar[m,jper] = etal[m,jper].conj()
                etaa[m,iper] = abs(etal[m,iper])
                etaa[m,jper] = abs(etal[m,jper])
            else:
                raise ValueError("Not prepared for Delta=0")

        for ipsd in xrange(npsd):
        
            iper = ndru+nsdr*2+ipsd
            zomg = -1.J*pole[ipsd]*temp
            jsum = sum(jwdru(zomg,x) for x in jdru)+sum(jwsdr(zomg,x) for x in jsdr)
            expn[m,iper] = pole[ipsd]*temp            
            etal[m,iper] = -2.J*resi[ipsd]*temp*jsum   
            etar[m,iper] = etal[m,iper].conj()
            etaa[m,iper] = abs(etal[m,iper])  
                            
    arma.save (etal,inidic['etalFile'])
    arma.save (etar,inidic['etarFile'])
    arma.save (etaa,inidic['etaaFile'])
    arma.save (expn,inidic['expnFile'])
    arma.save (delr,inidic['delrFile'])
示例#9
0
文件: gen_input.py 项目: dupl10/raman
                    "nt2": 512,
                    "nk": 16,
                    "staticErr": 2.0e-8,
                    "sch_hei": "hei",
                    "dip0": "inp_dip0.mat",
                    "dip1": "inp_dip1.mat",
                    "dip2": "inp_dip2.mat",
                }
            }
   #jsonInit = {"deom":ini,
   #            "linear":{
   #                "wmax": 1200*cm2au,  # cm-1 convert to au
   #                "dt":  1.0*fs2au,    # fs   convert to au
   #                "nt": 512,
   #                "nk": 16,
   #                "staticErr": 2.0e-9,
   #                "dip0": "inp_dip0.mat",
   #                "dip1": "inp_dip1.mat",
   #            }
   #        }
    dipo0 = (qmd1)*(1.0+0.0J)
    dipo1 = (qmd1)*(1.0+0.0J)
    dipo2 = np.dot(qmd1,qmd1)*(1.0+0.0J)
    arma.save(dipo0,"inp_dip0.mat")
    arma.save(dipo1,"inp_dip1.mat")
    arma.save(dipo2,"inp_dip2.mat")

    
    with open('input.json','w') as f:
        json.dump(jsonInit,f,indent=4) 
示例#10
0
def init (inidic):
        
    try:
        exbe = inidic['exbe']
    except:
        exbe = 0

    pade = 0
    npsd = inidic['npsd']
    temp = inidic['temp']
    jomg = inidic['jomg']
    nmod = len(jomg)

    nind = 0
    mode = []
    for m in xrange(nmod):
        try:
            ndru = len(jomg[m]['jdru'])
        except:
            ndru = 0
        nper = ndru+npsd*2
        nind += nper
        mode.extend([m for i in xrange(nper)])
    mode = np.array(mode)
    delr = np.zeros(nmod,dtype=float)
    expn = np.zeros(nind,dtype=complex)
    etal = np.zeros(nind,dtype=complex)
    etar = np.zeros(nind,dtype=complex)
    etaa = np.zeros(nind,dtype=float)

    iind = 0

    for m in xrange(nmod):

        try:
            jdru = jomg[m]['jdru']
        except:
            jdru = []

        ndru = len(jdru)
    
        for idru in xrange(ndru):

            if len(jdru[idru]) != 2:
                raise ValueError('Invalid drude input')

            lamd, gamd = jdru[idru][0], jdru[idru][1]
            expn[iind] = 0.0
            etal[iind] = 2*lamd*temp
            etar[iind] = 0.0
            etaa[iind] = abs(etal[iind])
            iind += 1

        for ipsd in xrange(npsd):
            expn[iind] = 2.0*pi*temp*(ipsd+1)
            expn[iind+1] = -2.0*pi*temp*(ipsd+1)
            etal[iind] = 2*lamd*gamd*temp/(gamd+expn[iind])
            etal[iind+1] = 2*lamd*gamd*temp/(gamd+expn[iind])
            etar[iind] = 0.0
            etar[iind+1] = 0.0
            etaa[iind] = abs(etal[iind])  
            etaa[iind+1] = abs(etal[iind+1])  
            iind += 2

    arma.save (mode,inidic['modeFile'])
    arma.save (etal,inidic['etalFile'])
    arma.save (etar,inidic['etarFile'])
    arma.save (etaa,inidic['etaaFile'])
    arma.save (expn,inidic['expnFile'])
    arma.save (delr,inidic['delrFile'])
            
    return etal, expn