当前位置: 首页>>代码示例>>Python>>正文


Python constants.k方法代码示例

本文整理汇总了Python中scipy.constants.k方法的典型用法代码示例。如果您正苦于以下问题:Python constants.k方法的具体用法?Python constants.k怎么用?Python constants.k使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scipy.constants的用法示例。


在下文中一共展示了constants.k方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: population

# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import k [as 别名]
def population(self, Mole, Temp):
        """Calculate population for each level at given temperature"""
        RoTemp = np.reshape(Temp*1., (Temp.size, 1))
        Qr = self.weighti*np.exp(-(self.e_cm1*100*c*h)/(k*RoTemp))
        # RoPr = Qr/Ntotal  # This is for all transitions
        RoPr = Qr/(Qr.sum(axis=1).reshape(RoTemp.size, 1))  # only given trans.
        linet = []
        for xx in range(self.nt):
            gdu, gdl = self.weighti[self.tran_tag[xx][1:].astype(int)]
            _up = int(self.tran_tag[xx][1])
            _low = int(self.tran_tag[xx][2])
            Aei = self.ai[_up, _low]
            line_const = (c*10**2)**2*Aei*(gdu/gdl)*1.e-6*1.e14 /\
                         (8.*np.pi*(self.freq_array[xx]*1.e9)**2)
            # Hz->MHz,cm^2 ->nm^2
            # W = C.h*C.c*E_cm1[_low]*100.  # energy level above ground state
            "This is the function of calculating H2O intensity"
            line = (1.-np.exp(-h*(self.freq_array[xx]*1.e9) /
                              k/RoTemp))*line_const
            linet.append(line[:, 0]*RoPr[:, _low])  # line intensity non-LTE
        Ni_LTE = Mole.reshape((Mole.size, 1))*RoPr  # *0.75  # orth para ratio
        Ite_pop = [[Ni_LTE[i].reshape((self.ni, 1))] for i in range(Mole.size)]
        return Ite_pop

#import numba 
开发者ID:atmtools,项目名称:typhon,代码行数:27,代码来源:__init__.py

示例2: test_tlcorrection

# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import k [as 别名]
def test_tlcorrection(self):
        # testing long correction function
        x_for_long = np.array([20.,21.,22.,23.,24.,25.])
        y_for_long = np.array([1.0,1.0,1.0,1.0,1.0,1.0])

        nu0 = 1.0/(514.532)*1e9 #laser wavenumber at 514.532
        nu = 100.0*x_for_long # cm-1 to m-1
        T = 23.0+273.15 # the temperature in K

        x_long,long_res,eselong = rp.tlcorrection(x_for_long, y_for_long,23.0,514.532,correction = 'long',normalisation='area') # using the function
        t0 = nu0**3.0*nu/((nu0-nu)**4)
        t1= 1.0 - np.exp(-h*c*nu/(k*T)) # c in m/s  : t1 dimensionless
        long_calc= y_for_long*t0*t1 # pour les y
        long_calc = long_calc/np.trapz(long_calc,x_for_long) # area normalisation

        np.testing.assert_equal(long_res,long_calc)
        np.testing.assert_equal(x_for_long,x_long)

        x_long,long_res,eselong = rp.tlcorrection(x_for_long, y_for_long,23.0,514.532,correction = 'long',normalisation='no') # using the function
        t0 = nu0**3.0*nu/((nu0-nu)**4)
        t1= 1.0 - np.exp(-h*c*nu/(k*T)) # c in m/s  : t1 dimensionless
        long_calc= y_for_long*t0*t1 # pour les y

        np.testing.assert_equal(long_res,long_calc)
        np.testing.assert_equal(x_for_long,x_long) 
开发者ID:charlesll,项目名称:rampy,代码行数:27,代码来源:test_tlcorrection.py

示例3: FermiDirac

# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import k [as 别名]
def FermiDirac(Ef, EJ, T):
    """
    Returns the Fermi-Dirac probability distribution, given the crystal's
    Fermi energy, the temperature and the energy where the distribution values
    is required.

    Args:
        | Ef: Fermi energy in J
        | EJ: Energy in J
        | T : Temperature in K

    Returns:
        | fermiD : the Fermi-Dirac distribution
    """
    #prevent divide by zero
    den = (1 + np.exp( ( EJ - Ef ) / ( T * const.k) ) )
    return 1 / den



