pybemt

pybemt.solver module

Module for the solver class.

class pybemt.solver.Solver(config_path)

Bases: object

The Solver object loads the config file and contains functions for running a single simulation, parameter sweeps and optimization.

Parameters

config_path (string) – Path to config file

brute_solve(sec, v, omega, n=3600)

Solve by a simple brute force procedure, iterating through all possible angles and selecting the one with lowest residual.

Parameters
  • sec (Section) – Section to solve for

  • v (float) – Axial inflow velocity

  • omega (float) – Tangential rotational velocity

  • n (int) – Number of angles to test for, optional

Returns

Inflow angle with lowest residual

Return type

float

optimize_pitch()

Optimize rotor pitch for either maximum thrust (propeller) or maximum power (turbine) using a genetic evolution algorithm.

This is intended as an example of how optimization can be done using the scipy.optimize package. The overall procedure can be readily modified to optimize for other parameters, e.g. a parametrized function for the pitch, or for a parameter sweep instead of a single parameter set.

return: Array of optimized pitches

rotor_coeffs(T, Q, P)

Dimensionless coefficients for a rotor.

\[\begin{split}\text{J} = \frac{V_\infty}{nD} \\ C_T = \frac{T}{\rho n^2 D^4} \\ C_Q = \frac{Q}{\rho n^2 D^5} \\ C_P = 2\pi C_Q \\ \eta = \frac{C_T}{C_P}J \\\end{split}\]
Parameters
  • T (float) – Thrust

  • Q (float) – Torque

  • P (float) – Power

Returns

Advance ratio, thrust coefficient, torque coefficient, power coefficient and efficiency

Return type

tuple

run()

Runs the solver, i.e. finds the forces for each rotor.

Returns

Calculated thrust, torque, power and DataFrame with properties for all sections.

Return type

tuple

run_sweep(parameter, n, low, high)

Utility function to run a sweep of a single parameter.

Parameters
  • parameter (string) – Parameter to sweep, must be a member of the Solver class.

  • n (int) – Number of runs

  • low (float) – Minimum parameter value

  • high (float) – Maximum parameter value

Returns

DataFrame of results and list of sections for each run

Return type

tuple

slipstream()

For coaxial calculations. Calculates slipstream radius and velocity for the upper rotor according to momentum theory. Currently only the static case is included.

\[\begin{split}r_s = \frac{R}{\sqrt{2}} \\ v_s = C_s\sqrt{\frac{2 T}{\rho A}} \\\end{split}\]
Returns

Radius and velocity of the slipstream

Return type

tuple

solve(rotor, twist, rpm, v_inflow, r_inflow)

Find inflow angle and calculate forces for a single rotor given rotational speed, inflow velocity and radius.

Parameters
  • rotor (Rotor) – Rotor to solve for

  • twist (float) – Angle to adjust rotor pitch

  • rpm (float) – Rotations per minute

  • v_inflow (float) – Inflow velocity

  • r_inflow (float) – Inflow radius (equal to blade radius for single rotors)

Returns

Calculated thrust, torque and power for the rotor

Return type

tuple

turbine_coeffs(T, Q, P)

Dimensionless coefficients for a turbine.

\[\begin{split}\text{TSR} = \frac{\Omega R}{V_\infty} \\ C_T = \frac{2T}{\rho A V_\infty^2} \\ C_P = \frac{2P}{\rho A V_\infty^3} \\\end{split}\]
Parameters
  • T (float) – Thrust

  • Q (float) – Torque

  • P (float) – Power

Returns

Tip-speed ratio, power coefficient and thrust coefficient

Return type

tuple

pybemt.airfoil module

Module for holding airfoil data, and providing drag and lift coefficients to the solver.

Airfoil data is stored in the folder pybemt/airfoils. Currently, the Aerodyn format is supported, with only a single airfoil table. Data must be available from -180 to 180 degrees, and a quadratic function is built to interpolate between data in the airfoil table.

This module can also be executed from the command-line to plot drag and lift coefficients for a single airfoil, e.g.

python airfoil.py NACA_4412
class pybemt.airfoil.Airfoil

Bases: object

Class for storing airfoil drag and lift coefficients. Should be initialized using the load_airfoil() function.

Cd(alpha)

Provide drag coefficent for a given angle of attack.

Parameters

alpha (float) – Angle in radians

Returns

Drag coefficient

Return type

float

Cl(alpha)

Provide drag coefficent for a given angle of attack.

Parameters

alpha (float) – Angle in radians

Returns

Drag coefficient

Return type

float

plot(color='k')

Plot lift and drag coefficients.

Parameters

color (string) – Matplotlib color key. Default value is k, i.e. black.

pybemt.airfoil.load_airfoil(name)

Load airfoil data from data file into an Airfoil object.

Parameters

name (string) – name of the airfoil to load, e.g. ‘NACA_4412’.

Returns

Airfoil object

Return type

pybemt.Airfoil

pybemt.rotor module

