@@ -2,7 +2,7 @@ module MTKHomotopyContinuationExt
22
33using ModelingToolkit
44using ModelingToolkit. SciMLBase
5- using ModelingToolkit. Symbolics: unwrap
5+ using ModelingToolkit. Symbolics: unwrap, symtype
66using ModelingToolkit. SymbolicIndexingInterface
77using ModelingToolkit. DocStringExtensions
88using HomotopyContinuation
@@ -32,8 +32,25 @@ function is_polynomial(x, wrt)
3232 end
3333 if operation (x) == (^ )
3434 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
3652 end
53+ @warn " In $x : Unrecognized operation $(operation (x)) . Allowed polynomial operations are `*, +, -, ^`"
3754 return false
3855end
3956
@@ -124,7 +141,7 @@ function MTK.HomotopyContinuationProblem(
124141
125142 for eq in eqs
126143 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. " )
128145 end
129146 end
130147
0 commit comments