@@ -2,7 +2,7 @@ module MTKHomotopyContinuationExt
2
2
3
3
using ModelingToolkit
4
4
using ModelingToolkit. SciMLBase
5
- using ModelingToolkit. Symbolics: unwrap
5
+ using ModelingToolkit. Symbolics: unwrap, symtype
6
6
using ModelingToolkit. SymbolicIndexingInterface
7
7
using ModelingToolkit. DocStringExtensions
8
8
using HomotopyContinuation
@@ -32,8 +32,25 @@ function is_polynomial(x, wrt)
32
32
end
33
33
if operation (x) == (^ )
34
34
b, p = arguments (x)
35
- return is_polynomial (b, wrt) && ! contains_variable (p, wrt)
35
+ is_pow_integer = symtype (p) <: Integer
36
+ if ! is_pow_integer
37
+ if symbolic_type (p) == NotSymbolic ()
38
+ @warn " In $x : Exponent $p is not an integer"
39
+ else
40
+ @warn " In $x : Exponent $p is not an integer. Use `@parameters p::Integer` to declare integer parameters."
41
+ end
42
+ end
43
+ exponent_has_unknowns = contains_variable (p, wrt)
44
+ if exponent_has_unknowns
45
+ @warn " In $x : Exponent $p cannot contain unknowns of the system."
46
+ end
47
+ base_polynomial = is_polynomial (b, wrt)
48
+ if ! base_polynomial
49
+ @warn " In $x : Base is not a polynomial"
50
+ end
51
+ return base_polynomial && ! exponent_has_unknowns && is_pow_integer
36
52
end
53
+ @warn " In $x : Unrecognized operation $(operation (x)) . Allowed polynomial operations are `*, +, -, ^`"
37
54
return false
38
55
end
39
56
@@ -124,7 +141,7 @@ function MTK.HomotopyContinuationProblem(
124
141
125
142
for eq in eqs
126
143
if ! is_polynomial (eq. lhs, dvs) || ! is_polynomial (eq. rhs, dvs)
127
- error (" Equation $eq is not a polynomial in the unknowns" )
144
+ error (" Equation $eq is not a polynomial in the unknowns. See warnings for further details. " )
128
145
end
129
146
end
130
147
0 commit comments