예제 #1
0
파일: becke.py 프로젝트: dftlibs/xcauto
def _b88_a_gaa(a, gaa):
    na43 = a**(4.0 / 3.0)
    chi2 = gaa * a**(-8.0 / 3.0)
    chi = np.sqrt(chi2)
    d = 0.0042
    b88 = -(d * na43 * chi2) / (1.0 + 6.0 * d * chi * np.arcsinh(chi))
    return slaterx_a(a) + b88
예제 #2
0
def plasticity(x, sigma_tr, kappa_tr, kappa_n, delta_eps_P_n):  # solves using yield function and isotropic hardening equation
    delta_eps_p = x[0]
    kappa_n1 = x[1]
    beta = V * jnp.arcsinh(delta_eps_p/time_step/f)
    F1 = sigma_tr-kappa_tr-beta # yield function
    F2 = kappa_n-(R_d*delta_eps_p+R_s*time_step)*kappa_n1**2-kappa_n1
    fs = jnp.asarray([F1, F2])  # Write outputs to function array for logical loop
    return fs
def radialReturn(sigma_n, delta_eps_p_n,
                 kappa_n):  # Defines function inputs from main logical loop
    # sigma_tr_n: trial stress from current time iteration
    # kappa_n: kappa from current time iteration
    # kappa_n1: guess for kappa at next timestep iteration

    # First making Elastic prediction
    # Elastic strain increment
    delta_eps_e = eps_dot * time_step  # eps = (eps_dot)*(time)
    # Hooke's Law (2*mu = E)
    delta_sigma_tr = 2 * mu * delta_eps_e  # MPa   <-- this come from mu (line 42) !!
    # Stress at next iteration is equal to stress at current iteration plus a change in stress
    sigma_tr = sigma_n + delta_sigma_tr  # MPa
    print(sigma_tr)
    # ___ = ___ - [(1/P)(eps) + (s/P)(s)](___)^2
    # kappa needs to evaluate to (MPa) for Y_f (line 107) !!
    # kappa_tr = kappa_n-(R_d*delta_eps_p_n+R_s*time_step)*kappa_n**2
    kappa_tr = kappa_n - (R_d * delta_eps_e + R_s * time_step) * kappa_n**2
    # beta = V * jnp.arcsinh(delta_eps_p_n/time_step/f)         # MPa
    beta = V * jnp.arcsinh(eps_dot / f)  # MPa[sin((1/s)/(1/s))]
    # Yield function should be a function of stress, ISV's, and strain rate
    Y_f = sigma_tr - kappa_tr - beta  # MPa

    if Y_f <= 0:  # If less than zero, deformation is purely elastic
        # Stress at next iteration is equal to stress at current iteration plus a change in stress
        sigma_n1 = sigma_tr  # MPa
        # Total strain is equal to the elastic strain
        delta_eps = delta_eps_e  # eps
        kappa_n1 = kappa_tr  # MPa
        delta_eps_p_n1 = 0  # eps
        print("ELASTIC")
    else:  # If yield function greater than zero, plasticity occurs. Must solve for plastic strain numerically
        # (reference the N-R method function here so solve plastic strain)
        # initial guess for plastic strain is previous plastic strain
        delta_eps_p_n1 = delta_eps_p_n  # eps/s
        # initial guess of future kappa with initial guess of future plastic strain
        kappa_n1 = kappa_tr + H * delta_eps_p_n1  # must be MPa <-- H must be MPa
        xs = [delta_eps_p_n1, kappa_n1]  # vector of future guesses

        def fs(x):
            result = plasticity(x, sigma_tr, kappa_tr, kappa_n,
                                delta_eps_p_n)  # input "xs" returns array "fs"
            return result

        res = multivariateNewton(
            fs, xs, 1e-5, 30
        )  # Perform Newton Method for System "fs" with guess  [x0,x1,x2] = [1,1,1] with tol = 1e-8 and N maximum iterations
        # print(fs(res))                  # Print "fs" output for system
        # proclaims future delta_eps_p from Newton Raphson
        delta_eps_p_n1 = res[0]  # eps
        # proclaims future stress
        sigma_n1 = sigma_tr - 2 * mu * delta_eps_p_n1  # MPa
        # print(sigma_n1)
        # proclaims future kappa from Newton Raphson's F2
        kappa_n1 = res[1]  # MPa
    return [sigma_n1, kappa_n1, delta_eps_p_n1]
def plasticity(x, sigma_tr, kappa_tr, kappa_n, delta_eps_P_n):
    # solves using yield function and isotropic hardening equation
    delta_eps_p = x[0]  # eps
    kappa_n1 = x[1]  # MPa
    beta = V * jnp.arcsinh(
        delta_eps_p / time_step / f)  # MPa[sin((1/s)/(1/s))]
    # yield function
    F1 = sigma_tr - kappa_tr - beta  # MPa
    # P - [(1/P) + (s2/P)](P2) - P
    # R_s can't be s^2 !!! (look back @ line 71)
    F2 = kappa_n - (R_d * delta_eps_p +
                    R_s * time_step) * kappa_n1**2 - kappa_n1
    fs = jnp.asarray([F1,
                      F2])  # Write outputs to function array for logical loop
    return fs
