Ejemplo n.º 1
0
    R12b = -dns.uv*utau*utau
    
    f = interp1d(ydns, ub)
    qtarget[::6] = f(eqn.y)
    f = interp1d(ydns, R11b)
    qtarget[1::6] = f(eqn.y)
    f = interp1d(ydns, R12b)
    qtarget[2::6] = f(eqn.y)
    f = interp1d(ydns, R22b)
    qtarget[3::6] = f(eqn.y)
    f = interp1d(ydns, R33b)
    qtarget[4::6] = f(eqn.y)
    
        
    beta_map = eqn.beta[:]
    eqn.objective = BayesianObjectiveStats(qtarget, beta_prior, sigma_obs, sigma_prior)

    n = np.size(qtarget)/6
    try:
        dat = io.loadmat("H.mat")
        H = data["H"]
        print 1000*"#"
        print "Using Hessian from file"
    except:
        njac = 10
        Jac = np.zeros([njac, 4*n])
        for i in range(njac):
            print "\rBuilding jac %i of %i"%(i, 5*n),
            sys.stdout.flush()
            eqn.objective.set_index(i)
            dJdbeta = eqn.calc_sensitivity()
up_prior = eqn.up.copy()

dns = np.loadtxt("data/DNSsol.dat")
utau = Retau*eqn.nu*2.0
ydns = dns[:,0]*0.5
udns = dns[:,2]*utau
f = interp1d(ydns, udns)
utarget = f(eqn.y)



beta_prior = eqn.beta.copy()
sigma_obs = 1e-10
sigma_prior = 1.0

eqn.objective = BayesianObjectiveU(utarget, beta_prior, sigma_obs, sigma_prior)
inverse_solver = InverseSolver(eqn)
inverse_solver.maxiter = 10
inverse_solver.stepsize = 0.1
inverse_solver.algo = "gn"
eqn = inverse_solver.solve()

plt.figure(11)
plt.semilogx(eqn.yp, up_prior, 'g-', label=r'Prior')
plt.semilogx(eqn.yp, eqn.up, 'r-', label=r'Posterior')
plt.semilogx(eqn.yp[::5], utarget[::5]/utau, 'b.', label=r'DNS')
plt.xlabel(r"$y^+$")
plt.ylabel(r"$u^+$")
plt.legend(loc=2)
plt.tight_layout()
plt.savefig("figs/inverse_matchu_u.pdf")