-
Notifications
You must be signed in to change notification settings - Fork 8
/
inversion_l2.jl
37 lines (28 loc) · 1.14 KB
/
inversion_l2.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# this is for the 41-120 iteration with cg algorithm
using Printf
@printf "Initializing...\n"
@everywhere include("code/acoustic_solver_parallel.jl")
@everywhere include("code/adjoint_method.jl")
@everywhere include("code/optimization.jl")
@everywhere begin
@printf "Loading...\n"
@load "temp_data/data.jld2"
u0 = copy(c)
@printf "Preparing optimization function handle...\n"
eval_fn(x) = obj_func_l2(received_data, x, rho, Nx, h, Ny, h, Nt, dt, source, source_position, receiver_position; pml_len=pml_len, pml_coef=pml_coef);
eval_grad(x) = grad_l2(received_data, x, rho, Nx, h, Ny, h, Nt, dt, source, source_position, receiver_position; pml_len=pml_len, pml_coef=pml_coef);
@printf "Initializing optimization ...\n"
min_value = 0
max_value = 10
# alpha = 1e-8
# alpha = 1e7
alpha = 9e6
iterNum = 20
rrho = 0.2
cc = 1e-10
maxSearchTime = 5
x0 = reshape(c, Nx*Ny, 1);
end
println("Start nonlinear CG.")
xk, fn = nonlinear_cg(eval_fn, eval_grad, x0, alpha, iterNum, min_value, max_value; rho=rrho, c=cc, maxSearchTime=maxSearchTime, threshold=1e-10);
@save "ex4_l2_result.jld2" xk