Code Monkey home page Code Monkey logo

blocksystems.jl's People

Contributors

anbue63 avatar github-actions[bot] avatar hexaeder avatar lindnemi avatar timholy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

blocksystems.jl's Issues

Derivatives of Inputs are removed when not used as an Output

Hey,

When I calculate the derivative of an input i(t) BlockSystem automatically reduces the derivative idi(t). I think we should have a look at this! I have set up an MWE, which simply contains a block that squares the input and a derivative block:

using Pkg
Pkg.activate(@__DIR__)

using ModelingToolkit
using BlockSystems

@parameters t
dt = Differential(t)

@parameters x(t) i(t)
@variables x2(t) o(t) ii(t) idi(t)

square_block = IOBlock([x2 ~ x^2], [x], [x2], name = :square_block) 
derivative_block = IOBlock([o ~ idi, ii ~ i, dt(ii) ~ idi], [i], [o, idi, ii], name = :derivative_block)

test = IOSystem([square_block.x2 => derivative_block.i], 
                [square_block, derivative_block],
                outputs=[derivative_block.o], 
                name = :test)

connect_system(test, verbose=true)

This results in the following error. The internal states are incorrectly reduced which you can quickly see in the debugger.

ERROR: ArgumentError: inputs must be parameters
  (Set(inputs) ⊆ Set(parameters(odes))) == false
   ├ (Set(inputs)) = Set(Term{Real, Base.ImmutableDict{DataType, Any}}[x(t)])
   └ (Set(parameters(odes))) = Set{Any}()

But there is a workaround by explicitly using the derivative idi(t) and the internal state ii(t) so that it is not reduced. It works but becomes very messy once the IOSystem becomes bigger!

test = IOSystem([square_block.x2 => derivative_block.i], 
                [square_block, derivative_block],
                outputs=[derivative_block.o, derivative_block.idi, derivative_block.ii], 
                name = :test)

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.