예제 #5
0
def radialReturn(sigma_n, delta_eps_p_n, kappa_n):          # Defines function inputs from main logical loop
    # sigma_tr_n: trial stress from current time iteration
    # kappa_n: kappa from current time iteration
    # kappa_n1: guess for kappa at next timestep iteration

    # First making Elastic prediction
    delta_eps_e = eps_dot*time_step             # Elastic strain increment
    delta_sigma_tr = 2*mu*delta_eps_e           # Hooke's Law (2*mu = E)
    sigma_tr = sigma_n + delta_sigma_tr  # Stress at next iteration is equal to stress at current iteration plus a change in stress
    print(sigma_tr)
    # kappa_tr = kappa_n-(R_d*delta_eps_p_n+R_s*time_step)*kappa_n**2
    kappa_tr = kappa_n-(R_d*delta_eps_e+R_s*time_step)*kappa_n**2
    # beta = V * jnp.arcsinh(delta_eps_p_n/time_step/f)
    beta = V * jnp.arcsinh(eps_dot/f)
    Y_f = sigma_tr-kappa_tr-beta                # Yield function. Should be a function of stress, ISV's, and strain rate

    if Y_f <= 0:                                # If less than zero, deformation is purely elastic
        sigma_n1 = sigma_tr                     # Stress at next iteration is equal to stress at current iteration plus a change in stress
        delta_eps = delta_eps_e  # Total strain is equal to the elastic strain
        kappa_n1 = kappa_tr
        delta_eps_p_n1 = delta_eps
        print("ELASTIC")
    else:                                       # If yield function greater than zero, plasticity occurs. Must solve for plastic strain numerically
        # (reference the N-R method function here so solve plastic strain)
        delta_eps_p_n1 = delta_eps_p_n  # initial guess for plastic strain is previous plastic strain
        kappa_n1 = kappa_tr + H * delta_eps_p_n1   # initial guess of future kappa with initial guess of future plastic strain
        xs = [delta_eps_p_n1, kappa_n1]    # vector of future guesses
        def fs(x):
            result = plasticity(x, sigma_tr, kappa_tr, delta_eps_p_n, kappa_n)  # input "xs" returns array "fs"
            return result
        res = multivariateNewton(fs, xs, 1e-5, 30) # Perform Newton Method for System "fs" with guess  [x0,x1,x2] = [1,1,1] with tol = 1e-8 and N maximum iterations
        # print(fs(res))                  # Print "fs" output for system
        delta_eps_p_n1 = res[0]         # proclaims future delta_eps_p from Newton Raphson
        sigma_n1 = sigma_tr - 2 * mu * delta_eps_p_n1  # proclaims future stress
        # print(sigma_n1)
        kappa_n1 = res[1]                   # proclaims future kappa from Newton Raphson's F2
    return [sigma_n1, kappa_n1, delta_eps_p_n1]
예제 #6
0
def hyperbolic_arcsin(x: Array) -> Array:
    """Hyperbolic arcsinus transform."""
    chex.assert_type(x, float)
    return jnp.arcsinh(x)
예제 #7
0
def arcsinh(x):
  if isinstance(x, JaxArray): x = x.value
  return JaxArray(jnp.arcsinh(x))
예제 #8
0
argmax = utils.copy_docstring(
    tf.math.argmax,
    lambda input, axis=None, output_type=tf.int64, name=None: (  # pylint: disable=g-long-lambda
        np.argmax(input, axis=0 if axis is None else _astuple(axis)).astype(
            utils.numpy_dtype(output_type))))

argmin = utils.copy_docstring(
    tf.math.argmin,
    lambda input, axis=None, output_type=tf.int64, name=None: (  # pylint: disable=g-long-lambda
        np.argmin(input, axis=0 if axis is None else _astuple(axis)).astype(
            utils.numpy_dtype(output_type))))

asin = utils.copy_docstring(tf.math.asin, lambda x, name=None: np.arcsin(x))

asinh = utils.copy_docstring(tf.math.asinh, lambda x, name=None: np.arcsinh(x))

atan = utils.copy_docstring(tf.math.atan, lambda x, name=None: np.arctan(x))

atan2 = utils.copy_docstring(tf.math.atan2,
                             lambda y, x, name=None: np.arctan2(y, x))

atanh = utils.copy_docstring(tf.math.atanh, lambda x, name=None: np.arctanh(x))

bessel_i0 = utils.copy_docstring(tf.math.bessel_i0,
                                 lambda x, name=None: scipy_special.i0(x))

bessel_i0e = utils.copy_docstring(tf.math.bessel_i0e,
                                  lambda x, name=None: scipy_special.i0e(x))

bessel_i1 = utils.copy_docstring(tf.math.bessel_i1,