In [1]:
# Setup stuff
%load_ext autoreload
%autoreload 2
import io
import base64
from IPython.display import HTML
from importlib.machinery import SourceFileLoader
%matplotlib inline
import os
talk_dir = os.getcwd()
import matplotlib.pyplot as plt
import seaborn as sns
from pxl.styleplot import set_sns
# Set plot styling
set_sns(context="talk", rc={"lines.markersize": 14, "lines.markeredgewidth": 2, "axes.grid": True,
"font.size": 1.5*14.3})
# Define some directories
exp_dir = "C:/Users/Pete/Research/Experiments"
rvat_baseline_dir = "C:/Users/Pete/Research/Experiments/RVAT baseline"
rvat_re_dep_dir = os.path.join(exp_dir, "RVAT Re dep")
def embed_video(fpath):
video = io.open(fpath, 'r+b').read()
encoded = base64.b64encode(video)
return HTML(data='''<center><video controls loop>
<source src="data:video/mp4;base64,{0}" type="video/mp4" />
</video></center>'''.format(encoded.decode('ascii')))
In [2]:
import warnings
warnings.filterwarnings("ignore")
os.chdir(os.path.join(os.path.expanduser("~"), "Google Drive", "Research", "CFT-vectors"))
import cft_vectors
fig, ax = plt.subplots(figsize=(15, 15))
old_fontsize = plt.rcParams["font.size"]
plt.rcParams["font.size"] *= 1.5
cft_vectors.plot_diagram(fig, ax, theta_deg=52, axis="off", label=True)
os.chdir(talk_dir)
plt.rcParams["font.size"] = old_fontsize
In [3]:
# Generate figures from the experiments by their own methods
os.chdir("C:/Users/Pete/Research/Experiments/RVAT baseline")
import py_rvat_baseline.plotting as rvat_baseline
fig, (ax1, ax2) = plt.subplots(figsize=(14, 5), nrows=1, ncols=2)
rvat_baseline.plot_cp(ax1)
rvat_baseline.plot_cd(ax2, color=sns.color_palette()[2])
fig.tight_layout()
In [4]:
os.chdir(rvat_baseline_dir)
rvat_baseline.plotwake("meancontquiv", scale=1.8)
rvat_baseline.plotwake("kcont", scale=1.8)
In [5]:
os.chdir("C:/Users/Pete/Research/Experiments/RVAT baseline")
import py_rvat_baseline.plotting as rvat_baseline
rvat_baseline.plotwake("mombargraph", scale=1.8, barcolor=None)
plt.grid(True)
In [6]:
os.chdir("C:/Users/Pete/Research/Experiments/RVAT baseline")
import py_rvat_baseline.plotting as rvat_baseline
rvat_baseline.plotwake("Kbargraph", scale=1.8, barcolor=sns.color_palette()[1])
plt.grid(True)
In [7]:
os.chdir(rvat_re_dep_dir)
import py_rvat_re_dep.plotting as rvat_re_dep
fig, (ax1, ax2) = plt.subplots(figsize=(15, 6.5), nrows=1, ncols=2)
rvat_re_dep.plot_perf_curves(ax1, ax2)
fig.tight_layout()
In [8]:
os.chdir(rvat_re_dep_dir)
import py_rvat_re_dep.plotting as rvat_re_dep
fig, (ax1, ax2) = plt.subplots(figsize=(14, 6), nrows=1, ncols=2)
rvat_re_dep.plot_perf_re_dep(ax1, ax2)
fig.tight_layout()
In [9]:
os.chdir(rvat_re_dep_dir)
import py_rvat_re_dep.plotting as rvat_re_dep
fig, ax = plt.subplots(figsize=(13, 7))
rvat_re_dep.make_mom_bar_graph(ax, print_analysis=False)
fig.tight_layout()
In [10]:
os.chdir(rvat_re_dep_dir)
import py_rvat_re_dep.plotting as rvat_re_dep
fig, ax = plt.subplots()
rvat_re_dep.plot_wake_trans_totals(ax, emptymarkers=False, ucolor=sns.color_palette()[0],
kcolor=sns.color_palette()[1])
fig.tight_layout()
In [11]:
import warnings
warnings.filterwarnings("ignore")
os.chdir(os.path.join(os.path.expanduser("~"), "Google Drive", "Research", "CFT-vectors"))
import cft_vectors
fig, ax = plt.subplots(figsize=(15, 15))
old_fontsize = plt.rcParams["font.size"]
plt.rcParams["font.size"] *= 1.5
cft_vectors.plot_diagram(fig, ax, theta_deg=52, axis="off", label=True)
os.chdir(talk_dir)
plt.rcParams["font.size"] = old_fontsize
turbinesFoamAL force added to Navier–Stokes as body force source term at element positions:
$$ \frac{\partial \vec{u}}{\partial t} + \vec{u} \cdot \nabla \vec{u} = -\frac{1}{\rho}\nabla p + \nabla^2 \vec{u} + \boxed{\vec{f}} $$Force is smoothed outwards with a spherical Gaussian function to avoid numerical instability.
OpenFOAM extension library using fvOptions generic mechanism for adding sources at run time:
// Solve the Momentum equation
tmp<fvVectorMatrix> UEqn
(
fvm::ddt(U)
+ fvm::div(phi, U)
+ turbulence->divDevReff(U)
==
fvOptions(U)
);
Leverage existing solvers, parallelization, turbulence models. No wheel reinvention.