TAGGED: error, photonics, simulation
-
-
March 20, 2025 at 4:30 am
marinella.guzman
SubscriberHow to simulate a Hadamard gate using qInterconnect? I am trying to learn qInterconnect and first I wanted to see if I can use it to analyze a simple hadamard gate using a directional coupler. However, every time I try to run it, I get an error saying that the input state does not exist in the created Hilbert space. How do i fix this?ÂÂFor context, this is the code I am trying to run:Âimport sys,os
from qinterconnect.solver import QSolver
os.chdir(os.path.dirname(os.path.abspath(__file__)))
nlsparams = {
      "mode_per_channel": 1,
      "nchannel": 2,
      "interconnect_file": "Trial.icp",
      "circuit": "Comp_DC",
      "input_ports": ["port 1", "port 2"],
      "output_ports": ["port 3", "port 4"],
      "nmax":2,
      "input_dims": [2,2],
      "ket_in":{
         (0, 1): [1,0],
         (1, 0): [1,0]          Â
           },
      "ket_out":{
         (0,1): [0.707,0],
         (1,0): [0.707,0]          Â
           },
      "measurement_mask":[1,0],            Â
   }
    Â
nls = QSolver(**nlsparams)
success_prob=nls.run()
print(success_prob)
print('Final Density Matrix:')
print(nls.rho_final.tidyup(atol=1e-3)) -
April 2, 2025 at 3:20 pm
Artemis Karvounis
Ansys EmployeeHello,
thank you for contacting us.
Well, you need to define properly the measurement mask. Therefore you need to modify your script in the following way:
Instead of "measurement_mask":[1,0] you need to write:   "measurement_mask":[100,1]
More specifically, the measurement_mask is a required parameter in the dictionary of the simulation parameters. You may find more details on the following link: https://optics.ansys.com/hc/en-us/articles/7369338471443-qINTERCONNECT-User-GuideÂ
Kind regards,
Artemis
Â
-
Viewing 1 reply thread
- You must be logged in to reply to this topic.
Ansys Innovation Space
Trending discussions
Top Contributors
-
2878
-
970
-
852
-
599
-
591
Top Rated Tags
© 2025 Copyright ANSYS, Inc. All rights reserved.
Ansys does not support the usage of unauthorized Ansys software. Please visit www.ansys.com to obtain an official distribution.