nPF, nCS, nTF = 5, 5, 18 config = {'TF': 'dtt', 'eq': 'SFm'} config['TF'] = '{}{}{:d}'.format(config['eq'], config['TF'], nTF) setup = Setup(config['eq']) sf = SF(setup.filename) rb = RB(setup, sf) pf = PF(sf.eqdsk) tf = TF( Profile(config['TF'], family='S', part='TF', nTF=nTF, obj='L', load=True)) eq = EQ(sf, pf, dCoil=2.0, sigma=0, n=1e4, boundary=sf.get_sep(expand=0.75), rmin=sf.Xpoint[0] - 3.5, zmin=sf.Xpoint[1] - 3.5) eq.gen_opp() theta, dXpoint = -5 * np.pi / 180, [0.5, -1] pivot = np.argmin(sf.rbdry) # rotate/translate eqdsk rp, zp = sf.rbdry[pivot], sf.zbdry[pivot] TRT = geom.rotate2D(theta, xo=rp, yo=zp)[1] # trial rotate/translate zref = sf.Mpoint[1] dz = zref - np.dot(TRT, np.append(sf.Mpoint, 1))[1] # correct z-shift R, TRT = geom.rotate2D(theta, xo=rp, yo=zp, dy=dz) points = np.zeros((eq.nr * eq.nz, 2)) values = eq.psi.flatten()
sf = SF(setup.filename) rb = RB(setup, sf) pf = PF(sf.eqdsk) tf = TF( Profile(config['TF'], family='S', part='TF', nTF=config['nTF'], obj='L', load=True)) #tf.fill() eq = EQ(sf, pf, dCoil=1.5, sigma=0, n=5e3, boundary=sf.get_sep(expand=1.1), zmin=-abs(sf.Xpoint[1]) - 2, zmax=abs(sf.Xpoint[1]) + 2) #eq.gen_opp(Zerr=5e-4) eq.gen_bal(Zerr=5e-4, tol=1e-4) ''' inv = INV(sf,eq,tf) Lpf = inv.grid_PF(nPF=config['nPF']) Lcs = inv.grid_CS(nCS=config['nCS'],Zbound=[-8,8],gap=0.1,fdr=1) L = np.append(Lpf,Lcs) inv.update_coils() inv.fit_PF(offset=0.3) inv.fix_boundary_psi(N=25,alpha=1-1e-2,factor=1) # add boundary points #inv.fix_boundary_feild(N=25,alpha=1-1e-2,factor=1) # add boundary points
sns.set(context='paper',style='white',font='sans-serif',palette='Set2', font_scale=7/8,rc=rc) Color = cycle(sns.color_palette('Set2')) pkl = PKL('DEMO_SN54') nTF = 16 config = {'TF':'SN','eq':'DEMO_SN'} setup = Setup(config['eq']) sf = SF(setup.filename) rb = RB(setup,sf) pf = PF(sf.eqdsk) tf = TF(Profile(config['TF'],family='S',part='TF',nTF=nTF,obj='L',load=True)) eq = EQ(sf,pf,dCoil=2.0,sigma=0,boundary=sf.get_sep(expand=1.5),n=1e4) eq.gen_opp() inv = INV(sf,eq,tf) Lpf = inv.grid_PF(nPF=4) Lcs = inv.grid_CS(nCS=3,Zbound=[-8.2,11],gap=0.1) Lo = np.append(Lpf,Lcs) inv.update_coils() inv.fit_PF(offset=0.3) # fit PF coils to TF inv.fix_boundary_psi(N=25,alpha=1-1e-4,factor=1) # add boundary points inv.fix_boundary_feild(N=25,alpha=1-1e-4,factor=1) # add boundary points inv.add_null(factor=1,point=sf.Xpoint) inv.set_swing()
'lines.linewidth':2} sns.set(context='talk',style='white',font='sans-serif',palette='Set2', font_scale=7/8,rc=rc) nTF,nPF,nCS = 18,4,3 config = {'TF':'dtt','eq':'SN'} config,setup = select(config,nTF=nTF,nPF=nPF,nCS=nCS,update=False) profile = Profile(config['TF'],family='S',part='TF', nTF=nTF,obj='L',load=True,npoints=50) sf = SF(setup.filename) tf = TF(profile,sf=sf) tf.fill() #rb = RB(setup,sf) pf = PF(sf.eqdsk) eq = EQ(sf,pf,boundary=tf.get_loop(expand=0.5),n=1e3,sigma=0) eq.get_plasma_coil() ff = force_feild(pf.index,pf.coil,eq.coil,eq.plasma_coil) #eq.run() #eq.plotj() #pf.coil['Coil6']['r'] -= 1.5 #eq.coils() #eq.gen_opp(sf.Mpoint[1]) #eq.resample() #eq.plotb(alpha=1) #inv = INV(sf,pf,eq) pf.plot(coils=eq.coil,label=False,plasma=True,current=False,alpha=0.5) #inv.plot_coils()
from nova import loops import scipy.optimize as op from amigo.addtext import linelabel from nova.loops import Profile config = 'SN' setup = Setup(config) sf = SF(setup.filename) rb = RB(setup, sf) pf = PF(sf.eqdsk) profile = Profile(config, family='S', part='TF', nTF=18, objective='L') tf = TF(profile) eq = EQ(sf, pf, dCoil=2.5, sigma=0, boundary=sf.get_sep(expand=0.5), n=5e2) eq.get_plasma_coil() eq.run(update=False) inv = INV(sf, eq, tf) inv.initialize_log() Lpf = inv.grid_PF(nPF=5) Lcs = inv.grid_CS(nCS=5) Lo = np.append(Lpf, Lcs) inv.update_coils() inv.fit_PF(offset=0.3) inv.fix_boundary_psi(N=31, alpha=1 - 1e-4, factor=1) # add boundary points #inv.fix_boundary_feild(N=11,alpha=1-1e-4,factor=1) # add boundary points
palette='Set2', font_scale=7 / 8, rc=rc) config = 'DEMO_SN' setup = Setup(config) sf = SF(setup.filename) sf.get_boundary(plot=True) config = 'DEMO_SNb' setup = Setup(config) sf = SF(setup.filename) sf.get_boundary(plot=True) pf = PF(sf.eqdsk) eq = EQ(sf, pf, limit=[4.5, 14.5, -8, 8], n=1e4) rb = RB(setup, sf) #sf.contour(plot_vac=True) #sf.get_legs(debug=True) rb.set_firstwall(sf.eqdsk['xlim'], sf.eqdsk['ylim']) pl.plot(rb.Rb, rb.Zb) sf.sol(dr=3e-3) rb.get_sol(plot=True) pl.plot(sf.eqdsk['xlim'], sf.eqdsk['ylim']) r = demo.parts['Vessel']['r'] # set vessel boundary z = demo.parts['Vessel']['z']