Comments (4)
Good to have this documented but I don't expect someone to fix it any time soon. Looks deep in RCall. Not sure how JuliaCall fixes it.
from modelingtoolkit.jl.
On the surface, it looks like it's just because the types from Symbolics.jl aren't wrapped (in this case, Num
). I thought that it would work OOTB as diffeqr
works ...
from modelingtoolkit.jl.
I thought it too would work the same way as diffeqr, so I'm a bit puzzled as to why RCall doesn't auto-wrap the same.
from modelingtoolkit.jl.
This code doesn't throw an error, but it gets stuck on modelingtoolkitize
. I'm not sure whether I'm wrapping wrong, or whether ModelingToolkit is just having a really hard time:
using OrdinaryDiffEq
using ModelingToolkit
using Symbolics
using RCall
RCall.sexp(::Type{RCall.Sxp}, x::Num) = RCall.sexp(x.val)
RCall.sexpclass(::Num) = RCall.Sxp
RCall.sexp(::Type{RCall.Sxp}, x::Term{Real, Base.ImmutableDict{DataType, Any}}) = RCall.sexp(eval(x))
RCall.sexpclass(::Term{Real, Base.ImmutableDict{DataType, Any}}) = RCall.Sxp
R"""
sir_ode_r <- function(u,p,t){
S <- u[1]
I <- u[2]
R <- u[3]
N <- S+I+R
beta <- p[1]
cee <- p[2]
gamma <- p[3]
dS <- -beta*cee*I/N*S
dI <- beta*cee*I/N*S - gamma*I
dR <- gamma*I
return(c(dS,dI,dR))
}
"""
function sir_ode_jl(u,p,t)
robj = rcall(:sir_ode_r, u, p, t)
return convert(Array,robj)
end
δt = 0.1
tmax = 40.0
tspan = (0.0,tmax)
u0 = [990.0,10.0,0.0] # S,I,R
p = [0.05,10.0,0.25] # β,c,γ
prob = ODEProblem{false}(sir_ode_jl, u0, tspan, p)
@named sys = modelingtoolkitize(prob)
from modelingtoolkit.jl.
Related Issues (20)
- Observed variables are computed even when unused HOT 10
- Optimizing a control signal
- undefvar and bounds error in linearization_function
- Support for callable parameters in `IndexCache` HOT 4
- Warning: Internal error HOT 3
- Missing variables from variable map in second order coupled PDE - but only if fully coupled (?) HOT 2
- High Level example 2 error: ExtraVariablesSystemException: The system is unbalanced
- Replacing tunables of dependent parameter vector fails
- MTK & linearization -- `MTKParameters` access out of bounds
- MTK & Symbolic linearization -- why 2 inputs when I specify 1 input? HOT 1
- Initialization system fails to structural simplify
- Autodiff fails when initial conditions contain dual and non-dual HOT 9
- provide exported function for generating MTKParameters from user parameter maps HOT 5
- `u0_constructor` for SDEProblem HOT 1
- Variables introduced during simplification of 2nd order to first order dont have the correct units. HOT 1
- Vector ODE duplicating length of intial condition and not shifting equation to observed HOT 1
- Type piracy by DataFrames.jl causes error during SDE simplification
- more than one component definition in if statement `@mtkmodel`
- Reversediff with in optimization problem HOT 2
- `ODEProblem` from `ODESystem` does not sub nested constants
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from modelingtoolkit.jl.