Example #1
0
    def __init__(self, infile, comment, element, speckle, trs, refined,
                 outmode):
        # read comment & zoom from setting file first
        # if not exist, read from cmd args, then default
        self.cell = GeneralIO.from_file(infile)

        self.comment = comment or self.cell.comment

        self.element = element

        # Get number and index of target element
        num = self.cell.numbers
        if element is None:
            tgt_ele = int(num[1])
        else:
            tgt_ele = Specie(element).Z
        tgt_ele_index = np.where(num == tgt_ele)[0]
        self.n = tgt_ele_index.size

        self.s1, self.s2 = speckle
        # self.ele for function all-speckle-gen-of-ele in run
        self.ele = Specie.from_num(tgt_ele)

        # if there no restriction given then no restriction
        if trs != ():
            self.tr = trs[0]
        else:
            self.tr = None

        self.refined = refined
        self.outmode = outmode
Example #2
0
 def __init__(self, position, ele):
     self._position = tuple(position)
     if isinstance(ele, Specie):
         self._element = ele
     elif isinstance(ele, int):
         self._element = Specie.from_num(ele)
     else:
         self._element = Specie(ele)
Example #3
0
    def __init__(self, settings, comment, element, speckle, nspeckle, zoom,
                 trs, refined, outmode, mpr):
        # read comment & zoom from setting file first
        # if not exist, read from cmd args, then default
        if zoom is None:
            try:
                zoom = settings['zoom']
            except:
                zoom = 1
        self.zoom = zoom

        if comment is None:
            try:
                comment = settings['comment']
            except:
                comment = 'default'
        self.comment = comment

        lat = np.array(settings['lattice'])
        pos = np.array(settings['positions'])
        num = np.array(settings['numbers'])
        self.cell = GeneralCell(lat * self.zoom, pos, num)

        self.element = element

        # Get number and index of target element
        if element is None:
            tgt_ele = int(num[1])
        else:
            tgt_ele = Specie(element).Z
        tgt_ele_index = np.where(num == tgt_ele)[0]

        self.s1, self.s2 = speckle
        self.n1, self.n2 = nspeckle
        # self.ele for function all-speckle-gen-of-ele in run
        self.ele = Specie.from_num(tgt_ele)

        # if there no restriction given then no restriction
        if trs != ():
            self.tr = trs[0]
        else:
            self.tr = None

        self.refined = refined
        self.outmode = outmode
        self.mpr = mpr

        self.n0 = tgt_ele_index.size - self.n1 - self.n2
Example #4
0
 def from_array(cls, arr):
     mfunc = np.vectorize(lambda n: Specie.from_num(n))
     sarr = mfunc(arr)
     return cls(sarr.tolist())