Skip to content

Commit

Permalink
Merge pull request #68 from sintefmath/dev
Browse files Browse the repository at this point in the history
Fixes to parameter optimization
  • Loading branch information
moyner authored May 6, 2024
2 parents e0ccc39 + 94459e5 commit 47ed79c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Jutul"
uuid = "2b460a1a-8a2b-45b2-b125-b5c536396eb9"
authors = ["Olav Møyner <[email protected]>"]
version = "0.2.30"
version = "0.2.31"

[deps]
AlgebraicMultigrid = "2169fc97-5a83-5252-b627-83903c6c433c"
Expand Down
2 changes: 1 addition & 1 deletion src/ad/gradients.jl
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ function next_lagrange_multiplier!(adjoint_storage, i, G, state, state0, state_n
dt = dt,
extra_out = true
)
if !converged && il >= 0
if !converged && il > 0
jutul_message("Warning", "Simulation was not converged to default tolerances for step $i in adjoint solve", color = :yellow)
if il > 1.5
get_convergence_table(errors, il, 1, config)
Expand Down
46 changes: 24 additions & 22 deletions src/conservation/conservation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -303,29 +303,31 @@ function fill_conservation_eq!(nz, r, cell, acc, cell_flux, conn_pos, ::Val{Np},
# Fluxes
start = @inbounds conn_pos[cell]
stop = @inbounds conn_pos[cell + 1] - 1
for i = start:stop
for e in 1:Ne
v = acc_r[e] + get_entry_val(cell_flux, i, e)
acc_r = setindex(acc_r, v, e)
end
fpos_outer = get_jacobian_pos(cell_flux, i, 1, 1)
is_inner = fpos_outer > 0
if is_inner
@simd for p in 1:Np
@inbounds for e in 1:Ne
= get_entry(cell_flux, i, e, p)
f_v = acc_partials[e, p] +
acc_partials = setindex(acc_partials, f_v, e, p)
fpos = get_jacobian_pos(cell_flux, i, e, p)
update_jacobian_inner!(nz, fpos, -∂)
end
if Np > 0
for i = start:stop
for e in 1:Ne
v = acc_r[e] + get_entry_val(cell_flux, i, e)
acc_r = setindex(acc_r, v, e)
end
else
@simd for p in 1:Np
@inbounds for e in 1:Ne
= get_entry(cell_flux, i, e, p)
f_v = acc_partials[e, p] +
acc_partials = setindex(acc_partials, f_v, e, p)
fpos_outer = get_jacobian_pos(cell_flux, i, 1, 1)
is_inner = fpos_outer > 0
if is_inner
@simd for p in 1:Np
@inbounds for e in 1:Ne
= get_entry(cell_flux, i, e, p)
f_v = acc_partials[e, p] +
acc_partials = setindex(acc_partials, f_v, e, p)
fpos = get_jacobian_pos(cell_flux, i, e, p)
update_jacobian_inner!(nz, fpos, -∂)
end
end
else
@simd for p in 1:Np
@inbounds for e in 1:Ne
= get_entry(cell_flux, i, e, p)
f_v = acc_partials[e, p] +
acc_partials = setindex(acc_partials, f_v, e, p)
end
end
end
end
Expand Down
1 change: 1 addition & 0 deletions src/simulator/optimization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function setup_parameter_optimization(case::JutulCase, G, opt_cfg = optimization
else
@assert grad_type == :adjoint
end
sort_variables!(model, :parameters)
mapper, = variable_mapper(model, :parameters, targets = targets, config = opt_cfg)
lims = optimization_limits(opt_cfg, mapper, parameters, model)
if verbose
Expand Down

2 comments on commit 47ed79c

@moyner
Copy link
Member Author

@moyner moyner commented on 47ed79c May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/106237

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.31 -m "<description of version>" 47ed79c08faa63b29a7e0cdb67f8598adcc73ed5
git push origin v0.2.31

Please sign in to comment.