qiskit-community / qiskit-metal

Quantum Hardware Design. Open-source project for engineers and scientists to design superconducting quantum devices with ease.
https://qiskit-community.github.io/qiskit-metal/
Apache License 2.0
289 stars 208 forks source link

Input Type error of 'render_design()' in class 'QHFSSDrivenmodalPyaedt()' #992

Open ChrisW918 opened 4 months ago

ChrisW918 commented 4 months ago

Information

What is the current behavior?

I wanted to use pyaedt to build connect between my Ansys Student Version and the metal script, following by the notebook DrivenModal.

The issue occurs when I execute

hfss_dm.render_design(selection=[
    'TQ1', 'TQ2', 'cpw_openRight', 'cpw_openLeft', 'cpw_middle', 'Q1', 'Q2'],
                      open_pins=[],
                      port_list=[
                          ('cpw_openRight', 'end', 50),
                                 ('cpw_openLeft', 'end', 50)
                                 ],
                      jj_to_port=[ ('Q2', 'rect_jj', 51)],
                      ignored_jjs=[('Q1', 'rect_jj')],
                      box_plus_buffer=True)

, and it reports

TypeError: unsupported operand type(s) for /: 'Dict' and 'int'

Steps to reproduce the problem

I looked into the function description of render_design() and the suggested format of input is exactly (component name[str], element name[str], impedence[int]).

What I've tried is to replace the int value of impedence as str '50', and the cell successfully executed with notification

11:42PM 08s ERROR [confirm_port_list_have_valid_request]: Impedance should be either float or int. You have impedance=50 11:42PM 08s ERROR [valid_input_arguments]: Arguments are not in Design for port_list. 11:42PM 08s ERROR [render_design]: Check the arguments to render_design, invalid name was probably used.

Therefore, the value is not succefully imported.

What is the expected behavior?

As I run the cells in notebook, it should be well worked.

Suggested solutions

I would like to ask to look deep into the function of render_design() and its inherted functions to see which one reports the TypeError, and eventually makes the notebook successfully executes.

zlatko-minev commented 4 months ago

Hi Chris,

Thanks for checking this out.

Let's see, so the pyaedt codebase has changed a bit since the notebook was written.

Can you show the full trace back? So the issue is only with the port values?

Have you looked in here btw? https://github.com/qiskit-community/qiskit-metal/blob/main/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_drivenmodal_aedt.py This is where render_design is defined

ChrisW918 commented 4 months ago

Hi @zlatko-minev,

Here is the full trace back,

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[43], [line 1](vscode-notebook-cell:?execution_count=43&line=1)
----> [1](vscode-notebook-cell:?execution_count=43&line=1) hfss_dm.render_design(selection=[
      [2](vscode-notebook-cell:?execution_count=43&line=2)     'TQ1', 'TQ2', 'cpw_openRight', 'cpw_openLeft', 'cpw_middle', 'Q1', 'Q2'
      [3](vscode-notebook-cell:?execution_count=43&line=3) ],
      [4](vscode-notebook-cell:?execution_count=43&line=4)                       open_pins=[],
      [5](vscode-notebook-cell:?execution_count=43&line=5)                       port_list=[('cpw_openRight', 'end', 50),
      [6](vscode-notebook-cell:?execution_count=43&line=6)                                  ('cpw_openLeft', 'end', 50)],
      [7](vscode-notebook-cell:?execution_count=43&line=7)                       jj_to_port=[('Q2', 'rect_jj', 51)],
      [8](vscode-notebook-cell:?execution_count=43&line=8)                       ignored_jjs=[('Q1', 'rect_jj')],
      [9](vscode-notebook-cell:?execution_count=43&line=9)                       box_plus_buffer=True)

File c:\Users\kriswang\anaconda3\envs\qiskitMetal\lib\site-packages\qiskit_metal\renderers\renderer_ansys_pyaedt\hfss_renderer_drivenmodal_aedt.py:513, in QHFSSDrivenmodalPyaedt.render_design(self, selection, open_pins, port_list, jj_to_port, ignored_jjs, box_plus_buffer)
    [509](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_drivenmodal_aedt.py:509) # self.fill_info will hold the name of newly generated box,
    [510](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_drivenmodal_aedt.py:510) # along with information from layer stack
    [511](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_drivenmodal_aedt.py:511) self.fill_info = self.design.ls.get_layer_datatype_when_fill_is_true()
