Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Other direction #5

Merged
merged 8 commits into from
Oct 6, 2020
Merged

Other direction #5

merged 8 commits into from
Oct 6, 2020

Conversation

JKRT
Copy link
Owner

@JKRT JKRT commented Oct 5, 2020

No description provided.

@JKRT
Copy link
Owner Author

JKRT commented Oct 5, 2020

@adrpo I managed to get it to flatten with some changes after the faulty commit.
I did so by commenting out most of the thing in typeExp. It seems Julia really messes things up there with the recursion. I then did some more changes (While using revise) and got to the final stage. DAE conversion.
There it seem to have stuck :( JuliaLang/julia#8853 I am starting to get pretty sure that this is the issue we are having and that we are in fact dealing with a bug in Julia

@JKRT
Copy link
Owner Author

JKRT commented Oct 5, 2020

Verified. I seem to be able to make it run by commenting out everything in type binary exp. It seems to be a bug in Julia. E.g when it does type inference in recusion with big structures. Things become messy.

Working on a solution

@JKRT JKRT requested a review from adrpo October 5, 2020 22:06
@JKRT JKRT self-assigned this Oct 5, 2020
@JKRT
Copy link
Owner Author

JKRT commented Oct 5, 2020

It worked now I have the DAE.

So how to get the DAE.. Well first you need to comment out typeExp. Then you need to compile with revise. After that you need to restart the compilation with the stuff put back in once that is done it works:))

