示例#1
0
def test_simple_xsection(datadir):
    small1 = part_3d.ExtrudePart("small1", "Sketch001", z0=-2, thickness=2)

    big = part_3d.ExtrudePart("big", "Sketch", 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),
    }
示例#2
0
def test_dot_geo(datadir):
    """
    Tests building a simplified version of the example 'quantum_dot_device.'
    The syntax of this example should match the corresponding example.
    ANY CHANGES MADE TO THIS TEST SHOULD ALSO BE MADE IN CORRESPONDING EXAMPLE.
    """

    substrate = part_3d.ExtrudePart("Substrate",
                                    "Sketch027",
                                    z0=-2,
                                    thickness=2.0)

    gate1 = part_3d.ExtrudePart("Gate 1", "Sketch003", z0=0, thickness=10)

    wrap1 = part_3d.LithographyPart(
        "Wrap 1",
        "Sketch028",
        z0=0,
        thickness=2,
        layer_num=1,
        litho_base=[substrate, gate1],
    )

    layer2 = part_3d.LithographyPart("Layer 2",
                                     "Sketch002",
                                     z0=0,
                                     thickness=10,
                                     layer_num=2)

    wrap2 = part_3d.LithographyPart("Wrap 2",
                                    "Sketch029",
                                    z0=0,
                                    thickness=2,
                                    layer_num=3)

    layer3 = part_3d.ExtrudePart("Layer 3", "Sketch023", z0=0, thickness=30)

    # Parameters for geometry building
    input_file = os.path.join(datadir, "qd_device_parts.FCStd")
    input_parts = [substrate, gate1, wrap1, layer2, wrap2, layer3]

    # Compute parametrised geometries in parallel with dask
    geo = build_3d_geometry(input_parts=input_parts, input_file=input_file)

    # Create a local temporary directory to investigate results
    with tempfile.TemporaryDirectory() as temp_dir_path:
        geo.write_fcstd(os.path.join(temp_dir_path, "tmp.fcstd"))
        for label, part in geo.parts.items():
            part.write_stl(os.path.join(temp_dir_path, label + ".stl"))
示例#3
0
                                 thickness=10,
                                 layer_num=2)

wrap2 = part_3d.LithographyPart("Wrap 2",
                                "Sketch029",
                                z0=0,
                                thickness=2,
                                layer_num=3)

layer3 = part_3d.ExtrudePart("Layer 3", "Sketch026", z0=0, thickness=30)

# Parameters for geometry building
input_file = "qd_device_parts.fcstd"
input_parts = [
    substrate, gate1, gate2, gate3, gate4, wrap1, layer2, wrap2, layer3
]

# Compute parametrised geometries in parallel with dask
geo = build_3d_geometry(input_parts=input_parts, input_file=input_file)

# Create a local temporary directory to investigate results
os.makedirs("tmp", exist_ok=True)

print("Writing in directory tmp:")

print("Writing parametrised instance to FreeCAD file.")
geo.write_fcstd(os.path.join("tmp", "tmp.fcstd"))
for label, part in geo.parts.items():
    print(f'"{label}" ({part.fc_name} -> {part.built_fc_name}) to STL file.')
    part.write_stl(os.path.join("tmp", label + ".stl"))
示例#4
0
def test_geo_task(datadir):
    """
    Tests the build geometry task. For now, just verifies that the build doesn't encounter errors.
    """

    block1 = part_3d.ExtrudePart("Parametrised block",
                                 "Sketch",
                                 thickness=5.0,
                                 z0=-2.5)
    block2 = part_3d.ExtrudePart("Two blocks", "Sketch001", thickness=0.5)
    sag = part_3d.SAGPart("Garage",
                          "Sketch002",
                          z0=0,
                          z_middle=5,
                          thickness=6,
                          t_in=2.5,
                          t_out=0.5)
    wire = part_3d.WirePart("Nanowire", "Sketch003", z0=0, thickness=0.5)
    shell = part_3d.WireShellPart(
        "Wire cover",
        "Sketch004",
        depo_mode="depo",
        target_wire=wire,
        thickness=0.2,
        shell_verts=[1, 2],
    )
    block3 = part_3d.Geo3DPart("Passthrough", "Box")
    substrate = part_3d.ExtrudePart("Substrate",
                                    "Sketch005",
                                    z0=-2,
                                    thickness=2)
    wrap = part_3d.LithographyPart(
        "First Layer",
        "Sketch006",
        z0=0,
        layer_num=1,
        thickness=4,
        litho_base=[substrate],
    )
    wrap2 = part_3d.LithographyPart("Second Layer",
                                    "Sketch007",
                                    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, f"{i}.fcstd")
            result.write_fcstd(file_name)
示例#5
0
virt = part_3d.ExtrudePart("Virtual Domain",
                           "Sketch008",
                           thickness=5.5,
                           virtual=True)

# Parameters for geometry building
input_file = "geometry_sweep_showcase.fcstd"  # contains a model parameter 'd1'
input_parts = [block1, block2, sag, virt, wire, shell, 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"))