當前位置: 首頁>>代碼示例>>Python>>正文


Python scipy.constants方法代碼示例

本文整理匯總了Python中scipy.constants方法的典型用法代碼示例。如果您正苦於以下問題:Python scipy.constants方法的具體用法?Python scipy.constants怎麽用?Python scipy.constants使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在scipy的用法示例。


在下文中一共展示了scipy.constants方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import scipy [as 別名]
# 或者: from scipy import constants [as 別名]
def __init__(self):
        self.kappa         = 0.              # inverse of Debye length
        self.restart       = 0               # Restart of GMRES
        self.tol           = 0.              # Tolerance of GMRES
        self.max_iter      = 0               # Max number of GMRES iterations
        self.P             = 0               # Order of Taylor expansion
        self.eps           = 0               # Epsilon machine
        self.Nm            = 0               # Number of terms in Taylor expansion
        self.NCRIT         = 0               # Max number of targets per twig box
        self.theta         = 0.              # MAC criterion for treecode
        self.K             = 0               # Number of Gauss points per element
        self.K_fine        = 0               # Number of Gauss points per element for near singular integrals
        self.threshold     = 0.              # L/d criterion for semi-analytic intergrals
        self.Nk            = 0               # Gauss points per side for semi-analytical integrals
        self.BSZ           = 0               # CUDA block size
        self.Nround        = 0               # Max size of sorted target array
        self.BlocksPerTwig = 0               # Number of CUDA blocks that fit per tree twig
        self.N             = 0               # Total number of elements
        self.Neq           = 0               # Total number of equations
        self.qe            = scipy.constants.e
        self.Na            = scipy.constants.Avogadro
        self.E_0           = scipy.constants.epsilon_0
        self.REAL          = 0               # Data type
        self.E_field       = []              # Regions where energy will be calculated
        self.GPU           = -1              # =1: with GPU, =0: no GPU 
開發者ID:pygbe,項目名稱:pygbe,代碼行數:27,代碼來源:classes.py

示例2: preprocess_ods

# 需要導入模塊: import scipy [as 別名]
# 或者: from scipy import constants [as 別名]
def preprocess_ods(*require, require_mode=['warn_through', 'warn_skip', 'raise'][0]):
    '''
    Decorator function that:
     * checks that required quantities are there
    '''

    def _req(f):
        from functools import wraps
        @wraps(f)
        def wrapper(*args1, **kw1):
            args, kw = args_as_kw(f, args1, kw1)

            # handle missing required quantities
            missing = []
            for k in require:
                if k not in kw['ods']:
                    missing.append(k)
            if len(missing):
                txt = 'could not evaluate %s because of missing %s ODS' % (f.__name__, missing)
                if require_mode == 'warn_through':
                    printe(txt)
                elif require_mode == 'warn_skip':
                    printe(txt)
                    return kw['ods']
                elif require_mode == 'raise':
                    raise RuntimeError(txt)

            # run function
            return f(*args, **kw)

        return wrapper

    return _req


# constants class that mimics scipy.constants 
開發者ID:gafusion,項目名稱:omas,代碼行數:38,代碼來源:omas_physics.py

示例3: SetMaterial

# 需要導入模塊: import scipy [as 別名]
# 或者: from scipy import constants [as 別名]
def SetMaterial(self, name):
        """
        Set a particular material in the database as the actual material.  All
        operations like setting and getting optical constants are done for this
        particular material.

        Parameters
        ----------
        name :  str
            name of the material
        """
        if self.matname == name:
            return
        try:
            self.h5group = self.h5file[name]
        except KeyError:
            print("XU.materials.database: material '%s' not existing!" % name)

        try:
            self.f0_params = self.h5group['f0']
        except KeyError:
            self.f0_params = None
        try:
            self.f1_en = self.h5group['en_f12']
            self.f1 = self.h5group['f1']
        except KeyError:
            self.f1_en = None
            self.f1 = None
        try:
            self.f2_en = self.h5group['en_f12']
            self.f2 = self.h5group['f2']
        except KeyError:
            self.f2_en = None
            self.f2 = None
        try:
            self.weight = self.h5group.attrs['atomic_standard_weight']
        except KeyError:
            self.weight = None
        try:
            self.radius = self.h5group.attrs['atomic_radius']
        except KeyError:
            self.radius = numpy.nan
        try:
            self.color = self.h5group.attrs['color']
        except KeyError:
            self.color = None
        self.matname = name 
開發者ID:dkriegner,項目名稱:xrayutilities,代碼行數:49,代碼來源:database.py

示例4: add_mass_from_NIST

# 需要導入模塊: import scipy [as 別名]
# 或者: from scipy import constants [as 別名]
def add_mass_from_NIST(db, nistfile, verbose=False):
    """
    Read atoms standard mass and save it to the database.
    The mass of the natural isotope mixture is taken from the NIST data!
    """
    # some regular expressions
    isotope = re.compile(r"^Atomic Number =")
    standardw = re.compile(r"^Standard Atomic Weight")
    relativew = re.compile(r"^Relative Atomic Mass")
    number = re.compile(r"[0-9.]+")
    multiblank = re.compile(r"\s+")

    # parse the nist file
    with open(nistfile, "r") as nf:
        while True:
            lb = nf.readline()
            if lb == "":
                break
            lb = lb.strip()

            if isotope.match(lb):
                # found new element
                lb = multiblank.split(lb)
                lb = nf.readline()
                lb = lb.strip()
                lb = multiblank.split(lb)
                ename = lb[-1]

                if verbose:
                    print("set element %s" % ename)
                db.SetMaterial(ename)

                # read data
                while True:
                    lb = nf.readline()
                    lb = lb.strip()
                    if relativew.match(lb):
                        lb = multiblank.split(lb)
                        # extract fallback weight
                        w = float(number.findall(lb[-1])[0])
                        db.SetWeight(w * scipy.constants.atomic_mass)
                    elif standardw.match(lb):
                        lb = multiblank.split(lb)
                        # extract average weight
                        try:
                            w = float(number.findall(lb[-1])[0])
                            db.SetWeight(w * scipy.constants.atomic_mass)
                        except IndexError:
                            pass
                        break 
開發者ID:dkriegner,項目名稱:xrayutilities,代碼行數:52,代碼來源:database.py


注:本文中的scipy.constants方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。