Example #1
0
import sys
sys.path.append("..")
import channel
from numpy import *

# TANGENT WITH FORCING
Re = 200
dRe = 1E-6
ru_steps = 0
n_steps = int(sys.argv[1])
i_restart = int(sys.argv[2])
restart = 'keefe_runup_stage_5.hd5' if i_restart else None
channel.dt = 0.01
channel.meanU = 1.0
channel.Re = Re
channel.init(n_steps, ru_steps, restart=restart)

# tangent 
IC = zeros_like(channel.get_solution(0))
channel.tangent(0, n_steps, IC, 1)

from pylab import *
y, w = channel.quad()
IU = channel.spec2phys(IC)
plot(y, IU[0].mean(0).mean(1))
savefig('testTanManu{0:06d}_restart{1:1d}'.format(n_steps, restart is not None))

# channel.destroy()
Example #2
0
# Primal
n_steps = 100

channel.Re = 2000
channel.init(n_steps, ru_steps=0, restart=restart_file) # turbulent

# channel.Re = 100
# channel.init(n_steps, ru_steps=0, restart=None) # laminar
C = channel.get_solution(0)

# perturbation
IC = zeros(C.shape, complex)
IC[0,0,:,0] = random.normal(size=C.shape[2])
IC = random.normal(size=C.shape) + 0j
channel.tangent(0, 1, IC, 0)
IC0 = IC.copy()

# run tangent
print('tangent')
channel.tangent(1, n_steps-1, IC, 0)
IC_tmp = IC.copy()
channel.tangent(n_steps-1, n_steps, IC_tmp, 0)
print('done')

# linear functional
AC = zeros(C.shape, complex)
AC[0,0,:,0] = random.normal(size=C.shape[2])
AC = random.normal(size=C.shape) + 0j
channel.adjoint(n_steps, n_steps-1, AC, 0, strength=0.0)
AC0 = AC.copy()