julia> @time include("test.jl")
[ Info: Translation to SCode
[ Info: SCode -> DAE
[ Info: Parsing buildin stuff
[ Info: SCode translation
┌ Error: The questions is the semantics here double check!!
└ @ HybridDAEParser.Main C:\Users\johti17\Projects\Programming\JuliaPackages\HybridDAEParser\src\NewFrontend\NFInst.jl:660
┌ Error: Double check this line. Might be ome translation error here.
└ @ HybridDAEParser.Main C:\Users\johti17\Projects\Programming\JuliaPackages\HybridDAEParser\src\NewFrontend\NFInst.jl:688
┌ Error: Here we have an error
└ @ HybridDAEParser.Main C:\Users\johti17\Projects\Programming\JuliaPackages\HybridDAEParser\src\NewFrontend\NFCall.jl:1959
┌ Error: Did we get here. After calling instArgs in NFCall
└ @ HybridDAEParser.Main C:\Users\johti17\Projects\Programming\JuliaPackages\HybridDAEParser\src\NewFrontend\NFCall.jl:1961
┌ Error: Error.. MatchFailure("unfinished", (1, HybridDAEParser.Main.LookupTree.LEAF("a", HybridDAEParser.Main.LookupTree.COMPONENT(2))))
└ @ HybridDAEParser.Main C:\Users\johti17\Projects\Programming\JuliaPackages\HybridDAEParser\src\NewFrontend\NFLookup.jl:589
┌ Error: Before set node type
└ @ HybridDAEParser.Main C:\Users\johti17\Projects\Programming\JuliaPackages\HybridDAEParser\src\NewFrontend\NFFunction.jl:2039
┌ Error: After setNodeType
└ @ HybridDAEParser.Main C:\Users\johti17\Projects\Programming\JuliaPackages\HybridDAEParser\src\NewFrontend\NFFunction.jl:2042
┌ Error: Calling inst function 3
└ @ HybridDAEParser.Main C:\Users\johti17\Projects\Programming\JuliaPackages\HybridDAEParser\src\NewFrontend\NFFunction.jl:1975
┌ Error: The questions is the semantics here double check!!
└ @ HybridDAEParser.Main C:\Users\johti17\Projects\Programming\JuliaPackages\HybridDAEParser\src\NewFrontend\NFInst.jl:660
┌ Error: Double check this line. Might be ome translation error here.
└ @ HybridDAEParser.Main C:\Users\johti17\Projects\Programming\JuliaPackages\HybridDAEParser\src\NewFrontend\NFInst.jl:688
┌ Error: Callng cache init func!
└ @ HybridDAEParser.Main C:\Users\johti17\Projects\Programming\JuliaPackages\HybridDAEParser\src\NewFrontend\NFFunction.jl:1981
┌ Error: ADD FUNC CALLED
└ @ HybridDAEParser.Main C:\Users\johti17\Projects\Programming\JuliaPackages\HybridDAEParser\src\NewFrontend\NFInstNode.jl:148
[ Info: TYPECLASS(inst_cls, name)
┌ Error: ErrorExt.setCheckpoint(getInstanceName())
└ @ HybridDAEParser.Main C:\Users\johti17\Projects\Programming\JuliaPackages\HybridDAEParser\src\NewFrontend\NFTyping.jl:1015
┌ Error: @match list(arg) = args
└ @ HybridDAEParser.Main C:\Users\johti17\Projects\Programming\JuliaPackages\HybridDAEParser\src\NewFrontend\NFBuiltinCall.jl:578
┌ Error: @match list(fn) = P_Function.typeRefCache(fn_ref) TODO
└ @ HybridDAEParser.Main C:\Users\johti17\Projects\Programming\JuliaPackages\HybridDAEParser\src\NewFrontend\NFBuiltinCall.jl:588
[ Info: AFTER type class
[ Info: START FLATTENING!
[ Info: CONSTANT EVALUATION
[ Info: FLATTENING DONE: flat_model
[ Info: COLLECT FUNCTIONS
[ Info: COLLECTED FUNCTIONS!
[ Info: COLLECT CONSTANTS
[ Info: COLLECTED CONSTANTS
[ Info: After DAE Translation
dae = HybridDAEParser.Main.DAE.DAE_LIST(Cons{HybridDAEParser.Main.DAE.Element}(HybridDAEParser.Main.DAE.COMP("HelloWorld", Cons{HybridDAEParser.Main.DAE.Element}(HybridDAEParser.Main.DAE.EQUATION(HybridDAEParser.Main.DAE.CREF(HybridDAEParser.Main.DAE.CREF_IDENT("x", HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), Nil{Any}()), HybridDAEParser.Main.DAE.T_REAL(Nil{Any}())), HybridDAEParser.Main.DAE.UNARY(HybridDAEParser.Main.DAE.UMINUS(HybridDAEParser.Main.DAE.T_REAL(Nil{Any}())), HybridDAEParser.Main.DAE.BINARY(HybridDAEParser.Main.DAE.CREF(HybridDAEParser.Main.DAE.CREF_IDENT("a", HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), Nil{Any}()), HybridDAEParser.Main.DAE.T_REAL(Nil{Any}())), HybridDAEParser.Main.DAE.MUL(HybridDAEParser.Main.DAE.T_REAL(Nil{Any}())), HybridDAEParser.Main.DAE.CALL(IDENT("der"), Cons{HybridDAEParser.Main.DAE.Exp}(HybridDAEParser.Main.DAE.CREF(HybridDAEParser.Main.DAE.CREF_IDENT("x", HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), Nil{Any}()), HybridDAEParser.Main.DAE.T_REAL(Nil{Any}())), Nil{Any}()), HybridDAEParser.Main.DAE.CALL_ATTR(HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), false, true, false, false, HybridDAEParser.Main.DAE.NO_INLINE(), HybridDAEParser.Main.DAE.NO_TAIL())))), HybridDAEParser.Main.DAE.SOURCE(SOURCEINFO("example.mo", true, 6, 3, 6, 19, 0.0), Nil{Any}(), "TODO Dummy", Nil{Any}(), Nil{Any}(), Nil{Any}(), Cons{SCode.Comment}(SCode.COMMENT(nothing, nothing), Nil{Any}()))), Cons{HybridDAEParser.Main.DAE.Element}(HybridDAEParser.Main.DAE.VAR(HybridDAEParser.Main.DAE.CREF_IDENT("x", HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), Nil{Any}()), HybridDAEParser.Main.DAE.VARIABLE(), HybridDAEParser.Main.DAE.BIDIR(), HybridDAEParser.Main.DAE.NON_PARALLEL(), HybridDAEParser.Main.DAE.PUBLIC(), HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), nothing, Nil{Any}(), HybridDAEParser.Main.DAE.NON_CONNECTOR(), HybridDAEParser.Main.DAE.SOURCE(SOURCEINFO("", false, 0, 0, 0, 0, 0.0), Nil{Any}(), nothing, Nil{Any}(), Nil{Any}(), Nil{Any}(), Nil{Any}()), nothing, SOME{SCode.Comment}(SCode.COMMENT(nothing, nothing)), NOT_INNER_OUTER()), Cons{HybridDAEParser.Main.DAE.Element}(HybridDAEParser.Main.DAE.VAR(HybridDAEParser.Main.DAE.CREF_IDENT("a", HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), Nil{Any}()), HybridDAEParser.Main.DAE.PARAM(), HybridDAEParser.Main.DAE.BIDIR(), HybridDAEParser.Main.DAE.NON_PARALLEL(), HybridDAEParser.Main.DAE.PUBLIC(), HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), SOME{HybridDAEParser.Main.DAE.Exp}(HybridDAEParser.Main.DAE.RCONST(1.0)), Nil{Any}(), HybridDAEParser.Main.DAE.NON_CONNECTOR(), HybridDAEParser.Main.DAE.SOURCE(SOURCEINFO("", false, 0, 0, 0, 0, 0.0), Nil{Any}(), nothing, Nil{Any}(), Nil{Any}(), Nil{Any}(), Nil{Any}()), nothing, SOME{SCode.Comment}(SCode.COMMENT(nothing, nothing)), NOT_INNER_OUTER()), Nil{Any}()))), HybridDAEParser.Main.DAE.SOURCE(SOURCEINFO("", false, 0, 0, 0, 0, 0.0), Nil{Any}(), nothing, Nil{Any}(), Nil{Any}(), Nil{Any}(), Nil{Any}()), SOME{SCode.Comment}(SCode.COMMENT(nothing, nothing))), Nil{Any}()))
0.670599 seconds (448.71 k allocations: 21.823 MiB)
HybridDAEParser.Main.DAE.DAE_LIST(Cons{HybridDAEParser.Main.DAE.Element}(HybridDAEParser.Main.DAE.COMP("HelloWorld", Cons{HybridDAEParser.Main.DAE.Element}(HybridDAEParser.Main.DAE.EQUATION(HybridDAEParser.Main.DAE.CREF(HybridDAEParser.Main.DAE.CREF_IDENT("x", HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), Nil{Any}()), HybridDAEParser.Main.DAE.T_REAL(Nil{Any}())), HybridDAEParser.Main.DAE.UNARY(HybridDAEParser.Main.DAE.UMINUS(HybridDAEParser.Main.DAE.T_REAL(Nil{Any}())), HybridDAEParser.Main.DAE.BINARY(HybridDAEParser.Main.DAE.CREF(HybridDAEParser.Main.DAE.CREF_IDENT("a", HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), Nil{Any}()), HybridDAEParser.Main.DAE.T_REAL(Nil{Any}())), HybridDAEParser.Main.DAE.MUL(HybridDAEParser.Main.DAE.T_REAL(Nil{Any}())), HybridDAEParser.Main.DAE.CALL(IDENT("der"), Cons{HybridDAEParser.Main.DAE.Exp}(HybridDAEParser.Main.DAE.CREF(HybridDAEParser.Main.DAE.CREF_IDENT("x", HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), Nil{Any}()), HybridDAEParser.Main.DAE.T_REAL(Nil{Any}())), Nil{Any}()), HybridDAEParser.Main.DAE.CALL_ATTR(HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), false, true, false, false, HybridDAEParser.Main.DAE.NO_INLINE(), HybridDAEParser.Main.DAE.NO_TAIL())))), HybridDAEParser.Main.DAE.SOURCE(SOURCEINFO("example.mo", true, 6, 3, 6, 19, 0.0), Nil{Any}(), "TODO Dummy", Nil{Any}(), Nil{Any}(), Nil{Any}(), Cons{SCode.Comment}(SCode.COMMENT(nothing, nothing), Nil{Any}()))), Cons{HybridDAEParser.Main.DAE.Element}(HybridDAEParser.Main.DAE.VAR(HybridDAEParser.Main.DAE.CREF_IDENT("x", HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), Nil{Any}()), HybridDAEParser.Main.DAE.VARIABLE(), HybridDAEParser.Main.DAE.BIDIR(), HybridDAEParser.Main.DAE.NON_PARALLEL(), HybridDAEParser.Main.DAE.PUBLIC(), HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), nothing, Nil{Any}(), HybridDAEParser.Main.DAE.NON_CONNECTOR(), HybridDAEParser.Main.DAE.SOURCE(SOURCEINFO("", false, 0, 0, 0, 0, 0.0), Nil{Any}(), nothing, Nil{Any}(), Nil{Any}(), Nil{Any}(), Nil{Any}()), nothing, SOME{SCode.Comment}(SCode.COMMENT(nothing, nothing)), NOT_INNER_OUTER()), Cons{HybridDAEParser.Main.DAE.Element}(HybridDAEParser.Main.DAE.VAR(HybridDAEParser.Main.DAE.CREF_IDENT("a", HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), Nil{Any}()), HybridDAEParser.Main.DAE.PARAM(), HybridDAEParser.Main.DAE.BIDIR(), HybridDAEParser.Main.DAE.NON_PARALLEL(), HybridDAEParser.Main.DAE.PUBLIC(), HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), SOME{HybridDAEParser.Main.DAE.Exp}(HybridDAEParser.Main.DAE.RCONST(1.0)), Nil{Any}(), HybridDAEParser.Main.DAE.NON_CONNECTOR(), HybridDAEParser.Main.DAE.SOURCE(SOURCEINFO("", false, 0, 0, 0, 0, 0.0), Nil{Any}(), nothing, Nil{Any}(), Nil{Any}(), Nil{Any}(), Nil{Any}()), nothing, SOME{SCode.Comment}(SCode.COMMENT(nothing, nothing)), NOT_INNER_OUTER()), Nil{Any}()))), HybridDAEParser.Main.DAE.SOURCE(SOURCEINFO("", false, 0, 0, 0, 0, 0.0), Nil{Any}(), nothing, Nil{Any}(), Nil{Any}(), Nil{Any}(), Nil{Any}()), SOME{SCode.Comment}(SCode.COMMENT(nothing, nothing))), Nil{Any}()))

