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

Commit 1809d2b

Browse files
Merge pull request #483 from SciML/fixmaster
fix master
2 parents b0cda99 + 40bbfa3 commit 1809d2b

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/MOLFiniteDifference/MOL_discretization.jl

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,24 @@ function SciMLBase.symbolic_discretize(pdesys::ModelingToolkit.PDESystem,discret
334334
Num(substitute(substitute(*(~~a..., ~~b...), r_mid_dep(II, j, k, 1)), r_mid_indep(II, j, 1)))],
335335
[-b1(II, j, k), b2(II, j, k)])
336336
for (j, iv) in enumerate(nottime) for (k, dv) in enumerate(depvars)]
337-
spherical_deriv_rules = [@rule (~a) * (iv^-2) * ($(Differential(iv))((iv^2)*$(Differential(iv))(dv))) =>
338-
(~a) * central_deriv_spherical(II, j, k)
337+
338+
cartesian_deriv_rules = vcat(vec(cartesian_deriv_rules),vec(
339+
[@rule ($(Differential(iv))($(Differential(iv))(dv)/~a)) =>
340+
dot([Num(substitute(substitute(1/~a, r_mid_dep(II, j, k, -1)), r_mid_indep(II, j, -1))),
341+
Num(substitute(substitute(1/~a, r_mid_dep(II, j, k, 1)), r_mid_indep(II, j, 1)))],
342+
[-b1(II, j, k), b2(II, j, k)])
343+
for (j, iv) in enumerate(nottime) for (k, dv) in enumerate(depvars)]))
344+
345+
spherical_deriv_rules = [@rule *(~~a, ($(Differential(iv))((iv^2)*$(Differential(iv))(dv))), ~~b) / (iv^2) =>
346+
*(~a..., central_deriv_spherical(II, j, k), ~b...)
339347
for (j, iv) in enumerate(nottime) for (k, dv) in enumerate(depvars)]
348+
349+
# r^-2 needs to be handled separately
350+
spherical_deriv_rules = vcat(vec(spherical_deriv_rules),vec(
351+
[@rule *(~~a, (iv^-2) * ($(Differential(iv))((iv^2)*$(Differential(iv))(dv))), ~~b) =>
352+
*(~a..., central_deriv_spherical(II, j, k), ~b...)
353+
for (j, iv) in enumerate(nottime) for (k, dv) in enumerate(depvars)]))
354+
340355
rhs_arg = istree(eq.rhs) && (SymbolicUtils.operation(eq.rhs) == +) ? SymbolicUtils.arguments(eq.rhs) : [eq.rhs]
341356
lhs_arg = istree(eq.lhs) && (SymbolicUtils.operation(eq.lhs) == +) ? SymbolicUtils.arguments(eq.lhs) : [eq.lhs]
342357
nonlinlap_rules = []

0 commit comments

Comments
 (0)