Skip to content

Commit

Permalink
docs update
Browse files Browse the repository at this point in the history
missed name

new figs
  • Loading branch information
odunbar committed Sep 22, 2023
1 parent 227dc96 commit f5c97bb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Binary file modified docs/src/assets/darcy_final.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/src/assets/darcy_prior.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/src/assets/darcy_true.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions examples/Darcy/darcy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# In this example we hope to illustrate function learning. One may wish to use function learning in cases where the underlying parameter of interest is actual a finite-dimensional approximation (e.g. spatial discretization) of some "true" function. Treating such an object directly will lead to increasingly high-dimensional learning problems as the spatial resolution is increased, resulting in poor computational scaling and increasingly ill-posed inverse problems. Treating the object as a discretized function from a function space, one can learn coefficients not in the standard basis, but instead in a basis of this function space, it is commonly the case that functions will have relatively low effective dimension, and will be depend only on the spatial discretization due to discretization error, that should vanish as resolution is increased.

# We will solve for an unknown permeability field ``\kappa`` governing the velocity of a Darcy flow on a square 2D domain. To learn about the permeability we shall take few pointwise measurements of the solved velocity field within the domain. The forward solver is a simple finite difference scheme taken and modified from code [here](https://github.com/Zhengyu-Huang/InverseProblems.jl/blob/master/Fluid/Darcy-2D.jl).
# We will solve for an unknown permeability field ``\kappa`` governing the pressure field of a Darcy flow on a square 2D domain. To learn about the permeability we shall take few pointwise measurements of the solved pressure field within the domain. The forward solver is a simple finite difference scheme taken and modified from code [here](https://github.com/Zhengyu-Huang/InverseProblems.jl/blob/master/Fluid/Darcy-2D.jl).

# First we load standard packages
using LinearAlgebra
Expand Down Expand Up @@ -112,7 +112,7 @@ for i in 1:N_iter
println("Iteration: " * string(i) * ", Error: " * string(err[i]))
end

# We plot first the prior ensemble mean and pointwise variance of the permeability field, and also the velocity field solved with the ensemble mean. Each ensemble member is stored as a column and therefore for uses such as plotting one needs to reshape to the desired dimension.
# We plot first the prior ensemble mean and pointwise variance of the permeability field, and also the pressure field solved with the ensemble mean. Each ensemble member is stored as a column and therefore for uses such as plotting one needs to reshape to the desired dimension.
if PLOT_FLAG
gr(size = (1500, 400), legend = false)
prior_κ_ens = get_ϕ(prior, ekiobj, 1)
Expand All @@ -129,14 +129,14 @@ if PLOT_FLAG
colorbar = true,
)
h_2d = solve_Darcy_2D(darcy, κ_ens_mean)
p3 = contour(pts_per_dim, pts_per_dim, h_2d', fill = true, levels = 15, title = "flow", colorbar = true)
p3 = contour(pts_per_dim, pts_per_dim, h_2d', fill = true, levels = 15, title = "pressure", colorbar = true)
l = @layout [a b c]
plt = plot(p1, p2, p3, layout = l)
savefig(plt, joinpath(fig_save_directory, "output_prior.png")) # pre update

end

# Now we plot the final ensemble mean and pointwise variance of the permeability field, and also the velocity field solved with the ensemble mean.
# Now we plot the final ensemble mean and pointwise variance of the permeability field, and also the pressure field solved with the ensemble mean.
if PLOT_FLAG
gr(size = (1500, 400), legend = false)
final_κ_ens = get_ϕ_final(prior, ekiobj) # the `ϕ` indicates that the `params_i` are in the constrained space
Expand All @@ -153,7 +153,7 @@ if PLOT_FLAG
colorbar = true,
)
h_2d = solve_Darcy_2D(darcy, κ_ens_mean)
p3 = contour(pts_per_dim, pts_per_dim, h_2d', fill = true, levels = 15, title = "flow", colorbar = true)
p3 = contour(pts_per_dim, pts_per_dim, h_2d', fill = true, levels = 15, title = "pressure", colorbar = true)
l = @layout [a b c]
plt = plot(p1, p2, p3; layout = l)
savefig(plt, joinpath(fig_save_directory, "output_it_" * string(N_iter) * ".png")) # pre update
Expand All @@ -162,11 +162,11 @@ end
println("Final coefficients (ensemble mean):")
println(get_u_mean_final(ekiobj))

# We can compare this with the true permeability and velocity field:
# We can compare this with the true permeability and pressure field:
if PLOT_FLAG
gr(size = (1000, 400), legend = false)
p1 = contour(pts_per_dim, pts_per_dim, κ_true', fill = true, levels = 15, title = "kappa true", colorbar = true)
p2 = contour(pts_per_dim, pts_per_dim, h_2d_true', fill = true, levels = 15, title = "flow true", colorbar = true)
p2 = contour(pts_per_dim, pts_per_dim, h_2d_true', fill = true, levels = 15, title = "pressure true", colorbar = true)
l = @layout [a b]
plt = plot(p1, p2, layout = l)
savefig(plt, joinpath(fig_save_directory, "output_true.png"))
Expand Down

0 comments on commit f5c97bb

Please sign in to comment.