import analytic_Euler
import fit_r_t0 as fit
import diff_cooling_paths
import fillesing as fl
import matplotlib.pyplot as plt
import ipywidgets as wid

def main(valg):
    if valg == "Plot analytical and numeric solution vs. experimental data":
        print('Showing analytical and numerical solution of "The coffee cup problem". Numerical solution diverges for '
              'large h (If |T_1| > |T_0|)')
        wid.interact(analytic_Euler.plot_Analytical_Euler,
                     h = wid.FloatSlider(min = 0.001, max = 5, step = 0.001, continuous_update = False),
                     T_s = wid.IntSlider(min = 10, max = 30, step = 1, continuous_update = False),
                     T_0 = wid.IntSlider(min = 50, max = 90, step = 1, continuous_update = False),
                     r = wid.FloatSlider(min = 0.01, max = 3, step = 0.01, continuous_update = False),
                     T_f = wid.IntSlider(min = 10, max = 90, step = 2, continuous_update = False),
                     t_f = wid.IntSlider(min = 10, max = 90, step = 2, continuous_update = False))
        plt.show()

    elif valg == 'Fit r and T0 to experimental data':
        fit.finn_r_T0()

    elif valg == 'Show different cooling paths':
        print('Shows cooling path with from T = T0 to T = T_cold with addition of cream at t = 0 '
              'and at the latest possible time. Assuming coffee is cooled "cream_cooling" degrees '
              'instantaneously upon addition of cream. Solution is numeric, using RK4 with stepsize dT.')
        wid.interact(diff_cooling_paths.plot_optimum_cooling,
                     T0 = wid.IntSlider(min = 70, max = 90, step = 1, continuous_update = False),
                     T_cold = wid.IntSlider(min = 40, max = 80, step = 1, continuous_update = False),
                     cream_cooling = wid.IntSlider(min = 1, max = 10, step = 1, continuous_update = False),
                     dT = wid.FloatSlider(min = 0.01, max = 3.0, step = 0.01, continuous_update = False))
        plt.show()
    return 0

def run():
    wid.interact(main, valg = wid.Dropdown(options=
                       ['Plot analytical and numeric solution vs. experimental data',
                        'Fit r and T0 to experimental data',
                        'Show different cooling paths']))