pkl = PKL('moveSX_Dev2') import seaborn as sns rc = {'figure.figsize':[7*12/16,7],'savefig.dpi':150, #*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('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
'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('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))
from itertools import cycle import seaborn as sns rc = {'figure.figsize':[3.14*12/16,3.14],'savefig.dpi':350, #*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('SX') sf = SF(conf) ''' 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)
} sns.set(context='poster', style='white', font='sans-serif', palette='Set2', font_scale=1.0, 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()
matplotlib.rc('font', **font) fig_path = '../Figs/' config = 'DD3' # 'DD1' geom = extract_geom(config) I = 16e6 # plasma current [MA] delta = 0.4 # node spaceing [m] geom.plasma_coils(I, delta) Cmove = 'P6' Pz = geom.coil[Cmove]['z'] Xmove = [1, 10, 100] Nc = 5 cm = pl.get_cmap('cool', Nc) plot = layout(geom) sf = SF(geom.coil, res=0.2, rlim=[5, 14], zlim=[-10, 1]) # res=0.2 for dx in Xmove: fig = pl.figure(figsize=(4, 4)) #plot.sol() # scrape-off layer plot.plates() # divertor plates plot.TF() # TF coil plot.FW() #plot.plasma() plot.coil_fill() plot.coil_label(['P6', 'P5']) plot.coil_sheild() sf.sol(color='k') Pz_delta = np.linspace(-dx * 1e-3, dx * 1e-3, Nc)
font_scale=7 / 8, rc=rc) Color = cycle(sns.color_palette('Set2', 3)) figheight = 8.0 mpl.rcParams['figure.figsize'] = [figheight, figheight * 5 / 9] xlim, ylim = [8, 12], [-8, -7] pl.figure() pl.axis('equal') pl.axis('off') pl.xlim(xlim) pl.ylim(ylim) conf = Config('SX7') sf = SF(conf, sample=1) conf.TF(sf) rb = RB(conf, sf, Np=1e3) rb.divertor_outline(True, color=next(Color)) Rt, Zt = rb.targets['outer']['R'], rb.targets['outer']['Z'] Ro, Zo = rb.targets['outer']['Rsol'][-1], rb.targets['outer']['Zsol'][-1] index = np.argmin((Rt - Ro)**2 + (Zt - Zo)**2) R, Z = Rt[:index + 1], Zt[:index + 1] graze = sf.get_graze([Ro, Zo], [R[-2] - R[-1], Z[-2] - Z[-1]]) print(graze * 180 / np.pi, rb.targets['outer']['theta'] * 180 / np.pi) conf = Config('SX8') sf = SF(conf, sample=1) conf.TF(sf) rb = RB(conf, sf, Np=1e3) rb.divertor_outline(True, color=next(Color))
} 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') 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'])) '''
from config import layout from extract import extract_geom from streamfunction import SF from cross_coil import Fcoil import matplotlib font = {'family': 'serif', 'serif': 'Times', 'weight': 'normal', 'size': 12} matplotlib.rc('font', **font) fig_path = '../Figs/' config = 'DD3' # 'DD1' geom = extract_geom(config) I = 16e6 # plasma current [MA] delta = 0.4 # node spaceing [m] geom.plasma_coils(I, delta) fig = pl.figure(figsize=(12, 6)) plot = layout(geom) plot.plates() # divertor plates plot.TF() # TF coil plot.FW() plot.plasma() plot.coil_fill() plot.coil_sheild() sf = SF(geom.coil, res=0.2, rlim=[4,14], zlim=[-10,4.5]) sf.sol() sf.contour() pl.axis('equal') pl.ylim([-8, -5]) pl.tight_layout()
'savefig.pad_inches': 0.1 } sns.set(context='paper', style='white', font='serif', palette='Set2', font_scale=7 / 8, rc=rc) pl.figure() pl.axis('equal') config = 'SN' # SN,X,SX,SF,SX2 conf = Config(config, inside=False) sf = SF(conf, sample=2) sf.contour() rb = RB(conf, sf, Np=90) rb.sf.sol(plot=False) radius, theta = np.array([]), np.array([]) for N in range(rb.sf.Nsol): #pl.plot(rb.sf.Rsol[N],rb.sf.Zsol[N]) pl.plot(sf.Xpoint[0], sf.Xpoint[1], 'o', markersize=1) c = sns.color_palette('Set2', 4) if rb.sf.nleg == 6: # snow flake leglist = ['inner1', 'inner2', 'outer1', 'outer2'] else: leglist = ['inner', 'outer'] for N in range(rb.sf.Nsol):
def plasma_contor(zo, ro, A, k, delta): theta = np.linspace(0, 2 * np.pi, 50) R = ro + ro / A * np.cos(theta + delta * np.sin(theta)) Z = zo + ro / A * k * np.sin(theta) return (R, Z) pl.figure(figsize=(14, 10)) pl.axis('equal') r = np.linspace(0.1, ro / A, 7) # minor radius for Ar in ro / r: R, Z = plasma_contor(zo, ro, Ar, k, delta) pl.plot(R, Z, 'b-') Jmax = 2e7 # [A/m^2] coil = {} for i, z in enumerate([-1, 1]): name = 'plasma-' + str(i) coil[name] = {} coil[name]['I'] = 5e3 coil[name]['r'] = ro coil[name]['z'] = z coil[name]['rc'] = (abs(coil[name]['I']) / (Jmax * np.pi))**0.5 sf = SF(coil, res=0.1, rlim=[7, 18], zlim=[-4, 4]) sf.contour(label=True)
from itertools import cycle import seaborn as sns 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
import numpy as np from radial_build import RB from shelf import PKL from eqConfig import Config import seaborn as sns rc = { 'figure.figsize': [6, 6 * 12 / 16], 'savefig.dpi': 125, #*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=1.5, rc=rc) Color = cycle(sns.color_palette('Set2')) conf = Config('SN') sf = SF(conf, sample=1, Nova=False) #sf.contour(lw=0.5) pl.figure() pl.plot(np.linspace(0, 1, len(sf.eq['pressure'])), sf.eq['pressure']) pl.figure() pl.plot(np.linspace(0, 1, len(sf.eq['pressure'])), sf.eq['fpol']) #sf.eqwrite()
import pylab as pl from config import Setup from streamfunction import SF from radial_build import RB for config in ['SN', 'SX', 'SFm', 'SFp', 'Xic']: setup = Setup(config) sf = SF(setup.filename) pl.plot(sf.rbdry, sf.zbdry, label=config) #rb = RB(setup,sf) #rb.firstwall(calc=False,plot=True) pl.axis('equal') pl.legend(loc=10)
pkl = PKL('moveSX') sf, eq, inv = pkl.fetch(['sf', 'eq', 'inv']) sf.config = 'SXex' inv.swing_fix(np.mean(inv.Swing)) inv.solve_slsqp() eq.run(update=False) conf = Config('SXex') conf.TF(sf) sf.conf = conf rb = RB(conf, sf, Np=500) rb.divertor_outline(False, plot=True, debug=False) eq.grid(boundary={'R': rb.Rb, 'Z': rb.Zb}, n=5e3) eq.set_sf_psi() # set psi eq.run() sf.set_plasma({'r': eq.r, 'z': eq.z, 'psi': eq.psi}, contour=True) inv.plot_fix() sf.eqwrite() sf = SF(conf, sample=1, Nova=True) sf.contour(lw=0.5) sf.plot_coils(next(Color), coils=sf.coil, label=True, plasma=False, current=False)
'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('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)
'lines.linewidth': 2 } sns.set(context='talk', style='white', font='sans-serif', palette='Set2', font_scale=7 / 8, rc=rc) pl.figure() text = linelabel(Ndiv=42, value=' 1.0f', postfix='m', loc='end') for config in ['SN', 'SFp', 'SFm']: #,'SFm','SFp','X','SX8','SXex']: # color = next(Color) conf = Config(config) sf = SF(conf, sample=1) rb = RB(conf, sf, Np=250) rb.divertor_outline(False, plot=False, debug=False) ''' sf.eq['ncoil'] = 0 eq = EQ(sf,boundary={'R':rb.Rb,'Z':rb.Zb,'expand':0.5},n=1e4) #'expand':0.5,'zmax':sf.Xpoint[1]+sf.rcirc+sf.drcirc} if 'ex' not in config: eq.run() eq.set_eq_psi() ''' sf.sol(Nsol=21, update=True, plot=False) rb.trim_sol(plot=False) # trim legs to targets sf.add_core() # referance low field midplane '''
sns.set_style('ticks') sns.set_palette('Set2') Color = cycle(sns.color_palette('Set2')) from eqConfig import Config from radial_build import RB from streamfunction import SF config = 'SN' # SN,X,SX,SF pl.figure(figsize=(9,12)) pl.axis('equal') pl.xlim([5,12]),pl.ylim([-6,6]) conf = Config(config,inside=False) sf = SF(conf,sample=1) sf.contour() N = 100 sf.get_boundary(alpha=1) rb,zb = sf.eq['rbdry'],sf.eq['zbdry'] L = sf.length(rb,zb) Lpoints = np.linspace(1/(2*(N-1)),1-1/(2*(N-1)),N) R = interp1(L,rb)(Lpoints) Z = interp1(L,zb)(Lpoints) with open('../Data/SN_ref_bdry.txt','w') as f: f.write('Npoints = {:1.0f}\n\n'.format(N)) f.write('R[m]\t\tZ[m]\n')
gd = gridspec.GridSpec(1, 4, wspace=0.0, hspace=0.0) for i, config in enumerate(['SN', 'X', 'SF', 'SX']): sns.set_palette('Set2') ax = pl.Subplot(fig, gd[i]) fig.add_subplot(ax) fig.sca(ax) pl.axis('equal') pl.axis('off') pl.tight_layout() #pl.xlim([4,14]),pl.ylim([-13,8]) pl.xlim([3, 17]), pl.ylim([-12, 10]) conf = Config(config, inside=False) sf = SF(conf) sf.contour() sf.plot_coils(Color) conf.TF(sf) rb = RB(conf, sf, Np=200) rb.divertor_outline(True) rb.fill(dt=conf.tfw, alpha=0.7, color=next(Color)) rb.fill(dt=conf.BB, alpha=0.7, color=next(Color)) rb.fill(dt=conf.tBBsupport, alpha=0.7, color=next(Color)) rb.BBsheild_fill(dt=conf.sheild, ref_o=2 / 8 * np.pi, alpha=0.7, color=next(Color)) rb.fill(dt=conf.VV, alpha=0.7, color=next(Color), loop=True) rb.set_TFbound() # TF boundary conditions #rb.TFbound['ro_min'] -= 0.25
'savefig.dpi': 200, #*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.figure(figsize=(12,8)) pl.axis('equal') pl.axis('off') #pl.xlim([4,14]),pl.ylim([-13,8]) pl.xlim([6, 11]), pl.ylim([-6.5, -4.5]) config = 'SFp' # SN,X,SX,SF,SX2 conf = Config(config, inside=False) sf = SF(conf, sample=1) rb = RB(conf, sf, Np=360) rb.divertor_outline(True, color=next(Color)) config = 'SFm' # SN,X,SX,SF,SX2 conf = Config(config, inside=False) sf = SF(conf, sample=1) rb = RB(conf, sf, Np=360) rb.divertor_outline(True, color=next(Color))
'lines.linewidth':2} sns.set(context='talk',style='white',font='sans-serif',palette='Set2', font_scale=7/8,rc=rc) color = sns.color_palette('Set2') Color = cycle(color) config = 'SX8' # SN,X,SX,SX8,SFm,SX2 pl.figure(figsize=(10*14/16,10)) pl.axis('equal') pl.axis('off') #pl.ylim([-12.5,11]) #pl.xlim([7,8]) setup = Setup('SN') sf = SF(setup.filename,sample=4,Nova=False) rb = RB(setup,sf,Np=250) #conf = Config(config) #sf = SF(conf,sample=4,Nova=False) sf.contour() #eq = EQ(sf,sigma=0,limit=[5.5,12,-8,5],n=5e4) # resample #eq.plotj() # #conf.TF(sf) #rb = RB(conf,sf,Np=250) rb.firstwall(calc=True,plot=True,debug=False) rb.trim_sol(plot=True)
config = 'DD3' # 'DD1' geom = extract_geom(config) I = 16e6 # plasma current [MA] delta = 1.0 # node spaceing [m] (0.4) #geom.plasma_coils(I, delta) plasma_name = 'plasma-1' geom.coil[plasma_name] = {} geom.coil[plasma_name]['I'] = I geom.coil[plasma_name]['r'] = geom.plasma['rc'] geom.coil[plasma_name]['z'] = geom.plasma['zc'] geom.coil[plasma_name]['rc'] = delta sf = SF(geom.coil, res=0.1, rlim=[5, 14], zlim=[-12, 6]) # res=0.2 fig = pl.figure(figsize=(12, 20)) sf.sol(color='b') Xpsi, Xpoint = sf.get_Xpsi([8, -4]) # Xpoint ''' lower_coils = ['CS3L','CS3LB','PS4','PS3','P6C','PS1'] for lowc in lower_coils: # lift lower coils geom.coil[lowc]['z'] = geom.coil[lowc]['z'] + 0.5 ''' #geom.coil['P6']['r'] = geom.coil['P6']['r'] + 0.75 #geom.coil['P6']['z'] = geom.coil['P6']['z'] + 0.75 #geom.coil['P5']['r'] = 6 #geom.coil['P5']['z'] = -4
} 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=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)
radius = np.zeros(1) theta = np.zeros(1) if rL > 0: n_theta = np.int(2 * np.pi * rL / delta) thetaL = np.linspace(0, 2 * np.pi, n_theta, endpoint=False) rm = np.append(rm, rc + rL * np.cos(thetaL)) zm = np.append(zm, zc + rL * np.sin(thetaL)) theta = np.append(theta, thetaL) radius = np.append(radius, rL * np.ones(n_theta)) Icoil = I / len(theta) for i, r, z in zip(range(len(theta)), rm, zm): coil[str(i)] = {'I': Icoil, 'r': r, 'z': z, 'rc': delta} from streamfunction import SF sf = SF(coil, res=0.05, rlim=[0.3, 3.5], zlim=[-1.5, 1.5]) pl.figure(figsize=(9, 9)) sf.Bcontor('r', Nstd=3) pl.plot(rm, zm, 'bo') pl.axis('equal') pl.xlim([1.5, 2.5]) pl.grid() pl.savefig(fig_path + 'coil_Br.png', dpi=300) pl.figure(figsize=(9, 9)) sf.Bcontor('z', Nstd=3) pl.plot(rm, zm, 'bo') pl.axis('equal') pl.xlim([1.5, 2.5]) pl.grid()
'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('SN') sf = SF(conf) conf.TF(sf) rb = RB(conf, sf, Np=500) a = (sf.LFPr - sf.HFPr) / 2 R = (sf.LFPr + sf.HFPr) / 2 AR = R / a r95, z95 = sf.get_boundary(alpha=0.95) ru = r95[np.argmax(z95)] # triangularity rl = r95[np.argmin(z95)] del_u = (R - ru) / a del_l = (R - rl) / a kappa = (np.max(z95) - np.min(z95)) / (2 * a) pl.plot(sf.Mpoint[0], sf.Mpoint[1], 'o')
import seaborn as sns rc = {'figure.figsize':[7*12/14,7],'savefig.dpi':110, #*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') 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)