|
1 | 1 | using Base.Broadcast |
2 | 2 |
|
| 3 | +# build_expr was removed from Symbolics.jl v7; define locally |
| 4 | +function build_expr(head::Symbol, args) |
| 5 | + ex = Expr(head) |
| 6 | + append!(ex.args, args) |
| 7 | + return ex |
| 8 | +end |
| 9 | + |
3 | 10 | """ |
4 | 11 | Override `Broadcast.__dot__` with `Broadcast.dottable(x::Function) = true` |
5 | 12 |
|
@@ -155,8 +162,11 @@ function _transform_expression( |
155 | 162 | derivative_variables = Symbol[] |
156 | 163 | order = 0 |
157 | 164 | while (_args[1] isa Differential) |
158 | | - order += 1 |
159 | | - push!(derivative_variables, toexpr(_args[1].x)) |
| 165 | + d_order = _args[1].order |
| 166 | + order += d_order |
| 167 | + for _ in 1:d_order |
| 168 | + push!(derivative_variables, toexpr(_args[1].x)) |
| 169 | + end |
160 | 170 | _args = _args[2].args |
161 | 171 | end |
162 | 172 | depvar = _args[1] |
@@ -197,7 +207,19 @@ function _transform_expression( |
197 | 207 | integrating_var_id = [dict_indvars[i] for i in integrating_variable] |
198 | 208 | else |
199 | 209 | integrating_variable = toexpr(_args[1].domain.variables) |
200 | | - integrating_var_id = [dict_indvars[integrating_variable]] |
| 210 | + # In SymbolicUtils v4, a symbolic tuple may produce |
| 211 | + # Expr(:call, :tuple, :x, :y) instead of a Julia Tuple |
| 212 | + if integrating_variable isa Expr && |
| 213 | + integrating_variable.head == :call && |
| 214 | + integrating_variable.args[1] === tuple |
| 215 | + integrating_variable = integrating_variable.args[2:end] |
| 216 | + integrating_var_id = [ |
| 217 | + dict_indvars[i] |
| 218 | + for i in integrating_variable |
| 219 | + ] |
| 220 | + else |
| 221 | + integrating_var_id = [dict_indvars[integrating_variable]] |
| 222 | + end |
201 | 223 | end |
202 | 224 |
|
203 | 225 | integrating_depvars = [] |
@@ -336,8 +358,10 @@ Parse ModelingToolkit equation form to the inner representation. |
336 | 358 | (derivative(phi2, u2, [x, y], [[ε,0]], 1, θ2) + 9 * derivative(phi1, u, [x, y], [[0,ε]], 1, θ1)) - 0] |
337 | 359 | """ |
338 | 360 | function parse_equation(pinnrep::PINNRepresentation, eq) |
339 | | - eq_lhs = isequal(expand_derivatives(eq.lhs), 0) ? eq.lhs : expand_derivatives(eq.lhs) |
340 | | - eq_rhs = isequal(expand_derivatives(eq.rhs), 0) ? eq.rhs : expand_derivatives(eq.rhs) |
| 361 | + eq_lhs = SymbolicUtils._iszero(expand_derivatives(eq.lhs)) ? eq.lhs : |
| 362 | + expand_derivatives(eq.lhs) |
| 363 | + eq_rhs = SymbolicUtils._iszero(expand_derivatives(eq.rhs)) ? eq.rhs : |
| 364 | + expand_derivatives(eq.rhs) |
341 | 365 | left_expr = transform_expression(pinnrep, toexpr(eq_lhs)) |
342 | 366 | right_expr = transform_expression(pinnrep, toexpr(eq_rhs)) |
343 | 367 | left_expr = _dot_(left_expr) |
@@ -379,7 +403,7 @@ function get_vars(indvars_, depvars_) |
379 | 403 | depvars = Symbol[] |
380 | 404 | dict_depvar_input = Dict{Symbol, Vector{Symbol}}() |
381 | 405 | for d in depvars_ |
382 | | - if unwrap(d) isa SymbolicUtils.BasicSymbolic |
| 406 | + if SymbolicUtils.iscall(unwrap(d)) |
383 | 407 | dname = SymbolicIndexingInterface.getname(d) |
384 | 408 | push!(depvars, dname) |
385 | 409 | push!( |
|
0 commit comments