# Path: fluids/drag.py
# def Stokes(Re):
# def Barati(Re):
# def Barati_high(Re):
# def Rouse(Re):
# def Engelund_Hansen(Re):
# def Clift_Gauvin(Re):
# def Morsi_Alexander(Re):
# def Graf(Re):
# def Flemmer_Banks(Re):
# def Khan_Richardson(Re):
# def Swamee_Ojha(Re):
# def Yen(Re):
# def Haider_Levenspiel(Re):
# def Cheng(Re):
# def Terfous(Re):
# def Mikhailov_Freire(Re):
# def Clift(Re):
# def Ceylan(Re):
# def Almedeij(Re):
# def Morrison(Re):
# def Song_Xu(Re, sphericity=1., S=1.):
# def drag_sphere_methods(Re, check_ranges=True):
# def drag_sphere(Re, Method=None):
# def _v_terminal_err(V, Method, Re_almost, main):
# def v_terminal(D, rhop, rho, mu, Method=None):
# def time_v_terminal_Stokes(D, rhop, rho, mu, V0, tol=1e-14):
# def integrate_drag_sphere(D, rhop, rho, mu, t, V=0, Method=None,
#                           distance=False):
#     def dv_dt(V, t):
#     E = 0.383*Re**0.356 - 0.207*Re**0.396 - 0.143/(1 + (log10(Re))**2)


from fluids.drag import drag_sphere, drag_sphere_methods, v_terminal, integrate_drag_sphere, time_v_terminal_Stokes, drag_sphere_correlations
from fluids.drag import *
from fluids.numerics import assert_close1d, assert_close
import pytest
    # It also has another example
    v_t = v_terminal(D=50E-6, rhop=2.8E3, rho=1000., mu=1E-3)
    assert_close(v_t, 0.0024195143465496655)
    # vs 0.002453 in [2]

    # Laminar example
    v_t = v_terminal(D=70E-6, rhop=2600., rho=1000., mu=1E-1)
    assert_close(v_t, 4.271340888888888e-05)

    v_t = v_terminal(D=70E-6, rhop=2600., rho=1000., mu=1E-3, Method='Rouse')
    assert_close(v_t, 0.003991779430745852)

@pytest.mark.scipy
def test_integrate_drag_sphere():
    ans = integrate_drag_sphere(D=0.001, rhop=2200., rho=1.2, mu=1.78E-5, t=0.5, V=30.0, distance=True)
    assert_close1d(ans, (9.686465044063436, 7.829454643649386))

    ans = integrate_drag_sphere(D=0.001, rhop=2200., rho=1.2, mu=1.78E-5, t=0.5, V=30.0)
    assert_close(ans, 9.686465044063436)

    # Check no error when V is zero


    ans = integrate_drag_sphere(D=0.001, rhop=1.20001, rho=1.2, mu=1.78E-5, t=0.5, V=0.0)
    assert_close(ans, 3.0607521920092645e-07)

    # Stokes law regime integration
    ans = integrate_drag_sphere(D=0.001, rhop=2200., rho=1.2, mu=1.78E-5, t=0.1, V=0, distance=True, Method='Stokes')
    assert_close1d(ans, [0.9730274844308592, 0.04876946395795378])


# Path: fluids/drag.py
# def Stokes(Re):
# def Barati(Re):
# def Barati_high(Re):
# def Rouse(Re):
# def Engelund_Hansen(Re):
# def Clift_Gauvin(Re):
# def Morsi_Alexander(Re):
# def Graf(Re):
# def Flemmer_Banks(Re):
# def Khan_Richardson(Re):
# def Swamee_Ojha(Re):
# def Yen(Re):
# def Haider_Levenspiel(Re):
# def Cheng(Re):
# def Terfous(Re):
# def Mikhailov_Freire(Re):
# def Clift(Re):
# def Ceylan(Re):
# def Almedeij(Re):
# def Morrison(Re):
# def Song_Xu(Re, sphericity=1., S=1.):
# def drag_sphere_methods(Re, check_ranges=True):
# def drag_sphere(Re, Method=None):
# def _v_terminal_err(V, Method, Re_almost, main):
# def v_terminal(D, rhop, rho, mu, Method=None):
# def time_v_terminal_Stokes(D, rhop, rho, mu, V0, tol=1e-14):
# def integrate_drag_sphere(D, rhop, rho, mu, t, V=0, Method=None,
#                           distance=False):
#     def dv_dt(V, t):
#     E = 0.383*Re**0.356 - 0.207*Re**0.396 - 0.143/(1 + (log10(Re))**2)


# Path: tests/test_drag.py
from fluids.drag import drag_sphere, drag_sphere_methods, v_terminal, integrate_drag_sphere, time_v_terminal_Stokes, drag_sphere_correlations
from fluids.drag import *
from fluids.numerics import assert_close1d, assert_close
import pytest

    # It also has another example
    v_t = v_terminal(D=50E-6, rhop=2.8E3, rho=1000., mu=1E-3)
    assert_close(v_t, 0.0024195143465496655)
    # vs 0.002453 in [2]

    # Laminar example
    v_t = v_terminal(D=70E-6, rhop=2600., rho=1000., mu=1E-1)
    assert_close(v_t, 4.271340888888888e-05)

    v_t = v_terminal(D=70E-6, rhop=2600., rho=1000., mu=1E-3, Method='Rouse')
    assert_close(v_t, 0.003991779430745852)

@pytest.mark.scipy
def test_integrate_drag_sphere():
    ans = integrate_drag_sphere(D=0.001, rhop=2200., rho=1.2, mu=1.78E-5, t=0.5, V=30.0, distance=True)
    assert_close1d(ans, (9.686465044063436, 7.829454643649386))

    ans = integrate_drag_sphere(D=0.001, rhop=2200., rho=1.2, mu=1.78E-5, t=0.5, V=30.0)
    assert_close(ans, 9.686465044063436)

    # Check no error when V is zero


    ans = integrate_drag_sphere(D=0.001, rhop=1.20001, rho=1.2, mu=1.78E-5, t=0.5, V=0.0)
    assert_close(ans, 3.0607521920092645e-07)

    # Stokes law regime integration
    ans = integrate_drag_sphere(D=0.001, rhop=2200., rho=1.2, mu=1.78E-5, t=0.1, V=0, distance=True, Method='Stokes')
    assert_close1d(ans, [0.9730274844308592, 0.04876946395795378])


    ans = integrate_drag_sphere(D=0.001, rhop=2200., rho=1.2, mu=1.78E-5, t=0.1, V=10, distance=True, Method='Stokes')