Exemplo n.º 1
0
# Build solenoid 1 (outer solenoid)
# h number of turns in z direction
# w number of turns in r direction
h1 = 20
w1 = 5
n_coils1 = h1 * w1
rlocs1 = np.linspace(0.948, 1, w1)
zlocs1 = np.linspace(-0.025, 0.228, h1)
rlocs1, zlocs1 = np.meshgrid(rlocs1, zlocs1)
rlocs1 = rlocs1.flatten()
zlocs1 = zlocs1.flatten()
cur_dir1 = np.ones(n_coils1)
# zip current locations and directions into a list of 3-tuples (needed
# for compute_greens function)
rzdir1 = zip(rlocs1, zlocs1, cur_dir1)
gpsi1, gBR1, gBZ1 = compute_greens(R.flatten(), Z.flatten(), rzdir1)
#------------------------------------------------------------------------------
# Build solenoid 2 ( outer solenoid)
# h number of turns in z direction
# w number of turns in r direction
h2 = 20
w2 = 5
n_coils2 = h2 * w2
rlocs2 = np.linspace(0.948, 1, w2)
zlocs2 = np.linspace(0.506, 0.759, h2)
rlocs2, zlocs2 = np.meshgrid(rlocs2, zlocs2)
rlocs2 = rlocs2.flatten()
zlocs2 = zlocs2.flatten()
cur_dir2 = np.ones(n_coils2)
# zip current locations and directions into a list of 3-tuples (needed
# for compute_greens function)
Exemplo n.º 2
0
r = np.linspace(0, 1, m)
z = np.linspace(-1, 1, n)
R, Z = np.meshgrid(r, z)

#################################################################
# Example 1: single current loop at R = 0.5 m Z = 0.0 m
#
rlocs = [0.5]
zlocs = [0.0]
cur_dir = [1]
# zip current locations and directions into a list of 3-tuples (needed
# for compute_greens function)
rzdir = zip(rlocs, zlocs, cur_dir)
# create greens functions for magnetic flux, and 2 components of B
# these matrices are m*n x n_coils
gpsi, gBR, gBZ = compute_greens(R.flatten(), Z.flatten(), rzdir)
# specify number of amps in each of the coils, here we are using 100 amps
# in 1 coil
coil_currents = 100 * np.ones(1)
# take dot product of greens function for desired field and coil currents
# and reshape to same shape as the 2D RZ grid
psi = (gpsi.dot(coil_currents)).reshape(R.shape)
BR = (gBR.dot(coil_currents)).reshape(R.shape)
BZ = (gBZ.dot(coil_currents)).reshape(R.shape)
# Note: All quantities are in SI units
plot_fields(R, Z, psi, BR, BZ)
#################################################################
"""
#################################################################
# Example 2: Solenoid
#