sequence-toolbox / SeQUeNCe

Simulator of QUantum Network Communication (SeQUeNCe) is an open-source tool that allows modeling of quantum networks including photonic network components, control protocols, and applications.
https://sequence-rtd-tutorial.readthedocs.io/
Other
92 stars 42 forks source link

Synchronisation between two scheduled event using kernel.events #167

Open ninjha252 opened 1 year ago

ninjha252 commented 1 year ago

hello,

I'm trying to implement synchronise two discrete events scheduled. I want event2 to be run only when event1 has been executed. I'm attaching the snippet of the code where I need to synchronise event1 and event2. I want to make sure that event1 has executed before event2 starts.I can't find sub-modules to do the this, can anyone help out with this?

CODE SNIPPET

process1 = Process(self.memory, "update_state", [[complex(math.sqrt(1/2)), complex(math.sqrt(1/2))]]) process2 = Process(self.memory, "excite", ["node2"]) for i in range(NUM_TRIALS): self.timeline.show_progress = False event1 = Event(i period, process1, priority=0) event2 = Event(i period + (period / 2), process2, priority=np.infty) self.own.timeline.schedule(event1) self.own.timeline.schedule(event2)

ENDS HERE

I'll be really grateful for any help? Thank you.

Sincerely, Nitin Jha

anshsingal commented 1 year ago

I'm not sure I fully understand your question. Do you want event1 to signal event2 to execute or should event2 be executed if (and only if) event1 has been executed? According to your code, since you have scheduled event2 at a later time than event1 (i * period + (period / 2)), event2 should already execute only after event1 does.