Auxillary methods

e2d_run_aoa

e2dpolar.runaoa.e2d_run_aoa(boostconv_on=False, **boostconv_params)[source]

PyEllipSys2D based CFD run for a single angle-of-attack.

runcluster

e2dpolar.lib_cluster.group_runcluster(runmachine='sophia', jobname='polar', queue='windq', walltime='00:10:00', nodes=1, nprocs=1, command='flowfieldMPI', cpfiles=['input.dat', 'grid.X2D', 'grid.T2D'], movefiles=['*.o*', '*.res', '*.?pr*', '*.?P?*', '*.?F?*', '*.?H?*', '*.OUT', '*.?force', '*.force', '*.points', '*.plt', '*.RST*', '*.PLT*', '*.xyz*', '*.f', 'transition.dat', '*.pdf'], act_script='activate_pye2dpolar.sh', dry_run=False, aoas=None)[source]

Function writing the runbatch file launching multiple angle-of-attack computations on sophia in sequence.

e2dpolar.lib_cluster.runcluster(runmachine='sophia', jobname='polar', queue='windq', walltime='00:10:00', nodes=1, nprocs=1, command='flowfieldMPI', cpfiles=['input.dat', 'grid.X2D', 'grid.T2D'], movefiles=['*.o*', '*.res', '*.?pr*', '*.?P?*', '*.?F?*', '*.?H?*', '*.OUT', '*.?force', '*.force', '*.points', '*.plt', '*.RST*', '*.PLT*', '*.xyz*', '*.f', 'transition.dat', '*.pdf'], act_script='activate_pye2dpolar.sh', dry_run=False)[source]

Function writing the runbatch file launching a single angle-of-attack computation on the specified machine or launches locally.

in_out

e2dpolar.in_out.calc_rough_hcrit(Rehh_crit, yn, vt, Rec=7000000.0, chord=1.0, rho=1.225, mu=1.789e-05)[source]

Calculate critical distributed surface roughness height triggering transition as proposed by Doenhoff & Brasloff (1961) and many more

Parameters:
  • Rehh_crit (float) – Critical roughness Reynolds number based on roughness element height and velocity at the top of element

  • yn (2D-array) – chord-normalised wall normal distance of BL profiles, shape: [nr_profiles, nj]

  • vt (2D-array) – freestream-normalised wall tangential velocity BL profiles, shape: [nr_profiles, nj]

  • Rec (float) – chord-based Reynolds number

  • chord (float) – chord length

  • rho (float) – air density

  • mu (float) – air dynamic viscosity

Returns:

  • h_crit (float) – critical roughness height

  • Rehh (2D-array) – Roughness element Reynolds number shape: [nr_profiles, nj]

e2dpolar.in_out.calc_step_hcrit(Reh_crit, Ue_Uinf, Rec=7000000.0, chord=1.0, rho=1.225, mu=1.789e-05)[source]

Calculate critical surface step height triggering transition according to Schrauf (2022) and Nenni-Gluyas (1966) criterion

Parameters:
  • Reh_crit (float) – Critical step height Reynolds number

  • Ue_Uinf (float) – BL edge velocity normalised with free-stream

  • Rec (float) – chord-based Reynolds number

  • chord (float) – chord length

  • rho (float) – air density

  • mu (float) – air dynamic viscosity

Returns:

h_crit – critical step height according to Schrauf and Nenni-Gluyas criterion

Return type:

float

e2dpolar.in_out.check_exist(check_dir='.', rm_dir=False, rerun=False, files_to_search=['test.pkl'])[source]

Check whether a certain file locally or inside a folder exist

Parameters:
  • check_dir (string) –

    folder name

    (default: ‘.’, check locally)

  • rm_dir (bool) –

    should the folder specified in ‘check_dir’ be removed (only if not ‘.’ or ‘..’)

    (default: False)

  • rerun (bool) –

    if True, all files and the folder are removed

    (default: False)

  • files_to_search (list(string)) –

    list of file names to search for

    (default: [‘test.pkl’])

Returns:

out – False if any of the files to search for does not exist

Return type:

bool

e2dpolar.in_out.convert_polars_pkl2mat(infile='polars', indict=None)[source]

convert assembled polars using ‘gather_rundir_pkls’ from .pkl to .mat files

