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:
parent
054477fbae
commit
2c6a29906e
@ -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
|
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],...]
|
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))
|
inner_raster = np.zeros((raster_value ** 2, 2))
|
||||||
it = 0
|
it = 0
|
||||||
@ -200,15 +211,15 @@ class BCoil:
|
|||||||
|
|
||||||
return full_ras
|
return full_ras
|
||||||
|
|
||||||
def plot_raster(self, raster_value):
|
def plot_raster(self, raster_value = 100):
|
||||||
full_structure = self.full_raster(100) * 1e3
|
full_structure = self.full_raster(raster_value) * 1e3
|
||||||
if self.get_coil_width() > self.get_coil_height():
|
if self.get_coil_width() > self.get_coil_height():
|
||||||
extension = self.get_coil_width()
|
extension = self.get_coil_width()
|
||||||
else:
|
else:
|
||||||
extension = self.get_coil_height()
|
extension = self.get_coil_height()
|
||||||
extension *= 1e3
|
extension *= 1e3
|
||||||
plt.figure(77, figsize=(5, 5))
|
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.xlabel("radius [mm]")
|
||||||
plt.ylabel("z position [mm]")
|
plt.ylabel("z position [mm]")
|
||||||
plt.xlim(1e3 * self.get_R_inner() - 0.5, 1e3 * self.get_R_inner() + extension + 0.5)
|
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
|
return B_r
|
||||||
|
|
||||||
def B_field(self, I_current, x, z, raster=10):
|
def B_field(self, I_current, x, z, raster=10):
|
||||||
pass
|
|
||||||
"""
|
"""
|
||||||
Returns B_z along z-axis and B_x along x-axis,
|
Returns B_z along z-axis and B_x along x-axis,
|
||||||
HH = +1 --> Helmholtz configuration, HH = -1 --> Anti Helmholtz configuration
|
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])
|
B = np.zeros([len(z_SI), len(x_SI), 2])
|
||||||
|
|
||||||
calc_raster = self.full_raster(raster)
|
calc_raster = self.full_raster(raster)
|
||||||
|
|
||||||
if self.get_N() != len(calc_raster):
|
if self.get_N() != len(calc_raster):
|
||||||
log.error("N is not equal length of raster")
|
log.error("N is not equal length of raster")
|
||||||
|
|
||||||
rastering_value = len(calc_raster[0])
|
rastering_value = len(calc_raster[0])
|
||||||
|
|
||||||
# TODO: why division by zero?
|
# TODO: why division by zero?
|
||||||
|
|
||||||
I_current /= rastering_value # divide current into smaller currents for mapping the whole wire
|
I_current /= rastering_value # divide current into smaller currents for mapping the whole wire
|
||||||
@ -435,7 +444,9 @@ class BCoil:
|
|||||||
x = np.arange(-x_lim, x_lim, 5)
|
x = np.arange(-x_lim, x_lim, 5)
|
||||||
z = np.arange(-z_lim, z_lim, 5)
|
z = np.arange(-z_lim, z_lim, 5)
|
||||||
x_m, z_m = np.meshgrid(x, z)
|
x_m, z_m = np.meshgrid(x, z)
|
||||||
|
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 = self.B_multiple_3d(I_current, x, z, raster=2)
|
||||||
B_tot = BCoil.B_tot_3d(B)
|
B_tot = BCoil.B_tot_3d(B)
|
||||||
|
|
||||||
@ -590,14 +601,20 @@ class BCoil:
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
HH_Coil = BCoil(HH=1, distance=50, radius=40, layers=8, windings=8, wire_height=0.4, wire_width=0.4,
|
HH_Coil = BCoil(HH=1, distance=50, radius=40, layers=8, windings=3, wire_height=0.4, wire_width=0.4,
|
||||||
insulation_thickness=0.1, is_round=True, winding_offset=True)
|
insulation_thickness=0.2, is_round = True, winding_offset=True)
|
||||||
x = np.linspace(-50, 50, 300)
|
#ras = HH_Coil.full_raster(raster_value = 3)
|
||||||
z = np.linspace(-50, 50, 300)
|
# 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)
|
||||||
# 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(Bx)
|
||||||
# #print(Bz)
|
# # #print(Bz)
|
||||||
# plt.plot(x,Bx,label = "Bx")
|
# plt.plot(x,Bx,label = "Bx")
|
||||||
# plt.plot(z,Bz, label = "Bz")
|
# plt.plot(z,Bz, label = "Bz")
|
||||||
# plt.legend()
|
# plt.legend()
|
||||||
|
Loading…
Reference in New Issue
Block a user