<jupyter_start><jupyter_text>Plot forces for flow past cylinder grid0 case, old BC<jupyter_code>%%capture
import sys
sys.path.insert(1, '../utilities')
import litCdData
import numpy as np
import matplotlib.pyplot as plt
# Basic problem parameters
D     = 6            # Cylinder diameter
U     = 20           # Freestream velocity
Lspan = 24           # Spanwise length
A     = D*Lspan      # frontal area
rho   = 1.225        # density
Q     = 0.5*rho*U*U  # Dynamic head
vis   = 1.8375e-5    # viscosity
ReNum = rho*U*D/vis  # Reynolds number

avgt = [160.0, 260.0] # Average times
saveinfo = True
# Load the force data
force01  = np.loadtxt('forces01.dat', skiprows=1)
force02  = np.loadtxt('forces02.dat', skiprows=1)
forcedat = np.vstack((force01, force02))
t        = forcedat[:,0]*U/D  # Non-dimensional time
# Calculate the Cl, Cd
Cd = (forcedat[:,1]+forcedat[:,4])/(Q*A)
Cl = (forcedat[:,2]+forcedat[:,5])/(Q*A)
# Calculate time average
def timeaverage(time, f, t1, t2):
    filt = ((time[:] >= t1) & (time[:] <= t2))
    # Filtered time
    t     = time[filt]
    # The total time
    dt = np.amax(t) - np.amin(t)
    #  Filtered field
    filtf = f[filt]
     # Compute the time average as an integral
    avg = np.trapz(filtf, x=t, axis=0) / dt
    return avg
# Calculate averaged Cp, Cd
avgCd = timeaverage(t, Cd, avgt[0], avgt[1])
avgCl = timeaverage(t, Cl, avgt[0], avgt[1])
print("Avg Cd = %f"%avgCd)
print("Avg Cl = %f"%avgCl)<jupyter_output>Avg Cd = 0.557448
Avg Cl = 0.015747<jupyter_text>Plot Lift and Drag coefficients<jupyter_code>plt.rc('font', size=16)
plt.figure(figsize=(10,8))
plt.plot(t,Cd)
plt.hlines(avgCd, np.min(t), np.max(t), linestyles='dashed', linewidth=1)
plt.xlabel(r'Non-dimensional time $t U_{\infty}/D$');
plt.ylabel('$C_D$')
plt.title('Drag coefficient $C_D$');
plt.figure(figsize=(10,8))
plt.plot(t,Cl)
plt.hlines(avgCl, np.min(t), np.max(t), linestyles='dashed', linewidth=1)
plt.xlabel(r'Non-dimensional time $t U_{\infty}/D$');
plt.ylabel('$C_l$')
plt.title('Lift coefficient $C_l$');<jupyter_output><empty_output><jupyter_text>Plot Cd versus Reynolds number<jupyter_code>plt.figure(figsize=(10,8))
litCdData.plotEXP()
litCdData.plotCFD()
plt.semilogx(ReNum, avgCd, '*', color='k',  ms=10, label='Nalu SST-IDDES')
plt.grid()
plt.legend()

plt.xlabel(r'Reynolds number Re');
plt.ylabel('$C_D$')
plt.title('Drag coefficient $C_D$');
# Write the YAML file these averaged quantities
import yaml
if saveinfo:
    savedict={'Re':float(ReNum), 'avgCd':float(avgCd), 'avgCl':float(avgCl)}
    f=open('istats.yaml','w')
    f.write('# Averaged quantities from %f to %f\n'%(avgt[0], avgt[1]))
    f.write('# Grid: grid0\n')
    f.write(yaml.dump(savedict, default_flow_style=False))
    f.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17378711078928313, 'fraction_numerical': 0.031498913830557564, 'mean_word_length': 4.375486381322958, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '225017', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1189, 'n_tokens_neox': 1095, 'n_words': 240, 'path': 'cylinder/cylgrid0_sst_iddes_matula_01/plotForces.ipynb', 'repo_name': 'Exawind/iddes', 'size': '2762'}