mvwf / qublitz

8 stars 8 forks source link

Fixing Add Square Pulse Not working #13

Open anushkrishnav opened 2 months ago

anushkrishnav commented 2 months ago

Clearing the data in the pulse_vector and Updated_pulse_vector seems to fix this problem

fix #10

Neo-Cai commented 2 months ago

Thanks! But it doesn't seem like the issue is solved, if you do a 20 ns pulse, then add a 10-30 ns pulse, then clear all pulses and re-add the 10-30 ns pulse, running the simulation still does not do anything: for reference:

anushkrishnav commented 2 months ago

Thank you for the detailed explanation, i am currently investigating it

anushkrishnav commented 2 months ago

The first problem was due to the cache not being cleared correctly, i was able to fix that, can you check it on your end . when running the simulation, now the data persists ( the top graph doesn't get cleared out) but the simulation shows nothing, is it supposed to be like that? for 10ns-30ns ? image

Neo-Cai commented 2 months ago

Yeah, that is part of the issue, it should produce a graph that oscillates but it currently does not. Thanks for investigating!

anushkrishnav commented 2 months ago

@Neo-Cai in the reun_quantum_simulation method

    for state in result.states:
        # print(state)
        prob_0 = np.abs(state[0, 0])**2 # Probability of being in state |0>
        prob_1 = 1 - prob_0
        probabilities.append(prob_1)
        # Sample the distribution
        samples = np.random.choice([0, 1], size=num_shots, p=[prob_0, prob_1])
        sampled_prob_1 = np.sum(samples == 0) / num_shots
        sampled_probabilities.append(sampled_prob_1)

if we wanted to find the sampled prob pf 1 then it must be np.sum(samples==1)/num_shots rt ?

anushkrishnav commented 2 months ago

Okay the problem is when the time doesn't start from 0 prob_0 = np.abs(state[0, 0])**2 this is always 0 , for all states , hence the prob_1 becomes all 1.0

The problem is with mesolve

Neo-Cai commented 2 months ago

Yes good catch, it should be: sampled_prob_1 = np.sum(samples == 1) / num_shots

Neo-Cai commented 2 months ago

If you run a simulation from the very beginning by starting at t =/= 0, the simulation still works. I would play around and see which increments work and don't work to debug: image image

anushkrishnav commented 2 months ago

If you run a simulation from the very beginning by starting at t =/= 0, the simulation still works. I would play around and see which increments work and don't work to debug:

just for confirmation , there must be data for all possible values rt ? I am looking at how H values( Hamilton I believe) are calculated , the problem seems to be from the output of mesolve but they look alright so I am currently inspecting the parameters

anushkrishnav commented 2 months ago

So i checked for stop time of 30 , 0-8 in start works for 30 stop after that there is none, I am not sure how to move forward here @Neo-Cai

anushkrishnav commented 2 months ago

image This is the result I get for 10-30 when i updated the psi0 basis from (2,1) to (2,0) kindly check if it solved the problem.

This was from chatgpt I am trying to understand why prob_0 is 0 for all the states

    for state in result.states:
        # print(state)
        prob_0 = np.abs(state[0, 0])**2 # Probability of being in state |0>
        prob_1 = 1 - prob_0
        probabilities.append(prob_1)
        # Sample the distribution
        samples = np.random.choice([0, 1], size=num_shots, p=[prob_0, prob_1])
        sampled_prob_1 = np.sum(samples == 1) / num_shots
        sampled_probabilities.append(sampled_prob_1)
. If your initial state `psi0` is set as `basis(2, 1)`, it means the quantum system starts in the `|1>` state, and `state[0,0]` corresponds to the probability of the system being in the `|0>` state. Since you initialize the system in `|1>`, without any effective interaction (like a pulse or other Hamiltonian dynamics) causing a transition to `|0>`, the probability `state[0,0]` will remain zero. This is because there's no mechanism in the system's evolution (as set by your current parameters and setup) to populate the `|0>` state from the `|1>` state.

To observe dynamics where the system transitions between `|0>` and `|1>`, you'd either need to adjust your pulse parameters or initial state—or ensure that the Hamiltonian and any applied fields (like those represented by time-dependent terms in your Hamiltonian) effectively couple these two states. If you want to see how the system evolves from `|0>` and expect some population transfer due to your pulse, you should initialize the system in `|0>`, which would be `basis(2, 0)`.

@Neo-Cai Can you test the code and let me know what more is required or is something is not working as expected

anushkrishnav commented 2 months ago

@Neo-Cai Unitary hacks has extended the review time till 19 the I am hoping to keep working and hopefully close it by 19th, is there anything else needed ?

Neo-Cai commented 2 months ago

nope, just the bugs I identified above

anushkrishnav commented 2 months ago

nope, just the bugs I identified above

Okay updating the psi basis seems to fix the issue pushing the changes shortly for check

anushkrishnav commented 2 months ago

@Neo-Cai Pushed the changes

Neo-Cai commented 2 months ago

Unfortunately, I am not sure that it is working for me when I test it, I am unable to add a pulse from 10-20 ns when I first load the app. updating the psi basis flips the initial state the simulation starts in but we want to keep it starting in the 0 state.