# -*- coding: utf-8 -*-
"""
Created on Wed Oct 16 16:16:07 2019

@author: Daniel Powell
"""

import numpy as np
from matplotlib import pyplot as plt


def C_c_factor(d_p, lamb=67e-9):
    # Davies, C. (1945).
    # "Definitive equations for the fluid resistance of spheres".
    # Proceedings of the Physical Society. 57: 259.
    # Bibcode:1945PPS....57..259D. doi:10.1088/0959-5309/57/4/301.
    return 1 + ((2 * lamb / d_p) * (1.257 + (0.4 * np.exp(-0.55 * d_p / lamb))))


def plot_c_c(save=0):
    d_p = np.linspace(1e-7, 1e-6, num=10000)
    C_c = C_c_factor(d_p)

    plt.figure()
    plt.plot(d_p * 1e6, C_c, 'k-')
    plt.xlabel(r"$d_p$ ($\mu m$)", fontsize=16)
    plt.ylabel(r"$C_c$", fontsize=16)
    plt.tight_layout()
    if save != 0:
        plt.savefig("C_c_plot.png", dpi=600)
    plt.show()


def tau_p(d_p):
    mu_f = 1.789e-5
    rho_p = 2650
    C = C_c_factor(d_p)
    
    return rho_p * d_p ** 2 * C / (18 * mu_f)