示例#1
0
def declining_phase(target_teff,
                    log_el1_over_el2,
                    time,
                    el1,
                    el2,
                    logg=8.0,
                    steady_state_start=False,
                    cross_extrap=True):
    """
    provide log_el1_over_el2 as an absolute number ratio not the one normalized to solar abundances.
    
    the output value will be in log10 of absolute number abundances... hopefully
    """
    if cross_extrap:
        el1_logtau = itau.extrapolate_tau_x_logg(target_teff, logg, el1)
        el2_logtau = itau.extrapolate_tau_x_logg(target_teff, logg, el2)
    else:
        el1_logtau = itau.extrapolate_single_el_tau(target_teff,
                                                    el1,
                                                    input_logg=logg)
        el2_logtau = itau.extrapolate_single_el_tau(target_teff,
                                                    el2,
                                                    input_logg=logg)

    el1_tau = 10.**el1_logtau
    el2_tau = 10.**el2_logtau
    exp_term = np.exp(
        time * ((el2_tau - el1_tau) /
                (el1_tau * el2_tau)))  #from equation 3 of Harrison et al. 2018
    if steady_state_start:
        coeff = 10.**(log_el1_over_el2) * el2_tau / el1_tau
    else:
        coeff = 10.**(log_el1_over_el2)
    dp_el1el2 = coeff * exp_term
    return np.log10(dp_el1el2)
示例#2
0
def el1el2_DP_el3el2_ftimes(target_teff,
                            log_el1el2,
                            log_el3el2,
                            time,
                            el1,
                            el2,
                            el3,
                            logg=8.0,
                            steady_state_start=False,
                            cross_extrap=True):
    if cross_extrap:
        el1_logtau = itau.extrapolate_tau_x_logg(target_teff, logg, el1)
        el2_logtau = itau.extrapolate_tau_x_logg(target_teff, logg, el2)
        el3_logtau = itau.extrapolate_tau_x_logg(target_teff, logg, el3)
    else:
        el1_logtau = itau.extrapolate_single_el_tau(target_teff,
                                                    el1,
                                                    input_logg=logg)
        el2_logtau = itau.extrapolate_single_el_tau(target_teff,
                                                    el2,
                                                    input_logg=logg)
        el3_logtau = itau.extrapolate_single_el_tau(target_teff,
                                                    el3,
                                                    input_logg=logg)
    print(el1, 'log tau', el1_logtau)
    print(el2, 'log tau', el2_logtau)
    print(el3, 'log tau', el3_logtau)

    log_el1el2_dp = get_el1el2_wrt_time(log_el1el2, time, el1_logtau,
                                        el2_logtau)
    log_el3el2_dp = get_el1el2_wrt_time(log_el3el2, time, el3_logtau,
                                        el2_logtau)
    return log_el1el2_dp, log_el3el2_dp
示例#3
0
    def get_ssp(teff,
                logg,
                el1el2,
                el3el2,
                elements,
                plot_all=plot_all,
                tau_rand=False,
                tau_add=tau_add):
        tau_el1 = itau.extrapolate_tau_x_logg(teff, logg, elements[0])
        tau_el2 = itau.extrapolate_tau_x_logg(teff, logg, elements[1])
        tau_el3 = itau.extrapolate_tau_x_logg(teff, logg, elements[2])

        tau2_tau1 = tau_el2 - tau_el1
        tau2_tau3 = tau_el2 - tau_el3
        if tau_rand:
            #print('tau2_tau1.shape',tau2_tau1.shape)
            tau2_tau1 = np.random.normal(loc=tau2_tau1, scale=tau_add)
            tau2_tau3 = np.random.normal(loc=tau2_tau3, scale=tau_add)
            print("tau_" + elements[0] + "-tau_" + elements[1],
                  -1 * np.mean(tau2_tau1), "+/-", np.std(tau2_tau1))
            print("tau_" + elements[2] + "-tau_" + elements[1],
                  -1 * np.mean(tau2_tau3), "+/-", np.std(tau2_tau3))
            #print('tau2_tau1.shape',tau2_tau1.shape)
        else:

            pass

        el1el2 = el1el2 + tau2_tau1
        el3el2 = el3el2 + tau2_tau3
        if plot_all:
            plt.hist(tau_el1 - tau_el2,
                     alpha=0.5,
                     label='no addition',
                     normed=True)
            plt.hist(-1 * tau2_tau1, alpha=0.5, label='addition', normed=True)
            plt.title(r'$\tau$' + elements[0] + '-' + elements[1])
            plt.legend()
            plt.show()

            plt.hist(tau_el3 - tau_el2, label='no addition', normed=True)
            plt.hist(-1 * tau2_tau3, alpha=0.5, label='addition', normed=True)
            plt.title(r'$\tau$' + elements[2] + '-' + elements[1])
            plt.legend()
            plt.show()

        return el1el2, el3el2