--> [513](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_drivenmodal_aedt.py:513) super().render_design(selection, open_pins, port_list, jj_to_port,
    [514](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_drivenmodal_aedt.py:514)                       ignored_jjs, box_plus_buffer)
    [516](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_drivenmodal_aedt.py:516) if self.case == 2:
    [517](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_drivenmodal_aedt.py:517)     self.logger.warning(
    [518](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_drivenmodal_aedt.py:518)         'Unable to proceed with rendering. Please check selection.')

File c:\Users\kriswang\anaconda3\envs\qiskitMetal\lib\site-packages\qiskit_metal\renderers\renderer_ansys_pyaedt\hfss_renderer_aedt.py:240, in QHFSSPyaedt.render_design(self, selection, open_pins, port_list, jj_to_port, ignored_jjs, box_plus_buffer)
    [236](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_aedt.py:236) # Add something to clear design.
...
    [342](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/pyaedt_base.py:342)     matname=material)
    [344](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/pyaedt_base.py:344) # The transparency is hardcoded.  Ugh.
    [345](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/pyaedt_base.py:345) # However, it was hardcoded without pyaedt, so for now, will leave it alone.

TypeError: unsupported operand type(s) for /: 'Dict' and 'int'

and here I also attach the argment setting, which should be two pairs of float Transmon-resonator model sharing one transmission line. Pleas check my arguments setting.

hfss_dm.render_design(selection=[
    'TQ1', 'TQ2', 'cpw_openRight', 'cpw_openLeft', 'cpw_middle', 'Q1', 'Q2'
],
                      open_pins=[],

                      port_list=[('cpw_openRight', 'end', '50'),
                                 ('cpw_openLeft', 'start', '50')
                                 ],
                      jj_to_port=[ ('Q2', 'rect_jj', 51),
                                  ('Q1', 'rect_jj', 52)],
                    #   ignored_jjs=[('Q1', 'rect_jj')],
                      box_plus_buffer=True)

I think only the port values arg report this issue since as I change the value into str and keep the setting of jj_to_port, it does not report error.

Also, I read the function description, and confused about the blink arg open_pins since apparently, the two pins of the transmission line should be open right?

zlatko-minev commented 4 months ago

I think you cut the stack printout, it shows ..., so it's hard to see where the error actually occurred

ChrisW918 commented 3 months ago

generated box,
    [510](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_drivenmodal_aedt.py:510) # along with information from layer stack
    [511](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_drivenmodal_aedt.py:511) self.fill_info = self.design.ls.get_layer_datatype_when_fill_is_true()
--> [513](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_drivenmodal_aedt.py:513) super().render_design(selection, open_pins, port_list, jj_to_port,
    [514](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_drivenmodal_aedt.py:514)                       ignored_jjs, box_plus_buffer)
    [516](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_drivenmodal_aedt.py:516) if self.case == 2:
    [517](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_drivenmodal_aedt.py:517)     self.logger.warning(
    [518](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_drivenmodal_aedt.py:518)         'Unable to proceed with rendering. Please check selection.')

File c:\Users\kriswang\anaconda3\envs\qiskitMetal\lib\site-packages\qiskit_metal\renderers\renderer_ansys_pyaedt\hfss_renderer_aedt.py:240, in QHFSSPyaedt.render_design(self, selection, open_pins, port_list, jj_to_port, ignored_jjs, box_plus_buffer)
    [236](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_aedt.py:236) # Add something to clear design.
    [238](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_aedt.py:238) self.draw_sample_holder()
--> [240](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_aedt.py:240) self.aedt_render_by_layer_then_tables(skip_junction=False,
    [241](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_aedt.py:241)                                       open_pins=open_pins,
    [242](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_aedt.py:242)                                       port_list=port_list,
    [243](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_aedt.py:243)                                       jj_to_port=jj_to_port,
    [244](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_aedt.py:244)                                       ignored_jjs=ignored_jjs)

