# -*- coding: utf-8 -*-
"""
Created on Tue Sep  7 13:18:18 2021

@author: Joschka
"""

import matplotlib.pyplot as plt
import numpy as np
import matplotlib
#matplotlib.use('Qt5Agg')
from src import coil_class as BC

scale = 1000
lim = 5
nr_points = (2 * lim) * scale + 1
x = np.linspace(-lim,lim,nr_points)
z = np.linspace(-lim,lim,nr_points)


def mu_it(x_pos):
    it = nr_points//2 + x_pos
    return it


Wire_1 = [0.45, 0.6514]
for ll in range(7,11):
    for ww in range(7,11)
Coil_1 = BC.BCoil(HH = 1, distance = 54, radius = 48, layers = 8, windings = 8, wire_height = Wire_1[0], wire_width = Wire_1[0], insulation_thickness= (Wire_1[1] - Wire_1[0])/2, is_round = True, winding_scheme= 2)
print(Coil_1.get_tot_wire_width())
Coil_1.set_R_outer(50.5-Coil_1.get_tot_wire_width())
Coil_1.set_d_min(47.15)
Coil_1.print_info()


print(Coil_1.get_coil_width() * 1e3 * Coil_1.get_coil_height() * 1e3)
print(f"H = {Coil_1.get_coil_height() * 1e3}, W = {Coil_1.get_coil_width() * 1e3}")

I = 64 / Coil_1.get_N() * 1.25
print(f"I = {I} A")
Coil_1.cooling(I, 22.5)

Coil_1.plot_raster(30)
Bz, Bx = Coil_1.B_field(I, x, z, raster = 1)
Bz_curv = BC.BCoil.curv(Bz,z)
zero = mu_it(0)
print(z[zero])
print(f"Curvature = {Bz_curv[zero]}")

#Wire_1.B_quick_plot(I)
#Wire_1.B_curv_quick_plot(I,nr_points= 1000)


