Exemplo n.º 1
0
    def generate(cls, atom_types):
        '''
        Randomly generate parameters for morse.

        **Parameters**

            atom_types: *list, str*
                A list of all the atom types to have parameters generated for.

        **Returns**

            morse_objs: *list, Morse*
                Returns a list of Morse objects.
        '''
        from helper import random_in_range

        morse_objs = []

        for indices in combinations_with_replacement(atom_types, 2):
            D0 = random_in_range((0.1, 1000))
            alpha = random_in_range((0.1, 100))
            r0 = random_in_range((0.1, 5.0))
            rc = random_in_range((0.1, 15.0))
            morse_objs.append(cls(indices, D0, alpha, r0, rc))

        return morse_objs
Exemplo n.º 2
0
    def generate(cls, atom_types, elems, signs):
        """
        Randomly generate parameters for coulomb.

        **Parameters**

            atom_types: *list, str*
                A list of all the atom types to have parameters generated for.
            elems: *list, str*
                List of the elements (in the same order as atom_types).
            signs: *list, float*
                The list of the signs of the charges (in the same order as the atom_types).

        **Returns**

            coul_objs: *list, Coul*
                Returns a list of Coul objects.
        """
        from helper import random_in_range

        coul_objs = []

        for atype, elem, sign in zip(atom_types, elems, signs):
            assert sign in [-1.0, 1.0
                            ], "Error - sign is not valid! Must be -1.0 or 1.0"
            charge_bounds = tuple(
                sorted(
                    [CHARGE_LOWER * float(sign), CHARGE_UPPER * float(sign)]))
            charge = random_in_range(charge_bounds)
            mass = elem_weight(elem)
            coul_objs.append(cls(atype, charge, mass, elem))
            coul_objs[-1].charge_bounds = charge_bounds

        return coul_objs
Exemplo n.º 3
0
    def generate(cls, atom_types):
        '''
        Randomly generate parameters for lj sigma and epsilon.

        **Parameters**

            atom_types: *list, str*
                A list of all the atom types to have parameters generated for.

        **Returns**

            lj_objs: *list, LJ*
                Returns a list of LJ objects.
        '''
        from helper import random_in_range

        LJ_objs = []

        for atype in atom_types:
            eps = random_in_range((0, 3.0))
            sig = random_in_range((0.01, 5.0))
            LJ_objs.append(cls(atype, sig, eps))

        return LJ_objs