Parameters:
  • infile (string) –

    name of pkl file to convert, if ‘indict’ is None than data in indict will be used

    (default: ‘polars’)

  • indict (dict, Optional) –

    dict holidng assembled polar data to be converted

    (default: None)

e2dpolar.in_out.convert_x2s(af, x)[source]
e2dpolar.in_out.critical_waviness(Rec, chord, lam, sweep=0.0)[source]

Calculate critical surface waviness as

Parameters:
  • Rec (float) – chord-based Reynolds number

  • chord (float) – chord length

  • lam (float) – wave length

  • sweep (float) – wing sweep

Returns:

h_crit – critical peak-to-peak wave height

Return type:

float

e2dpolar.in_out.gather_rundir_pkls(main_dir='.', pkl_name='polar', run_dir_regex='Re\\d*.\\d{2}e6_..', outfile='polars')[source]

Gather data that is stored at run directory level, like polar.pkl. Could also be used to find and gather data files from any folder located in ‘main_dir’ that conforms with the format specified in ‘run_dir_regex’.

Parameters:
  • main_dir (string) –

    folder name of main directory in which run directories are assumed to be located

    (default: ‘.’, here)

  • pkl_name (string) –

    file name without file type located in run directory or folder format according to ‘run_dir_regex’

    (default: ‘polar’)

  • run_dir_regex (regex pattern) – pattern of folders to check in for ‘pkl_name.pkl’ files, default is run directories conforming with pyE2Dpolar run directory format.

  • outfile (string) –

    name of output file that is saved in ‘main_dir’

    (default: ‘polars’)

Returns:

out – directory holding assembled data, with keys corresponding to the run directory names from which data was assembled

Return type:

dict

e2dpolar.in_out.interp_bl_prof(xq, bl_data, bl_profiles, xq_def='x', nTE=0)[source]
e2dpolar.in_out.linear_interp(vals, ic, fc)[source]
e2dpolar.in_out.load_dict(name)[source]

Load pickle file

Parameters:

name (string) – file base name

Returns:

dat – loaded dictionary

Return type:

dict

e2dpolar.in_out.rain_impact_force(dp, aoa=0.0, u_r=100.0, d_r=0.003, rho_r=1000.0)[source]

Compute rain impact force according to Keegan et al. and Fiore et al.

Input aerofoil coordinate directional vectors and compute force at certain AoA for a certain drop size.

[1] M.H. Keegan, D.H. Nash, and M.M. Stack. “On Erosion Issues Associated With the Leading Edge of Wind Turbine Blades”. In: Journal of Physics D: Applied Physics 46.38 (2013)

[2] G. Fiore, G.E.C. Camarinha Fujiwara, and M.S. Selig. “A Damage Assessment for Wind Turbine Blades From Heavy Atmospheric Particles”. In: 53rd AIAA Aerospace Sciences Meeting. American (2015)

Parameters:
  • dp (2D-array(float)) – direction vectors between aerofoil coordinates, first column e_x, second e_y.

  • aoa (float) –

    angle-of-attack, [deg]

    (default: 0.)

  • u_r (float) –

    rain impact velocity, [m/s]

    (default: 100.)

  • d_r (float) –

    droplet diameter, [m]

    (default: 3e-3)

  • rho_r (float) –

    droplet density, [kg/m^3]

    (default: 1e3)

Returns:

  • f_r (1D-array(float)) – impact force as function of coordinate, [N]

  • angle (1D-array(float)) – impact angle as function of coordinate, [deg] 90 deg if head-on

e2dpolar.in_out.save_dict(dat, name)[source]

Save dictionary in pickle file

Parameters:
  • dat (dict) – dictionary to save

  • name (string) – file base name

e2dpolar.in_out.sec2timestr(sec)[source]

Convert seconds to time string

Parameters:

sec (float) – time period in seconds

Returns:

out – time period string in the form hh:mm:ss

Return type:

float

e2dpolar.in_out.ti_ncrit(ti=None, ncrit=None, a=-8.43, b=-2.4, c=0.025)[source]

Mack’s relationship with constants from Coder (2020), which is a slightly modified version of Drela’s; lower bound 2.5% instead of 2.7%. Preserves positive values of ‘ncrit’.

