Skip to content
This repository was archived by the owner on Jul 19, 2023. It is now read-only.

Conversation

@ChrisRackauckas
Copy link
Member

No description provided.

xtalax and others added 30 commits May 1, 2020 19:02
…ivativeOperator` an `AbstractDiffEqLinearOperator`
- Rename some files to make them more consistent with the julia
styleguide
- Add some tests for concretizations
- Remove duplicate method definition
@ChrisRackauckas
Copy link
Member Author

@grahamas @xtalax when you rebase you have to force push, not do a merge afterwards. So I cherrypicked one commit back and it's all good.

@test size(A) == (10, 10)
@test size(A, 1) == 10
@test length(A) == 100
@test_broken size(A) == (10, 10)
Copy link
Member Author

Choose a reason for hiding this comment

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

how did these break?

Copy link
Contributor

@grahamas grahamas Jun 7, 2020

Choose a reason for hiding this comment

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

edit: disregard this comment

one of my "rebase" commits changes A.L.len to size(A.L, 2) in the definition of size(::GhostDerivativeOperator) which all the broken tests rely on. I don't see any reason whatsoever why I would have done that -- both master and xtalax have A.L.len and I'm aware that those aren't the same thing. Best guess is I was being stupid. So I can fix that, but where should I commit?

Copy link
Member Author

Choose a reason for hiding this comment

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

PR to this branch.

Copy link
Contributor

@grahamas grahamas Jun 7, 2020

Choose a reason for hiding this comment

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

Unfortunately I can't fix this. In doing this rebase, I was purely fixing things that didn't require me to make changes to what I saw as @xtalax's intentions/the code's semantics.

My mistake was today, not in the rebase. Today, I was mistakenly looking at xtalax:master rather than xtalax:#168 to figure out what the outcome is supposed to be.

In fact, xtalax:#168 does redefine size(A::GhostDerivativeOperator) = (size(A.L, 2),size(A.L, 2)). But the constructor for CenteredDifference(_, _, 10) will very definitely have second dimension of size 10+2. I don't know which definition of size (or maybe the constructor?) is wrong. So two different parts of the code have two clear but conflicting effects. I can start trying to fix the code's semantics, but that'll be a longer process.

edit: concisely, branch #168 breaks this test by redefining size(::GhostDerivativeOperator) and the rebase faithfully also breaks the test.

Copy link
Member Author

Choose a reason for hiding this comment

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

I would revert that change I think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Reverted and passing. @ChrisRackauckas how often do you want me to PR from my personal branch into this branch?

@@ -0,0 +1,36 @@
using DiffEqOperators, DifferentialEquations, ProgressMeter
function main()
Copy link
Member Author

Choose a reason for hiding this comment

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

@xtalax note that this isn't needed anymore now that we are using @safetestsets

Copy link
Member

Choose a reason for hiding this comment

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

noted, i'll change that around on my next commit

@ChrisRackauckas
Copy link
Member Author

Not sure if this is perfect, but perfect might be the enemy of good here. Let's make sure this is passing tests and get it merged. Then we can continue to clean up the other little pieces. I think the next thing I want to do is to try and start getting a real documentation together for this library to really take stock of where we're at.

@ChrisRackauckas
Copy link
Member Author

It looks like there's a lot of failing tests? Are there commits that were not on that branch?

@ChrisRackauckas
Copy link
Member Author

Doesn't look like this can merge because there's a ton of broken tests.

@time @safetestset "Upwind Operator Interface" begin include("upwind_operators_interface.jl") end
@time @safetestset "MOLFiniteDifference Interface" begin include("MOLtest.jl") end
@time @safetestset "Basic SDO Examples" begin include("BasicSDOExamples.jl") end
@time @safetestset "3D laplacian Test" begin include("3D_laplacian.jl") end
Copy link
Contributor

@grahamas grahamas Jun 7, 2020

Choose a reason for hiding this comment

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

Something's weird -- I'm not sure this is from the right commit. Line 23 of test/runtests.jl is causing an error that's fixed post-rebase (cf. https://github.com/xtalax/DiffEqOperators.jl/pull/26/files#diff-fce720c43af3c52c862fd7451c7374b8 which shows how I'd expect this file to look)

@grahamas
Copy link
Contributor

grahamas commented Jun 7, 2020 via email

@ChrisRackauckas
Copy link
Member Author

No worries. I think these test failures are what stalled it in the first place, so we can work through them whenever there's time.

@test As_l analytic_AL #This is true
@test As_b analytic_Ab #This is true
@test Vector(u .- analytic_Ab) Vector(u .- As_b) #this is true
@test_broken analytic_AL\Vector(u .- analytic_Ab) As_l\Vector(u .- As_b) #Then why isn't this working?
Copy link
Member

Choose a reason for hiding this comment

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

@ChrisRackauckas this error and those just below are what stalled progress before - I really have no idea why this isn't working

Copy link
Member Author

Choose a reason for hiding this comment

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

what's the error?

Copy link
Member

@xtalax xtalax Jun 16, 2020

Choose a reason for hiding this comment

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

the test marked broken should definitely pass if the above three are passing, and yet it doesn't

Copy link
Contributor

@grahamas grahamas Aug 4, 2020

Choose a reason for hiding this comment

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

It feels like it has to be a bug in the one of the \ implementations (or, more likely, expected imprecision). Running everything in the REPL:

EDIT: added fourth_deriv_approx_stencil definition; other things that I accidentally got from including test file

julia> using DiffEqOperators

julia> function fourth_deriv_approx_stencil(N)
    A = zeros(N,N+2)
    A[1,1:8] = [3.5 -56/3 42.5 -54.0 251/6 -20.0 5.5 -2/3]
    A[2,1:8] = [2/3 -11/6 0.0 31/6 -22/3 4.5 -4/3 1/6]

    A[N-1,N-5:end] = reverse([2/3 -11/6 0.0 31/6 -22/3 4.5 -4/3 1/6], dims=2)
    A[N,N-5:end] = reverse([3.5 -56/3 42.5 -54.0 251/6 -20.0 5.5 -2/3], dims=2)

    for i in 3:N-2
        A[i,i-2:i+4] = [-1/6 2.0 -13/2 28/3 -13/2 2.0 -1/6]
    end
    return A
end

julia> dx = 0.01; x = 0.01:dx:0.2; N=length(x); u=sin.(x); L = CenteredDifference(4, 4, dx, N); Q = RobinBC((1.0, 0.0, 0.0), (1.0, 0.0, sin(0.2+dx)), dx); A = L*Q;                         
                                                                                              
julia> analytic_L = fourth_deriv_approx_stencil(N) ./ dx^4; analytic_QL = [transpose(zeros(N)); Diagonal(ones(N)); transpose(zeros(N))]; analytic_AL = analytic_L * analytic_QL; analytic_Qb = [zeros(N+1); sin(0.2+dx)]; analytic_Ab = analytic_L*analytic_Qb; 

julia> using SparseArrays; As_l, As_b = sparse(A, length(u))

julia> analytic_AL \ Vector(u .- analytic_Ab) ≈ As_l \ Vector(u .- As_b)
false

julia> analytic_AL \ Vector(u .- analytic_Ab) ≈ Array(As_l) \ Vector(u .- As_b)
true

julia> methods(\, typeof.([analytic_AL, Vector(u .- analytic_Ab)]))
# 1 method for generic function "\":                                                                                         
[1] \(A::AbstractArray{T,2} where T, B::Union{AbstractArray{T,1}, AbstractArray{T,2}} where T)
 in LinearAlgebra at /home/graham/.local/opt/julia-1.5.0/share/julia/stdlib/v1.5/LinearAlgebra
/src/generic.jl:1102

julia> methods(\, typeof.([As_l, Vector(u .- As_b)]))
# 1 method for generic function "\":
[1] \(A::SparseArrays.AbstractSparseMatrixCSC, B::Union{AbstractArray{T,1}, AbstractArray{T,2}} where T) in SparseArrays at /home/graham/.local/opt/julia-1.5.0/share/julia/stdlib/v1.5/SparseArrays/src/linalg.jl:1460  

Copy link
Contributor

Choose a reason for hiding this comment

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

I filed an issue with an MWE: JuliaLang/julia#37004. I'll mark this as broken for now and move on.

Copy link
Contributor

Choose a reason for hiding this comment

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

They pointed out that the difference is within the expected range given the condition number of analytic_AL. I've revised the test to reflect that, and now it and a nearby similar test are passing. I imagine this is a problem in some other tests as well. Would we rather use a better conditioned matrix? I wouldn't know how to choose.

Copy link
Member Author

Choose a reason for hiding this comment

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

Just change the tolerance to be fit for the condition number. Any stencil operation is going to be pretty ill-conditioned (this is where the stiffness comes from)

@grahamas
Copy link
Contributor

grahamas commented Sep 26, 2020

Status update: Only two problem areas remaining.

  1. upwind_operators_interface.jl (test file) produces errors at random, varying between runs. This obviously drives me insane, especially since I'm not even sure how the ghost derivative stuff should be affecting upwind operators, so I'm leaving it for last.

  2. 3D_laplacian.jl (test file) reveals that there's no mul! method for multidimensional operators -- all existing mul! methods assert that the padding is in only one dimension. A cursory dive back into the pre-rebase commit history suggests I didn't accidentally delete anything. That being the case, I'll have to rework the fallback in derivative_operator_functions.jl to do a check for higher dimensional padding.

@grahamas
Copy link
Contributor

grahamas commented Sep 26, 2020

The fallback mul! now works with multidimensionally padded inputs by introducing unpadded_size helper function. TODO:

  1. Update specialized mul!s that call NNlib.conv! [done!]
  2. R̶e̶d̶e̶f̶i̶n̶e̶ ̶̶A̶*̶Q̶̶ ̶f̶o̶r̶ ̶̶A̶:̶:̶D̶i̶f̶f̶E̶q̶O̶p̶e̶r̶a̶t̶o̶r̶C̶o̶m̶b̶i̶n̶a̶t̶i̶o̶n̶̶ ̶(̶j̶u̶s̶t̶ ̶̶A̶<̶:̶A̶b̶s̶t̶r̶a̶c̶t̶D̶i̶f̶f̶E̶q̶O̶p̶e̶r̶a̶t̶o̶r̶̶?̶)̶ ̶a̶n̶d̶ ̶̶Q̶:̶:̶C̶o̶m̶p̶o̶s̶e̶d̶M̶u̶l̶t̶i̶D̶i̶m̶B̶C̶̶ ̶(̶j̶u̶s̶t̶ ̶̶Q̶<̶:̶M̶u̶l̶t̶i̶D̶i̶m̶B̶C̶̶?̶)̶ ̶a̶s̶ ̶a̶ ̶c̶o̶m̶p̶o̶s̶i̶t̶i̶o̶n̶ ̶s̶o̶ ̶t̶h̶a̶t̶ ̶̶A̶*̶Q̶*̶u̶̶ ̶j̶u̶s̶t̶ ̶w̶o̶r̶k̶s̶ ̶(̶a̶l̶t̶e̶r̶n̶a̶t̶i̶v̶e̶ ̶i̶s̶ ̶r̶e̶p̶a̶d̶d̶i̶n̶g̶ ̶̶u̶̶ ̶f̶o̶r̶ ̶e̶v̶e̶r̶y̶ ̶d̶i̶m̶e̶n̶s̶i̶o̶n̶.̶.̶.̶ ̶s̶e̶e̶m̶s̶ ̶u̶n̶w̶i̶s̶e̶)̶ hah I almost tried to reinvent GhostDerivativeOperators -- caught myself just in time.

@ChrisRackauckas
Copy link
Member Author

Awesome. Should this be passing then?

@ChrisRackauckas
Copy link
Member Author

Looks like there's a merge conflict.

@grahamas
Copy link
Contributor

@ChrisRackauckas Nope! I don't have access to this branch; I was working on yet another fork. I've opened #279 which is rebased to master as of 20 minutes ago and is passing all tests on my machine.

@ChrisRackauckas
Copy link
Member Author

alright, let's continue there.

@ChrisRackauckas ChrisRackauckas deleted the rebased branch September 27, 2020 04:31
@assert size(ops[i]) == size(ops[1]) "Operators must be of the same size to be combined! Mismatch between $(ops[i]) and $(ops[i-1]), which are operators $i and $(i-1) respectively"
end
if cache == nothing
cache = Vector{T}(undef, size(ops[1], 1))
Copy link
Member Author

Choose a reason for hiding this comment

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

Let's zero this so errors with undef memory don't pop up.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants