Skip to content

Instantly share code, notes, and snippets.

@greenty5
Last active February 14, 2021 06:36
Show Gist options
  • Save greenty5/75b4ff0763bbf03aae48e26863d03601 to your computer and use it in GitHub Desktop.
Save greenty5/75b4ff0763bbf03aae48e26863d03601 to your computer and use it in GitHub Desktop.
"""
calculation code for turbulence initial condition
"""
import numpy as np
import matplotlib.pyplot as plt
import scipy.interpolate as interpolate
class Water:
def __init__(self,temp):
if temp >40 or temp <-10: print("temp. range of air is between 0 and 50 -C\n")
self._temp = temp
self._table = np.array([0, 10, 20, 30, 40, 50]) # [-C]
self._rho = np.array([999.89, 999.69, 998.22, 995.67, 992.24, 988.02]) # [kg/m3]
self._mu = np.array([1.729e-3, 1.307e-3, 1.004e-3, 0.801e-3, 0.658e-3, 0.554e-3]) #[Pa-s]
def rho(self):
func_rho = interpolate.interp1d(self._table, self._rho, kind='cubic')
return func_rho(self._temp)
def mu(self):
func_mu = interpolate.interp1d(self._table, self._mu, kind='cubic')
return func_mu(self._temp)
def nu(self):
return self.mu()/self.rho()
class Air:
def __init__(self,temp):
if temp >40 or temp <-10: print("temp. range of air is between -10 and 40 -C\n")
self._temp = temp
self._table = np.array([-10, 0, 10, 20, 30, 40]) #[-C]
self._rho = np.array([1.342, 1.293, 1.247, 1.205, 1.165, 1.128]) #[kg/m3]
self._mu = np.array([1.673e-5, 1.724e-5, 1.772e-5, 1.822e-5, 1.869e-5, 1.915e-5]) #[Pa-s]
def rho(self):
func_rho = interpolate.interp1d(self._table, self._rho, kind='cubic')
return func_rho(self._temp)
def mu(self):
func_mu = interpolate.interp1d(self._table, self._mu, kind='cubic')
return func_mu(self._temp)
def nu(self):
return self.mu()/self.rho()
# +*+*+*+*
tIntensity = 0.05 # turbulent intensity [-]
cmu = 0.09
U = 0.04568 # [m/s]
cLength = 1.0 # characteristic length [m]
# +*+*+*+*
# air = Air(20)
water = Water(20)
rho = water.rho()
mu = water.mu()
tKineticEnergy = 3.0/2.0 * pow(U*tIntensity, 2.0)
mLength = 0.07 * cLength # mixing length
epsilon = pow(tKineticEnergy,3/2) * pow(tKineticEnergy, 3/2) / mLength
omega = pow(tKineticEnergy, 1/2) / pow(cmu, 1/4) / mLength
print(tKineticEnergy, epsilon)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment