示例#1
0
文件: shape.py 项目: tokasamwin/Nova
 def __init__(self,profile,eqconf='unset',sep='unset',**kwargs):
     self.ny = kwargs.get('ny',3)  # TF filament number (y-dir)
     self.alpha = kwargs.get('alpha',1-1e-4)
     self.color = cycle(sns.color_palette('Set2',10))
     self.profile = profile
     self.loop = self.profile.loop
     self.bound = {}  # initalise bounds
     self.bindex = {'internal':[0],'interior':[0],'external':[0]}  # index
     for side in ['internal','interior','external']:
         self.bound[side] = {'r':[],'z':[]}
         if side in kwargs:
             self.add_bound(kwargs[side],side)
     if self.profile.nTF is not 'unset' and \
     (eqconf is not 'unset' or sep is not 'unset'):
         if eqconf is not 'unset':
             plasma = {'config':eqconf}
             sf = SF(Setup(eqconf).filename)
             self.tf = TF(profile=self.profile,sf=sf)
         else:
             plasma = {'r':sep['r'],'z':sep['z']}
             self.tf = TF(profile=self.profile)
         self.cage = coil_cage(nTF=self.profile.nTF,rc=self.tf.rc,
                               plasma=plasma,ny=self.ny,alpha=self.alpha)
         x = self.tf.get_loops(self.loop.draw())
         self.cage.set_TFcoil(x['cl'],smooth=False)
     else:
         if self.profile.obj is 'E':
             errtxt = 'nTF and SFconfig keywords not set\n'
             errtxt += 'unable to calculate stored energy\n'
             errtxt += 'initalise with \'nTF\' keyword'
             raise ValueError(errtxt)
示例#2
0
文件: ripple.py 项目: tokasamwin/Nova
 def get_seperatrix(self, nplasma=80, alpha=1 - 1e-3, **kwargs):
     self.nplasma = nplasma
     self.plasma_loop = np.zeros((self.nplasma, 3))  # initalise loop array
     if 'sf' in kwargs:  # seperatrix directly from sf object
         r, z = kwargs['sf'].get_boundary(alpha=alpha)
     elif 'config' in kwargs:
         setup = Setup(kwargs.get('config'))
         r, z = ripple.get_boundary(setup.filename, alpha=alpha)
     elif 'eqdsk' in kwargs:  # seperatrix from eqdsk
         eqdsk = geqdsk.read(kwargs.get('eqdsk'))
         r, z = eqdsk['rbdry'], eqdsk['zbdry']
     elif 'r' in kwargs and 'z' in kwargs:  # separatrix from input
         r, z = kwargs.get('r'), kwargs.get('z')
     else:
         errtxt = '\n'
         errtxt += 'Require plasma={} input of following types:\n'
         errtxt += '1) configuration flag, {\'config\':\'SN\'} \n'
         errtxt += '2) eqdsk file, {\'eqdsk\':\'\'} \n'
         errtxt += '3) seperatrix profile, {\'r\':[],\'z\':[]}'
         raise ValueError(errtxt)
     r, z = geom.clock(r, z)
     (self.plasma_loop[:,0],self.plasma_loop[:,2]) = \
     geom.rzSLine(r,z,npoints=self.nplasma)
     self.plasma_length = geom.length(self.plasma_loop[:, 0],
                                      self.plasma_loop[:, 2])
     rfun, zfun = geom.rzfun(r, z)
     self.plasma_interp = {'r': rfun, 'z': zfun}
示例#3
0
文件: SALOME.py 项目: tokasamwin/Nova
 def __init__(self, config, family='S', nTF=16, obj='L'):
     self.nTF = nTF
     self.config = config
     datadir = trim_dir('../../Data')
     file = 'salome_input'  #  config #  +'_{}{}{}'.format(family,nTF,obj)
     self.filename = datadir + '/' + file + '.json'
     self.profile = Profile(config['TF'],
                            family=family,
                            load=True,
                            part='TF',
                            nTF=nTF,
                            obj=obj,
                            npoints=250)
     setup = Setup(config['eq'])
     self.sf = SF(setup.filename)
     self.tf = TF(self.profile, sf=self.sf)
     self.pf = PF(self.sf.eqdsk)
     self.PF_support()  # calculate PF support seats
     self.CS_support()  # calculate CS support seats
     self.Gravity_support()
     self.cage = coil_cage(nTF=nTF,
                           rc=self.tf.rc,
                           ny=3,
                           plasma={'config': config['eq']},
                           coil=self.tf.x['cl'])
     self.eq = EQ(self.sf,
                  self.pf,
                  dCoil=0.5,
                  sigma=0,
                  boundary=self.sf.get_sep(expand=0.5),
                  n=1e3)
     self.eq.plasma()
     self.ff = force_feild(self.pf.index, self.pf.coil, self.eq.coil,
                           self.eq.plasma_coil)
示例#4
0
 def load_sf(self, eq_names):
     sf_dict, sf_list = OrderedDict(), []
     for configuration in eq_names:
         sf = SF(Setup(configuration).filename)
         sf_dict[configuration] = sf.filename.split('/')[-1]
         sf_list.append(sf)
     self.config['eqdsk'] = sf_dict
     return sf_list
示例#5
0
 def get_seperatrix(self, nplasma=80, alpha=1 - 1e-4, plot=False, **kwargs):
     self.nplasma = nplasma
     self.plasma_loop = np.zeros((self.nplasma, 3))  # initalise loop array
     if 'sf' in kwargs or 'setup' in kwargs or 'config' in kwargs:
         if 'sf' in kwargs:  # seperatrix directly from sf object
             sf = kwargs['sf']
         elif 'setup' in kwargs:
             setup = kwargs.get('setup')
             sf = SF(setup.filename)
         elif 'config' in kwargs:
             setup = Setup(kwargs.get('config'))
             sf = SF(setup.filename)
         r, z = sf.get_boundary(alpha=alpha)
         self.eqdsk = sf.eqdsk
         self.LFP = np.array([sf.LFPr, sf.LFPz])
     else:
         if 'eqdsk' in kwargs:  # seperatrix from eqdsk
             self.eqdsk = geqdsk.read(kwargs.get('eqdsk'))
             r, z = self.eqdsk['rbdry'], self.eqdsk['zbdry']
         elif 'r' in kwargs and 'z' in kwargs:  # separatrix from input
             r, z = kwargs.get('r'), kwargs.get('z')
             self.eqdsk = {
                 'rcentr': 9.0735,
                 'zmagx': 0.15295,
                 'bcentr': -5.6211
             }
         LFindex = np.argmax(r)
         self.LFP = np.array([r[LFindex], z[LFindex]])
     if not hasattr(self, 'eqdsk'):
         errtxt = '\n'
         errtxt += 'Require plasma={} input of following types:\n'
         errtxt += '1) configuration flag, {\'config\':\'SN\'} \n'
         errtxt += '2) eqdsk file, {\'eqdsk\':\'\'} \n'
         errtxt += '3) seperatrix profile, {\'r\':[],\'z\':[]}'
         raise ValueError(errtxt)
     r, z = geom.clock(r, z)
     (self.plasma_loop[:,0],self.plasma_loop[:,2]) = \
     geom.rzSLine(r,z,npoints=self.nplasma)
     self.plasma_length = geom.length(self.plasma_loop[:, 0],
                                      self.plasma_loop[:, 2])
     rfun, zfun = geom.rzfun(r, z)
     self.plasma_interp = {'r': rfun, 'z': zfun}
     if plot:
         pl.plot(self.plasma_loop[:, 0], self.plasma_loop[:, 2])
示例#6
0
tf = TF(R=X[:,0],Z=X[:,2])
tf.energy(nTF,Iturn=134*68e3)
pl.plot(tf.Rmid,tf.Zmid)
'''

#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'
示例#7
0
    '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'))

#pkl = PKL('moveSX_Dev3')

nPF, nCS, nTF = 4, 3, 18
config = {'TF': 'dtt', 'eq': 'SN'}
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)

profile = Profile(config['TF'],
                  family='S',
                  part='TF',
                  nTF=nTF,
                  obj='L',
                  load=True)

tf = TF(profile, sf=sf)
eq = EQ(sf, pf, dCoil=2.0, limit=[5.2, 13, -6.5, 6], n=5e3)  #
eq.get_plasma_coil()
eq.run(update=False)
示例#8
0
inv.update_position(Lnorm, update_area=True)
inv.optimize(Lnorm)

#swing = SWING(inv,sf,plot=True)
eq.run(update=False)
sf.contour()
pf.plot(subcoil=False, current=True, label=True)
pf.plot(subcoil=True)

inv.ff.plot()

mc = main_chamber('dtt', date='2017_03_08')
mc.load_data(plot=True)  # load from file
mc.shp.plot_bounds()

rb = RB(sf, Setup(name))
rb.generate(mc, debug=False)
#profile = Profile(config['TF'],family='S',part='TF',nTF=nTF,obj='L')
shp = Shape(tf.profile, eqconf=config['eq_base'], ny=3)
shp.add_vessel(rb.segment['vessel_outer'])
#shp.minimise(ripple=ripple,verbose=True)
shp.tf.fill()

sf.eqwrite(sf, config='SXex')
'''
inv.Lnorm = Lnorm
sw = SWING(inv,sf)
sw.flat_top()
sw.output()

for ends,name in zip([0,-1],['SOF','EOF']):
示例#9
0
文件: force.py 项目: tokasamwin/Nova
                          point)  # rotate to PF plane
        pf_b = Bpoint([pf_point[0],
                       pf_point[2]])  # PF feild (sf-fast, eq-slow)
        b += np.dot(geom.rotate(theta, 'z'), [pf_b[0], 0, pf_b[1]])  # add PF
        Fbody = np.cross(J, b)  # body force
        return Fbody


if __name__ is '__main__':  # test functions
    from nova.config import Setup
    from nova.streamfunction import SF
    from nova.elliptic import EQ
    from nova.coils import PF
    from nova.radial_build import RB

    setup = Setup('SN_3PF_18TF')

    sf = SF(setup.filename)
    pf = PF(sf.eqdsk)
    rb = RB(setup, sf)
    eq = EQ(sf,
            pf,
            dCoil=0.25,
            sigma=0,
            boundary=rb.get_fw(expand=0.25),
            n=1e3)
    eq.get_plasma_coil()
    #eq.gen_opp()

    ff = force_feild(pf.index, pf.coil, eq.coil, eq.plasma_coil)
    Fcoil = ff.get_force()
示例#10
0
        ax[i][j].set_yticks([])
        ax[i][j].axis('equal')
        #ax[i][j].set_xlim([2.6000000000000001, 17.699999999999999])
        #ax[i][j].set_ylim([-14.292150967273809, 9.0768966517738079])

        ax[i][j].axis('off')

title = ['SN', 'X', 'SF-', 'SF+', 'SX', 'SXex']
for j, config in enumerate(['SN', 'X', 'SFm', 'SFp', 'SX', 'SXex']):
    print('')
    print(config)
    pl.sca(ax[0][j])
    pl.title(title[j])
    Color = cycle(sns.color_palette('Set2'))

    setup = Setup(config)
    sf = SF(setup.filename)
    rb = RB(setup, sf)
    pf = PF(sf.eqdsk)
    eq = EQ(sf, pf, sigma=0.1, boundary=rb.get_fw(expand=0.25), n=5e4)
    #eq = EQ(sf,pf,sigma=0.1,boundary=rb.get_fw(expand=0.25),n=5e3)
    sf.contour(Nlevel=21, lw=0.5)

    pl.plot([14, 14], [-14.5, 9.5], 'o', alpha=0)

    pf.plot(coils=pf.coil, label=False, plasma=False, current=False)
    rb.firstwall(calc=False, plot=True, debug=False)

    rb.vessel()
    tf = TF(nTF=16,
            shape={