################################################################################
# 
开发者ID:NelisW,项目名称:pyradi,代码行数:24,代码来源:rydetector.py

示例4: kTCnoiseCsn

# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import k [as 别名]
def kTCnoiseCsn(temptr, sensecapacity):
    """

        Args:
            | temptr (scalar): temperature in K
            | sensecapacity (): sense node capacitance F
 
        Returns:
            | n (scalar): noise as number of electrons 

        Raises:
            | No exception is raised.
    """
    return np.sqrt(const.k * temptr * sensecapacity) / const.e

############################################################
## 
开发者ID:NelisW,项目名称:pyradi,代码行数:19,代码来源:rystare.py

示例5: DopplerWind

# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import k [as 别名]
def DopplerWind(Temp, FreqGrid, Para, wind_v, shift_direction='red'):
    u"""#doppler width
    #Para[transient Freq[Hz], relative molecular mass[g/mol]]"""
    # step1 = Para[0]/c*(2.*R*gct/(Para[1]*1.e-3))**0.5
    # outy = np.exp(-(Freq-Para[0])**2/step1**2) / (step1*(np.pi**0.5))
    #wind_v = speed[:,10] 
    #Temp=temp[10]
    #FreqGrid = Fre_range_i[0]
    wind = wind_v.reshape(wind_v.size, 1)
    FreqGrid = FreqGrid.reshape(1, FreqGrid.size)
    deltav = Para[0]*wind/c
    if shift_direction.lower() == 'red':
        D_effect = (deltav)
    elif shift_direction.lower() == 'blue':
        D_effect = (-deltav)
    else:
        raise ValueError('Set shift direction to "red" or "blue".')

#    step1 = Para[0]/c*(2.*R*Temp*np.log(2.)/(Para[1]*1.e-3))**0.5  # HWHM
#    outy = np.exp(-np.log(2.)*(FreqGrid-Para[0])**2/step1**2) *\
#                 (np.log(2.)/np.pi)**0.5/step1
#    outy_d = np.exp(-np.log(2.)*(FreqGrid+D_effect-Para[0])**2/step1**2) *\
#                   (np.log(2.)/np.pi)**0.5/step1
    GD = np.sqrt(2*k*ac/Para[1]*Temp)/c*Para[0]
    step1 = GD
    outy_d = wofz((FreqGrid+D_effect-Para[0])/GD).real / np.sqrt(np.pi) / GD
    #plot(FreqGrid, outy)
    #plot(FreqGrid, outy_d[:,0])
    return outy_d 
开发者ID:atmtools,项目名称:typhon,代码行数:31,代码来源:lineshape.py

示例6: Bv_T

# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import k [as 别名]
def Bv_T(Freq, T):
    # brbr = 1  # .e7*1.e-4
    Bv_out = 2.*h*Freq**3/c**2/(np.exp(h*Freq/k/T)-1.)
    return Bv_out 
开发者ID:atmtools,项目名称:typhon,代码行数:6,代码来源:source_function.py

示例7: energies

# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import k [as 别名]
def energies(samples: list, w: np.ndarray, wp: np.ndarray) -> Union[list, float]:
    r"""Computes the energy :math:`E = \sum_{k=1}^{N}m_k\omega'_k - \sum_{k=N+1}^{2N}n_k\omega_k`
    of each GBS sample in units of :math:`\text{cm}^{-1}`.

    **Example usage:**

    >>> samples = [[1, 1, 0, 0, 0, 0], [1, 2, 0, 0, 1, 1]]
    >>> w  = np.array([300.0, 200.0, 100.0])
    >>> wp = np.array([700.0, 600.0, 500.0])
    >>> energies(samples, w, wp)
    [1300.0, 1600.0]

    Args:
        samples (list[list[int]] or list[int]): a list of samples from GBS, or alternatively a
            single sample
        w (array): normal mode frequencies of initial state in units of :math:`\text{cm}^{-1}`
        wp (array): normal mode frequencies of final state in units of :math:`\text{cm}^{-1}`

    Returns:
        list[float] or float: list of GBS sample energies in units of :math:`\text{cm}^{-1}`, or
        a single sample energy if only one sample is input
    """
    if not isinstance(samples[0], list):
        return np.dot(samples[: len(samples) // 2], wp) - np.dot(samples[len(samples) // 2 :], w)

    return [np.dot(s[: len(s) // 2], wp) - np.dot(s[len(s) // 2 :], w) for s in samples] 
开发者ID:XanaduAI,项目名称:strawberryfields,代码行数:28,代码来源:vibronic.py

示例8: test_twomode

# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import k [as 别名]
def test_twomode(self):
        """Test if function returns two-mode squeezing parameters that correctly reconstruct the
        input normal mode frequencies."""
        w = -k * self.T / (0.5 * h * c * 100) * np.log(np.tanh(self.t))
        assert np.allclose(w, self.w) 
开发者ID:XanaduAI,项目名称:strawberryfields,代码行数:7,代码来源:test_vibronic.py

示例9: planck

# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import k [as 别名]
def planck(lam, T):
    """ Returns the spectral radiance of a black body at temperature T.

    Returns the spectral radiance, B(lam, T), in W.sr-1.m-2 of a black body
    at temperature T (in K) at a wavelength lam (in nm), using Planck's law.

    """

    lam_m = lam / 1.e9
    fac = h*c/lam_m/k/T
    B = 2*h*c**2/lam_m**5 / (np.exp(fac) - 1)
    return B 
开发者ID:mjhoptics,项目名称:ray-optics,代码行数:14,代码来源:colour_system.py

示例10: Absorption

# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import k [as 别名]
def Absorption(wavelength, Eg, tempDet, a0, a0p):
    """
    Calculate the spectral absorption coefficient
    for a semiconductor material with given material values.

    The model used here is based on Equations 3.5, 3.6 in Dereniaks book.

    Args:
        | wavelength: spectral variable [m]
        | Eg: bandgap energy [Ev]
        | tempDet: detector's temperature in [K]
        | a0: absorption coefficient [m-1] (Dereniak Eq 3.5 & 3.6)
        | a0p:  absorption coefficient in [m-1] (Dereniak Eq 3.5 & 3.6)

    Returns:
        | absorption: spectral absorption coefficient in [m-1]
    """

    #frequency/wavelength expressed as energy in Ev
    E = const.h * const.c / (wavelength * const.e )

    # the np.abs() in the following code is to prevent nan and inf values
    # the effect of the abs() is corrected further down when we select
    # only the appropriate values based on E >= Eg and E < Eg

    # Absorption coef - eq. 3.5- Dereniak
    a35 = (a0 * np.sqrt(np.abs(E - Eg))) + a0p
    # Absorption coef - eq. 3.6- Dereniak
    a36 = a0p * np.exp((- np.abs(E - Eg)) / (const.k * tempDet))
    absorption = a35 * (E >= Eg) + a36 * (E < Eg)

    return absorption

################################################################################
# 
开发者ID:NelisW,项目名称:pyradi,代码行数:37,代码来源:rydetector.py

示例11: IXV

# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import k [as 别名]
def IXV(V, IVbeta, tDetec, iPhoto,I0):
    """
    This function provides the diode curve for a given photocurrent.

    The same function is also used to calculate the dark current, using
    IVbeta=1 and iPhoto=0

    Args:
        | V: bias [V]
        | IVbeta: diode equation non linearity factor;
        | tDetec: detector's temperature [K]
        | iPhoto: photo-induced current, added to diode curve [A]
        | I0: reverse sat current [A]

    Returns:
        | current from detector [A]
    """

    # diode equation from Dereniak's book eq. 7.23
    return I0 * (np.exp(const.e * V / (IVbeta * const.k * tDetec)) - 1) - iPhoto




################################################################################
# 
开发者ID:NelisW,项目名称:pyradi,代码行数:28,代码来源:rydetector.py

示例12: __init__

# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import k [as 别名]
def __init__(self):
        """ Precalculate the Planck function constants.

        Reference: http://www.spectralcalc.com/blackbody/appendixC.html
        """

        import scipy.optimize

        self.c1em = 2 * np.pi * const.h * const.c * const.c
        self.c1el = self.c1em * (1.0e6)**(5-1) # 5 for lambda power and -1 for density
        self.c1en = self.c1em * (100)**3 * 100 # 3 for wavenumber, 1 for density
        self.c1ef = 2 * np.pi * const.h / (const.c * const.c)

        self.c1qm = 2 * np.pi * const.c
        self.c1ql = self.c1qm * (1.0e6)**(4-1) # 5 for lambda power and -1 for density
        self.c1qn = self.c1qm * (100)**2 * 100 # 2 for wavenumber, 1 for density
        self.c1nf = 2 * np.pi  / (const.c * const.c)

        self.c2m = const.h * const.c / const.k
        self.c2l = self.c2m * 1.0e6 # 1 for wavelength density
        self.c2n = self.c2m * 1.0e2 # 1 for cm-1 density
        self.c2f = const.h / const.k

        self.sigmae = const.sigma
        self.zeta3 = 1.2020569031595942853
        self.sigmaq = 4 * np.pi * self.zeta3 * const.k ** 3 \
               / (const.h ** 3 * const.c ** 2)

        self.a2 = scipy.optimize.brentq(self.an, 1, 2, (2) )
        self.a3 = scipy.optimize.brentq(self.an, 2, 3, (3) )
        self.a4 = scipy.optimize.brentq(self.an, 3.5, 4, (4) )
        self.a5 = scipy.optimize.brentq(self.an, 4.5, 5, (5) )

        self.wel = 1e6 * const.h * const.c /(const.k * self.a5)
        self.wql = 1e6 * const.h * const.c /(const.k * self.a4)
        self.wen = self.a3 * const.k /(100 * const.h * const.c )
        self.wqn = self.a2 * const.k /(100 * const.h * const.c )
        self.wef = self.a3 * const.k /(const.h )
        self.wqf = self.a2 * const.k /(const.h ) 
开发者ID:NelisW,项目名称:pyradi,代码行数:41,代码来源:ryplanck.py

示例13: kTCnoiseGv

# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import k [as 别名]
def kTCnoiseGv(temptr, gv):
    """

        Args:
            | temptr (scalar): temperature in K
            | gv (scalar): sense node gain V/e
 
 
        Returns:
            | n (scalar): noise as number of electrons 

        Raises:
            | No exception is raised.
    """
    return np.sqrt(const.k * temptr / (const.e * gv))

############################################################
##
#def 
    """

        Args:
            | (): 
            | (): 
            | (): 
            | (): 
            | (): 
            | (): 
            | (): 
 
        Returns:
            | n (scalar): noise as number of electrons 

        Raises:
            | No exception is raised.
    """


###################################################################################### 
开发者ID:NelisW,项目名称:pyradi,代码行数:41,代码来源:rystare.py

示例14: getNumberDensity

# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import k [as 别名]
def getNumberDensity(self, temperature):
        """ Atom number density at given temperature

            See `calculation of basic properties example snippet`_.

            .. _`calculation of basic properties example snippet`:
                ./Rydberg_atoms_a_primer.html#General-atomic-properties

            Args:
                temperature (float): temperature in K
            Returns:
                float: atom concentration in :math:`1/m^3`
        """
        return self.getPressure(temperature) / (C_k * temperature) 
开发者ID:nikolasibalic,项目名称:ARC-Alkali-Rydberg-Calculator,代码行数:16,代码来源:alkali_atom_functions.py

示例15: getAverageSpeed

# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import k [as 别名]
def getAverageSpeed(self, temperature):
        """
            Average (mean) speed at a given temperature

            Args:
                temperature (float): temperature (K)

            Returns:
                float: mean speed (m/s)
        """
        return sqrt(8. * C_k * temperature / (pi * self.mass)) 
开发者ID:nikolasibalic,项目名称:ARC-Alkali-Rydberg-Calculator,代码行数:13,代码来源:alkali_atom_functions.py


注:本文中的scipy.constants.k方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。