Exemplo n.º 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()
Exemplo n.º 2
0
#!/bin/py
#
# run the channel and create plots comparable to keefe (92)
#
import os
import sys
sys.path.append("..")
import channel 

# for plotting
import pylab as pl
import numpy as np

# reynolds number
channel.Re=2000

# invoke init
channel.init(100, 0, None)

C = channel.get_solution(0) * 0
channel.primal(C)

y, w = channel.quad()

for i in [0, 2, 10, 40, 100]:
    u = channel.spec2phys(i)
    pl.plot(y, u[0].mean(0).mean(1), '.-')

Exemplo n.º 3
0
# 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()

# run adjoint
print('adjoint')
channel.adjoint(n_steps-1, 1, AC, 0, strength=0.0)
print('done')

y, w = channel.quad()

Au = channel.spec2phys(AC)
Au0 = channel.spec2phys(AC0)
Iu = channel.spec2phys(IC)
Iu0 = channel.spec2phys(IC0)

print((Au0 * Iu * w[:,newaxis]).sum())
print((Au * Iu0 * w[:,newaxis]).sum())

# run adjoint again
AC1 = zeros_like(AC0)
print('adjoint again')
channel.adjoint(n_steps-1, 1, AC1, 0, strength=1.0)
print('done')

Au1 = channel.spec2phys(AC1)
print((Au1 * Iu0 * w[:,newaxis]).sum())