Skip to content

Commit

Permalink
updated figures
Browse files Browse the repository at this point in the history
  • Loading branch information
vpuri3 committed Jul 1, 2024
1 parent f5cd27d commit 15d0b37
Show file tree
Hide file tree
Showing 48 changed files with 102 additions and 63 deletions.
1 change: 1 addition & 0 deletions experiments_SNFROM/smoothNF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ function evolve_SNF(
end

plrnd = begin
# FIX: want [N_ROM, NT]
_data, _, _ = makedata_SNF(datafile; Ix = [1,], _Ib = [case], verbose)
_prm = _data[1][2]
hyper[1](_prm, hyper[2], hyper[3])[1] # [N_ROM, N_CASES]
Expand Down
8 changes: 0 additions & 8 deletions figs/Project.toml

This file was deleted.

156 changes: 101 additions & 55 deletions figs/makefigs_SNFROM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ function makeplots(
ifdt::Bool = false,
)

mkpath(outdir)

data = h5open(datafile)
xFOM = data["xFOM"] |> Array # [in_dim, grid...]
tFOM = data["tFOM"] |> Array # [Nt]
Expand Down Expand Up @@ -63,6 +65,8 @@ function makeplots(
nothing, nothing, nothing, nothing, nothing
end

close(data)

#======================================================#

in_dim = size(xFOM, 1)
Expand All @@ -81,7 +85,7 @@ function makeplots(
i1, i2 = Itplt[2], Itplt[5]

## normalize
nr = sum(abs2, uFOM; dims = 2:in_dim+1) ./ Nxyz .|> sqrt
nr = sum(abs2, uFOM; dims = 1:in_dim+1) ./ Nfom .|> sqrt

ePCA = (uFOM - uPCA) ./ nr
eCAE = (uFOM - uCAE) ./ nr
Expand Down Expand Up @@ -447,11 +451,14 @@ function makeplots(
end
#======================================================#

function makeplots_exp3(
datafiles::String...;
function makeplots_parametric(
datafiles::NTuple{N, String},
outdir::String,
ifdt::Bool = false,
)
casename::String,
) where{N}

mkpath(outdir)

figp = Figure(; size = (1200, 400), backgroundcolor = :white, grid = :off)
fige = Figure(; size = (1200, 400), backgroundcolor = :white, grid = :off)

Expand Down Expand Up @@ -482,16 +489,28 @@ function makeplots_exp3(
# FIGP
#===============================#

labels = (
L"$\mu = 0.500$ (Training)",
L"$\mu = 0.525$ (Interpolation)",
L"$\mu = 0.550$ (Training)",
L"$\mu = 0.575$ (Interpolation)",
L"$\mu = 0.600$ (Training)",
L"$\mu = 0.625$ (Extrapolation)",
)
labels = if occursin("exp3", casename)
(
L"$\mu = 0.500$ (Training)",
L"$\mu = 0.525$ (Interpolation)",
L"$\mu = 0.550$ (Training)",
L"$\mu = 0.575$ (Interpolation)",
L"$\mu = 0.600$ (Training)",
L"$\mu = 0.625$ (Extrapolation)",
)
elseif occursin("exp4", casename)
(
L"$\mu = 0.900$ (Training)",
L"$\mu = 0.933$ (Training)",
L"$\mu = 0.966$ (Training)",
L"$\mu = 1.000$ (Interpolation)",
L"$\mu = 1.033$ (Training)",
L"$\mu = 1.066$ (Training)",
L"$\mu = 1.100$ (Training)",
)
end

colors = (:blue, :orange, :green, :red, :purple, :brown,)
colors = (:blue, :orange, :green, :red, :purple, :brown, :magenta)

for (i, datafile) in enumerate(datafiles)
data = h5open(datafile)
Expand All @@ -505,6 +524,10 @@ function makeplots_exp3(
qSNL = data["qSNL"] |> Array
qSNW = data["qSNW"] |> Array

@show size(pCAE), size(qCAE)
@show size(pSNL), size(qSNL) # wrong size.
@show size(pSNW), size(qSNW) # wrong size.

color = colors[i]
label = labels[i]
sckwq = (; color, markersize = 15, marker = :star5,)
Expand Down Expand Up @@ -543,7 +566,7 @@ function makeplots_exp3(

ylims!(axp1, -8, 20)

save(joinpath(outdir, "exp3p.pdf"), figp)
save(joinpath(outdir, "$(casename)p.pdf"), figp)

#===============================#
# FIGE
Expand All @@ -553,29 +576,38 @@ function makeplots_exp3(
styles = (:solid, :dash, :dashdot, :dashdotdot, :dot)
labels = (L"POD-ROM$$", L"CAE-ROM$$", L"SNFL-ROM$$", L"SNFW-ROM$$",)

in_dim, out_dim = 1, 1
Nxyz = 1024
in_dim, out_dim, grid = if occursin("exp3", casename)
1, 1, (1024,)
elseif occursin("exp4", casename)
2, 2, (512, 512)
end

Nxyz = prod(grid)
Nfom = Nxyz * out_dim

for (j, datafile) in enumerate(datafiles[4:6])
data = h5open(datafile)
tFOM = Array(data["tFOM"])
uFOM = Array(data["uFOM"])[1, :, :]
uPCA = Array(data["uPCA"])[1, :, :]
uCAE = Array(data["uCAE"])[1, :, :]
uSNL = Array(data["uSNL"])[1, :, :]
uSNW = Array(data["uSNW"])[1, :, :]

nr = sum(abs2, uFOM; dims = 1:in_dim) ./ prod(size(uFOM)[1:in_dim]) .|> sqrt
tFOM = data["tFOM"] |> Array
uFOM = data["uFOM"] |> Array
uPCA = data["uPCA"] |> Array
uCAE = data["uCAE"] |> Array
uSNL = data["uSNL"] |> Array
uSNW = data["uSNW"] |> Array

close(data)

nr = sum(abs2, uFOM; dims = 1:in_dim+1) ./ Nfom .|> sqrt

ePCA = (uFOM - uPCA) ./ nr
eCAE = (uFOM - uCAE) ./ nr
eSNL = (uFOM - uSNL) ./ nr
eSNW = (uFOM - uSNW) ./ nr

e2tPCA = sum(abs2, ePCA; dims = 1:in_dim) / Nxyz |> vec
e2tCAE = sum(abs2, eCAE; dims = 1:in_dim) / Nxyz |> vec
e2tSNL = sum(abs2, eSNL; dims = 1:in_dim) / Nxyz |> vec
e2tSNW = sum(abs2, eSNW; dims = 1:in_dim) / Nxyz |> vec
e2tPCA = sum(abs2, ePCA; dims = 1:in_dim+1) / Nfom |> vec
e2tCAE = sum(abs2, eCAE; dims = 1:in_dim+1) / Nfom |> vec
e2tSNL = sum(abs2, eSNL; dims = 1:in_dim+1) / Nfom |> vec
e2tSNW = sum(abs2, eSNW; dims = 1:in_dim+1) / Nfom |> vec

e2tPCA = sqrt.(e2tPCA) .+ 1f-12
e2tCAE = sqrt.(e2tCAE) .+ 1f-12
Expand Down Expand Up @@ -616,7 +648,7 @@ function makeplots_exp3(
colsize!(fige.layout, 2, Relative(0.33))
colsize!(fige.layout, 3, Relative(0.33))

save(joinpath(outdir, "exp3e.pdf"), fige)
save(joinpath(outdir, "$(casename)e.pdf"), fige)

nothing
end
Expand Down Expand Up @@ -664,10 +696,13 @@ end
#======================================================#
function makeplots_hyper(
e2hyper::String,
outdir::String,
casename::String,
)
### Get fields

mkpath(outdir)

# Get fields
grid = if occursin("exp2", casename)
128, 128
elseif occursin("exp4", casename)
Expand Down Expand Up @@ -719,18 +754,18 @@ function makeplots_hyper(
e3 = Tuple(sqrt(sum(abs2, epreds[k]) / length(udata)) for k in k3)
e4 = Tuple(sqrt(sum(abs2, epreds[k]) / length(udata)) for k in k4)

@show round.(e1 .* 100, sigdigits = 4)
@show round.(e2 .* 100, sigdigits = 4)
@show round.(e3 .* 100, sigdigits = 4)
@show round.(e4 .* 100, sigdigits = 4)
# @show round.(e1 .* 100, sigdigits = 4)
# @show round.(e2 .* 100, sigdigits = 4)
# @show round.(e3 .* 100, sigdigits = 4)
# @show round.(e4 .* 100, sigdigits = 4)

println()

t1 = Tuple(times[k] for k in k1)
t2 = Tuple(times[k] for k in k2)
t3 = Tuple(times[k] for k in k3)
t4 = Tuple(times[k] for k in k4)

nn = 1024^3

m1 = Tuple(mems[k] for k in k1) ./ nn
Expand All @@ -757,9 +792,9 @@ function makeplots_hyper(
# @show round.(m3, sigdigits = 4)
# @show round.(m4, sigdigits = 4)

println()

return df
# println()
#
# return df

### Make plots

Expand Down Expand Up @@ -931,8 +966,8 @@ function makeplots_hyper(
colsize!(figc.layout, 5, Relative(0.19))

# save
save(joinpath(outdir, "hyper_$(casename)_c.pdf"), figc)
save(joinpath(outdir, "hyper_$(casename)_e.pdf"), fige)
# save(joinpath(outdir, "hyper_$(casename)_c.pdf"), figc)
# save(joinpath(outdir, "hyper_$(casename)_e.pdf"), fige)
save(joinpath(outdir, "hyper_$(casename)_p.pdf"), figp)

return df
Expand All @@ -942,37 +977,48 @@ end
outdir = joinpath(@__DIR__, "results")
datadir = joinpath(@__DIR__, "datafiles")

# EXP 1, 2, 5
e1file = joinpath(datadir, "advect1d.h5")
e2file = joinpath(datadir, "advect2d.h5")
e4file = joinpath(datadir, "burgers2d.h5")
e5file = joinpath(datadir, "ks1d.h5")

# EXP 3
e3file1 = joinpath(datadir, "burgers1dcase1.h5")
e3file2 = joinpath(datadir, "burgers1dcase2.h5")
e3file3 = joinpath(datadir, "burgers1dcase3.h5")
e3file4 = joinpath(datadir, "burgers1dcase4.h5")
e3file5 = joinpath(datadir, "burgers1dcase5.h5")
e3file6 = joinpath(datadir, "burgers1dcase6.h5")

e3files = (e3file1, e3file2, e3file3, e3file4, e3file5, e3file6)

# EXP 4
e4file1 = joinpath(datadir, "burgers2dcase1.h5")
e4file2 = joinpath(datadir, "burgers2dcase2.h5")
e4file3 = joinpath(datadir, "burgers2dcase3.h5")
e4file4 = joinpath(datadir, "burgers2dcase4.h5")
e4file5 = joinpath(datadir, "burgers2dcase5.h5")
e4file6 = joinpath(datadir, "burgers2dcase6.h5")
e4file7 = joinpath(datadir, "burgers2dcase7.h5")
e4files = (e4file1, e4file2, e4file3, e4file4, e4file5, e4file6, e4file7)

# # EXP 1, 2, 5
# makeplots(e1file, outdir, "exp1"; ifdt = true)
# makeplots(e2file, outdir, "exp2"; ifdt = false)
# makeplots(e4file, outdir, "exp4")
# makeplots(e5file, outdir, "exp5")
# makeplots(e5file, outdir, "exp5"; ifdt = false)
#
# # EXP 3
# makeplots(e3file4, outdir, "exp3case4")
# makeplots(e3file5, outdir, "exp3case5")
# makeplots_exp3(e3file1, e3file2, e3file3, e3file4, e3file5, e3file6; outdir)

e4case4file = joinpath(datadir, "burgers2dcase4.h5")
e4case5file = joinpath(datadir, "burgers2dcase5.h5")
# makeplots_parametric(e3files, outdir, "exp3")

makeplots(e4case4file, outdir, "exp4case4")
makeplots(e4case5file, outdir, "exp4case5")
# # EXP 4
# makeplots(e4file4, outdir, "exp4case4")
makeplots_parametric(e4files, outdir, "exp4")

e2hyper = joinpath(@__DIR__, "..", "experiments_SNFROM", "advect_fourier2D", "dump", "hypercompiled.jld2")
e4hyper = joinpath(@__DIR__, "..", "experiments_SNFROM", "burgers_fourier2D", "dump", "hypercompiled.jld2")

# df_exp2 = makeplots_hyper(e2hyper, "exp2")
# df_exp4 = makeplots_hyper(e4hyper, "exp4")
# e2hyper = joinpath(@__DIR__, "..", "experiments_SNFROM", "advect_fourier2D", "dump", "hypercompiled.jld2")
# e4hyper = joinpath(@__DIR__, "..", "experiments_SNFROM", "burgers_fourier2D", "dump", "hypercompiled.jld2")
#
# df_exp2 = makeplots_hyper(e2hyper, outdir, "exp2")
# df_exp4 = makeplots_hyper(e4hyper, outdir, "exp4")
#======================================================#
nothing
Binary file modified figs/results/exp1p1.pdf
Binary file not shown.
Binary file modified figs/results/exp1p2.pdf
Binary file not shown.
Binary file modified figs/results/exp1p4.pdf
Binary file not shown.
Binary file modified figs/results/exp1p5.pdf
Binary file not shown.
Binary file modified figs/results/exp2p1.pdf
Binary file not shown.
Binary file modified figs/results/exp2p2.pdf
Binary file not shown.
Binary file modified figs/results/exp2p3.pdf
Binary file not shown.
Binary file modified figs/results/exp2p4.pdf
Binary file not shown.
Binary file modified figs/results/exp2p5.pdf
Binary file not shown.
Binary file modified figs/results/exp3case4p1.pdf
Binary file not shown.
Binary file modified figs/results/exp3case4p2.pdf
Binary file not shown.
Binary file modified figs/results/exp3case4p4.pdf
Binary file not shown.
Binary file modified figs/results/exp3case4p5.pdf
Binary file not shown.
Binary file modified figs/results/exp3case5p1.pdf
Binary file not shown.
Binary file modified figs/results/exp3case5p2.pdf
Binary file not shown.
Binary file modified figs/results/exp3case5p4.pdf
Binary file not shown.
Binary file modified figs/results/exp3case5p5.pdf
Binary file not shown.
Binary file modified figs/results/exp3e.pdf
Binary file not shown.
Binary file modified figs/results/exp3p.pdf
Binary file not shown.
Binary file modified figs/results/exp4case4p1.pdf
Binary file not shown.
Binary file modified figs/results/exp4case4p2.pdf
Binary file not shown.
Binary file modified figs/results/exp4case4p3.pdf
Binary file not shown.
Binary file modified figs/results/exp4case4p4.pdf
Binary file not shown.
Binary file modified figs/results/exp4case4p5.pdf
Binary file not shown.
Binary file removed figs/results/exp4case5p1.pdf
Binary file not shown.
Binary file removed figs/results/exp4case5p2.pdf
Binary file not shown.
Binary file removed figs/results/exp4case5p3.pdf
Binary file not shown.
Binary file removed figs/results/exp4case5p4.pdf
Binary file not shown.
Binary file removed figs/results/exp4case5p5.pdf
Binary file not shown.
Binary file added figs/results/exp4e.pdf
Binary file not shown.
Binary file added figs/results/exp4p.pdf
Binary file not shown.
Binary file removed figs/results/exp4p1.pdf
Binary file not shown.
Binary file removed figs/results/exp4p2.pdf
Binary file not shown.
Binary file removed figs/results/exp4p3.pdf
Binary file not shown.
Binary file removed figs/results/exp4p4.pdf
Binary file not shown.
Binary file removed figs/results/exp4p5.pdf
Binary file not shown.
Binary file modified figs/results/exp5p1.pdf
Binary file not shown.
Binary file modified figs/results/exp5p2.pdf
Binary file not shown.
Binary file modified figs/results/exp5p5.pdf
Binary file not shown.
Binary file removed figs/results/hyper_exp2_c.pdf
Binary file not shown.
Binary file removed figs/results/hyper_exp2_e.pdf
Binary file not shown.
Binary file modified figs/results/hyper_exp2_p.pdf
Binary file not shown.
Binary file removed figs/results/hyper_exp4_c.pdf
Binary file not shown.
Binary file removed figs/results/hyper_exp4_e.pdf
Binary file not shown.
Binary file modified figs/results/hyper_exp4_p.pdf
Binary file not shown.

0 comments on commit 15d0b37

Please sign in to comment.