Tool for composable circuit simulation?

structural simplify before complete? I am surprised that didn’t error

Its actually after, but both structural simplify and complete taking the original system as argument.

Yes, that’s why I’m saying your issue is. You want to complete the structurally simplified system.

sys = complete(structural_simplify(gsys))

Note this will likely change soon.

OK, but this fails at attempted parameter setting in problem creation:

@named gsys = G2()
sys = complete(structural_simplify(gsys))

# Run g1 with one switch open, one closed, expecting current 0 (open circuit) 
prob = ODAEProblem(sys, [], (0, 10.0), [sys.g1.b1 => true, sys.g1.b2 => false])

giving

ERROR: ArgumentError: System gsys: variable g1 does not exist

Using gsys rather than sys for parameter keys fails to “bite” with the namespacing issues described above.

Interesting. Check:

@named gsys = G2()
gsys = complete(structural_simplify(gsys))

# Run g1 with one switch open, one closed, expecting current 0 (open circuit) 
prob = ODAEProblem(sys, [], (0, 10.0), [gsys.g1.b1 => true, gsys.g1.b2 => false])

(Assuming the first argument to ODAEProblem is also supposed to be gsys)
Fails with identical error message.

Still, solving the single-gadget problem above gives correct results with a problem defined on the structurally simplified system and parameterised with the “completed” parameter keys.
Also the two-gadget problem seems (to me at least) to be apparently OK set up at least parameter-wise and it would be interesting to dig into that solution. Guess I just need a pickaxe… Is my failure to access variables in that solution related to the ordering of structural-simplify and complete?

Also, anything more you could share on “this will likely change soon”…? I’m obviously interested in getting this to work and its feels like I’m getting close, but I don’t want to kick a dead horse if there is a promise (or even hope) of a healthier one showing up soon :wink:

There is a new front end syntax coming that will simplify this issue out and not require calling complete

Great! Any idea about the timing and is there an issue for it? If I can be of any help, I’d be happy to.

It will hopefully merge next week Refactor tutorials with `@mtkmodel` by ven-k · Pull Request #2286 · SciML/ModelingToolkit.jl · GitHub