Giter Club home page Giter Club logo

Comments (5)

ChrisRackauckas avatar ChrisRackauckas commented on May 30, 2024

From the Gitter:

I don't think it's a big task
and I think it's just the Dirichlet BCs
https://github.com/JuliaDiffEq/DiffEqOperators.jl/blob/master/src/derivative_operators/boundary_operators.jl#L305
https://github.com/JuliaDiffEq/DiffEqOperators.jl/blob/master/src/derivative_operators/boundary_operators.jl#L353
you'd just have to modify these two in order to have them take into account the fact that the last point should just have the BC imposed.
https://github.com/JuliaDiffEq/DiffEqOperators.jl/blob/master/src/derivative_operators/boundary_operators.jl#L181
this is what ends up callin them
so from that you can look at the whole logic pretty quick

from diffeqoperators.jl.

ChrisRackauckas avatar ChrisRackauckas commented on May 30, 2024

But Dirichlet is a little weird, with that implementation what should we do if the BCs don't match what you put on the ends of the vector?

from diffeqoperators.jl.

ChrisRackauckas avatar ChrisRackauckas commented on May 30, 2024

From Gitter:

the left BC for Dirichlet is here: https://github.com/JuliaDiffEq/DiffEqOperators.jl/blob/master/src/derivative_operators/boundary_operators.jl#L53
for i in 1 : A.boundary_point_count[1]
for each point where the boundary would go over the edge
(so for 2nd order that's just the last point)
it calls dirichlet_1!(x_temp, x, A.stencil_coefs, mid, i)
https://github.com/JuliaDiffEq/DiffEqOperators.jl/blob/master/src/derivative_operators/boundary_operators.jl#L353
so that's the function to find out
x_temp[i] is the output
coeffs is the stencil [-1 2 1]
x is the initial vector
i is the current location, so at the edge it's 1
need to find out what mid is

function dirichlet_1!(x_temp::AbstractVector{T}, x::AbstractVector{T}, coeffs::SVector, mid::Int, i::Int) where T<:Real
    stencil_length = length(coeffs)
    N = length(x)
    #=
        Here we are taking the weighted sum of a window of the input vector to calculate the derivative
        at the middle point. Once the stencil goes out of the edge, we assume that it's has a constant
        value outside for all points.
    =#
    xtempi = zero(T)
    @inbounds for idx in 1:stencil_length
        xtempi += coeffs[idx] * x[limit(i - (mid-idx), N)]
    end
    x_temp[i] = xtempi
end

so something about x[limit(i - (mid-idx), N)] is making the x's all do something
but whatever it is, that's a weird line of code and should be changed.
it should have the user's BC there
and basically if i-idx<1, it's a point over the boundary and should use the BC value.

so my guess is it needs to be something like

     @inbounds for idx in 1:stencil_length
        loc = i - idx
        if loc < 0
           xtempi += coeffs[idx]*bc_right
        else
           xtempi += coeffs[idx] * x[i-idx]
         end
    end

then the function needs to get passed bc_right
err, left
mb
so the function call dirichlet_1!(x_temp, x, A.stencil_coefs, mid, i)
needs to change
the type is defined here: https://github.com/JuliaDiffEq/DiffEqOperators.jl/blob/master/src/derivative_operators/derivative_operator.jl#L57
so you can see that A.boundary_condition is where that tuple is stored
so it should be passed
dirichlet_1!(x_temp, x, A.stencil_coefs, mid, i,A.boundary_condition[1])
the function should be expanded
and it should replace the loop to put in the BC like that

from diffeqoperators.jl.

ChrisRackauckas avatar ChrisRackauckas commented on May 30, 2024

Example problem: https://github.com/francispoulin/DiffEqOperators.jl/blob/master/docs/DiffusionEqTutorial.ipynb

from diffeqoperators.jl.

ChrisRackauckas avatar ChrisRackauckas commented on May 30, 2024

Here's a review of the BCs:

  • Dirichlet0 assumes the boundary points are the first points off the boundary
  • Dirichet assumes the last points are the boundary points and fixes them
  • Neumann0 assumes the boundary points are the last points on the vector
  • Neumann assumes the boundary points are the last points on the vector
  • Periodic assumes the first point is a BC and the last point is not (since they would be the same.

We should make these all CenterPeriodic, etc., and then have Periodic be the case where the boundary is included in the ends (and do error checks).

from diffeqoperators.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.