# -*- coding: utf-8 -*-
"""
Created on Mon Aug 16 11:49:41 2021

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

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

#set up axis
x_m = np.linspace(-0.05, 0.05, 51)
z_m = np.linspace(-0.05, 0.05, 201)


z = z_m*1e3
x = x_m*1e3 #for plotting in mm


################# My simulation #########################
I = 5
HH = 1
d_coils = 54
R_radius = 48.8
R_inner = R_radius-3*1.7

layers = 4
windings = 4
wire_width = 1
wire_height = 1


B_z, B_x = bf.B_multiple_raster(I,HH,R_inner,d_coils,layers,windings,wire_width, wire_height, x_m,z_m)

#Calculate gradients/curvature
B_z_grad = np.gradient(np.gradient(B_z,z_m),z_m)/1e4
B_x_grad = np.gradient(B_x,x_m)/100


wire_area = wire_height * wire_width

wire_length = layers*windings*2*R_radius*np.pi


j_dens = I/wire_area #[A/mm^2]
Power = cs.rho_copper_20 *wire_length*1e-3* I**2 /(wire_area* 1e-6)


print(f"current density = {j_dens} A/mm^2")
print(f"Power = {Power} W")
