font_scale=7 / 8, rc=rc) color = cycle(sns.color_palette('Set2')) pl.figure() pl.axis('equal') pl.axis('off') eqdsk = 'vde' #eqdsk = 'SN' sf = SF(Config(eqdsk)) sf.eq['ncoil'] = 0 if eqdsk == 'vde': eq = EQ(sf, dCoil=1, limit=[4.25, 8, -4.5, 2], n=8e3) #eq = EQ(sf,dCoil=1,limit=[3,9,-6,6],n=5e3) else: eq = EQ(sf, dCoil=1, limit=[5, 13, -5.5, 5], n=1e3) eq.set_eq_psi() levels = eq.sf.contour() psi_o = eq.psi.copy() psi_flux = np.linspace(0, 1, 500) eq.edgeBC() def flux_fit(b, *args):
''' zcs_space = np.linspace(6,-8,13) rcs_space = 2.9*np.ones(len(zcs_space)) pl.plot(rcs_space,zcs_space,'-o',markersize=1.5) for i in range(5): del sf.coil['Coil{:1.0f}'.format(i)] for i in range(len(zcs_space)): name = 'Coilcs{:1.0f}'.format(i) sf.coil[name] = {'r':rcs_space[i],'z':zcs_space[i],'dr':1, 'dz':abs(np.diff(zcs_space))[0],'I':1} ''' rb = RB(conf,sf,Np=150) eq = EQ([4,15.5],[-12,6.5],5e4,sf) eq.get_plasma_coil() #sf.plasma_coils(N=11,dL=0.25) eq.coils(delta=0.25) # multi-filiment coils r,z = sf.get_boundary(alpha=0.99) L = sf.length(r,z) Lc = np.linspace(0,1,1)[:-1] fix = {} fix['r'],fix['z'] = interp1(L,r)(Lc),interp1(L,z)(Lc) fix['value'] = eq.psi_coil(fix['r'],fix['z']) fix['BC'] = np.array(['psi']*len(fix['r'])) ''' r,z = sf.get_boundary(alpha=0.45) L = sf.length(r,z)
font_scale=7/8,rc=rc) Color = cycle(sns.color_palette('Set2')) pl.figure() pl.axis('equal') pl.axis('off') conf = Config('SN') sf = SF(conf) conf = Config('X') sf.conf = conf conf.TF(sf) #rb = RB(conf,sf,Np=200) #rb.divertor_outline(False,plot=False,debug=False) eq = EQ(sf,dCoil=0.5,limit=[5,12,-8,5.5],n=1e4) eq.set_sf_psi() # set psi eq.gen() inv = INV(sf,eq,configTF='X',config='X') Lpf = inv.grid_PF(nPF=5) Lcs = inv.grid_CS(nCS=5) Lo = np.append(Lpf,Lcs) inv.eq.coils() # re-grid inv.update_coils() inv.fix_boundary_psi(N=31,alpha=1-1e-4,factor=1) # add boundary points #inv.fix_boundary_feild(N=31,alpha=1-1e-4,factor=1) # add boundary points inv.add_null(factor=1,point=sf.Xpoint) R,arg = 1.5,20
sns.set(context='paper', style='white', font='sans-serif', palette='Set2', font_scale=7 / 8, rc=rc) Color = cycle(sns.color_palette('Set2')) pl.figure() pl.axis('equal') pl.axis('off') conf = Config('SN') sf = SF(conf) pl.plot(sf.rbdry, sf.zbdry) eq = EQ(sf, dCoil=1, limit=[4, 15.5, -13, 5.5], n=1e4) eq.get_plasma_coil() #eq.set_coil_psi() #eq.get_Xpsi() #eq.get_Mpsi() inv = INV(sf, eq, configTF='SN', config='SN') inv.fix_boundary_psi(N=25, alpha=0.99, factor=1) # add boundary points inv.add_null(factor=1, point=sf.Xpoint) inv.add_alpha(1, factor=1, point=sf.Xpoint) #inv.add_alpha(1,factor=1,point=(12,-8.5)) #inv.add_alpha(0.95,factor=1,point=(8.5,-8.5)) #inv.add_alpha(1,factor=1,Lin=0.2,norm=-0.5)
style='white', font='sans-serif', palette='Set2', font_scale=7 / 8, rc=rc) Color = cycle(sns.color_palette('Set2')) pl.figure() pl.axis('equal') pl.axis('off') conf = Config('SFm') sf = SF(conf) sf.contour(Nstd=1.5, color=next(Color)) eq = EQ([4, 13], [-6, 6], 1e4, sf) eq.Vtarget = sf.Mpoint[1] rbdry, zbdry = sf.get_boundary() # update boundary pl.plot(rbdry, zbdry) pl.plot(sf.Mpoint[0], sf.Mpoint[1], 'o', markersize=1) eq.gen(Verr=1e-4) sf.contour(levels=sf.cs.levels, color=next(Color)) rbdry, zbdry = sf.get_boundary() # update boundary pl.plot(rbdry, zbdry) pl.plot(sf.Mpoint[0], sf.Mpoint[1], 'ko', markersize=1) pl.imshow(eq.b.reshape((eq.nr, eq.nz)).T, cmap='RdBu',
style='white', font='sans-serif', palette='Set2', font_scale=7 / 8, rc=rc) Color = cycle(sns.color_palette('Set2')) pl.figure() pl.axis('equal') pl.axis('off') config = 'X' # SN,X,SX,SF conf = Config(config, inside=False) sf = SF(conf) rb = RB(conf, sf, Np=150) eq = EQ([2, 16], [-10, 9], 5000, sf) sf.plasma_coils(N=7, dL=0.25) eq.coils(delta=0.25) # multi-filiment coils #sf.contour() r, z = sf.get_boundary(alpha=0.95) L = sf.length(r, z) Lc = np.linspace(0, 1, 21)[:-1] fix = {} fix['r'], fix['z'] = interp1(L, r)(Lc), interp1(L, z)(Lc) fix['value'] = eq.Pcoil(fix['r'], fix['z']) fix['BC'] = np.array(['psi'] * len(fix['r'])) ''' fix['r'] = np.append(fix['r'],8.6089790197) fix['z'] = np.append(fix['z'],-7.12320200125)
rc = {'figure.figsize':[3.14*12/16,3.14],'savefig.dpi':400, #*12/16 'savefig.jpeg_quality':100,'savefig.pad_inches':0.1, 'lines.linewidth':0.75} sns.set(context='paper',style='white',font='sans-serif',palette='Set2', font_scale=7/8,rc=rc) Color = cycle(sns.color_palette('Set2')) pl.figure() pl.axis('equal') pl.axis('off') conf = Config('X') sf = SF(conf) rb = RB(conf,sf,Np=150) eq = EQ([4,12.5],[-9.5,6.5],5e4,sf) sf.plasma_coils(N=11,dL=0.25) eq.coils(delta=0.25) # multi-filiment coils r,z = sf.get_boundary(alpha=0.95) L = sf.length(r,z) Lc = np.linspace(0,1,21)[:-1] fix = {} fix['r'],fix['z'] = interp1(L,r)(Lc),interp1(L,z)(Lc) fix['value'] = eq.Pcoil(fix['r'],fix['z']) fix['BC'] = np.array(['psi']*len(fix['r'])) rx,zx = 8.9,-8 fix['r'] = np.append(fix['r'],rx)
rc=rc) color = sns.color_palette('Set1', 12) pl.figure() #pl.axis('equal') pl.axis('off') eqdsk = 'vde' #eqdsk = 'SN' sf = SF(Config(eqdsk)) sf.eq['ncoil'] = 0 if eqdsk == 'vde': #eq = EQ(sf,dCoil=1,limit=[4.25,8,-4.5,2],n=1e5) #eq = EQ(sf,dCoil=1,delta=0.25,n=5e4) #,limit=[3,9,-6,6] eq = EQ(sf, limit=[4, 8, -4.5, 1.5], n=1e5) #eq = EQ(sf,dCoil=1,n=1e5) #eq = EQ(sf,dCoil=1,limit=[-1+sf.Xpoint[0],1+sf.Xpoint[0], # -1+sf.Xpoint[1],2+sf.Xpoint[1]],n=1e3) else: #eq = EQ(sf,dCoil=1,limit=[4,13,-5.5,4.75],n=5e3) eq = EQ(sf, delta=5) #eq.set_eq_psi() levels = sf.contour(lw=0.75, Nstd=5, Nlevel=50) cref = sf.cfeild # store referance contour pl.plot(sf.eq['xlim'] * 1e-2, sf.eq['ylim'] * 1e-2, 'k', alpha=0.75,
sns.set(context='paper',style='white',font='sans-serif',palette='Set2', font_scale=7/8,rc=rc) color = cycle(sns.color_palette('Set2')) pl.figure() pl.axis('equal') pl.axis('off') eqdsk = 'vde' eqdsk = 'SN' sf = SF(Config(eqdsk)) sf.eq['ncoil'] = 0 if eqdsk == 'vde': eq = EQ(sf,dCoil=1,limit=[4.25,8,-4.5,2],n=1e3) #eq = EQ(sf,dCoil=1,limit=[3,9,-6,6],n=5e3) else: eq = EQ(sf,dCoil=1,limit=[5,13,-5.5,5],n=5e4) eq.set_eq_psi() levels = eq.sf.contour() I = 0 R,Z = sf.get_boundary(1-1e-4) tR,tZ,R,Z = cc.tangent(R,Z,norm=False) for r,z,tr,tz in zip(R,Z,tR,tZ): B = sf.Bcoil((r,z)) t = np.array([tr,tz]) I += np.dot(B,t)