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

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: SciML/DiffEqOperators.jl
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.16.0
Choose a base ref
...
head repository: SciML/DiffEqOperators.jl
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.17.0
Choose a head ref
  • 11 commits
  • 6 files changed
  • 2 contributors

Commits on Dec 9, 2020

  1. Copy the full SHA
    29c3e8c View commit details

Commits on Dec 10, 2020

  1. Copy the full SHA
    e454189 View commit details
  2. #300 add Robin BCs

    valentinsulzer committed Dec 10, 2020
    Copy the full SHA
    3d4a8f4 View commit details
  3. #300 update examples

    valentinsulzer committed Dec 10, 2020
    Copy the full SHA
    cde0e97 View commit details
  4. #300 fix typo

    valentinsulzer committed Dec 10, 2020
    Copy the full SHA
    fd61dd8 View commit details
  5. #300 remove Plots

    valentinsulzer committed Dec 10, 2020
    Copy the full SHA
    964c593 View commit details
  6. Copy the full SHA
    5cd91bf View commit details
  7. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ce1a3f1 View commit details

Commits on Dec 17, 2020

  1. Merge pull request #306 from tinosulzer/issue-300-Robin-Neumann-bcs

    Issue 300 robin neumann bcs
    ChrisRackauckas authored Dec 17, 2020
    Copy the full SHA
    c552b76 View commit details
  2. Update Project.toml

    ChrisRackauckas authored Dec 17, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c7b7f34 View commit details
  3. Update Project.toml

    ChrisRackauckas authored Dec 17, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    a7faab6 View commit details
Showing with 642 additions and 80 deletions.
  1. +1 −1 Project.toml
  2. +126 −5 docs/src/examples.md
  3. +4 −0 src/DiffEqOperators.jl
  4. +159 −48 src/MOL_discretization.jl
  5. +7 −0 src/exceptions.jl
  6. +345 −26 test/MOL_1D_Linear_Diffusion.jl
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DiffEqOperators"
uuid = "9fdde737-9c7f-55bf-ade8-46b3f136cc48"
authors = ["Chris Rackauckas <accounts@chrisrackauckas.com>"]
version = "4.16.0"
version = "4.17.0"

[deps]
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
131 changes: 126 additions & 5 deletions docs/src/examples.md
Original file line number Diff line number Diff line change
@@ -2,8 +2,12 @@

## Heat equation

### Dirichlet boundary conditions

```julia
using ModelingToolkit, DiffEqOperators
# Method of Manufactured Solutions: exact solution
u_exact = (x,t) -> exp.(-t) * cos.(x)

# Parameters, variables, and derivatives
@parameters t x
@@ -13,13 +17,13 @@ using ModelingToolkit, DiffEqOperators

# 1D PDE and boundary conditions
eq = Dt(u(t,x)) ~ Dxx(u(t,x))
bcs = [u(0,x) ~ -x*(x-1)*sin(x),
u(t,0) ~ 0.0,
u(t,1) ~ 0.0]
bcs = [u(0,x) ~ cos(x),
u(t,0) ~ exp(-t),
u(t,1) ~ exp(-t) * cos(1)]

# Space and time domains
domains = [t IntervalDomain(0.0,1.0),
x IntervalDomain(0.0,1.0)]
x IntervalDomain(0.0,1.0)]

# PDE system
pdesys = PDESystem(eq,bcs,domains,[t,x],[u])
@@ -34,5 +38,122 @@ prob = discretize(pdesys,discretization)

# Solve ODE problem
using OrdinaryDiffEq
sol = solve(prob,Tsit5(),saveat=0.1)
sol = solve(prob,Tsit5(),saveat=0.2)

# Plot results and compare with exact solution
x = prob.space[2]
t = sol.t

using Plots
plt = plot()
for i in 1:length(t)
plot!(x,Array(prob.extrapolation[1](t[i])*sol.u[i]),label="Numerical, t=$(t[i])")
scatter!(x, u_exact(x, t[i]),label="Exact, t=$(t[i])")
end
display(plt)
```
### Neumann boundary conditions

