Exemple #1
0
    def output_points(self, defectsys, jdata):
        ''' format:
        I 1 10.0 10.0 10.0
        V 1 10.0 10.0 10.0
        '''

        box = np.array(j_must_have(jdata, 'box'))
        total_point_defects_str_list = self._return_points(defectsys, jdata)

        new_total_point_defects_str_list = [
            to_str(box) + ' # b011, b022, b033\n'
        ]

        for item in total_point_defects_str_list:

            defectStr = item.lstrip().rstrip()
            defectStr_list = defectStr.split()
            position = np.array(
                [np.float64(item2) for item2 in defectStr_list[0:3]]) * box

            if defectStr_list[3] == '0':
                new_defectStr = 'V ' + ' 1 ' + to_str(position) + '\n'
            else:
                new_defectStr = 'I ' + ' 1 ' + to_str(position) + '\n'

            new_total_point_defects_str_list.append(new_defectStr)

        self.file_out_points.writelines(new_total_point_defects_str_list)
Exemple #2
0
    def output_defectStr(self, defectsys):
        '''
        output defectStr for next cascade annealing input
        format : ILoop111 13 10.0 10.0 10.0 0.5 0.5 0.5
        '''

        defectStr_list = []

        for item in defectsys.defectObject_list:

            if hasattr(item, 'burgers_vector_scale'):
                defectStr = item.defecttype + ' '                    \
                          + str( item.nsize ) + ' '                   \
                          + to_str( item.position ) + ' '              \
                          + to_str( item.burgers_vector_scale ) + '\n'
            else:
                defectStr = item.defecttype + ' '          \
                          + str( item.nsize ) + ' '         \
                          + to_str( item.position ) + '\n'

            defectStr_list.append(defectStr)

        self.file_out_defectStr.writelines(defectStr_list)
Exemple #3
0
    def load_point_defects_uniform_distribution(self, jdata, seed=None):
        '''
        self.defectStr_list, format: 
         'I 1 10.0 10.0 10.0\n'
         'V 1 10.0 10.0 10.0\n'

         len( ) == 5
        '''

        if seed != None: np.random.seed(seed)

        tmp_box = np.array(j_must_have(jdata, 'box'))

        self.defectStr_list = []

        for i in range(self.I_total):
            position = np.random.random(3) * tmp_box
            defectStr = 'I 1 ' + to_str(position) + '\n'
            self.defectStr_list.append(defectStr)

        for i in range(self.I_total):
            position = np.random.random(3) * tmp_box
            defectStr = 'V 1 ' + to_str(position) + '\n'
            self.defectStr_list.append(defectStr)
Exemple #4
0
    def cascade_cfg_2_points_defectStr(self, sys_path, cascade_prefix):
        '''
        cfg format:
        Number of particles =    564               0   4
        A = 1.0 Angstrom (basic length-scale)      1
        H0(1,1) =    481.11039925 A                2   2   
        H0(1,2) =      0.00000000 A
        H0(1,3) =      0.00000000 A
        H0(2,1) =      0.00000000 A
        H0(2,2) =    481.11039925 A                6   2
        H0(2,3) =      0.00000000 A
        H0(3,1) =      0.00000000 A
        H0(3,2) =      0.00000000 A
        H0(3,3) =    664.69199896 A               10   2
        .NO_VELOCITY.
        entry_count =  4
        auxiliary[0] = IV                         13
        183.84                                    14                    
        W                                         15
          0.45574900000000002        4.4982300000000003E-002  0.27725538095238089                1
        183.84
        W
         0.47206700000000001       0.10702200000000001       0.24135238095238087                1

        points_defectStr format:
        I 1 10.0 10.0 10.0
        V 1 10.0 10.0 10.0
        '''

        for i in range(len(self.defects_cfg_file)):

            file_in = open(self.defects_cfg_file[i], 'r')
            file_points_defectStr = os.path.join(sys_path,
                                                 cascade_prefix + '.' + str(i))
            file_out = open(file_points_defectStr, 'w')

            lines = []
            while True:
                s = file_in.readline()
                if s == '':
                    break
                lines.append(s)
            file_in.close()

            for i in range(11):

                defectStr = lines[i].lstrip().rstrip()
                defectStr_list = defectStr.split()

                if i == 0:
                    defects_numb = np.int64(defectStr_list[4])
                elif i == 2:
                    b011 = np.float64(defectStr_list[2])
                elif i == 6:
                    b022 = np.float64(defectStr_list[2])
                elif i == 10:
                    b033 = np.float64(defectStr_list[2])
                    tmp_box = np.array([b011, b022, b033]) / 10.0

            points_defectStr_list = [to_str(tmp_box) + ' # b011, b022, b033\n']

            for i in range(14, len(lines)):
                less = (i - 13) % 3
                defectStr = lines[i].lstrip().rstrip()
                defectStr_list = defectStr.split()
                if less == 1:
                    mass = np.float64(defectStr_list[0])
                elif less == 2:
                    symbol = defectStr_list[0]
                elif less == 0:
                    position_scale = np.array(
                        [np.float64(item) for item in defectStr_list[0:3]])
                    IV = defectStr_list[3]

                    if IV == '0':
                        points_defectStr_list.append('V 1 ' +
                                                     to_str(position_scale *
                                                            tmp_box) + '\n')
                    elif IV == '1':
                        points_defectStr_list.append('I 1 ' +
                                                     to_str(position_scale *
                                                            tmp_box) + '\n')

            file_out.writelines(points_defectStr_list)

            file_out.close()
