# 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

    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')
    assert_close1d(ans, [10.828446488771524, 1.041522867361668])

    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')
    assert_close1d(ans, [-8.882391519909806, -0.9439839394457605])

    # Stokes law regime - test case where particle is ensured to be laminar before and after the simulation
    for m in (None, 'Stokes'):
        ans = integrate_drag_sphere(D=0.000001, rhop=2200., rho=1.2, mu=1.78E-5, t=0.1, V=0, distance=True, Method=m)
        assert_close1d(ans, [6.729981897140177e-05, 6.729519788530099e-06], rtol=1e-11)

def test_time_v_terminal_Stokes():
    t = time_v_terminal_Stokes(D=1e-7, rhop=2200., rho=1.2, mu=1.78E-5, V0=1.0)
    assert_close(t, 3.188003113787154e-06)

    # Very slow - many iterations

# 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


    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')
    assert_close1d(ans, [10.828446488771524, 1.041522867361668])

    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')
    assert_close1d(ans, [-8.882391519909806, -0.9439839394457605])

    # Stokes law regime - test case where particle is ensured to be laminar before and after the simulation
    for m in (None, 'Stokes'):
        ans = integrate_drag_sphere(D=0.000001, rhop=2200., rho=1.2, mu=1.78E-5, t=0.1, V=0, distance=True, Method=m)
        assert_close1d(ans, [6.729981897140177e-05, 6.729519788530099e-06], rtol=1e-11)

def test_time_v_terminal_Stokes():
    t = time_v_terminal_Stokes(D=1e-7, rhop=2200., rho=1.2, mu=1.78E-5, V0=1.0)
    assert_close(t, 3.188003113787154e-06)

    # Very slow - many iterations

    t = time_v_terminal_Stokes(D=1e-2, rhop=2200., rho=1.2, mu=1.78E-5, V0=1.0, tol=1e-30)