''' #setup = Setup('SN') #sf = SF(setup.filename) #eq = EQ(sf,pf,sigma=0.2,boundary=rb.get_fw(expand=0.25),n=7.5e4) #eq.plotj(trim=True) #pl.plot(sf.rbdry,sf.zbdry,color=0.75*np.ones(3),lw=1.5) for conf in ['SN', 'X', 'SFm', 'SX', 'SXex']: # print(conf) setup = Setup(conf) sf = SF(setup.filename) pf = PF(sf.eqdsk) rb = RB(setup, sf) rb.firstwall(calc=False, plot=True, debug=False) rb.vessel() pf.plot(coils=pf.coil, label=True, plasma=False, current=False) tf = TF(nTF=18, shape={ 'vessel': rb.loop, 'pf': pf, 'fit': False, 'setup': setup, 'plot': True, 'config': conf, 'coil_type': 'A' }) tf.fill() pl.plot(tf.Rcl, tf.Zcl)
font='sans-serif', palette='Set2', font_scale=7 / 8, rc=rc) Color = cycle(sns.color_palette('Set2')) nTF = 18 #,nPF,nCS = 18,6,5 config = {'TF': 'dtt', 'eq': 'SFp'} config, setup = select(config, nTF=nTF, update=False) # nPF=nPF,nCS=nCS 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)) rb.firstwall(symetric=True, DN=True, plot=True) #pf.plot(coils=pf.coil,label=False,plasma=False,current=True) tf.fill() #sf.cpasma *= 1.1 eq = EQ(sf, pf, dCoil=1.5, sigma=0, boundary=sf.get_sep(expand=1.1), n=3e3) eq.gen_bal() #eq.gen_opp() sf.contour() inv = INV(sf, eq, tf) L = inv.grid_coils(offset=0.3) #pf.plot(coils=pf.coil,label=False,plasma=False,current=True) inv.fix_boundary_psi(N=25, alpha=1 - 1e-4, factor=1) # add boundary points
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-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() inv.update_limits(LCS=[-11.5, 10.5]) L = inv.optimize(L) #inv.plot_fix(tails=True) inv.fix_flux(inv.swing['flux'][1]) inv.solve_slsqp() eq.gen_opp() sf.contour(boundary=True, plot_vac=False) pf.plot(coils=pf.coil, label=True, plasma=False, current=True) rb.firstwall(mode='calc', plot=True, debug=False) rb.trim_sol() #loops.plot_variables(inv.Io,scale=1,postfix='MA') #loops.plot_variables(inv.Lo,scale=1) sf.eqwrite(pf, config=config['eq']) pkl = PKL(config['eq'], directory='../../Movies/') pkl.write(data={'sf': sf, 'eq': eq, 'inv': inv}) # pickle data
rc=rc) nPF, nTF = 3, 18 config = {'TF': 'SN_dtt', 'eq': 'SN_{:d}PF_{:d}TF'.format(nPF, nTF)} config = {'TF': 'SN_dtt', 'eq': 'DEMO_SNb'} setup = Setup(config['eq']) sf = SF(setup.filename) pf = PF(sf.eqdsk) pf.plot(coils=pf.coil, label=True, plasma=False, current=True) levels = sf.contour() rb = RB(setup, sf) rb.firstwall(plot=False, debug=False) profile = Profile(config['TF'], family='S', part='TF', nTF=18, obj='L', load=True) shp = Shape(profile, obj='L', eqconf=config['eq'], load=True) # ,nTF=18 rvv, zvv = geom.rzSLine(rb.segment['vessel']['r'], rb.segment['vessel']['z'], 31) rvv, zvv = geom.offset(rvv, zvv, 0.2) rmin = np.min(rvv) rvv[rvv <= rmin + 0.12] = rmin + 0.12
} sns.set(context='talk', style='white', font='sans-serif', palette='Set2', font_scale=7 / 8, rc=rc) color = sns.color_palette('Set2', 5) config, setup = select(base={'TF': 'dtt', 'eq': 'DEMO_FW_SOF'}, nTF=18) sf = SF(setup.filename) pf = PF(sf.eqdsk) pf.plot(coils=pf.coil, label=True, plasma=False, current=True) levels = sf.contour(plot_vac=False) rb = RB(setup, sf) rb.firstwall(plot=True, debug=False, color=color[1]) rb.trim_sol() filename = trim_dir('../../Data/') + 'CATIA_FW.xlsx' wb = load_workbook(filename=filename, read_only=True, data_only=True) ws = wb[wb.get_sheet_names()[0]] FW = {} for col, var in zip([5, 6], ['r', 'z']): row = ws.columns[col] FW[var] = np.zeros(len(row) - 1) for i, r in enumerate(row[1:]): try: FW[var][i] = 1e-3 * float(r.value) # m except: break
sf = SF(setup.filename) pf = PF(sf.eqdsk) ''' eq = EQ(sf,pf,dCoil=1.5,sigma=0,boundary=sf.get_sep(expand=1.05), zmin=-8,rmin=5.5,n=1e4) eq.gen_opp() ''' #pf.plot(coils=pf.coil,label=True,plasma=False,current=True) sf.contour() rb = RB(setup,sf) rb.firstwall(symetric=False,DN=False,plot=True,debug=False) rb.trim_sol() pl.axis('equal') pl.axis([sf.Xpoint[0]-2,sf.Xpoint[0]+5.5,sf.Xpoint[1]-4,8]) #pl.axis([sf.Xpoint[0]-2.5,sf.Xpoint[0]+2.5,sf.Xpoint[1]-3,sf.Xpoint[1]+0.75]) #sf.get_Xpsi(select='upper') # upper X-point #rb.trim_sol() ''' nTF = config['nTF'] profile = Profile(config['TF'],family='S',part='TF', nTF=nTF,obj='L',load=False,symetric=True) shp = Shape(profile,nTF=nTF,obj='L',eqconf=config['eq'],ny=1) shp.add_vessel(rb.segment['vessel_outer'])