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), }
def test_build_extrude(fix_FCDoc, fix_hexagon_sketch): from qmt.data import Part3DData sketch = fix_hexagon_sketch() input_part = Part3DData('label', sketch.Name, 'extrude', 'metal_gate', material='Au', thickness=10) built_part = build_extrude(input_part)
def test_build_extrude(fix_FCDoc, fix_hexagon_sketch): from qmt.data import Part3DData sketch = fix_hexagon_sketch() input_part = Part3DData("label", sketch.Name, "extrude", "metal_gate", material="Au", thickness=10) built_part = build_extrude(input_part)
def test_build(fix_exampleDir, fix_FCDoc): from qmt.data import Part3DData myPart = Part3DData('block_of_gold', 'Sketch', 'extrude', 'metal_gate', material='Au', thickness=10) opts = { 'pyenv': 'python2', 'file_path': os.path.join(fix_exampleDir, 'geometry_sweep_showcase.fcstd'), 'input_parts': [myPart] } fix_FCDoc.load(opts['file_path']) build(opts)
def test_build(fix_exampleDir, fix_FCDoc): from qmt.data import Part3DData myPart = Part3DData("block_of_gold", "Sketch", "extrude", "metal_gate", material="Au", thickness=10) opts = { "file_path": os.path.join(fix_exampleDir, "geometry_sweep", "geometry_sweep_showcase.fcstd"), "input_parts": [myPart], "xsec_dict": {}, } fix_FCDoc.load(opts["file_path"]) build(opts)
# -*- coding: utf-8 -*- """Example geometry sweeping.""" import os import numpy as np from qmt.data import Part3DData from qmt.tasks.basic.geometry import Geometry3D from qmt.tasks.sweep import SweepTag, SweepManager # Set up geometry task tag1 = SweepTag('d1 thickness') 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,
#!/usr/bin/env python # -*- coding: utf-8 -*- """Example geometry sweeping.""" import os import numpy as np from qmt.data import Part3DData from qmt.tasks import build_3d_geometry # Set up geometry task 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",
def test_geo_task(fix_py2env, fix_testDir): """ Tests the build geometry task. For now, just verifies that the build doesn't encounter errors. """ from qmt.tasks import SweepTag, Geometry3D, SweepManager from qmt.data import Part3DData import numpy as np import os import shutil tag1 = SweepTag('d1 thickness') 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, 'py3', 'data', 'geometry_test.fcstd')) # serial_fc_doc = Geometry3D.serialize_fc_file( input_file_path = os.path.join(fix_testDir, 'py3', 'data', 'geometry_test.fcstd') freecad_dict = { 'pyenv': fix_py2env, 'input_file': input_file_path, 'params': { 'd1': tag1 }, 'input_parts': [block1, block2, sag, wire, shell, block3, substrate, wrap, wrap2] } geo_task = Geometry3D(options=freecad_dict) # Run sweeps sweeps = [{tag1: val} for val in np.linspace(2, 7, 3)] result = SweepManager(sweeps).run(geo_task) # Investigate results if not os.path.exists('tmp'): os.makedirs('tmp') for i, future in enumerate(result.futures): geo = future.result() file_name = 'tmp/' + str(i) + '.fcstd' geo.write_fcstd(file_name) #TODO: should find a meaningful test here shutil.rmtree('tmp')
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)