def diagnostics(self, var, t): """ should provide at least 'maxspeed' (for cfl determination) """ nh = self.nh u = var.get('u') v = var.get('v') vort = var.get('vorticity') buoy = var.get('buoyancy') ke, maxu = fd.computekemaxu(self.msk, u, v, self.nh) z, z2 = fd.computesumandnorm(self.msk, vort, self.nh) b, b2 = fd.computesumandnorm(self.msk, buoy, self.nh) # potential energy (minus sign because buoyancy is minus density) pe = -self.gravity * fd.computesum(self.msk, buoy * self.yr, nh) cst = self.mpitools.local_to_global([(maxu, 'max'), (ke, 'sum'), (z, 'sum'), (z2, 'sum'), (pe, 'sum'), (b, 'sum'), (b2, 'sum')]) self.diags['maxspeed'] = cst[0] self.diags['ke'] = cst[1] / self.area self.diags['pe'] = cst[4] / self.area self.diags['energy'] = (cst[1] + cst[4]) / self.area self.diags['vorticity'] = cst[2] / self.area self.diags['enstrophy'] = 0.5 * cst[3] / self.area self.diags['buoyancy'] = cst[5] / self.area self.diags['brms'] = np.sqrt(cst[6] / self.area - (cst[5] / self.area)**2)
def diagnostics(self, var, t): """ should provide at least 'maxspeed' (for cfl determination) """ nh = self.nh u = var.get('u') v = var.get('v') vort = var.get('vorticity') buoy = var.get('buoyancy') V = var.get('V') qE = var.get('qE') qEneg = qE.copy() qEneg[qE > 0] = 0. ke, maxu = fd.computekemaxu(self.msk, u, v, self.nh) z, z2 = fd.computesumandnorm(self.msk, vort, self.nh) b, b2 = fd.computesumandnorm(self.msk, buoy, self.nh) vm, v2 = fd.computesumandnorm(self.msk, V, self.nh) q, q2 = fd.computesumandnorm(self.msk, qE, self.nh) qn, qn2 = fd.computesumandnorm(self.msk, qEneg, self.nh) # potential energy (minus sign because buoyancy is minus density) pe = fd.computesum(self.msk, buoy * self.yr, nh) pe = -self.gravity * pe cst = self.mpitools.local_to_global([(maxu, 'max'), (ke, 'sum'), (z, 'sum'), (z2, 'sum'), (pe, 'sum'), (b, 'sum'), (b2, 'sum'), (q, 'sum'), (q2, 'sum'), (qn, 'sum'), (qn2, 'sum'), (v2, 'sum')]) a = self.area self.diags['maxspeed'] = cst[0] self.diags['ke'] = (cst[1]) / a self.diags['keV'] = (0.5 * cst[11]) / a self.diags['pe'] = cst[4] / a self.diags[ 'energy'] = self.diags['ke'] + self.diags['pe'] + self.diags['keV'] self.diags['vorticity'] = cst[2] / a self.diags['enstrophy'] = 0.5 * cst[3] / a bm = cst[5] / a self.diags['buoyancy'] = bm self.diags['brms'] = sqrt(cst[6] / a - bm**2) pvm = cst[7] / a pvneg_mean = cst[9] / a self.diags['pv_mean'] = pvm self.diags['pv_std'] = sqrt(cst[8] / a - pvm**2) self.diags['pvneg_mean'] = pvneg_mean self.diags['pvneg_std'] = sqrt(cst[10] / a - pvneg_mean**2)
def diagnostics(self, var, t): """ should provide at least 'maxspeed' (for cfl determination) """ self.timers.tic('diag') u = var.get('u') v = var.get('v') trac = var.get('vorticity') psi = var.get('psi') source = self.var.get('source') xr = self.xr yr = self.yr ke, maxu = fd.computekemaxu(self.msk, u, v, self.nh) # ke = fd.computekewithpsi(self.msk, trac, psi, self.nh) z, z2 = fd.computesumandnorm(self.msk, trac, self.nh) px = fd.computedotprod(self.msk, trac, xr, self.nh) py = fd.computedotprod(self.msk, trac, yr, self.nh) angmom = fd.computesum(self.msk, psi, self.nh) sce = fd.computedotprod(self.msk, trac, source, self.nh) cst = self.mpitools.local_to_global([(maxu, 'max'), (ke, 'sum'), (z, 'sum'), (z2, 'sum'), (px, 'sum'), (py, 'sum'), (angmom, 'sum'), (sce, 'sum')]) self.diags['maxspeed'] = cst[0] self.diags['ke'] = cst[1] / self.area self.diags['vorticity'] = cst[2] / self.area self.diags['enstrophy'] = 0.5 * cst[3] / self.area self.diags['px'] = cst[4] / self.area self.diags['py'] = cst[5] / self.area self.diags['angmom'] = cst[6] / self.area self.diags['source'] = cst[7] / self.area self.timers.toc('diag')