# -*- 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
x = np.linspace(-50, 50, 300)
z = np.linspace(-50, 50, 301)



HH_Coil_78 = BC.BCoil(-1,54,37,4, 4, 1,1)



B_z,B_x = HH_Coil_78.B_field(1, x, z)

#B_x = np.concatenate((-np.flip(B_x),B_x))
#x = np.concatenate((-np.flip(r),r))


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

#plt.rcParams.update({'font.size': 15})
plt.suptitle("Anti Helmholtz coil field, I = 1 A, d = 54 mm, R = 37 mm ", fontsize = 30)


#Field plot
##########################
plt.subplot(2,1,1)
plt.plot(z,B_z,linestyle = "solid", label = r"$Bz$, d = 54 mm, R = 37 mm")
plt.plot(x,B_x, label = r"$B_x$, d = 54 mm, R = 37 mm")
#plt.xlim(-0.01,0.01)
plt.title("B-field" )

plt.ylabel(r"$B$ [G]")
plt.xlabel("z-axis / x-axis [mm]")
plt.legend()

plt.subplot(2,1,2)
plt.plot(z,B_z_grad,linestyle = "solid", label = r"$\nabla_z Bz$, d = 54 mm, R = 37 mm")
plt.plot(x,B_x_grad,linestyle = "solid", label = r"$\nabla_x B_x$, d = 54 mm, R = 37 mm")

plt.ylabel(r"$\nabla_i B_i [G/cm]$")
plt.xlabel("z-axis /x-axis [mm]")#plt.xlim(-10,10)
plt.title("Gradient of B-field")
plt.legend()

plt.show()
