def test_simple_xsection(datadir): small1 = Part3DData( "small1", "Sketch001", "extrude", domain_type="dielectric", material="HfO2", z0=-2, thickness=2, ) big = Part3DData( "big", "Sketch", "extrude", domain_type="metal_gate", material="Au", boundary_condition={"voltage": 0.0}, z0=-4, thickness=8, ) input_parts = [small1, big] file_path = os.path.join(datadir, "simple.FCStd") geo_data = build_3d_geometry( input_parts=input_parts, input_file=file_path, xsec_dict={"test_xsec": { "axis": (1, 0, 0), "distance": 0 }}, ) cut_2d_geo_data = geo_data.xsec_to_2d("test_xsec") assert set(cut_2d_geo_data.parts["small1"].exterior.coords) == { (-5.0, -2.0), (-5.0, 0.0), (5.0, -2.0), (5.0, 0.0), } assert set(cut_2d_geo_data.parts["big"].exterior.coords) == { (-10.0, -4.0), (-10.0, 4.0), (10.0, -4.0), (10.0, 4.0), }
"extrude", "virtual", thickness=5.5) # Parameters for geometry building input_file = "geometry_sweep_showcase.fcstd" # contains a model parameter 'd1' input_parts = [ block1, block2, sag, virt, wire, shell, block3, substrate, wrap, wrap2 ] # Compute parametrised geometries in parallel with dask geometries = [] for d1 in np.linspace(2.0, 7.0, 3): geometries.append( build_3d_geometry(input_parts=input_parts, input_file=input_file, params={"d1": d1})) # Create a local temporary directory to investigate results if not os.path.exists("tmp"): os.makedirs("tmp") print("Writing in directory tmp:") for i, geo in enumerate(geometries): print("Writing parametrised instance " + str(i) + " to FreeCAD file.") geo.write_fcstd(os.path.join("tmp", str(i) + ".fcstd")) for label, part in geo.parts.items(): print( f'{i}: "{label}" ({part.fc_name} -> {part.built_fc_name}) to STEP file.' ) part.write_stp(os.path.join("tmp", str(i) + "_" + label + ".stp"))
def test_geo_task(datadir): """ Tests the build geometry task. For now, just verifies that the build doesn't encounter errors. """ from qmt.tasks import build_3d_geometry from qmt.data import Part3DData import numpy as np import os import tempfile block1 = Part3DData( "Parametrised block", "Sketch", "extrude", "dielectric", material="air", thickness=5.0, z0=-2.5, ) block2 = Part3DData("Two blocks", "Sketch001", "extrude", "metal_gate", material="Au", thickness=0.5) sag = Part3DData( "Garage", "Sketch002", "SAG", "metal_gate", material="Au", z0=0, z_middle=5, thickness=6, t_in=2.5, t_out=0.5, ) wire = Part3DData("Nanowire", "Sketch003", "wire", "semiconductor", z0=0, thickness=0.5) shell = Part3DData( "Wire cover", "Sketch004", "wire_shell", "metal_gate", depo_mode="depo", target_wire=wire, thickness=0.2, shell_verts=[1, 2], ) block3 = Part3DData("Passthrough", "Box", "3d_shape", "metal_gate") substrate = Part3DData("Substrate", "Sketch005", "extrude", "dielectric", z0=-2, thickness=2) wrap = Part3DData( "First Layer", "Sketch006", "lithography", "dielectric", z0=0, layer_num=1, thickness=4, litho_base=[substrate], ) wrap2 = Part3DData( "Second Layer", "Sketch007", "lithography", "dielectric", layer_num=2, thickness=1, ) input_file_path = os.path.join(datadir, "geometry_test.fcstd") print(input_file_path) build_order = [ block1, block2, sag, wire, shell, block3, substrate, wrap, wrap2 ] results = [] for d1 in np.linspace(2.0, 7.0, 3): built_geo = build_3d_geometry(input_parts=build_order, input_file=input_file_path, params={"d1": d1}) results += [built_geo] # Investigate results with tempfile.TemporaryDirectory() as temp_dir_path: for i, result in enumerate(results): file_name = os.path.join(temp_dir_path, str(i) + ".fcstd") result.write_fcstd(file_name)
def test_geo_task(fix_testDir): """ Tests the build geometry task. For now, just verifies that the build doesn't encounter errors. """ from qmt.tasks import build_3d_geometry from qmt.data import Part3DData import numpy as np import os import tempfile block1 = Part3DData('Parametrised block', 'Sketch', 'extrude', 'dielectric', material='air', thickness=5.0, z0=-2.5) block2 = Part3DData('Two blocks', 'Sketch001', 'extrude', 'metal_gate', material='Au', thickness=0.5) sag = Part3DData('Garage', 'Sketch002', 'SAG', 'metal_gate', material='Au', z0=0, z_middle=5, thickness=6, t_in=2.5, t_out=0.5) wire = Part3DData('Nanowire', 'Sketch003', 'wire', 'semiconductor', z0=0, thickness=0.5) shell = Part3DData('Wire cover', 'Sketch004', 'wire_shell', 'metal_gate', depo_mode='depo', target_wire=wire, thickness=0.2, shell_verts=[1, 2]) block3 = Part3DData('Passthrough', 'Box', '3d_shape', 'metal_gate') substrate = Part3DData('Substrate', 'Sketch005', 'extrude', 'dielectric', z0=-2, thickness=2) wrap = Part3DData('First Layer', 'Sketch006', 'lithography', 'dielectric', z0=0, layer_num=1, thickness=4, litho_base=[substrate]) wrap2 = Part3DData('Second Layer', 'Sketch007', 'lithography', 'dielectric', layer_num=2, thickness=1) print(os.path.join(fix_testDir, 'data', 'geometry_test.fcstd')) input_file_path = os.path.join(fix_testDir, 'data', 'geometry_test.fcstd') build_order = [ block1, block2, sag, wire, shell, block3, substrate, wrap, wrap2 ] results = [] for d1 in np.linspace(2., 7., 3): built_geo = build_3d_geometry(input_parts=build_order, input_file=input_file_path, params={'d1': d1}) results += [built_geo] # Investigate results with tempfile.TemporaryDirectory() as temp_dir_path: for i, result in enumerate(results): file_name = os.path.join(temp_dir_path, str(i) + '.fcstd') result.write_fcstd(file_name)