Skip to content

Commit

Permalink
Merge pull request #404 from SciML/sb/ps
Browse files Browse the repository at this point in the history
refactor: pass in defaults in `transform_pde_system!`
  • Loading branch information
ChrisRackauckas authored Aug 12, 2024
2 parents afc1f7b + 13dfa1b commit d7e1e92
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/system_parsing/pde_system_transformation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function PDEBase.transform_pde_system!(
end
end

sys = PDESystem(eqs, bcs, sys.domain, sys.ivs, Num.(v.ū), sys.ps, name = sys.name)
sys = PDESystem(eqs, bcs, sys.domain, sys.ivs, Num.(v.ū), sys.ps, name = sys.name, defaults = sys.defaults)
return sys
end

Expand Down
4 changes: 2 additions & 2 deletions test/components/ODEFunction_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ bcs = [u(0, x) ~ x,
domains = [t Interval(t_min, t_max),
x Interval(x_min, x_max)]

@named pdesys = PDESystem(eq, bcs, domains, [t, x], [u(t, x)], [a => 1.0],
analytic_func = [u(t, x) => analytic_u])
@named pdesys = PDESystem(eq, bcs, domains, [t, x], [u(t, x)], [a],
analytic_func = [u(t, x) => analytic_u], defaults = Dict(a => 1.0))

disc = MOLFiniteDifference([x => 30], t, advection_scheme = WENOScheme())

Expand Down
4 changes: 2 additions & 2 deletions test/pde_systems/MOL_1D_Linear_Diffusion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ end
x Interval(0.0, 1.0)]

# PDE system
@named pdesys = PDESystem(eq, bcs, domains, [t, x], [u(t, x)], [D => 10.0])
@named pdesys = PDESystem(eq, bcs, domains, [t, x], [u(t, x)], [D]; defaults = Dict(D => 10.0))

# Method of lines discretization
dx = 1 / (5pi)
Expand Down Expand Up @@ -596,7 +596,7 @@ end
x Interval(0.0, 1.0)]

@named pdesys = PDESystem(
eqs, bcs, domains, [t, x], [u(t, x), v(t, x)], [Dn => 0.5, Dp => 2])
eqs, bcs, domains, [t, x], [u(t, x), v(t, x)], [Dn, Dp]; defaults = Dict(Dn => 0.5, Dp => 2))
discretization = MOLFiniteDifference([x => 0.1], t)
prob = discretize(pdesys, discretization)
# Make sure it can be solved
Expand Down
4 changes: 2 additions & 2 deletions test/pde_systems/MOL_1D_Linear_Diffusion_NonUniform.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ end
x Interval(0.0, 1.0)]

# PDE system
@named pdesys = PDESystem(eq, bcs, domains, [t, x], [u(t, x)], [D => 10.0])
@named pdesys = PDESystem(eq, bcs, domains, [t, x], [u(t, x)], [D]; defaults = Dict(D => 10.0))

# Method of lines discretization
dx = 0.0:0.1:1.0
Expand Down Expand Up @@ -624,7 +624,7 @@ end
rand(StableRNG(0), [0.001, -0.001], length(dx[2:(end - 1)]))

@named pdesys = PDESystem(
eqs, bcs, domains, [t, x], [u(t, x), v(t, x)], [Dn => 0.5, Dp => 2])
eqs, bcs, domains, [t, x], [u(t, x), v(t, x)], [Dn, Dp]; defaults = Dict(Dn => 0.5, Dp => 2))
discretization = MOLFiniteDifference([x => dx], t)
prob = discretize(pdesys, discretization)
# Make sure it can be solved
Expand Down
4 changes: 2 additions & 2 deletions test/pde_systems/MOLtest2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ end
Dt = Differential(t)
Dx = Differential(x)
Dxx = Differential(x)^2
params = Symbolics.scalarize(reduce(vcat, [p .=> [1.5, 2.0], q .=> [1.2, 1.8]]))
params = [p, q]
# 1D PDE and boundary conditions

eqs = [Dt(u(t, x)[i]) ~ p[i] * Dxx(u(t, x)[i]) for i in 1:n_comp]
Expand All @@ -391,7 +391,7 @@ end
# PDE system

@named pdesys = PDESystem(eqs, bcs_collected, domains, [t, x],
[u(t, x)[i] for i in 1:n_comp], Symbolics.scalarize(params))
[u(t, x)[i] for i in 1:n_comp], params; defaults = Dict(p => [1.5, 2.0], q => [1.2, 1.8]))

# Method of lines discretization
dx = 0.1
Expand Down

0 comments on commit d7e1e92

Please sign in to comment.