```julia
using ModelingToolkit, DiffEqOperators
# Method of Manufactured Solutions: exact solution
u_exact = (x,t) -> exp.(-t) * cos.(x)

# Parameters, variables, and derivatives
@parameters t x
@variables u(..)
@derivatives Dt'~t
@derivatives Dx'~x
@derivatives Dxx''~x

# 1D PDE and boundary conditions
eq = Dt(u(t,x)) ~ Dxx(u(t,x))
bcs = [u(0,x) ~ cos(x),
Dx(u(t,0)) ~ 0.0,
Dx(u(t,1)) ~ -exp(-t) * sin(1)]

# Space and time domains
domains = [t IntervalDomain(0.0,1.0),
x IntervalDomain(0.0,1.0)]

# PDE system
pdesys = PDESystem(eq,bcs,domains,[t,x],[u])

# Method of lines discretization
# Need a small dx here for accuracy
dx = 0.01
order = 2
discretization = MOLFiniteDifference(dx,order)

# Convert the PDE problem into an ODE problem
prob = discretize(pdesys,discretization)

# Solve ODE problem
using OrdinaryDiffEq
sol = solve(prob,Tsit5(),saveat=0.2)

# Plot results and compare with exact solution
x = prob.space[2]
t = sol.t

using Plots
plt = plot()
for i in 1:length(t)
plot!(x,Array(prob.extrapolation[1](t[i])*sol.u[i]),label="Numerical, t=$(t[i])")
scatter!(x, u_exact(x, t[i]),label="Exact, t=$(t[i])")
end
display(plt)
```

### Robin boundary conditions

```julia
using ModelingToolkit, DiffEqOperators
# Method of Manufactured Solutions
u_exact = (x,t) -> exp.(-t) * sin.(x)

# Parameters, variables, and derivatives
@parameters t x
@variables u(..)
@derivatives Dt'~t
@derivatives Dx'~x
@derivatives Dxx''~x

# 1D PDE and boundary conditions
eq = Dt(u(t,x)) ~ Dxx(u(t,x))
bcs = [u(0,x) ~ sin(x),
u(t,-1.0) + 3Dx(u(t,-1.0)) ~ exp(-t) * (sin(-1.0) + 3cos(-1.0)),
u(t,1.0) + Dx(u(t,1.0)) ~ exp(-t) * (sin(1.0) + cos(1.0))]

# Space and time domains
domains = [t IntervalDomain(0.0,1.0),
x IntervalDomain(-1.0,1.0)]

# PDE system
pdesys = PDESystem(eq,bcs,domains,[t,x],[u])

# Method of lines discretization
# Need a small dx here for accuracy
dx = 0.05
order = 2
discretization = MOLFiniteDifference(dx,order)

# Convert the PDE problem into an ODE problem
prob = discretize(pdesys,discretization)

# Solve ODE problem
using OrdinaryDiffEq
sol = solve(prob,Tsit5(),saveat=0.2)

# Plot results and compare with exact solution
x = prob.space[2]
t = sol.t

using Plots
plt = plot()
for i in 1:length(t)
plot!(x,Array(prob.extrapolation[1](t[i])*sol.u[i]),label="Numerical, t=$(t[i])")
scatter!(x, u_exact(x, t[i]),label="Exact, t=$(t[i])")
end
display(plt)
```
4 changes: 4 additions & 0 deletions src/DiffEqOperators.jl
Original file line number Diff line number Diff line change
@@ -21,6 +21,9 @@ include("jacvec_operators.jl")
### Utilities
include("utils.jl")

### Exceptions
include("exceptions.jl")

### Boundary Padded Arrays
include("boundary_padded_arrays.jl")

@@ -63,4 +66,5 @@ export compose, decompose, perpsize

export GhostDerivativeOperator
export MOLFiniteDifference
export BoundaryConditionError
end # module
Loading