Пример #1
0
 def surfgen():
     for i in range(ind0, ind1):
         f = (self.fix["f(psi)"])[i]
         R = (self.fix["R"])[i, :]
         Z = (self.fix["Z"])[i, :]
         Bp = (self.fix["Bp"])[i, :]
         f = FluxSurface(f, R, Z, Bp)
         try:
             # Try to get profiles
             psi = (self.fix["psinorm"])[i]
             d = self.dens(psi)
             T = self.temp(psi)
             dndpsi = self.ddpsi(self.dens)(psi)
             dTdpsi = self.ddpsi(self.temp)(psi)
             f.species = species.genSpecies(T, d, AA=[None, 2], dTdpsi=dTdpsi, dndpsi=dndpsi)
             f.psinorm = psi
         except:
             raise
         yield f
Пример #2
0
 def surfgen():
     for i in range(ind0, ind1):
         f = (self.fix['f(psi)'])[i]
         R = (self.fix['R'])[i, :]
         Z = (self.fix['Z'])[i, :]
         Bp = (self.fix['Bp'])[i, :]
         f = FluxSurface(f, R, Z, Bp)
         try:
             # Try to get profiles
             psi = (self.fix['psinorm'])[i]
             d = self.dens(psi)
             T = self.temp(psi)
             dndpsi = self.ddpsi(self.dens)(psi)
             dTdpsi = self.ddpsi(self.temp)(psi)
             f.species = species.genSpecies(T,
                                            d,
                                            AA=[None, 2],
                                            dTdpsi=dTdpsi,
                                            dndpsi=dndpsi)
             f.psinorm = psi
         except:
             raise
         yield f
Пример #3
0
    def getFluxSurface(self, psi):
        """ Return a FluxSurface object at a given psi 
        
        Will be created by interpolation if needed
        
        Paramaters
        ----------
        
        psi     =  Normalised poloidal flux
        
        """

        if self.fix != None:
            # Find the psi index this value comes before
            ind = searchsorted(self.fix['psinorm'], psi)
            psiarr = self.fix['psinorm']

            if ind == 0:
                ind = 1

            if (ind == self.fix['npsi']):
                raise ValueError(
                    "normalised psi value %e out of range %e to %e" %
                    (psi, psiarr[0], psiarr[-1]))

            # Indices
            im = ind - 1
            ip = ind

            # Weights for interpolation
            wp = (psi - psiarr[im]) / (psiarr[ip] - psiarr[im])
            wm = 1. - wp

            # Interpolate
            def inter1d(var):
                return wp * var[ip] + wm * var[im]

            def inter2d(var):
                return wp * var[ip, :] + wm * var[im, :]

            f = inter1d(self.fix['f(psi)'])
            R = inter2d(self.fix['R'])
            Z = inter2d(self.fix['Z'])
            Bp = inter2d(self.fix['Bp'])

            # Create the flux surface
            f = FluxSurface(f, R, Z, Bp)

            f.psinorm = psi

            # Create some species
            try:
                # Try to get profiles
                d = self.dens(psi)
                T = self.temp(psi)
                dndpsi = self.ddpsi(self.dens)(psi)
                dTdpsi = self.ddpsi(self.temp)(psi)
                f.species = species.genSpecies(T,
                                               d,
                                               AA=[None, 2],
                                               dTdpsi=dTdpsi,
                                               dndpsi=dndpsi)
            except:
                print("Warning: No species information")
            return f
        # No data
        return None
Пример #4
0
    def getFluxSurface(self, psi):
        """ Return a FluxSurface object at a given psi 
        
        Will be created by interpolation if needed
        
        Paramaters
        ----------
        
        psi     =  Normalised poloidal flux
        
        """

        if self.fix != None:
            # Find the psi index this value comes before
            ind = searchsorted(self.fix["psinorm"], psi)
            psiarr = self.fix["psinorm"]

            if ind == 0:
                ind = 1

            if ind == self.fix["npsi"]:
                raise ValueError("normalised psi value %e out of range %e to %e" % (psi, psiarr[0], psiarr[-1]))

            # Indices
            im = ind - 1
            ip = ind

            # Weights for interpolation
            wp = (psi - psiarr[im]) / (psiarr[ip] - psiarr[im])
            wm = 1.0 - wp

            # Interpolate
            def inter1d(var):
                return wp * var[ip] + wm * var[im]

            def inter2d(var):
                return wp * var[ip, :] + wm * var[im, :]

            f = inter1d(self.fix["f(psi)"])
            R = inter2d(self.fix["R"])
            Z = inter2d(self.fix["Z"])
            Bp = inter2d(self.fix["Bp"])

            # Create the flux surface
            f = FluxSurface(f, R, Z, Bp)

            f.psinorm = psi

            # Create some species
            try:
                # Try to get profiles
                d = self.dens(psi)
                T = self.temp(psi)
                dndpsi = self.ddpsi(self.dens)(psi)
                dTdpsi = self.ddpsi(self.temp)(psi)
                f.species = species.genSpecies(T, d, AA=[None, 2], dTdpsi=dTdpsi, dndpsi=dndpsi)
            except:
                print "Warning: No species information"
            return f
        # No data
        return None