Exemple #5
0
    def load_cascade_from_formula(self, jdata, seed=None):
        '''
        self.defectStr_list, defectStr format: 
         'I        1  10.0 10.0 10.0\n'
         'ICluster 7  10.0 10.0 10.0\n'
         'ILoop111 13 10.0 10.0 10.0\n'
         'ILoop100 13 10.0 10.0 10.0\n'

         'V        1  10.0 10.0 10.0\n'
         'VCluster 7  10.0 10.0 10.0\n'
         'VLoop111 13 10.0 10.0 10.0\n'
         'VLoop100 13 10.0 10.0 10.0\n'
        '''

        if seed != None: np.random.seed(seed)

        tmp_box = np.array(j_must_have(jdata, 'box'))

        self.create_defects_formula_distribution()

        self.defectStr_list = []

        for item in self.int_defect_size_R:

            if item[0] == 1:
                defecttype = 'I'
            elif item[0] >= 2 and item[0] <= self.ICluster_upper:
                defecttype = 'ICluster'
            elif item[0] > self.ICluster_upper:
                if np.random.rand() < self.ratio_ILoop111_ILoop100[0]:
                    defecttype = 'ILoop111'
                else:
                    defecttype = 'ILoop100'

            position = 0.5 * tmp_box + R_convert_to_position(item[1])
            defectStr = defecttype + ' ' + str(
                item[0]) + ' ' + to_str(position) + '\n'

            self.defectStr_list.append(defectStr)

        for item in self.vac_defect_size_R:

            if item[0] == 1:
                defecttype = 'V'
            elif item[0] >= 2 and item[0] < self.VLoop_lower:
                defecttype = 'VCluster'
            elif item[0] >= self.VLoop_lower:

                kesi = np.random.rand()

                if kesi < self.ratio_VCluster_VLoop100_VLoop111[0]:
                    defecttype = 'VCluster'
                elif kesi < self.ratio_VCluster_VLoop100_VLoop111[
                        0] + self.ratio_VCluster_VLoop100_VLoop111[1]:
                    defecttype = 'VLoop100'
                else:
                    defecttype = 'VLoop111'

            position = 0.5 * tmp_box + R_convert_to_position(item[1])
            defectStr = defecttype + ' ' + str(
                item[0]) + ' ' + to_str(position) + '\n'

            self.defectStr_list.append(defectStr)
Exemple #6
0
    def set_defectStr(self, alatt, ICluster_upper, VLoop_lower,
                      burgers_vector_unit_array,
                      burgers_vector_scale_length_array, d_probability):
        '''
        set self.defecttype and self.burgers_vector_scale.
        a. burgers_vector_unit_array, b. burgers_vector_scale_length_array, c. d_probability.
        '''

        if burgers_vector_unit_array.shape[
                0] != burgers_vector_scale_length_array.size:
            raise RuntimeError(
                'the size of burgers_vector_unit_array and burgers_vector_scale_length_array is not equal, wrong !'
            )

        '1. get sum probability of atoms belong to burgers range.'
        probability_distri = []
        for i in range(burgers_vector_unit_array.shape[0]):
            probability_distri.append(
                self.return_sum_probability_in_burgers_range(
                    alatt, burgers_vector_unit_array[i],
                    burgers_vector_scale_length_array[i], i))

        probability_distri_array = np.array(probability_distri)
        '''
        # test_cgzhang
        print( '# self.atoms_numb:', self.atoms_numb )
        print( '# self.position:', self.position )
        print( '# self.position_center:', self.position_center )
        print( '# self.IV:', self.IV )
        print( '# self.rcut:', self.rcut )
        print( '# probability_distri_array:', probability_distri_array )
        '''

        probability_distri_array = probability_distri_array / np.sum(
            probability_distri_array)

        '2. get find_index_list which is relate to selected burgers vector unit.'
        find_index_list = self.find_index_of_burgers_vector(
            d_probability, probability_distri_array)
        length_find_index_list = len(find_index_list)

        '3. set self.defecttype and self.burgers_vector_scale according to length_find_index_list.'
        if length_find_index_list == 1:
            if find_index_list[0] >= 0 and find_index_list[0] < 3:
                self.defecttype = self.IV + 'Loop100'
            else:
                'find_index_list[ 0 ] >= 3 and find_index_list[ 0 ] < probability_distri_array.size'
                self.defecttype = self.IV + 'Loop111'

            self.burgers_vector_scale = burgers_vector_unit_array[
                find_index_list[0]] * burgers_vector_scale_length_array[
                    find_index_list[0]]
            burgers_set = True
        else:
            'length_find_index_list == 0'
            self.defecttype = self.IV + 'Cluster'
            burgers_set = False

        '4. reset self.defecttype according to self.IV, self.atoms_numb, ICluster_upper and VLoop_lower.'
        if self.IV == 'I':

            if self.atoms_numb == 1:
                self.defecttype = self.IV
            elif self.atoms_numb > 1 and self.atoms_numb <= ICluster_upper:
                self.defecttype = 'ICluster'
                burgers_set = False
            else:
                'transite ICluster to ILoop111 or ILoop100, because self.atoms_numb > ICluster_upper.'
                if burgers_set:
                    pass
                else:
                    self.defecttype = 'ILoop111'

        if self.IV == 'V':

            if self.atoms_numb == 1:
                self.defecttype = self.IV
            elif self.atoms_numb > 1 and self.atoms_numb < VLoop_lower:
                self.defecttype = 'VCluster'
                burgers_set = False

        '5. set self.defectStr according to burgers_set.'
        if burgers_set:
            self.defectStr = self.defecttype + ' ' + str(
                self.atoms_numb) + ' ' + to_str(
                    self.position_center) + ' ' + to_str(
                        self.burgers_vector_scale) + '\n'
        else:
            self.defectStr = self.defecttype + ' ' + str(
                self.atoms_numb) + ' ' + to_str(self.position_center) + '\n'
        '''