Provide ‘ti’ to get ‘ncrit’ or vice versa, constants can be modified, whereby ‘c’ sets the lower limit.

See for instance: Reza Djeddi, Coleman D. Floyd, James G. Coder and Kivanc Ekici. “Adjoint-Based Uncertainty Quantification and Calibration of RANS-Based Transition Modeling,” AIAA 2021-3036. AIAA AVIATION 2021 FORUM. August 2021.

Parameters:
  • ti (float) – turbulence intensity (not in %)

  • ncrit (float) – critical amplification factor

Returns:

out – either ‘ncrit’ or ‘ti’ depending on input

Return type:

float

e2dpolar.in_out.ti_ncrit_nsqr(ti=None, ncrit=None, a=-8.43, b=-2.4, limits=[3.0, 10.0])[source]

Mack’s relationship as used inside EllipSys by nsqr.

Provide ‘ti’ to get ‘ncrit’ or vice versa, constants can be modified, whereby ‘c’ sets the lower limit.

Parameters:
  • ti (float) – turbulence intensity (not in %)

  • ncrit (float) – critical amplification factor

Returns:

out – either ‘ncrit’ or ‘ti’ depending on input

Return type:

float

e2dpolar.in_out.timestr2sec(timestr)[source]

Convert time string to seconds

Parameters:

dat (str) – time period string in the form hh:mm:ss

Returns:

out – seconds

Return type:

float

plotting

e2dpolar.plotting.plot_aero(aoa, cl, cd, cm, color=array([0.03137255, 0.28973472, 0.57031911, 1.0]), title=None, label=None, axs=None, fig=None, alpha=0.9, lw=1, ms=4)[source]

Plot polars, figure with four panels, AoA-Cl, AoA-Cd, AoA-Cl/Cd, AoA-Cm

Parameters:
  • aoa (float) – angle-of-attack

  • cl (float) – sectional lift coefficient

  • cd (float) – sectional drag coefficient

  • cm (float) – sectional moment coefficient

  • color (1D-array(float)) – default is blue

  • title (sring) – title string (default: None)

  • label (string) – line label, (default: None)

  • axs (obj) – axes object, (default: None)

  • fig (obj) – figure object, (default: None)

  • alpha (float) – transparency level, (default: 0.9)

  • lw (float) – line width, (default: 2)

  • ms (float) – marker size (default: 5)

Returns:

  • axs (obj) – axes object

  • fig (obj) – figure object

e2dpolar.plotting.plot_airfoil(af, color=array([0.03137255, 0.28973472, 0.57031911, 1.0]), axs=None, fig=None, alpha=1.0, lw=0.5, ms=0.5)[source]

Plot airfoil coordinates

Parameters:
  • af (obj) – PGL airfoil object

  • color (1D-array(float)) – default is blue

  • axs (obj) – axes object, (default: None)

  • fig (obj) – figure object, (default: None)

  • alpha (float) – transparency level, (default: 1.0)

  • lw (float) – line width, (default: 0.5)

  • ms (float) – marker size (default: 0.5)

Returns:

  • axs (obj) – axes object

  • fig (obj) – figure object

e2dpolar.plotting.plot_bl_data(bl_data, color=array([0.03137255, 0.28973472, 0.57031911, 1.0]), xmax=0.9, title=None, label=None, axs=None, fig=None, alpha=0.9, lw=1)[source]

Plot polars, figure with four panels, AoA-Cl, AoA-Cd, AoA-Cl/Cd, AoA-Cm

Parameters:
  • aoa (float) – angle-of-attack

  • cl (float) – sectional lift coefficient

  • cd (float) – sectional drag coefficient

  • cm (float) – sectional moment coefficient

  • color (1D-array(float)) – default is blue

  • title (sring) – title string (default: None)

  • label (string) – line label, (default: None)

  • axs (obj) – axes object, (default: None)

  • fig (obj) – figure object, (default: None)

  • alpha (float) – transparency level, (default: 0.9)

  • lw (float) – line width, (default: 2)

Returns:

  • axs (obj) – axes object

  • fig (obj) – figure object

e2dpolar.plotting.plot_bl_profiles(bl_profiles, afpoints, plotvar='vt', axs=None, aflw=1, pflw=0.5, pfms=1, aflimits=None, pflimits=None)[source]

