예제 #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
파일: 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)
예제 #3
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
예제 #4
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])
예제 #5
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'
            })
예제 #6
0
파일: ripple.py 프로젝트: tokasamwin/Nova
 def get_boundary(filename, alpha=1e-3):
     sf = SF(filename)
     r, z = sf.get_boundary(alpha=alpha)
     return r, z