Updatet plot_3d

fixed error in inner_raster for round wires and ras_value < 3 + improved rastering for round wires
This commit is contained in:
schoener 2021-10-22 11:59:48 +02:00
parent 054477fbae
commit 2c6a29906e

View File

@ -160,6 +160,17 @@ class BCoil:
raster_value (int): if N produces a N x N raster for rectangular and cut out of this for round
Returns: array containing raster around 0,0 [[z_pos_in_1,r_pos_in_1],...]
"""
# TODO: Less important, but rastering for round wires could be improved
if raster_value == 0:
raster_value = 1
log.warning("raster value is 0 increased to 1")
if raster_value == 1:
return [0,0]
if self.is_round & (raster_value % 2 == 0):
raster_value += 1
log.warning(f"for round wire rastering works better with uneven rastering value --> rastering value set to: {raster_value}")
inner_raster = np.zeros((raster_value ** 2, 2))
it = 0
@ -200,15 +211,15 @@ class BCoil:
return full_ras
def plot_raster(self, raster_value):
full_structure = self.full_raster(100) * 1e3
def plot_raster(self, raster_value = 100):
full_structure = self.full_raster(raster_value) * 1e3
if self.get_coil_width() > self.get_coil_height():
extension = self.get_coil_width()
else:
extension = self.get_coil_height()
extension *= 1e3
plt.figure(77, figsize=(5, 5))
plt.scatter(full_structure[:, :, 1], full_structure[:, :, 0], linewidths=0.01)
plt.scatter(full_structure[:, :, 1], full_structure[:, :, 0], linewidths=0.001)
plt.xlabel("radius [mm]")
plt.ylabel("z position [mm]")
plt.xlim(1e3 * self.get_R_inner() - 0.5, 1e3 * self.get_R_inner() + extension + 0.5)
@ -275,7 +286,6 @@ class BCoil:
return B_r
def B_field(self, I_current, x, z, raster=10):
pass
"""
Returns B_z along z-axis and B_x along x-axis,
HH = +1 --> Helmholtz configuration, HH = -1 --> Anti Helmholtz configuration
@ -391,11 +401,10 @@ class BCoil:
B = np.zeros([len(z_SI), len(x_SI), 2])
calc_raster = self.full_raster(raster)
if self.get_N() != len(calc_raster):
log.error("N is not equal length of raster")
rastering_value = len(calc_raster[0])
# TODO: why division by zero?
I_current /= rastering_value # divide current into smaller currents for mapping the whole wire
@ -435,8 +444,10 @@ class BCoil:
x = np.arange(-x_lim, x_lim, 5)
z = np.arange(-z_lim, z_lim, 5)
x_m, z_m = np.meshgrid(x, z)
B = self.B_multiple_3d(I_current, x, z, raster=2)
if self.is_round:
B = self.B_multiple_3d(I_current, x, z, raster=3)
else:
B = self.B_multiple_3d(I_current, x, z, raster=2)
B_tot = BCoil.B_tot_3d(B)
for xx in range(0, len(x)):
@ -590,14 +601,20 @@ class BCoil:
def main():
HH_Coil = BCoil(HH=1, distance=50, radius=40, layers=8, windings=8, wire_height=0.4, wire_width=0.4,
insulation_thickness=0.1, is_round=True, winding_offset=True)
x = np.linspace(-50, 50, 300)
z = np.linspace(-50, 50, 300)
HH_Coil = BCoil(HH=1, distance=50, radius=40, layers=8, windings=3, wire_height=0.4, wire_width=0.4,
insulation_thickness=0.2, is_round = True, winding_offset=True)
#ras = HH_Coil.full_raster(raster_value = 3)
# print(HH_Coil.is_round)
HH_Coil.plot_raster(4)
# if True & 1 == 1:
# print("test")
#print(ras)
# x = np.linspace(-50, 50, 300)
# z = np.linspace(-50, 50, 300)
# Bz, Bx = HH_Coil.B_tot_along_axis(1.25, x, z)
# Bz, Bx = HH_Coil.B_tot_along_axis(1.25, x, z)
# #print(Bx)
# #print(Bz)
# # Bz, Bx = HH_Coil.B_tot_along_axis(1.25, x, z)
# # #print(Bx)
# # #print(Bz)
# plt.plot(x,Bx,label = "Bx")
# plt.plot(z,Bz, label = "Bz")
# plt.legend()