def eval_fsa_beq2(self, grid=None): grid, rzp = self.get_gridrzp(grid) self.dump_fsa_beq2 = self.output_nml.get('dump_fsa_beq2', False) if self.dump_fsa_beq2: if len(rzp.shape) == 2: field = self.eval_symm('fsa_beq2', grid, dmode=1, eq=1) self.fielddict['fsa_beq2'] = fc.Scalar(field, rzp, 1, True) else: field = self.eval.eval_field('fsa_beq2', grid, dmode=1, eq=1) self.fielddict['fsa_beq2'] = fc.Scalar(field, rzp, 1, True) else: self.fielddict['fsa_beq2'] = 0.0 return None
def eval_diff(self, grid=None): ''' Get the diff shape scalars from eval nimrod Some extralogic is needed to pull apart the different diff shape scalar fields from the output of eval_field note when ds_nqty>1 elecd_diff is 0 iso_visc_diff is 1 ''' diff_dmode = self.diff_dmode grid, rzp = self.get_gridrzp(grid) self.ds_nqty = self.equil_nml.get('ds_nqty', 1) if len(rzp.shape) == 2: field = self.eval_symm('d', rzp, dmode=diff_dmode, eq=1) else: field = self.eval.eval_field('d', grid, dmode=diff_dmode, eq=1) diff_shape = [] ishape = list(field.shape) ishape[0] = ishape[0] // self.ds_nqty ifield = np.zeros(ishape) for ii in range(self.ds_nqty): ifield[0] = field[ii] if diff_dmode > 0: start = self.ds_nqty + ii * 3 end = start + 3 ifield[1:4] = field[start:end] if diff_dmode > 1: start = self.ds_nqty * 4 + ii * 6 end = start + 6 ifield[4:10] = field[start:end] diff_shape.append(fc.Scalar(ifield, rzp, diff_dmode, True)) self.fielddict['diff_shape'] = diff_shape return None
def eval_p(self, grid=None, fft=False): grid, rzp = self.get_gridrzp(grid) if self.peq or self.p0: if len(rzp.shape) == 2: field = self.eval_symm('p', rzp, dmode=self.pdmode, eq=1) self.fielddict['peq'] = fc.Scalar(field, rzp, self.pdmode, True) else: field = self.eval.eval_field('p', grid, dmode=self.pdmode, eq=1) self.fielddict['peq'] = fc.Scalar(field, rzp, self.pdmode, True) if self.p0: if len(rzp.shape) == 2: field2 = self.eval_symm('p', rzp, dmode=self.pdmode, eq=3) field2 = field2 - field #sutract eq self.fielddict['p0'] = fc.Scalar(field2, rzp, self.pdmode, True) else: field2 = self.eval.eval_field('p', grid, dmode=self.pdmode, eq=3) field2 = field2 - field #subtract eq self.fielddict['p0'] = fc.Scalar(field2, rzp, self.pdmode, True) if self.ppert: field = self.eval.eval_field('p', grid, dmode=self.pdmode, eq=0) if self.p0: field = field - field2 #remove n=0 perturbation self.fielddict['ppert'] = fc.Scalar(field, rzp, self.pdmode, True) if fft: self.fielddict['pfour'] = self.fft(field, type='s') return None
def eval_neo_mask(self, grid=None): grid, rzp = self.get_gridrzp(grid) r0 = self.closure_nml.get('neo_axis_r', 0) z0 = self.closure_nml.get('neo_axis_z', 0) rbump = self.closure_nml.get('neo_bump_r0', 1.0) shape = list(rzp.shape) shape[0] = 4 fval = np.zeros(shape) fval[0] = 1.0 r2 = (np.power(rzp[0] - r0, 2) + np.power(rzp[1] - z0, 2)) / rbump**2 if isinstance(r2, np.float): if r2 < 1.0: #check bump = np.exp(1 - 1. / (1. - r2)) dbumpdr2 = -r2 / (1 - r2)**3 dr2dx = 2 * (rzp[0] - r0) / rbump**2 dr2dz = 2 * (rzp[1] - r0) / rbump**2 d2r2dxx = 2 / rbump**2 d2r2dyy = 2 / rbump**2 d2r2dxy = 0.0 #print(type(bump),type(dbumpdr2),type(dr2dx)) #print(dbumpdr2.shape) fval[0] = 1.0 - bump fval[1] = -bump * dbumpdr2 * dr2dx fval[2] = -bump * dbumpdr2 * dr2dz else: result = np.where(r2 < 1.0) for indicies in zip(*result): #check bump = np.exp(1 - 1. / (1. - r2[indicies])) dbumpdr2 = -r2[indicies] / (1 - r2[indicies])**3 dr2dx = 2 * (rzp[(0, ) + indicies] - r0) / rbump**2 dr2dz = 2 * (rzp[(1, ) + indicies] - r0) / rbump**2 d2r2dxx = 2 / rbump**2 d2r2dyy = 2 / rbump**2 d2r2dxy = 0.0 #print(type(bump),type(dbumpdr2),type(dr2dx)) #print(dbumpdr2.shape) fval[(0, ) + indicies] = 1.0 - bump fval[(1, ) + indicies] = -bump * dbumpdr2 * dr2dx fval[(2, ) + indicies] = -bump * dbumpdr2 * dr2dz return fc.Scalar(fval, rzp, 1, True)