zekeriyasari / Causal.jl

Causal.jl - A modeling and simulation framework adopting causal modeling approach.
https://zekeriyasari.github.io/Causal.jl/dev/
Other
115 stars 7 forks source link

Connecting a Memory to a Sink that has multiple input pins obstructs simulation #50

Open zekeriyasari opened 4 years ago

zekeriyasari commented 4 years ago

Consider the following model

using Causal 

# Define the model 
@defmodel model begin 
    @nodes begin 
        gen = SinewaveGenerator() 
        mem = Memory(delay=1.)
        writer = Writer(input=Inport(2)) 
    end 
    @branches begin 
        gen => mem 
        gen[1] => writer[1]
        mem[1] => writer[2]
    end
end

# Simulate the model 
sim = simulate!(model, 0, 0.01, 5.)

In the model, both gen and mem are connected to writer. When the model is tried to be simulated, the simulation gets stuck.

However, when gen and mem are connected to different writers, the simulation is carried out without being blocked. Here is the latter case.

using Causal 
using Plots 

# Define the model 
@defmodel model begin 
    @nodes begin 
        gen = SinewaveGenerator() 
        mem = Memory(delay=1.)
        writer1 = Writer(input=Inport()) 
        writer2 = Writer(input=Inport()) 
    end 
    @branches begin 
        gen => mem 
        gen=> writer1
        mem => writer2
    end
end

# Simulate the model 
sim = simulate!(model, 0, 0.01, 5.)