SciML / DiffEqOperators.jl

Linear operators for discretizations of differential equations and scientific machine learning (SciML)
https://docs.sciml.ai/DiffEqOperators/stable/
Other
285 stars 74 forks source link

Implementing Drift-Diffusion model in higher dimensions #518

Closed apekshasingh closed 2 years ago

apekshasingh commented 2 years ago

Hi there! Thanks so much for your package. I'm trying to implement a drift-diffusion model with additional source/sink terms in 2-4 space dimensions. More specifically: image

I'm really only interested in solving for the steady state solution of c (at least for now). I'm trying to get a sense of how this package works and I'm just trying to implement something simple to start. Sticking with just 2 dimensions for now and just trying to implement the first term of the model I have:

using DiffEqOperators, LinearAlgebra n = 100 delta = 1/n

Dxx = CenteredDifference{1}(2, 2, delta, n) Dyy = CenteredDifference{2}(2, 2, delta, n) L = Dxx + Dyy

BCx = MultiDimBC{1}(DirichletBC(1.0, 0.0), (n,n)) BCy = MultiDimBC{2}(DirichletBC(1.0, 0.0), (n,n)) (actual model will have Neumann type BC) BC = compose(BCx, BCy)

Laplace = L * BC

c = Laplace\zeros(n) (I don't believe this is correct. I want to just solve for steady state, but I'm quite not sure how to implement solving the system of linear equations)

I think I'm not quite understanding how to use these DerivativeOperator objects. Any help getting on the right track would be greatly appreciated! Thank you so much!

xtalax commented 2 years ago

Hi! You might have better luck with what you are trying if you look at MethodOfLines.jl, this is the successor package to DiffEqOps and is under very active development.

But to answer your question, the operators behave like linear operators, and can be used as such - something like what you suggest c = Laplace\zeros(n,n) should work, though I think there was a bug associated with this particular operation.

apekshasingh commented 2 years ago

Thanks for your quick reply. I will try the MethodOfLines package as suggested; the operation c = Laplace\zeros(n,n) produces an error like you said. Thanks again!

xtalax commented 2 years ago

Another thing, we need a steady state tutorial, if you get this working in MethodOfLines please post an issue with your code and I will include it in the docs.