DAE for hello world

@JKRT
Copy link
Owner Author

JKRT commented Oct 5, 2020

Working on getting the other stuff going.. Ideally we should merge both branches I think we might be able to do that.. 🥇 Currently working on a solution to infinite looping so the restarts are not needed

@JKRT
Copy link
Owner Author

JKRT commented Oct 5, 2020

Seems to work now. Only issue is that it takes a little time to compile:

dae = HybridDAEParser.Main.DAE.DAE_LIST(Cons{HybridDAEParser.Main.DAE.Element}(HybridDAEParser.Main.DAE.COMP("HelloWorld", Cons{HybridDAEParser.Main.DAE.Element}(HybridDAEParser.Main.DAE.EQUATION(HybridDAEParser.Main.DAE.CREF(HybridDAEParser.Main.DAE.CREF_IDENT("x", HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), Nil{Any}()), HybridDAEParser.Main.DAE.T_REAL(Nil{Any}())), HybridDAEParser.Main.DAE.UNARY(HybridDAEParser.Main.DAE.UMINUS(HybridDAEParser.Main.DAE.T_REAL(Nil{Any}())), HybridDAEParser.Main.DAE.BINARY(HybridDAEParser.Main.DAE.CREF(HybridDAEParser.Main.DAE.CREF_IDENT("a", HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), Nil{Any}()), HybridDAEParser.Main.DAE.T_REAL(Nil{Any}())), HybridDAEParser.Main.DAE.MUL(HybridDAEParser.Main.DAE.T_REAL(Nil{Any}())), HybridDAEParser.Main.DAE.CALL(IDENT("der"), Cons{HybridDAEParser.Main.DAE.Exp}(HybridDAEParser.Main.DAE.CREF(HybridDAEParser.Main.DAE.CREF_IDENT("x", HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), Nil{Any}()), HybridDAEParser.Main.DAE.T_REAL(Nil{Any}())), Nil{Any}()), HybridDAEParser.Main.DAE.CALL_ATTR(HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), false, true, false, false, HybridDAEParser.Main.DAE.NO_INLINE(), HybridDAEParser.Main.DAE.NO_TAIL())))), HybridDAEParser.Main.DAE.SOURCE(SOURCEINFO("example.mo", true, 6, 3, 6, 19, 0.0), Nil{Any}(), "TODO Dummy", Nil{Any}(), Nil{Any}(), Nil{Any}(), Cons{SCode.Comment}(SCode.COMMENT(nothing, nothing), Nil{Any}()))), Cons{HybridDAEParser.Main.DAE.Element}(HybridDAEParser.Main.DAE.VAR(HybridDAEParser.Main.DAE.CREF_IDENT("x", HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), Nil{Any}()), HybridDAEParser.Main.DAE.VARIABLE(), HybridDAEParser.Main.DAE.BIDIR(), HybridDAEParser.Main.DAE.NON_PARALLEL(), HybridDAEParser.Main.DAE.PUBLIC(), HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), nothing, Nil{Any}(), HybridDAEParser.Main.DAE.NON_CONNECTOR(), HybridDAEParser.Main.DAE.SOURCE(SOURCEINFO("", false, 0, 0, 0, 0, 0.0), Nil{Any}(), nothing, Nil{Any}(), Nil{Any}(), Nil{Any}(), Nil{Any}()), nothing, SOME{SCode.Comment}(SCode.COMMENT(nothing, nothing)), NOT_INNER_OUTER()), Cons{HybridDAEParser.Main.DAE.Element}(HybridDAEParser.Main.DAE.VAR(HybridDAEParser.Main.DAE.CREF_IDENT("a", HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), Nil{Any}()), HybridDAEParser.Main.DAE.PARAM(), HybridDAEParser.Main.DAE.BIDIR(), HybridDAEParser.Main.DAE.NON_PARALLEL(), HybridDAEParser.Main.DAE.PUBLIC(), HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), SOME{HybridDAEParser.Main.DAE.Exp}(HybridDAEParser.Main.DAE.RCONST(1.0)), Nil{Any}(), HybridDAEParser.Main.DAE.NON_CONNECTOR(), HybridDAEParser.Main.DAE.SOURCE(SOURCEINFO("", false, 0, 0, 0, 0, 0.0), Nil{Any}(), nothing, Nil{Any}(), Nil{Any}(), Nil{Any}(), Nil{Any}()), nothing, SOME{SCode.Comment}(SCode.COMMENT(nothing, nothing)), NOT_INNER_OUTER()), Nil{Any}()))), HybridDAEParser.Main.DAE.SOURCE(SOURCEINFO("", false, 0, 0, 0, 0, 0.0), Nil{Any}(), nothing, Nil{Any}(), Nil{Any}(), Nil{Any}(), Nil{Any}()), SOME{SCode.Comment}(SCode.COMMENT(nothing, nothing))), Nil{Any}()))
453.884103 seconds (259.33 M allocations: 15.468 GiB, 2.28% gc time)
HybridDAEParser.Main.DAE.DAE_LIST(Cons{HybridDAEParser.Main.DAE.Element}(HybridDAEParser.Main.DAE.COMP("HelloWorld", Cons{HybridDAEParser.Main.DAE.Element}(HybridDAEParser.Main.DAE.EQUATION(HybridDAEParser.Main.DAE.CREF(HybridDAEParser.Main.DAE.CREF_IDENT("x", HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), Nil{Any}()), HybridDAEParser.Main.DAE.T_REAL(Nil{Any}())), HybridDAEParser.Main.DAE.UNARY(HybridDAEParser.Main.DAE.UMINUS(HybridDAEParser.Main.DAE.T_REAL(Nil{Any}())), HybridDAEParser.Main.DAE.BINARY(HybridDAEParser.Main.DAE.CREF(HybridDAEParser.Main.DAE.CREF_IDENT("a", HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), Nil{Any}()), HybridDAEParser.Main.DAE.T_REAL(Nil{Any}())), HybridDAEParser.Main.DAE.MUL(HybridDAEParser.Main.DAE.T_REAL(Nil{Any}())), HybridDAEParser.Main.DAE.CALL(IDENT("der"), Cons{HybridDAEParser.Main.DAE.Exp}(HybridDAEParser.Main.DAE.CREF(HybridDAEParser.Main.DAE.CREF_IDENT("x", HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), Nil{Any}()), HybridDAEParser.Main.DAE.T_REAL(Nil{Any}())), Nil{Any}()), HybridDAEParser.Main.DAE.CALL_ATTR(HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), false, true, false, false, HybridDAEParser.Main.DAE.NO_INLINE(), HybridDAEParser.Main.DAE.NO_TAIL())))), HybridDAEParser.Main.DAE.SOURCE(SOURCEINFO("example.mo", true, 6, 3, 6, 19, 0.0), Nil{Any}(), "TODO Dummy", Nil{Any}(), Nil{Any}(), Nil{Any}(), Cons{SCode.Comment}(SCode.COMMENT(nothing, nothing), Nil{Any}()))), Cons{HybridDAEParser.Main.DAE.Element}(HybridDAEParser.Main.DAE.VAR(HybridDAEParser.Main.DAE.CREF_IDENT("x", HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), Nil{Any}()), HybridDAEParser.Main.DAE.VARIABLE(), HybridDAEParser.Main.DAE.BIDIR(), HybridDAEParser.Main.DAE.NON_PARALLEL(), HybridDAEParser.Main.DAE.PUBLIC(), HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), nothing, Nil{Any}(), HybridDAEParser.Main.DAE.NON_CONNECTOR(), HybridDAEParser.Main.DAE.SOURCE(SOURCEINFO("", false, 0, 0, 0, 0, 0.0), Nil{Any}(), nothing, Nil{Any}(), Nil{Any}(), Nil{Any}(), Nil{Any}()), nothing, SOME{SCode.Comment}(SCode.COMMENT(nothing, nothing)), NOT_INNER_OUTER()), Cons{HybridDAEParser.Main.DAE.Element}(HybridDAEParser.Main.DAE.VAR(HybridDAEParser.Main.DAE.CREF_IDENT("a", HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), Nil{Any}()), HybridDAEParser.Main.DAE.PARAM(), HybridDAEParser.Main.DAE.BIDIR(), HybridDAEParser.Main.DAE.NON_PARALLEL(), HybridDAEParser.Main.DAE.PUBLIC(), HybridDAEParser.Main.DAE.T_REAL(Nil{Any}()), SOME{HybridDAEParser.Main.DAE.Exp}(HybridDAEParser.Main.DAE.RCONST(1.0)), Nil{Any}(), HybridDAEParser.Main.DAE.NON_CONNECTOR(), HybridDAEParser.Main.DAE.SOURCE(SOURCEINFO("", false, 0, 0, 0, 0, 0.0), Nil{Any}(), nothing, Nil{Any}(), Nil{Any}(), Nil{Any}(), Nil{Any}()), nothing, SOME{SCode.Comment}(SCode.COMMENT(nothing, nothing)), NOT_INNER_OUTER()), Nil{Any}()))), HybridDAEParser.Main.DAE.SOURCE(SOURCEINFO("", false, 0, 0, 0, 0, 0.0), Nil{Any}(), nothing, Nil{Any}(), Nil{Any}(), Nil{Any}(), Nil{Any}()), SOME{SCode.Comment}(SCode.COMMENT(nothing, nothing))), Nil{Any}()))

