Skip to content

Commit

Permalink
fix #222
Browse files Browse the repository at this point in the history
  • Loading branch information
xtalax committed Jan 6, 2023
1 parent 2c25702 commit 70b0e82
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/system_parsing/bcs/parse_boundaries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function _boundary_rules(v, orders, u, x, val)
spacerules = [(Differential(x)^d)(operation(u)(args...)) => [operation(u)(args...), x, d] for d in reverse(orders[x])]

if v.time !== nothing && x !== v.time
timerules = [Differential(v.time)(operation(u)(args...)) => [operation(u)(args...), v.time, d] for d in reverse(orders[v.time])]
timerules = [Differential(v.time)(operation(u)(args...)) => [operation(u)(args...), x, d] for d in reverse(orders[v.time])]
return vcat(spacerules, timerules, varrule)
else
return vcat(spacerules, varrule)
Expand Down
36 changes: 36 additions & 0 deletions test/pde_systems/MOLtest2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,39 @@ end
sol = solve(prob, FBDF())

end

@testset "Dt in BCs" begin
# Parameters, variables, and derivatives
@parameters t x
@variables u(..)
Dt = Differential(t)
Dxx = Differential(x)^2

# 1D PDE and boundary conditions
eq = Dt(u(t, x)) ~ Dxx(u(t, x))
bcs = [u(0, x) ~ 20,
Dt(u(t, 0)) ~ 100, # Heat source
Dt(u(t, 1)) ~ 0] # Zero flux

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

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

# Method of lines discretization
dx = 0.1
order = 2
discretization = MOLFiniteDifference([x => dx], t)

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

# Solve ODE problem
sol = solve(prob, Rodas4(), saveat=0.2)

discrete_x = sol[x]
discrete_t = sol[t]
solu = sol[u(t, x)] # Temperature should increase with time
end

0 comments on commit 70b0e82

Please sign in to comment.