Exemplo n.º 4
0
    def generate(cls,
                 atom_types,
                 lri,
                 gcut,
                 smooth_index,
                 coupled=False,
                 coupled_lr_smooth=None,
                 coupled_lr_cut=None,
                 coupled_smooth_index=None):
        '''
        Randomly generate parameters for smooths.

        **Parameters**

            atom_types: *list, str*
                A list of all the atom types to have parameters generated for.
            lri: *str*
                Whether this is sin_l, sin_r, or sin_inout.
            gcut: *float*
                The global cutoff, to not be exceeded.
            smooth_index: *int*
                This smooth's index.
            coupled: *bool, optional*
                Whether to couple this smooth with another smooth or not.  If
                so, then all coupled keywords need defining.
            coupled_lr_smooth: *str*
                Whether this is sin_l, sin_r, or sin_inout.
            coupled_lr_cut: *float*
                The global cutoff, to not be exceeded.
            coupled_smooth_index: *int*
                The coupled smooth's index.

        **Returns**

            smooth_objs: *list, SmoothSin*
                Returns a list of smooth objects.
        '''
        from helper import random_in_range

        smooth_objs = []

        if "inout" in lri:
            lri = None
        else:
            lri = lri.strip()[-1]
        if "inout" in coupled_lr_smooth:
            c_lri = None
        else:
            c_lri = coupled_lr_smooth.strip()[-1]

        for indices in combinations_with_replacement(atom_types, 2):
            R_IN_BOUNDS = (gcut * RADII_OFFSET, gcut * (1.0 - RADII_OFFSET))
            D_IN_BOUNDS = (LOWER_CUT, gcut * RADII_OFFSET - EPSILON)
            r_in = random_in_range(R_IN_BOUNDS)
            d_in = random_in_range(D_IN_BOUNDS)
            atom_i, atom_j = indices

            # In the case of inout, we need the outer bounds.  Further, if
            # we are coupling with inout and lri is not None, we STILL needs
            # the outer bounds
            if lri is None or (c_lri is None and coupled):

                # gcut for bounds will depend on which smooth is further out
                if coupled:
                    local_gcut = coupled_lr_cut
                else:
                    local_gcut = gcut

                R_IN_BOUNDS = (gcut * RADII_OFFSET, gcut * 0.5)
                R_OUT_BOUNDS = (gcut * 0.5, gcut * (1.0 - RADII_OFFSET))
                D_IN_BOUNDS = (LOWER_CUT, gcut * RADII_OFFSET - EPSILON)
                D_OUT_BOUNDS = (LOWER_CUT, gcut * RADII_OFFSET - EPSILON)

                # In the case when both are inout, we need to also use C_
                if lri is None and coupled and c_lri is None:
                    R_IN_BOUNDS = (gcut * RADII_OFFSET, gcut / 3.0)
                    D_IN_BOUNDS = (LOWER_CUT, gcut * RADII_OFFSET - EPSILON)
                    C_R_BOUNDS = (gcut * RADII_OFFSET, gcut * 2.0 / 3.0)
                    C_D_BOUNDS = (LOWER_CUT, gcut * RADII_OFFSET - EPSILON)

                    c_r = random_in_range(C_R_BOUNDS)
                    c_d = random_in_range(C_D_BOUNDS)
                else:
                    c_r = None
                    c_d = None
                    C_R_BOUNDS = None
                    C_D_BOUNDS = None

                r_in = random_in_range(R_IN_BOUNDS)
                d_in = random_in_range(D_IN_BOUNDS)

                r_out = random_in_range(R_OUT_BOUNDS)
                d_out = random_in_range(D_OUT_BOUNDS)
            else:
                r_out = None
                d_out = None
                c_r = None
                c_d = None
                C_R_BOUNDS = None
                C_D_BOUNDS = None
                R_OUT_BOUNDS = None
                D_OUT_BOUNDS = None

            smooth_objs.append(
                cls(smooth_index,
                    atom_i,
                    atom_j,
                    r_in,
                    d_in,
                    gcut,
                    lr=lri,
                    r_out=r_out,
                    d_out=d_out,
                    c_r=c_r,
                    c_d=c_d,
                    c_lr=c_lri,
                    c_gcut=coupled_lr_cut,
                    c_s_index=coupled_smooth_index))
            smooth_objs[-1].R_IN_BOUNDS = R_IN_BOUNDS
            smooth_objs[-1].D_IN_BOUNDS = D_IN_BOUNDS
            smooth_objs[-1].R_OUT_BOUNDS = R_OUT_BOUNDS
            smooth_objs[-1].D_OUT_BOUNDS = D_OUT_BOUNDS
            smooth_objs[-1].C_R_BOUNDS = C_R_BOUNDS
            smooth_objs[-1].C_D_BOUNDS = C_D_BOUNDS

        return smooth_objs
Exemplo n.º 5
0
    def generate(cls, atom_types, form="original"):
        '''
        Randomly generate parameters for tersoff.

        **Parameters**

            atom_types: *list, str*
                A list of all the atom types to have parameters generated for.
            form: *str*
                Whether to use the original form (m=3, gamma=1) or the
                Albe et al form (m=1, beta=1).  Must be original or albe.

        **Returns**

            ters_objs: *list, Tersoff*
                Returns a list of Tersoff objects.
        '''
        from helper import random_in_range

        form = form.lower()
        assert form in ["original", "albe"
                        ], "Error - form must be either original or albe."

        Tersoff_Objs = []

        for indices in list(product(atom_types, repeat=3)):
            if form == "original":
                m = 3
                gamma = 1
                beta = random_in_range((0.0, 1.0))
            elif form == "albe":
                m = 1
                beta = 1
                gamma = random_in_range((0.0, 1.0))

            lambda3 = random_in_range((0, 10.0))
            c = random_in_range((0.1, 150000.0))
            d = random_in_range((0.1, 50.0))
            costheta0 = random_in_range((-1.0, 1.0))
            n = random_in_range((0, 50.0))
            lambda2 = random_in_range((0, 10.0))
            B = random_in_range((100.0, 100000.0))
            R = random_in_range((1.1, 3.0))
            D = random_in_range((0.1, 1.0))
            lambda1 = random_in_range((0, 10.0))
            A = random_in_range((100.0, 100000.0))

            Tersoff_Objs.append(
                cls(indices, m, gamma, lambda3, c, d, costheta0, n, beta,
                    lambda2, B, R, D, lambda1, A))

        return Tersoff_Objs