Module for storing rotor properties and calculation of induction factors and forces for the airfoil sections.

class pybemt.rotor.Rotor(cfg, name, mode)

Bases: object

Holds rotor properties and a list of all airfoil sections.

Parameters
  • cfg (configparser.SafeConfigParser) – Configuration object

  • name (string) – Name of rotor

  • mode (string) – Solver mode

precalc(twist)

Calculation of properties before each solver run, to ensure all parameters are correct for parameter sweeps.

Returns

None

sections_dataframe()

Creates a pandas DataFrame with all calculated section properties.

Returns

DataFrame with section properties

Return type

pd.DataFrame

class pybemt.rotor.Section(airfoil, radius, width, pitch, chord, rotor, mode)

Bases: object

Class for calculating induction factors and forces according to the BEM theory for a single airfoil section.

Parameters
  • airfoil (Airfoil) – Airfoil of the section

  • radius (float) – Distance from center to mid of section

  • width (float) – Width of section

  • pitch (float) – Pitch angle in radians

  • chord (float) – Chord length of section

  • rotor (Rotor) – Rotor that section belongs to

  • mode (string) – Solver mode

airfoil_forces(phi)

Force coefficients on an airfoil, decomposed in axial and tangential directions:

\[\begin{split}C_T = C_l\cos{\phi} - CC_d\sin{\phi} \\ C_Q = C_l\sin{\phi} + CC_d\cos{\phi} \\\end{split}\]

where drag and lift coefficients come from airfoil tables.

Parameters

phi (float) – Inflow angle

Returns

Axial and tangential force coefficients

Return type

tuple

forces(phi, v_inf, omega, fluid)

Calculation of axial and tangential forces (thrust and torque) on airfoil section.

The definition of blade element theory is used,

\[\begin{split}\Delta T = \sigma\pi\rho U^2C_T r\Delta r \\ \Delta Q = \sigma\pi\rho U^2C_Q r^2\Delta r \\ U = \sqrt{v^2+v'^2} \\ v = (1 + Ca)V_\infty \\ v' = (1 - Ca')\Omega R \\\end{split}\]

Note that this is equivalent to the momentum theory definition,

\[\begin{split}\Delta T = 4\pi\rho r V_\infty^2(1 + Ca)aF\Delta r \\ \Delta Q = 4\pi\rho r^3 V_\infty\Omega(1 + Ca)a'F\Delta r \\\end{split}\]
Parameters
  • phi (float) – Inflow angle

  • v_inf (float) – Axial inflow velocity

  • omega (float) – Tangential rotational velocity

  • fluid (Fluid) – Fluid

Returns

Axial and tangential forces

Return type

tuple

func(phi, v_inf, omega)

Residual function used in root-finding functions to find the inflow angle for the current section.

\[\begin{split}\frac{\sin\phi}{1+Ca} - \frac{V_\infty\cos\phi}{\Omega R (1 - Ca')} = 0\\\end{split}\]
Parameters
  • phi (float) – Estimated inflow angle

  • v_inf (float) – Axial inflow velocity

  • omega (float) – Tangential rotational velocity

Returns

Residual

Return type

float

induction_factors(phi)

Calculation of axial and tangential induction factors,

\[\begin{split}a = \frac{1}{\kappa - C} \\ a' = \frac{1}{\kappa' + C} \\ \kappa = \frac{4F\sin^2{\phi}}{\sigma C_T} \\ \kappa' = \frac{4F\sin{\phi}\cos{\phi}}{\sigma C_Q} \\\end{split}\]
Parameters

phi (float) – Inflow angle

Returns

Axial and tangential induction factors

Return type

tuple

precalc()

Calculation of properties before each solver run, to ensure all parameters are correct for parameter sweeps.

Returns

None

stall_delay_model(phi, alpha, Cl, Cd)

The 3D correction model based on Chaviaropoulos and Hansen ref:

\[Cl_3D = Cl_2D + a (c / r)^h \cos^n{twist} (Cl_inv - Cl_2d) \ Cl_inv = \sqrt{Cl_2d^2 + Cd^2}\]

where: a = 2.2, h = 1.3 and n = 4

Parameters

phi (float) – Inflow angle

Returns

Lift coefficient with 3D correction

Return type

float

tip_loss(phi)

Prandtl tip loss factor, defined as

\[\begin{split}F = \frac{2}{\pi}\cos^{-1}e^{-f} \\ f = \frac{B}{2}\frac{R-r}{r\sin\phi}\end{split}\]

A hub loss is also caluclated in the same manner.

Parameters

phi (float) – Inflow angle

Returns

Combined tip and hub loss factor

Return type

float

pybemt.fluid module

Module for holding and calculating fluid properties. Currently, only viscosity and density are included.

class pybemt.fluid.Fluid(cfg)

Bases: object

Class for loading fluid properties from configuration file and providing them to the solver.

Parameters

cfg (configparser.SafeConfigParser) – Configuration object