示例#4
0
def get_time_since_accretion(target_teff,
                             log_atm_ratio,
                             log_desired_ratio,
                             el1,
                             el2,
                             logg=8.0,
                             steady_state_start=False,
                             cross_extrap=True):
    """
    track back some abundance ratio from the present atmospheric abundance ratio to some expected abundance 
    ratio based on a solar system object (most likely). This gives the amount of time that must have passed since 
    accreting whatever body of that abundance in order to get the present day abundance.
    
    """
    if cross_extrap:
        print('cross_extrap')
        el1_logtau = itau.extrapolate_tau_x_logg(target_teff, logg, el1)
        el2_logtau = itau.extrapolate_tau_x_logg(target_teff, logg, el2)
    else:
        el1_logtau = itau.extrapolate_single_el_tau(target_teff,
                                                    el1,
                                                    input_logg=logg)
        el2_logtau = itau.extrapolate_single_el_tau(target_teff,
                                                    el2,
                                                    input_logg=logg)
    el1_tau = 10.**el1_logtau
    el2_tau = 10.**el2_logtau
    t_coeffs = (el1_tau * el2_tau) / (el2_tau - el1_tau)
    pollutant_term = log_desired_ratio - log_atm_ratio
    if steady_state_start:
        print('\nusing steady state\n')
        pollutant_term = pollutant_term + el1_logtau - el2_logtau
    else:
        pass
    pollutant_term = pollutant_term * np.log(10.)
    #print("pollutant_term", pollutant_term)
    #print("t_coeffs", t_coeffs)
    return t_coeffs * pollutant_term
示例#5
0
def get_relHe_fwd(el,
                  time,
                  target_teff,
                  log_elHe_atm,
                  logg=8.0,
                  cross_extrap=True):
    """
    time input in Myr, it will be converted to years inside this function
    """
    if cross_extrap:
        el_logtau = itau.extrapolate_tau_x_logg(target_teff, logg, el)
    else:
        el_logtau = itau.extrapolate_single_el_tau(target_teff,
                                                   el,
                                                   input_logg=logg)
    time = time * 1e6
    return log_elHe_atm + np.log10(np.e) * (-time / (10.**el_logtau))
示例#6
0
def get_t_relHe_fwd(el,
                    target_teff,
                    log_elHe_atm,
                    log_elHe_des,
                    logg=8.0,
                    cross_extrap=True):
    """
    Take the present-day value for log10(el/He) and figure out how long would have to pass for diffusion to lower
    the overall photospheric abundance to log_elHe_des
    
    """
    if cross_extrap:
        el_logtau = itau.extrapolate_tau_x_logg(target_teff, logg, el)
    else:
        el_logtau = itau.extrapolate_single_el_tau(target_teff,
                                                   el,
                                                   input_logg=logg)
    return (log_elHe_atm - log_elHe_des) * np.log(10.) * 10.**(el_logtau)
示例#7
0
def get_accreted_mass(el,
                      log_elHe,
                      t_passed,
                      teff=5000.,
                      logg=8.0,
                      log_q=-5.0,
                      m_wd=0.56,
                      cross_extrap=True):
    """
    Assumes all of the convective mass can be treated as being helium and also that the helium isotope abundances are the same as that found on Earth(?, whatever the default periodic table mean molecular weight is). 
    
    returns the mass of whatever element that was present in the photosphere at the beginning of decline. 
    
    This should then be taken and divided by the mass of that element as a fraction of something like a chondrite 
    or eucrite or whatever to get the total mass of the accreted body.
    """
    el_num = cp.el_nums[el]
    if cross_extrap:
        log_el_tau = itau.extrapolate_tau_x_logg(teff, logg, el)
    else:
        log_el_tau = itau.extrapolate_single_el_tau(teff, el, input_logg=logg)
    #print('log_el_tau', log_el_tau)
    #print("t_passed", t_passed)
    #print('(t_passed/(10.**log_el_tau))',(t_passed/(10.**log_el_tau)))
    m_wd = (m_wd * const.M_sun).to(
        u.kg
    ).value  #converting the white dwarf mass to kg but making it a float again
    #print("np.log10(pt.elements[el_num].mass/pt.elements[2].mass)",np.log10(pt.elements[el_num].mass/pt.elements[2].mass))
    #print("pt.elements[el_num].mass", pt.elements[el_num].mass)
    #print("pt.elements[2].mass", pt.elements[2].mass)
    #print("log_elHe", log_elHe)
    #print("log_q", log_q)
    #print("np.log10(m_wd)", np.log10(m_wd))
    #print('====')
    log_m_acc = np.log10(pt.elements[el_num].mass /
                         pt.elements[2].mass) + log_elHe + log_q + np.log10(
                             m_wd) + (t_passed /
                                      (10.**log_el_tau)) * np.log10(np.e)
    return log_m_acc