@JKRT
Copy link
Owner Author

JKRT commented Oct 5, 2020

│ using DifferentialEquations
│ using Sundials
│ using Plots

│ function HelloWorldStartConditions(p, t0)
│ local x0 = Array{Float64}(undef, 1)
│ local dx0 = Array{Float64}(undef, 1)

│ return x0, dx0
│ end

│ function HelloWorldDifferentialVars()
│ return Bool[1]
│ end

│ function HelloWorldDAE_equations(res, dx #=The state derivatives =#, x #= State & alg variables =#, p, t #=time=#)
│ res[1] = ((x[1] #= x =#) - ((- ((p[1] #= a =#) * (dx[1] #= der(x) =#)))))
│ end

│ function HelloWorldParameterVars()
│ p = Array{Float64}(undef, 1)
│ p[1] #= a =# = (1.0)
│ return p
│ end

│ function HelloWorldSimulate(tspan = (0.0, 1.0))
│ # Define problem
│ p_is = HelloWorldParameterVars()
│ (x0, dx0) =HelloWorldStartConditions(p_is, tspan[1])
│ differential_vars = HelloWorldDifferentialVars()
│ #= Pass the residual equations =#
│ problem = DAEProblem(HelloWorldDAE_equations, dx0, x0, tspan, p_is, differential_vars=differential_vars, callback=CallbackSet())
│ # Solve with IDA:)
│ solution = solve(problem, IDA())
│ return solution
│ end

Backend seems to generate correct code

@JKRT
Copy link
Owner Author

JKRT commented Oct 5, 2020

bild

The issue is that parameters and start values does not seem to map correctly:(

@JKRT JKRT merged commit 4e9be43 into master Oct 6, 2020
@JKRT JKRT deleted the other-direction branch October 7, 2020 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant