# -*- coding: utf-8 -*-
"""
Created on Mon Aug 23 17:40:37 2021

@author: Joschka
"""


import matplotlib.pyplot as plt
import numpy as np
#from src import B_field_calculation as bf

from src import coil_class as BC

from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')
#get_ipython().run_line_magic('matplotlib', 'inline')

#set up axis

res = 1001
zr = res//2
x = np.linspace(-5, 5, res)
z = np.linspace(-5, 5, res)


#Field plot
##########################


I = 10


AHH_Coil = BC.BCoil(HH = -1, distance = 81.8 ,radius =  46.875 ,layers = 4, windings = 4 , wire_width= 1, wire_height= 2 ,layers_spacing = 0.25, windings_spacing= 0.25)
AHH_Coil.print_info()
AHH_Coil.cooling(I, 30)
print(f"R (30 degree C)= {AHH_Coil.resistance(30)}")

B_z,B_x = AHH_Coil.B_field(I, x, z)

B_z_grad = BC.BCoil.grad(B_z, z)
B_x_grad = BC.BCoil.grad(B_x, x)

B_z_curv = BC.BCoil.grad(B_z_grad, z)
B_x_curv = BC.BCoil.grad(B_z_grad, z)

B_z_3rd = BC.BCoil.grad(B_z_curv, z)
B_x_3rd = BC.BCoil.grad(B_z_curv, z)





"""
print(" ")
print(f"B_grad_z(0) = {B_z_grad[1500]} G/cm")
print(f"B_grad_z(10 mm) = {B_z_grad[1800]} G/cm")
print(f"Diff B_grad z 10mm - 0 mm, {-(B_z_grad[1800]-B_z_grad[1500])} G/cm, relative: {(B_z_grad[1800]-B_z_grad[1500])/-B_z_grad[1500]}")

print(" ")
print(f"B_grad_x(0) = {B_x_grad[1500]} G/cm")
print(f"B_grad_x(10 mm) = {B_x_grad[1800]} G/cm")
print(f"Diff B_grad x 10mm - 0 mm, {B_x_grad[1800]-B_x_grad[1500]} G/cm, relative: {(B_x_grad[1800]-B_x_grad[1500])/-B_x_grad[1500]}")
"""


