Пример #1
0
    def read_upar(self, lab_frame=False):
        """
        Read the parallel velocity.
        """

        self.upar_i = field.get_field(self.cdf_file, 'upar_igomega_by_mode', 0)
        self.upar_e = field.get_field(self.cdf_file, 'upar_igomega_by_mode', 1)

        if lab_frame:
            for ix in range(self.nkx):
                for iy in range(self.nky):
                    self.upar_i[:,ix,iy] = self.upar_i[:,ix,iy]* \
                                           np.exp(1j * self.n0 * iy * \
                                                  self.omega * self.t)
                    self.upar_e[:,ix,iy] = self.upar_e[:,ix,iy]* \
                                           np.exp(1j * self.n0 * iy * \
                                                  self.omega * self.t)

        self.upar_i = field.field_to_real_space(self.upar_i)*self.rho_star
        self.upar_e = field.field_to_real_space(self.upar_e)*self.rho_star
Пример #2
0
    def read_tperp(self, lab_frame):
        """
        Read the perpendicular temperature.
        """

        self.tperp_i = field.get_field(self.cdf_file, 'tperp_igomega_by_mode', 0)
        self.tperp_e = field.get_field(self.cdf_file, 'tperp_igomega_by_mode', 1)

        if lab_frame:
            for ix in range(self.nkx):
                for iy in range(self.nky):
                    self.tperp_i[:,ix,iy] = self.tperp_i[:,ix,iy]* \
                                            np.exp(1j * self.n0 * iy * \
                                                   self.omega * self.t)
                    self.tperp_e[:,ix,iy] = self.terp_e[:,ix,iy]* \
                                            np.exp(1j * self.n0 * iy * \
                                                   self.omega * self.t)

        # Convert to real space
        self.tperp_i = field.field_to_real_space(self.tperp_i)*self.rho_star
        self.tperp_e = field.field_to_real_space(self.tperp_e)*self.rho_star
Пример #3
0
    def read_ntot(self, lab_frame=False):
        """
        Read the 2D density fluctuations from the NetCDF file.
        """

        self.ntot_i = field.get_field(self.cdf_file, 'ntot_igomega_by_mode', 0)
        self.ntot_e = field.get_field(self.cdf_file, 'ntot_igomega_by_mode', 1)

        if lab_frame:
            for ix in range(self.nkx):
                for iy in range(self.nky):
                    self.ntot_i[:,ix,iy] = self.ntot_i[:,ix,iy]* \
                                           np.exp(1j * self.n0 * iy * \
                                                  self.omega * self.t)
                    self.ntot_e[:,ix,iy] = self.ntot_e[:,ix,iy]* \
                                           np.exp(1j * self.n0 * iy * \
                                                  self.omega * self.t)

        # Convert to real space
        self.ntot_i = field.field_to_real_space(self.ntot_i)*self.rho_star
        self.ntot_e = field.field_to_real_space(self.ntot_e)*self.rho_star
Пример #4
0
    def calculate_zf_shear(self):
        """
        Calculate the max rms zonal flow shear.
        """

        phi_k = field.get_field(self.cdf_file, 'phi_igomega_by_mode', None)

        self.kxfac = abs(self.qinp)/self.rhoc/abs(self.drho_dpsi)

        zf_shear = 0.5 * self.kxfac * (- phi_k[:, :, 0]*self.kx[np.newaxis, :]**2).real * self.rho_star / self.rhoref

        self.zf_shear_max = np.sqrt(np.mean(np.max(np.abs(zf_shear), axis=1)**2))
        self.zf_shear_rms = np.sqrt(np.mean(zf_shear**2))
Пример #5
0
    def calculate_zf_shear(self):
        """
        Calculate the shear in the  zonal flow velocity as a function of radius
        and time.
        """

        phi_k = field.get_field(self.cdf_file, 'phi_igomega_by_mode', None)

        self.kxfac = abs(self.qinp)/self.rhoc/abs(self.drho_dpsi)

        self.zf_shear = 0.5 * self.kxfac * \
                        np.fft.ifft(- phi_k[:, :, 0]*self.kx[np.newaxis, :]**2,
                                    axis=1).real * \
                        self.nx * self.rho_star / self.rhoref
Пример #6
0
    def read_phi(self, lab_frame=False):
        """
        Read the electrostatic potenential from the NetCDF file.
        """

        self.phi = field.get_field(self.cdf_file, 'phi_igomega_by_mode', None)

        if lab_frame:
            for ix in range(self.nkx):
                for iy in range(self.nky):
                    self.phi[:,ix,iy] = self.phi[:,ix,iy]* \
                                        np.exp(1j * self.n0 * iy * \
                                               self.omega * self.t)

        self.phi = field.field_to_real_space(self.phi)*self.rho_star
Пример #7
0
    def calculate_v_zf(self, add_mean_flow=False):
        """
        Calculate the zonal flow velocity as a function of radius and time.

        The velocity is in units of vth.
        """

        phi_k = field.get_field(self.cdf_file, 'phi_igomega_by_mode', None)

        self.kxfac = abs(self.qinp)/self.rhoc/abs(self.drho_dpsi)

        self.v_zf = 0.5 * self.kxfac * \
                    np.fft.ifft(-phi_k[:, :, 0] * self.kx[np.newaxis, :],
                                axis=1).imag * self.nx * self.rho_star

        if add_mean_flow:
            self.v_zf += self.r * self.g_exb / self.amin
Пример #8
0
    def calculate_v_exb(self, lab_frame=False):
        """
        Calculates the radial ExB velocity in real space in units of v_th,i.
        """

        phi_k = field.get_field(self.cdf_file, 'phi_igomega_by_mode', None)

        self.v_exb = 1j*self.ky*phi_k

        if lab_frame:
            for ix in range(self.nkx):
                for iy in range(self.nky):
                    self.v_exb[:,ix,iy] = self.v_exb[:,ix,iy]* \
                                          np.exp(1j * self.n0 * iy * \
                                                 self.omega * self.t)

        self.v_exb = field.field_to_real_space(self.v_exb)* \
                     self.rho_star*self.vth
Пример #9
0
    def calculate_q(self):
        """
        Calculate the local heat flux Q(x, y) for the ion species.
        """

        # Need phi as a function of kx, ky so read directly from netcdf file
        self.phi = field.get_field(self.cdf_file, 'phi_igomega_by_mode', None)
        self.read_ntot()
        self.read_tperp()
        self.read_tpar()

        # Convert to real space
        v_exb = field.field_to_real_space(1j*self.ky*self.phi)
        ntot_i = self.ntot_i/self.rho_star
        tperp_i = self.tperp_i/self.rho_star
        tpar_i = self.tpar_i/self.rho_star

        self.q = ((tperp_i + tpar_i/2 + 3/2*ntot_i)*v_exb).real/2

        dnorm = self.dtheta/self.bmag/self.gradpar
        wgt = np.sum(dnorm*self.grho)

        self.q = self.q * dnorm[int(self.nth/2)] / wgt