An acausal modeling framework for automatically parallelized scientific machine learning (SciML) in Julia. A computer algebra system for integrated symbolics for physics-informed machine learning and automated transformations of differential equations
I am using CoolProp and I have symbolically registered PropsSI . For testing with IntervalNonlinearSolve I intend to find the saturation pressure of water at 373K
Expected behavior
The solution should be PropsSI("P", "T", 373, "Q", 1, "Water") = 100876.29794371923
Minimal Reproducible Example 👇
Here is my test code
using ModelingToolkit, DifferentialEquations, Plots
using ModelingToolkit: t_nounits as t, D_nounits as D
using CoolProp
PropsSI(out::AbstractString, name1::AbstractString, value1::Real, name2::AbstractString, value2::Real, fluid::AbstractString) = CoolProp.PropsSI(out, name1, value1, name2, value2, fluid)
@register_symbolic PropsSI(out::AbstractString, name1::AbstractString, value1::Real, name2::AbstractString, value2::Real, fluid::AbstractString)
f(x) = PropsSI("T","P",x,"Q",1,"Water")
@register_symbolic f(x)
function IntervalSolveAcausal(T_sat,interval)
ff(x,p) = f(x) - T_sat
f_int = IntervalNonlinearFunction(ff)
prob = IntervalNonlinearProblem(f_int,interval)
sol = solve(prob)
return sol.u
end
@register_symbolic IntervalSolveAcausal(T_sat,interval)
function Test(;name)
para = @parameters begin
end
vars = @variables begin
p(t)
T(t)
end
eqs = [
p ~ IntervalSolveAcausal(T,(0.5*101325,1.5*101325))
T ~ 373
]
ODESystem(eqs, t, vars, para;name)
end
@show p_ = PropsSI("P","T",373,"Q",1,"Water")
@named test = Test()
sys = structural_simplify(test)
u0 = []
para = []
tspan = (0, 2π)
prob = ODEProblem(sys,u0,tspan,para)
sol = solve(prob)
Error & Stacktrace ⚠️
ERROR: LoadError: TypeError: non-boolean (Num) used in boolean context
A symbolic expression appeared in a Boolean context. This error arises in situations where Julia expects a Bool
if boolean_condition use ifelse(boolean_condition, then branch, else branch)
x && y use x & y
boolean_condition ? a : b use ifelse(boolean_condition, a, b)
but a symbolic expression appeared instead of a Bool. For help regarding control flow with symbolic variables, see https://docs.sciml.ai/ModelingToolkit/dev/basics/FAQ/#How-do-I-handle-if-statements-in-my-symbolic-forms?
Stacktrace:
[1] solve(::IntervalNonlinearProblem{…}, ::ITP{…}; maxiters::Int64, abstol::Nothing, kwargs::@Kwargs{})
@ SimpleNonlinearSolve C:\Users\sush9\.julia\packages\SimpleNonlinearSolve\YQl3A\src\bracketing\itp.jl:79
[2] solve
@ C:\Users\sush9\.julia\packages\SimpleNonlinearSolve\YQl3A\src\bracketing\itp.jl:59 [inlined]
[3] solve(prob::IntervalNonlinearProblem{…})
@ SimpleNonlinearSolve C:\Users\sush9\.julia\packages\SimpleNonlinearSolve\YQl3A\src\SimpleNonlinearSolve.jl:66
[4] IntervalSolveAcausal(T_sat::Num, interval::Tuple{Float64, Float64})
@ Main C:\Users\sush9\Documents\GitHub\CarnotCyclesTest\bug2.jl:15
[5] Test(; name::Symbol)
@ Main C:\Users\sush9\Documents\GitHub\CarnotCyclesTest\bug2.jl:28
[6] top-level scope
@ C:\Users\sush9\.julia\packages\ModelingToolkit\eiNg3\src\systems\abstractsystem.jl:2074
[7] include(fname::String)
@ Main .\sysimg.jl:38
[8] top-level scope
@ REPL[5]:1
Environment (please complete the following information):
Describe the bug 🐞
I am using CoolProp and I have symbolically registered
PropsSI
. For testing withIntervalNonlinearSolve
I intend to find the saturation pressure of water at 373KExpected behavior
The solution should be
PropsSI("P", "T", 373, "Q", 1, "Water") = 100876.29794371923
Minimal Reproducible Example 👇 Here is my test code
Error & Stacktrace ⚠️
Environment (please complete the following information):
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
Additional context