{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Welding groove types and definitions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Introduction\n", "\n", "\n", "This tutorial is about generating different groove types and using the groove methods. The methods are seperatable in X parts:\n", "\n", "* Creating a groove with `get_groove`\n", "* Converting a groove to a profile\n", "* Using `plot` on a profile constructed by a groove\n", "* All possible groove types as plot\n", "* Saving and loading grooves to/from weldx files\n", "\n", "First starting with the imports needed for this tutorial:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from IPython.display import display\n", "\n", "from weldx import WeldxFile, get_groove" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Creating a groove\n", "\n", "Each groove type has different input variables, which must be passed along with it. For this we need the `Groove Type` as string and the `attributes` that describe this `Groove Type`. All attributes are used with pint quantity, we recommend to use the quantity class created by us.\n", "\n", "Here an Example with a V-Groove. Note that `groove_type=\"VGroove\"` and the required attributes are `workpiece_thickness`, `groove_angle`, `root_gap` and `root_face`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "v_groove = get_groove(\n", " groove_type=\"VGroove\",\n", " workpiece_thickness=\"1 cm\", # (note the use of 'cm')\n", " groove_angle=\"55 deg\",\n", " root_gap=\"2 mm\",\n", " root_face=\"1 mm\",\n", ")\n", "\n", "display(v_groove)\n", "print(str(v_groove))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As shown above you pass the `groove_type` along with the `attributes` and get your `Groove class`. Function `get_groove` has a detailed description for all Groove Types and their Attributes.\n", "\n", "Note: All classes can also be created separately with the classes, but this is not recommended.\n", "```Python\n", "from weldx.welding.groove.iso_9692_1 import VGroove\n", "\n", "v_groove = VGroove(t, alpha, c, b)\n", "```\n", "\n", "## Converting a groove to a profile\n", "\n", "Each `groove class` can be converted into a `Profile` by calling its `to_profile` function. To learn more about the `Profile` class and its uses look into `geometry_01_profiles.ipynb`.\n", "Profiles created this way consist of one shape per mating part. For the V-Groove each mating part is made up of four basic lines." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "v_profile = v_groove.to_profile()\n", "print(v_profile)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### calculating groove cross sectional area\n", "An approximation of the groove cross sectional area can be calculated via the `cross_sect_area` property" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(v_groove.cross_sect_area)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Using plot on a profile constructed by a groove\n", "\n", "We can visualize the profile by simply calling the `plot()` function of the groove object. Carefully note the labeling (yz) and orientation of the axis. The plot shows the groove as seen along the negative x-axis (against the welding direction)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "v_groove.plot()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As explained above you see that this V-groove has two halves and a V-Groove layout. The plot scaling is always in `millimeter`.\n", "\n", "The `plot` method has the following attributes:\n", "\n", "* `title`\n", "\n", " Setting from matplotlib. Default: `None`\n", "* `raster_width`\n", "\n", " Is the ratio of the rasterized points between each joint.\n", "* `axis`\n", "\n", " Setting from matplotlib. Default: `equal`\n", "* `grid`\n", "\n", " Setting from matplotlib. Default: `True`\n", "* `line_style`\n", "\n", " Setting from matplotlib. Default: `'.'`\n", "* `ax`\n", "\n", " Setting from matplotlib. Default: `None`\n", "\n", "\n", "Here is the same plot with different options:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "v_profile.plot(title=\"V-Groove\", raster_width=\"0.5mm\", grid=False, line_style=\"rx\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## using ASDF\n", "All groove types can be saved to *weldx*-files.\n", "\n", "Here we demonstrate the writing of the groove data into a buffer (in-memory file):" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "tree = dict(test_v_groove=v_groove)\n", "file = WeldxFile(tree=tree, mode=\"rw\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can show the file header with all groove metadata:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "file.header()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we are taking a copy of the first file by calling `WeldxFile.write_to`.\n", "Then we read the file contents again and validating the extracted groove:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "file_copy = file.write_to()\n", "data = WeldxFile(file_copy)\n", "data[\"test_v_groove\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Examples of all possible Groove Types\n", "\n", "An overview of all possible groove types:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# generate test grooves\n", "from weldx.welding.groove.iso_9692_1 import _create_test_grooves\n", "\n", "groove_dict = _create_test_grooves()\n", "for k in [\"dv_groove2\", \"dv_groove3\", \"du_groove2\", \"du_groove3\", \"du_groove4\"]:\n", " groove_dict.pop(k, None)\n", "\n", "for _k, v in groove_dict.items():\n", " v[0].plot(line_style=\"-\")" ] } ], "metadata": { "kernelspec": { "display_name": "", "language": "python", "name": "" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.11" } }, "nbformat": 4, "nbformat_minor": 4 }