Plot boundary layer profiles

Parameters:
  • bl_profiles (dict) – boundary layer profile output data from ext_bl()

  • afpoints (2D-array(float)) – airfoil coordinates [x,y]

  • plotvar (sring) – variable to be plotted (default: ‘vt’)

  • axs (obj) – axes object, (default: None)

  • aflw (float) – airfoil section line width, (default: 1)

  • pflw (float) – bl profile line width, (default: 0.5)

  • pfms (float) – bl profile marker size, (default: 1)

  • aflimits (list(float)) – airfoil plot axes limits, (default: None)

  • pflimits (list(float)) – bl profile plot axes limits, (default: None)

Returns:

  • axs (obj) – axes object

  • fig (obj) – figure object

e2dpolar.plotting.plot_flowfield(ff, field='p', title='', limits=[-0.5, 1.5, -1.0, 1.0], axs=None, nlevels=50)[source]

Plot CFD flowfield

Parameters:
  • ff (dict) – flowfield dictionary from ext_flowfield()

  • field (string) – field name to be plotted, (default: ‘p’)

  • title (sring) – title string (default: None)

  • limits (list(float)) – axes limits, (default: [-0.5, 1.5, -1., 1.])

  • axs (obj) – axes object, (default: None)

  • nlevels (int) – no. of color levels in contour plot, (default: 50)

Returns:

  • axs (obj) – axes object

  • fig (obj) – figure object

e2dpolar.plotting.plot_force_resid(force_file=['grid', 'force'])[source]
e2dpolar.plotting.plot_profile(ax, x, q, color=array([0.03137255, 0.28973472, 0.57031911, 1.0]), alpha=0.9, lw=2, ms=5, labels=None)[source]

Plot data, q, along x

Parameters:
  • ax (obj) – axes object

  • x (1D-array(float)) – x coordinates

  • q (1D-array(float)) – y variable

  • color (1D-array(float)) – default is blue

  • alpha (float) – transparency level, (default: 0.9)

  • lw (float) – line width, (default: 2)

  • ms (float) – marker size (default: 5)

  • labels (string) – line labels, [pressure side, suction side] (default: None)

Returns:

ax – axes object

Return type:

obj

e2dpolar.plotting.plot_rain_impact(ri, axs=None, fig=None, alpha=0.9, lw=0.5, ms=5, xzoom=[-0.05, 0.05])[source]

Plot rain impact data

Parameters:
  • ri (dict) – dictionary holding rain impact data, output from rain_impact()

  • axs (obj) – axes object, (default: None)

  • fig (obj) – figure object, (default: None)

Returns:

  • axs (obj) – axes object

  • fig (obj) – figure object

e2dpolar.plotting.plot_residuals(resid_file='grid.res')[source]
e2dpolar.plotting.plot_surface(prdat, axs=None, fig=None, title=None)[source]

Plot surface data

Parameters:
  • prdat (dict) – dictionary holding surface data, output from ext_pr()

  • axs (obj) – axes object, (default: None)

  • fig (obj) – figure object, (default: None)

  • title (sring) – title string (default: None)

Returns:

  • axs (obj) – axes object

  • fig (obj) – figure object

e2dpolar.plotting.plot_trans(aoa, xtup, xtlow, cup=array([0.03137255, 0.28973472, 0.57031911, 1.0]), clow=array([0.59461745, 0.0461361, 0.07558631, 1.0]), title=None, label='', axs=None, fig=None, alpha=0.9, lw=2, ms=5)[source]

Plot variation of transition location with angle-of-attack

Parameters:
  • aoa (1D-array(float)) – angle-of-attack

  • xtup (1D-array(float)) – upper surface transition location

  • xtlow (1D-array(float)) – lower surface transition location

  • cup (1D-array(float)) – color for upper transition location, default is blue

  • clow (1D-array(float)) – color for lower transition location, default is red

  • title (sring) – title string, (default: None)

  • axs (obj) – axes object, (default: None)

  • fig (obj) – figure object, (default: None)

  • alpha (float) – transparency level, (default: 0.9)

  • lw (float) – line width, (default: 2)

  • ms (float) – marker size (default: 5)

Returns:

  • axs (obj) – axes object

  • fig (obj) – figure object