Usage

PyTurbSim was designed to meet the needs of several different user groups. To meet that objective it has three primary operational modes/interfaces. Those modes are described below. Once PyTurbSim is properly installed, all of these modes should work.

1) Input files

This mode is designed to mimic the O-TurbSim interface. It is designed for use by device developers and other users familiar with the O-TurbSim program who want output that is consistent with predifined models built into TurbSim. In this mode pyTurbSim reads O-TurbSim input files and writes out binary data in the same format as O-TurbSim. This mode can be run from a standard (i.e. DOS, UNIX) command line and is well suited for interfacing with FAST and other device simulation tools in the same way that O-TurbSim does. For more information on this mode, see the docstring in the pyts.runInput docstring.

To run PyTurbSim in this mode on the file ‘TurbSim.inp’ from the command line do:

$ pyTurbSim.py TurbSim.inp

Alternatively, this mode can be used from an interactive python shell by doing:

>>> from pyts.runInput.main import readInput, run, write
>>> config = readInput('TurbSim.inp')
>>> tsdat = run(config)
>>> write(tsdat, config, 'TurbSim')

These two approaches produce the same output. The first allows the user to run PyTurbSim without ever entering an interactive python shell, the latter provides the user with an opportunity to view the output data, tsdat, without reloading it from a file.

The source code for this mode is contained in the pyts.runInput package.

2) Advanced programming interface (API)

This interface was designed for researchers who wish to develop new methods and models for simulating turbulence, and/or want to control the statistics of PyTurbSim output explicitly. This api is the core interface of PyTurbSim (the other two are wrappers). As a starting point for using this interface checkout the API documentation. Or start navigating the api interactively by importing it:

import pyts.api as pyts

More specifically, the examples/api.py file includes an overview of how to begin using PyTurbSim. The contents of that file is:

"""
This script provides an example usage of the PyTurbSim API.
"""
# Begin by importing the PyTurbSim API:
import pyts.api as pyts

# Define some variables for the PyTurbSim run:
refht = 10.
ustar = 0.03
Uref = 3.

# First we initialize a PyTurbSim 'run' object:
tsr = pyts.tsrun()

# Next we give this run object a grid:
tsr.grid = pyts.tsGrid(
    center=refht, ny=5, nz=5, height=5, width=9, time_sec=1000, dt=0.5)

# Now we define a mean 'profile model',
prof_model = pyts.profModels.h2l(Uref, refht, ustar)
# and assign it to the run object,
tsr.prof = prof_model
# These two steps can be completed in one as:
#tsr.profModel=pyts.profModels.h2l(U,refht,ustar)

# Next we define and assign a 'spectral model' to the run object,
tsr.spec = pyts.specModels.tidal(ustar, refht)

# ... and define/assign a 'coherence model',
tsr.cohere = pyts.cohereModels.nwtc()

# ... and define/assign a 'stress model',
tsr.stress = pyts.stressModels.tidal(ustar, refht)

# Now simply 'call' the run oject to produce the TurbSim output.
turbsim_output = tsr()

# We can save the output in 'bladed' format,
turbsim_output.writeBladed('ExampleOutput.bl')

Reading output files

pyTurbSim comes with the ability to read (and write) TurbSim ‘.wnd’, ‘.bl’ (Bladed format) and ‘.bts’ (AeroDyn/TurbSim format) files. To read these files: 1) ‘import pyts.tsio’ 2) You can either use:

  1. pyts.io.bladed or pyts.io.aerodyn to return an array of the turbulence timeseries, or
  2. pyts.tsio.readModel() to read the appropriate data file, and also load information from the config (.inp) file to create a ‘tsdata’ object that includes both the array and also the config and turbModel objects.