File c:\Users\kriswang\anaconda3\envs\qiskitMetal\lib\site-packages\qiskit_metal\renderers\renderer_ansys_pyaedt\hfss_renderer_aedt.py:294, in QHFSSPyaedt.aedt_render_by_layer_then_tables(self, open_pins, port_list, jj_to_port, ignored_jjs, skip_junction, data_type)
    [291](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_aedt.py:291) for table_type in self.design.qgeometry.get_element_types():
    [292](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_aedt.py:292)     if table_type != 'junction' or not skip_junction:
    [293](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_aedt.py:293)         #At this point, we know table type,
--> [294](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_aedt.py:294)         self.render_components(table_type, layer_num,
    [295](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_aedt.py:295)                                port_list_subset, jj_to_port_subset,
    [296](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_aedt.py:296)                                ignored_jjs_subset)
    [298](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_aedt.py:298) #For each layer, add the endcaps and
    [299](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_aedt.py:299) # add polyline to subtract to self.chip_subtract_dict[layer_num].
    [301](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_aedt.py:301) if isinstance(open_pins_subset, list) and self.open_pins_is_valid:
    [302](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_aedt.py:302)     # Only use this method if user defines open pins.

File c:\Users\kriswang\anaconda3\envs\qiskitMetal\lib\site-packages\qiskit_metal\renderers\renderer_ansys_pyaedt\pyaedt_base.py:289, in QPyaedt.render_components(self, table_type, layer_num, port_list, jj_to_port, ignored_jjs)
    [286](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/pyaedt_base.py:286) table_to_use = table[mask_layer]
    [288](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/pyaedt_base.py:288) for _, qgeom in table_to_use.iterrows():
--> [289](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/pyaedt_base.py:289)     self.render_element(qgeom,
    [290](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/pyaedt_base.py:290)                         bool(table_type == 'junction'),
    [291](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/pyaedt_base.py:291)                         port_list=port_list,
    [292](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/pyaedt_base.py:292)                         jj_to_port=jj_to_port,
    [293](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/pyaedt_base.py:293)                         ignored_jjs=ignored_jjs)

File c:\Users\kriswang\anaconda3\envs\qiskitMetal\lib\site-packages\qiskit_metal\renderers\renderer_ansys_pyaedt\hfss_renderer_aedt.py:483, in QHFSSPyaedt.render_element(self, qgeom, is_junction, port_list, jj_to_port, ignored_jjs)
    [481](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_aedt.py:481)     self.render_element_poly(qgeom)
    [482](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_aedt.py:482) elif isinstance(qc_shapely, shapely.geometry.LineString):
--> [483](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/hfss_renderer_aedt.py:483)     self.render_element_path(qgeom)

File c:\Users\kriswang\anaconda3\envs\qiskitMetal\lib\site-packages\qiskit_metal\renderers\renderer_ansys_pyaedt\pyaedt_base.py:335, in QPyaedt.render_element_path(self, qgeom)
    [333](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/pyaedt_base.py:333) # LINESTRING does not have interior and exterior coords.
    [334](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/pyaedt_base.py:334) points_2d = list(qc_shapely.coords)
--> [335](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/pyaedt_base.py:335) points_3d = to_vec3D_list(points_2d, z_coord + (thickness / 2))
    [337](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/pyaedt_base.py:337) a_polyline = self.current_app.modeler.create_polyline(
    [338](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/pyaedt_base.py:338)     points_3d,
    [339](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/pyaedt_base.py:339)     name=name,
    [340](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/pyaedt_base.py:340)     cover_surface=False,
    [341](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/pyaedt_base.py:341)     close_surface=False,
    [342](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/pyaedt_base.py:342)     matname=material)
    [344](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/pyaedt_base.py:344) # The transparency is hardcoded.  Ugh.
    [345](file:///C:/Users/kriswang/anaconda3/envs/qiskitMetal/lib/site-packages/qiskit_metal/renderers/renderer_ansys_pyaedt/pyaedt_base.py:345) # However, it was hardcoded without pyaedt, so for now, will leave it alone.

TypeError: unsupported operand type(s) for /: 'Dict' and 'int'

Hi @zlatko-minev, sorry for the cut, and here are the full report. It turns out that the input variables for function to_vec3D_list are not in correct type. My breakpoints were failed to build in, so I was not able to debug for the inputs. Could you take a look to check this function, and in case possible, could you update the notebook that is compatible with the current version?