-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtime_pde_heating_ipopt_fixedT.jl
84 lines (61 loc) · 2.6 KB
/
time_pde_heating_ipopt_fixedT.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using DynamicNLPModels, NLPModels, Random, LinearAlgebra
using DelimitedFiles, SparseArrays, NLPModelsIpopt
using QuadraticModels, DataFrames, JLD, Printf
include("PDE_boundary_3d_heating.jl")
function time_PDE(lqdm_list, kkt_system, algorithm, device)
lens = length(lqdm_list)
t = zeros(lens)
f = zeros(lens)
iters = zeros(lens)
status = []
ips_tt = zeros(lens)
ips_st = zeros(lens)
ips_eft = zeros(lens)
ips_lst = zeros(lens)
for i in 1:length(lqdm_list)
lqdm = lqdm_list[i]
iters[i], t[i], s, f[i], ips_tt[i], ips_st[i], ips_eft[i], ips_lst[i] = solve_PDE(lqdm, kkt_system, algorithm, device)
push!(status, s)
end
return t, iters, status, f, ips_tt, ips_st, ips_eft, ips_lst
end
function solve_PDE(lqdm, kkt_system, algorithm, device)
N = lqdm.dynamic_data.N
ns = lqdm.dynamic_data.ns
for i in 1:2
if device == 1
sol_ref = ipopt(lqdm; output_file = "output_files/cpu_sparse_nz_range_ns$(ns)_T$(N)", linear_solver="ma27", print_timing_statistics="yes")
if i == 2
return sol_ref.iter, sol_ref.elapsed_time, sol_ref.status, sol_ref.objective, 0, 0, 0, 0
end
end
end
end
function build_lqdm(N_range, nx_range, lenx, dt, Tmax, Tstart; dense::Bool = true)
lqdm_list = []
for i in N_range
for j in nx_range
@time lqdm = build_3D_PDE(i, j, lenx, dt, Tmax, Tstart; dense = dense)
push!(lqdm_list, lqdm)
println("Done with T = $i and nx = $j")
end
end
return lqdm_list
end
function run_timers(N_range, nx_range, file_name1, n_vals, lenx, dt, Tmax, Tstart)
lqdm_list_sparse = build_lqdm(N_range, nx_range, lenx, dt, Tmax, Tstart; dense=false)
stats = Dict{Symbol, DataFrame}()
tcpu, kcpu, scpu, fcpu, ttcpu, stcpu, eftcpu, lstcpu = time_PDE(lqdm_list_sparse, MadNLP.SPARSE_KKT_SYSTEM, 0, 1)
df = DataFrame(name = [@sprintf("prof%03d", i) for i = 1:length(tcpu)], f = fcpu, t = tcpu, status = scpu, iter = kcpu, tot_time = ttcpu, sol_time = stcpu, fun_eval_time = eftcpu, lin_sol_time = lstcpu, n_vals = n_vals)
stats[:CPU_MA27] = df
JLD.save(file_name1, "data", stats)
end
N_range = 250
nx_range = [4, 5, 6, 7, 8]
run_timers(N_range, nx_range, "output_files/T250_sparse.jld", nx_range, .02, .5, 350., 300.)
N_range = 150
nx_range = [4, 5, 6, 7, 8, 9]
run_timers(N_range, nx_range, "output_files/T150_sparse.jld", nx_range, .02, .5, 350., 300.)
N_range = 50
nx_range = [4, 5, 6, 7, 8, 9]
run_timers(N_range, nx_range, "output_files/T50_sparse.jld", nx_range, .02, .5, 350., 300.)