pyts.profModels package¶
Submodules¶
pyts.profModels.api module¶
PyTurbSim mean velocity ‘profile models’ package.
Available profile models¶
log_models.nwtc
(alias: log)- The nwtc logarithmic mean wind-speed profile.
log_models.H2O
(alias: h2l)- The hydro (water) logarithmic mean velocity profile.
power_models.nwtc
(alias: pl)- The nwtc 1/7 power-law mean wind-speed profile.
iec_models.main
(alias: iec)- The IEC mean wind-speed profile.
profModelBase
- This is the base class for profile models. To create a new profile model, subclass this class or subclass and modify an existing profile model.
profObj
- This is the ‘profile object’ class. All profile model __call__
methods must take a
tsrun
as input and return this class.
Example usage¶
>>> import pyts.profModels.api as pm
Create a logarithmic mean wind-speed ‘profile model’ with 18m/s wind at 80m, and surface roughness length of 1m:
>>> my_prof_model=pm.log(18,80,1)
# Now set ‘tsrun’ to use this profile model:
>>> tsrun.prof=my_prof_model(tsrun)
Creating a new profile model¶
Creating new profile models in PyTurbSim is simple. Simply subclass
profModelBase
, then:
For example:
import pyts.profModels.api as pm # import the profModels api
from numpy import polyval # Import helper functions.
class my_new_model(pm.profModelBase):
"""
A polynomial mean-velocity profile, where coefficients can be
specified at initialization.
"""
def __init__(self,Uref,Zref,poly_coefs=[1.,0.]):
# All units should be in meters and seconds.
self.Uref=Uref
self.Zref=Zref
self.poly_coefs=poly_coefs
def __call__(self,tsrun):
out=pm.profObj(tsrun)
# Note here that tsrun contains the 'grid information', and
# we can use that information to construct the profObj.
out[0]=self.Uref*numpy.polyval(self.poly_coefs,tsrun.grid.z/Zref)
# Here we have set the u-component (index 0) to follow the
# polynomial, and we leave the other components to be zero.
return out
That’s all that is required to define a new profile model! Now,
assuming you have already created a tsrun
instance (e.g. tsr) you set that tsrun
to
use your new model by simply doing, for example:
>>> tsr.prof = my_new_model(3.,20,[.5,0])
Now your PyTurbSim run will utilize your newly defined model!
Notes¶
For a description of the difference between ‘profile models’ (e.g. ‘my_prof_model’ in example above) and the profile they output (tsrun.prof), see the Code Framework section of the PyTurbSim documentation.
pyts.profModels.base module¶
This is the velocity profile package’s base module.
-
class
pyts.profModels.base.
profModelBase
[source]¶ Bases:
pyts.base.modelBase
A base class for TurbSim profile models.
-
class
pyts.profModels.base.
profObj
(tsrun)[source]¶ Bases:
pyts.base.gridProps
,pyts.base.calcObj
Profile objects contain the array (self.array) of mean-velocity values for a specific PyTurbSim run.
Profile objects are created with/for a specific PyTurbSim run.
Parameters: tsrun :
tsrun
The PyTurbSim run object in which the profile will be used.
See also
profModelBase
- The abstract base class for classes that create this class.
-
dudz
¶ The vertical derivative of the u-component of the mean velocity field. (Centered difference)
-
dvdz
¶ The vertical derivative of the v-component of the mean velocity field. (Centered difference)
-
dwdz
¶ The vertical derivative of the w-component of the mean velocity field. (Centered difference)
-
u
¶ The w-component of the mean velocity field.
-
uhub
¶ The u-component hub-height wind speed.
-
v
¶ The w-component of the mean velocity field.
-
w
¶ The w-component of the mean velocity field.
pyts.profModels.iec module¶
- This module contains the power-law mean-velocity profiles:
- main - The IEC mean wind speed profile.
-
class
pyts.profModels.iec.
main
(URef, RefHt, Z0, PLexp=0.2, turbmodel=None)[source]¶ Bases:
pyts.profModels.power.nwtc
,pyts.profModels.log.nwtc
IEC wind profile model.
This profile is a power-law across the rotor disk and logarithmic elsewhere.
Parameters: grid :
tsGrid
The TurbSim grid object for this simulation.
URef : float
Reference velocity for the wind profile [m/s].
RefHt : float
Reference height of the reference velocity [m].
PLexp : float,optional (0.2)
The power-law exponent to be utilized for this simulation [non-dimensional], default=0.2 (per IEC specification).
Z0 : float
Surface roughness length [m].
Ri : float
The Richardon number [non-dimensional].
turbmodel : str
the name of the turbulence model in this simulationm, optional.
See also
power.nwtc
- The iec model is this law over the rotor disk
log.nwtc
- The iec model is this law outside the rotor disk
pyts.profModels.jet module¶
-
class
pyts.profModels.jet.
main
(URef, ZRef, UStar, Ri, zjet_max=None)[source]¶ Bases:
pyts.profModels.base.profModelBase
Low-level jet wind profile model.
Parameters: URef : float
Reference velocity for the wind profile [m/s].
ZRef : float
Reference height of the reference velocity [m].
UStar : float
The bottom-boundary friction velocity [m/s].
Ri : float
The Richardson number stability parameter.
zjet_max : float, optional
The maximum height of the jet. If a value is not specified, the zjet_max property provides a default.
-
__call__
(tsrun)[source]¶ Create and calculate the mean-profile object for a tsrun instance.
Parameters: tsrun :
tsrun
A TurbSim run object.
Returns: out :
profObj
A jet wind-speed profile for the grid in tsrun.
-
zjet_max
¶ The value of the jet height.
This property calculates a default value if one is not specified.
-
pyts.profModels.log module¶
- This module contains the log-law mean-velocity profiles:
- nwtc - The NWTC logarithmic mean wind speed profile. H2O - The hydro-logarithmic mean velocity profile.
-
class
pyts.profModels.log.
H2O
(Uref, Zref, ustar)[source]¶ Bases:
pyts.profModels.base.profModelBase
Logarithmic water velocity profile model.
Parameters: URef : float
Reference velocity for the wind profile [m/s].
ZRef : float
Reference height of the reference velocity [m].
ustar : float
Surface friction veclocity [m/s].
Notes
The precise form of this model is,
\[Ubar(z) = U_*/\kappa * \mathrm{Ln}( z / Z_{ref}) + U_{ref}\]
-
class
pyts.profModels.log.
nwtc
(URef, ZRef, Z0, Ri=0, turbmodel=None)[source]¶ Bases:
pyts.profModels.base.profModelBase
NWTC logarithmic wind-speed profile model.
Parameters: URef : float
Reference velocity for the wind profile [m/s].
ZRef : float
Reference height of the reference velocity [m].
Z0 : float
Surface roughness length [m].
Ri : float
The Richardon number [non-dimensional].
turbmodel : str, optional
The name of the turbulence model in this simulationm.
Notes
The exact form of this model is,
\[\bar{U}(z) = U_{Ref}\frac{ln( z / Z0 ) - \psi_M}{ln( Z_{Ref} / Z0) - \psi_M}\]Where psi_M is a function of Ri, the Richardson number (psi_M=0 for Ri=0), and the turbulence model.
-
__call__
(tsrun)[source]¶ Create and calculate the mean-profile object for a tsrun instance.
Parameters: tsrun :
tsrun
A TurbSim run object.
Returns: out :
profObj
A logarithmic wind-speed profile for the grid in tsrun.
-
model
(z)[source]¶ Calculate the log profile for heights z.
Parameters: z : array_like(dtype=float)
Height above the ground [m].
Returns: u : array_like(dtype=float)
The mean velocity array [m/s].
-
psiM
¶ The psi_M parameter for this profile model.
See the
pyts.misc.psiM()
function for details.
-
pyts.profModels.power module¶
The NWTC power-law profile model.
-
class
pyts.profModels.power.
nwtc
(Uref, Zref, PLexp=0.14285714285714285)[source]¶ Bases:
pyts.profModels.base.profModelBase
Power-law wind profile model.
\[\bar{U}(z) = U_{ref} * ( z / Z_{ref} )^{PLexp}\]Parameters: URef : float
Reference velocity for the wind profile [m/s].
Zref : float
Reference height of the reference velocity [m].
PLexp : float
The power-law exponent to be utilized for this simulation [non-dimensional], default=1/7.
pyts.profModels.simple module¶
- This module contains the log-law mean-velocity profiles:
- linear - A linear wind speed profile uniform - A uniform mean wind speed.
-
class
pyts.profModels.simple.
linear
(URef, ZRef, URef2=0.0, ZRef2=0.0)[source]¶ Bases:
pyts.profModels.base.profModelBase
A ‘linear’ mean wind-speed ‘profile’.
Parameters: URef : float
The mean velocity you wish to produce [m/s].
ZRef : float
Reference height of URef [m].
URef2 : float (default = 0)
Second velocity point [m/s].
ZRef2 : float (default = 0)
Reference height of second velocity point [m]
Notes
The u-component is set to a linear profile through the points (URef,Zref) and (URef2,ZRef2). v- and w-components are zero.
-
class
pyts.profModels.simple.
uniform
(URef)[source]¶ Bases:
pyts.profModels.base.profModelBase
Uniform wind-speed ‘profile’ model.
Parameters: URef : The mean velocity you wish to produce. Notes
This wind-speed ‘profile’ actually just sets the mean u-component wind-speed to be spatially uniform. The v- and w-components are zero.
Module contents¶
This is the PyTurbSim mean velocity ‘profile models’ package. This package contains pre-defined profile models that can be implemented in a PyTurbSim run.
For more information and to use this module import the profModels.api
package, e.g.
>>> import pyts.profModels.api as pm