本文整理汇总了Python中scipy.constants.c方法的典型用法代码示例。如果您正苦于以下问题:Python constants.c方法的具体用法?Python constants.c怎么用?Python constants.c使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scipy.constants
的用法示例。
在下文中一共展示了constants.c方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: population
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import c [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
示例2: test_tlcorrection
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import c [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)
示例3: __init__
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import c [as 别名]
def __init__(self, where=None, resistivity=0., eps=0.):
self.eps = 1.
omega0 = 1e-20 ## arbitrary low frequency that makes Lorentz model behave as Drude model
omega_p = 3640e12 ## plasma frequency of aluminium
#sigmafactor = 1
self.pol = [
#{'omega': 1e6*c*1e-20, 'gamma': 1e6*c*0.037908, 'sigma': 7.6347e+41},
{'omega': omega0, 'gamma': 1e6*c*0.037908, 'sigma': 7.6347e+41 * 1e-20**2 * (1e6*c)**2 / omega0**2},
{'omega': 1e6*c*0.13066, 'gamma': 1e6*c*0.26858, 'sigma': 1941},
{'omega': 1e6*c*1.2453, 'gamma': 1e6*c*0.25165, 'sigma': 4.7065},
{'omega': 1e6*c*1.4583, 'gamma': 1e6*c*1.0897, 'sigma': 11.396},
{'omega': 1e6*c*2.8012, 'gamma': 1e6*c*2.7278, 'sigma': 0.55813}]
#{'omega':1.39e9, 'gamma': 1.0e10, 'sigma':2.6e9},
#{'omega': omega0, 'gamma': 25e12, 'sigma': sigmafactor * omega_p**2 / omega0**2}, # (Lorentz) model for Al
#{'omega': omega0, 'gamma': 1e12, 'sigma': sigmafactor * omega_p**2 / omega0**2}, # stable? model at THz
#{'omega':1.39e9, 'gamma': 1e10, 'sigma':1e10}, # Original value, use sigmafactor=1
#]
self.name = "Aluminium"
self.shortname = "Al"
self.where = where
#}}}
示例4: shiftmp
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import c [as 别名]
def shiftmp(freq, s11, shiftplanes):#{{{
""" Adjusts the reflection phase like if the monitor planes were not centered.
For symmetric metamaterial cell, this function is not needed. The symmetry requires that
the monitor planes in front of and behind the mm cell are centered.
However, for an asymmetric metamaterial, the correct position has to be found. Otherwise
the Fresnel inversion gives negative imaginary part of N and/or negative real part of Z, which
is quite spooky for passive medium.
Even such metamaterials, however, may be properly homogenized if we define the
position of monitor planes as a function of frequency. We can assume that:
1) This optimum shift shall hold for all simulations with one or more unit cellnumber.
2) When the wave direction is reversed (to get s21, s22 parameters), the shift should be negated.
These rules should enable us to homogenize any asymmetric non-chiral metamaterial.
Note that this shifting is still an experimental technique and has to be tested out thoroughly.
"""
return np.array(s11) * np.exp(1j*np.array(shiftplanes)/(c/freq) * 2*pi * 2)
#}}}
示例5: Responsivity
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import c [as 别名]
def Responsivity(wavelength, quantumEffic):
"""
Responsivity quantifies the amount of output seen per watt of radiant
optical power input [1]. But, for this application it is interesting to
define spectral responsivity that is the output per watt of monochromatic
radiation.
The model used here is based on Equations 7.114 in Dereniak's book.
Args:
| wavelength: spectral variable [m]
| quantumEffic: spectral quantum efficiency
Returns:
| responsivity in [A/W]
"""
return (const.e * wavelength * quantumEffic) / (const.h * const.c)
################################################################################
#
示例6: plotSpectre
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import c [as 别名]
def plotSpectre(transitions, eneval, spectre):
""" plot the UV-visible spectrum using matplotlib. Absissa are converted in nm. """
# lambda in nm
lambdaval = [cst.h * cst.c / (val * cst.e) * 1.e9 for val in eneval]
# plot gaussian spectra
plt.plot(lambdaval, spectre, "r-", label = "spectre")
# plot transitions
plt.vlines([val[1] for val in transitions], \
0., \
[val[2] for val in transitions], \
color = "blue", \
label = "transitions" )
plt.xlabel("lambda / nm")
plt.ylabel("Arbitrary unit")
plt.title("UV-visible spectra")
plt.grid()
plt.legend(fancybox = True, shadow = True)
plt.show()
示例7: get_electron_wavelength
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import c [as 别名]
def get_electron_wavelength(accelerating_voltage):
"""Calculates the (relativistic) electron wavelength in Angstroms for a
given accelerating voltage in kV.
Parameters
----------
accelerating_voltage : float or 'inf'
The accelerating voltage in kV. Values `numpy.inf` and 'inf' are
also accepted.
Returns
-------
wavelength : float
The relativistic electron wavelength in Angstroms.
"""
if accelerating_voltage in (np.inf, "inf"):
return 0
E = accelerating_voltage * 1e3
wavelength = (
h / math.sqrt(2 * m_e * e * E * (1 + (e / (2 * m_e * c * c)) * E)) * 1e10
)
return wavelength
示例8: Linewidth
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import c [as 别名]
def Linewidth(Type, gct, Para):
"""#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
step1 = Para[0]/c*(2.*R*gct*np.log(2.)/(Para[1]*1.e-3))**0.5 # HWHM
return int(step1.max())
示例9: DopplerWind
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import c [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
示例10: PopuSource
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import c [as 别名]
def PopuSource(LowerPop, UpperPop, LowerDeg, UpperDeg, Freq_c):
sij = (2.*h*Freq_c**3)/(c**2*(LowerPop*UpperDeg/UpperPop/LowerDeg-1.))
return sij
示例11: Bv_T
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import c [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
示例12: test_twomode
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import c [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)
示例13: __init__
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import c [as 别名]
def __init__(self, comment="", simtime=30e-9, resolution=5e-3, cellnumber=1, padding=9e-3, radius=33.774e-3, height=122.36e-3 , Kx=0, Ky=0, **other_args):
meep_utils.AbstractMeepModel.__init__(self) ## Base class initialisation
self.simulation_name = "HollowCyl"
self.register_locals(locals(), other_args) ## Remember the parameters
## Obligatory parameters (used in the simulation)
self.pml_thickness = padding/2
self.simtime = simtime # [s]HollowCyl_simtime=3.000e-08_height=3.000e-02
self.src_freq, self.src_width = 3e9, 10e9 # [Hz] (note: gaussian source ends at t=10/src_width)
self.interesting_frequencies = (.1e9, 8e9) # Which frequencies will be saved to disk
self.size_x = 2*radius+padding*2
self.size_y = 2*radius+padding*2
self.size_z = height+padding*2
## Define materials
f_c = c / np.pi/self.resolution/meep_utils.meep.use_Courant()
self.materials = []
au = meep_materials.material_Au(where=self.where_metal)
self.fix_material_stability(au, verbose=0)
self.materials.append(au)
#self.materials += [meep_materials.material_DrudeMetal(lfconductivity=1e4, f_c=f_c, gamma_factor=.5, epsplus=0, where=self.where_metal)]
meep_utils.plot_eps(self.materials, plot_conductivity=True,
draw_instability_area=(self.f_c(), 3*meep.use_Courant()**2), mark_freq={self.f_c():'$f_c$'})
self.test_materials()
示例14: __init__
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import c [as 别名]
def __init__(self, comment="", simtime=100e-15, resolution=100e-9, size_x=16e-6, size_y=5e-6, size_z=5e-6,
metalthick=.5e-6, apdisty=0e-6, apdistx=14e-6, aprad=.1e-6, monzd=123.456e-6, electronmass=1, **other_args):
meep_utils.AbstractMeepModel.__init__(self) ## Base class initialisation
## Constant parameters for the simulation
self.simulation_name = "PlasmonsFilm"
self.src_freq = 400e12 # [Hz] (note: srcwidth irrelevant for continuous_source)
#self.interesting_frequencies = (0e9, 2000e9) # Which frequencies will be saved to disk (irrelevant here) XXX
self.pml_thickness = 1e-6
self.size_x = size_x
self.size_y = size_y
self.size_z = size_z
substrate_z = size_x / 3
self.simtime = simtime # [s]
self.Kx = 0; self.Ky = 0; self.padding=0
self.register_locals(locals(), other_args) ## Remember the parameters
## Define materials
f_c = c / np.pi/self.resolution/meep_utils.meep.use_Courant()
self.materials = [meep_materials.material_Au(where=self.where_metal)]
self.materials[0].pol[0]['sigma'] /= electronmass ## effective thin layer TODO test+tune+comment
self.materials[0].pol[1:] = [] ## rm other osc
#self.materials = [meep_materials.material_DrudeMetal(lfconductivity=1e8, f_c=.2*f_c, where = self.where_metal)]
#self.materials += [meep_materials.material_dielectric(where=self.where_diel, eps=2.)]
#self.TestMaterials()
#self.materials += [meep_materials.material_Au(where=None)]
meep_utils.plot_eps(self.materials, mark_freq=[f_c])
## Test the validity of the model
for material in self.materials: self.fix_material_stability(material, f_c=2e15, verbose=1)
meep_utils.plot_eps(self.materials, plot_conductivity=True,
draw_instability_area=(self.f_c(), 3*meep.use_Courant()**2), mark_freq={self.f_c():'$f_c$'})
self.test_materials()
示例15: right_tick_function
# 需要导入模块: from scipy import constants [as 别名]
# 或者: from scipy.constants import c [as 别名]
def right_tick_function(p): return p/(cellsize/c)/1e12