"""
Created on 3.11.21

@author: Joschka
"""
import numpy as np
import matplotlib.pyplot as plt
from src import coil_class as BC
from src import physical_constants as cs


def Q_heat(flow,d_T):

    V_t = 4.8 * 3.2 * 1e-6 * flow
    m = cs.water_dens * V_t
    Q = m * cs.water_c_p * d_T
    return Q

def main():


    d_T = 1.5

    flow = 0.3/5#/5 #m/s
    #flow *=2
    print(f"flow = {flow}m/s")
    V_t = 4.8 * 3.2 * 1e-6 * flow
    print(f"Volume rate = {V_t * 1e6} mL/s")
    m = cs.water_dens * V_t
    Q = m * cs.water_c_p * d_T
    print(f"Q = {Q} J/s")

    #flow = np.linspace(0,5,100)
    #plt.plot(flow,Q_heat(flow,3))
    #plt.show()

    HH_Coil = BC.BCoil(HH=1, distance=51.694, radius=47.9263, layers=8, windings=16, wire_height=0.5,
                       wire_width=0.5, insulation_thickness=0.034, is_round=True,
                       winding_scheme=2)
    for I in np.arange(1,20,0.001):
        P = HH_Coil.power(I, 23)
        if P > Q:
            break

    print(f"Power = {P} W @ {I} A")

    B_max = HH_Coil.max_field(I)

    print(f"max field = {B_max} G")

    print(HH_Coil.cooling(I, 25))




if __name__ == '__main__':
    main()