def _calcTimeSeries(self, ): """ Compute the u,v,w, timeseries based on the spectral, coherence and Reynold's stress models. This method performs the work of taking a specified spectrum and coherence function and transforming it into a spatial timeseries. It performs the steps outlined in Veers84's [1]_ equations 7 and 8. Returns ------- turb : the turbulent velocity timeseries array (3 x nz x ny x nt) for this PyTurbSim run. Notes ----- 1) Veers84's equation 7 [1]_ is actually a 'Cholesky Factorization'. Therefore, rather than writing this functionality explicitly we call 'cholesky' routines to do this work. 2) This function uses one of two methods for computing the Cholesky factorization. If the Fortran library tslib is available it is used (it is much more efficient), otherwise the numpy implementation of Cholesky is used. .. [1] Veers, Paul (1984) 'Modeling Stochastic Wind Loads on Vertical Axis Wind Turbines', Sandia Report 1909, 17 pages. """ grid = self.grid tmp = np.zeros((grid.n_comp, grid.n_z, grid.n_y, grid.n_f + 1), dtype=ts_complex) if dbg: self.timer.start() # First calculate the 'base' set of random phases: phases = self.phase(self) # Now correlate the phases at each point to set the Reynold's stress: phases = self.stress.calc_phases(phases) # Now correlate the phases between points to set the spatial coherence: phases = self.cohere.calc_phases(phases) # Now multiply the phases by the spectrum... tmp[..., 1:] = np.sqrt(self.spec.array) * grid.reshape(phases) # and compute the inverse fft to produce the timeseries: ts = irfft(tmp) if dbg: self.timer.stop() # Select only the time period requested: # Grab a random number of where to cut the timeseries. i0_out = self.randgen.randint(grid.n_t - grid.n_t_out + 1) ts = ts[..., i0_out:i0_out + grid.n_t_out] / (grid.dt / grid.n_f)**0.5 ts -= ts.mean(-1)[..., None] # Make sure the turbulence has zero mean. return ts
def ctke(self, ): return 0.5 * np.sqrt((self.stress**2).mean(-1).sum(0))
def _sumdict(self): out = dict() # Start by pulling values from the config file # if there was one. if 'config' in self.info: out.update(self.info['config']) uhub = out['uhub'] = statObj(self.uhub) out['vhub'] = statObj(self.vhub, uhub.mean) out['whub'] = statObj(self.whub, uhub.mean) out['hhub'] = statObj(np.sqrt(self.uhub**2 + self.vhub**2)) out['grid'] = self.grid out['upvp'] = statObj(self.uhub * self.vhub) out['upwp'] = statObj(self.vhub * self.whub) out['vpwp'] = statObj(self.vhub * self.whub) out['upvp'].scale = 1 out['upwp'].scale = 1 out['vpwp'].scale = 1 out['tke'] = statObj((self.uturb**2).sum(0)) out['tke'] = statObj((self.uturb**2).sum(0)) out['ctke'] = statObj(0.5 * np.sqrt((self.uturb[0] * self.uturb[1])**2 + (self.uturb[0] * self.uturb[2])**2 + (self.uturb[1] * self.uturb[2])**2)) out['u_sigma'] = self.uturb[0].flatten().std() out['v_sigma'] = self.uturb[1].flatten().std() out['w_sigma'] = self.uturb[2].flatten().std() out['TurbModel_desc'] = self.info['specModel']['description'] out['RandSeed1'] = self.info['RandSeed'] out['profModel_sumstring'] = self.info['profModel']['sumstring'] out['specModel_sumstring'] = self.info['specModel']['sumstring'] out['stressModel_sumstring'] = self.info['stressModel']['sumstring'] out['cohereModel_sumstring'] = self.info['cohereModel']['sumstring'] out['ver'] = ver out['NowDate'] = time.strftime('%a %b %d, %Y', self.info['StartTime']) out['NowTime'] = time.strftime('%H:%M:%S', self.info['StartTime']) out['RunTime'] = self.info['RunTime'] out['FreqNyquist'] = self.f[-1] out['GridBase'] = self.grid.z[0] out['HeightOffset'] = 0.0 # Is this correct? out['ydata'] = self.grid.y out['z_ustd'] = np.concatenate( (self.grid.z[:, None], self.uturb[0].std(-1)), axis=1) out['z_vstd'] = np.concatenate( (self.grid.z[:, None], self.uturb[1].std(-1)), axis=1) out['z_wstd'] = np.concatenate( (self.grid.z[:, None], self.uturb[2].std(-1)), axis=1) u, v, w = self.uprof.mean(-1)[:, :, None] out['WINDSPEEDPROFILE'] = np.concatenate(( self.grid.z[:, None], np.sqrt(u**2 + v**2), np.angle(u + 1j * v) * 180 / np.pi, u, v, w, ), axis=1) out['HFlowAng'] = np.angle(self.uprof[0][self.ihub] + 1j * self.uprof[1][self.ihub]) out['VFlowAng'] = np.angle(self.uprof[0][self.ihub] + 1j * self.uprof[2][self.ihub]) out['TurbModel'] = self.info['specModel']['name'] out['gridheader'] = '--------- ' * self.grid.n_y for nm in [ 'Zref', 'RefHt', 'ZRef', ]: if nm in self.info['profModel']['params']: out['RefHt'] = self.info['profModel']['params'][nm] for nm in [ 'URef', 'Uref', ]: if nm in self.info['profModel']['params']: out['URef'] = self.info['profModel']['params'][nm] out['PLExp'] = self.info['profModel']['params'].get('PLexp', None) return out