diff --git a/dev_utils/README.md b/dev_utils/README.md new file mode 100644 index 0000000000..290940c0cc --- /dev/null +++ b/dev_utils/README.md @@ -0,0 +1,5 @@ +# Development notebooks + +This directory contains Jupyter notebooks meant for interactively testing the code. + +Note that these notebooks are not checked as part of the CI pipeline, and could therefore be outdated. diff --git a/dev_utils/connection_test.ipynb b/dev_utils/connection_test.ipynb index eb38377c16..d744c49d79 100644 --- a/dev_utils/connection_test.ipynb +++ b/dev_utils/connection_test.ipynb @@ -13,9 +13,18 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This notebook tests the PyACP performance when run with a slower network connection. It uses the Linux ``tc-netem`` command to emulate a slower (latency- and bandwidth-restricted) network in a Docker container.\n", + "This notebook tests the PyACP performance when run with a slower network connection. It uses the Linux ``tc-netem`` command to emulate a slower (latency- and bandwidth-restricted) network in a Docker container." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "**NOTE**\n", "\n", - "Note that not all Linux kernels support ``tc-netem``: For example, it cannot be run on WSL2." + "- not all Linux kernels support ``tc-netem``. For example, it cannot be run on WSL2.\n", + "- this notebook may become outdated as the PyACP codebase evolves. It is not regularly checked for compatibility, and may need to be updated." ] }, { @@ -72,18 +81,7 @@ "metadata": {}, "outputs": [], "source": [ - "slow_server = pyacp.launch_acp(config=slow_launch)\n", - "normal_server = pyacp.launch_acp(config=normal_launch)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "slow_server.wait(timeout=30)\n", - "normal_server.wait(timeout=30)" + "slow_acp = pyacp.launch_acp(config=slow_launch)" ] }, { @@ -92,8 +90,7 @@ "metadata": {}, "outputs": [], "source": [ - "client_slow = pyacp.Client(slow_server)\n", - "client_normal = pyacp.Client(normal_server)" + "normal_acp = pyacp.launch_acp(config=normal_launch)" ] }, { @@ -110,13 +107,13 @@ "metadata": {}, "outputs": [], "source": [ - "def run_example(client):\n", - " f = client.upload_file(local_path=\"../examples/data/class40/class40.cdb\")\n", - " m = client.import_model(path=f, format=\"ansys:cdb\")\n", + "def run_example(acp_instance):\n", + " f = acp_instance.upload_file(local_path=\"../examples/data/class40/class40.cdb\")\n", + " m = acp_instance.import_model(path=f, format=\"ansys:cdb\")\n", " mg = m.create_modeling_group()\n", " for _ in range(100):\n", " mg.create_modeling_ply()\n", - " client.clear()" + " acp_instance.clear()" ] }, { @@ -125,7 +122,7 @@ "metadata": {}, "outputs": [], "source": [ - "run_example(client_normal)" + "run_example(normal_acp)" ] }, { @@ -134,7 +131,7 @@ "metadata": {}, "outputs": [], "source": [ - "run_example(client_slow)" + "run_example(slow_acp)" ] }, { diff --git a/dev_utils/material.ipynb b/dev_utils/material.ipynb deleted file mode 100644 index 4092f811e7..0000000000 --- a/dev_utils/material.ipynb +++ /dev/null @@ -1,392 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Material API demo" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Setup" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Import dependencies" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import os\n", - "import pathlib\n", - "\n", - "import ansys.acp.core as pyacp" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Launch server" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Note: Use the ansys-launcher to configure the desired launch mode, e.g. ``ansys-launcher configure ACP direct``" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "server = pyacp.launch_acp()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "server.wait(timeout=20)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "client = pyacp.Client(server)\n", - "client.clear()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Import model" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "test_model_data = pathlib.Path(os.environ[\"ACP_TEST_MODEL_DATA\"])\n", - "model_file = (\n", - " test_model_data\n", - " / \"model_data\"\n", - " / \"variable_material\"\n", - " / \"multi-dimensional_materials\"\n", - " / \"VariableSamplingPoint.acph5\"\n", - ")\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "model_file_remote = client.upload_file(str(model_file))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "model = client.import_model(path=str(model_file_remote))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Material API" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "list(model.materials.items())" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Constant Material" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Read-only, because the material is locked." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "mat1 = model.materials['Epoxy_Carbon_UD_230GPa_Prepreg']" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The `__str__` representation shows the gRPC attributes" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(str(mat1.density))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(str(mat1.engineering_constants))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Create a new material" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "mat2 = model.create_material()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "mat2.density.rho = 1200" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "mat2.density = None" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "mat2.engineering_constants.E1 = 1.2e7\n", - "mat2.engineering_constants.E1" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(str(mat2.engineering_constants))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now, changing the ply type to isotropic is blocked:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "mat2.ply_type = \"isotropic\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "mat2.engineering_constants.E1 = 0" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "mat2.ply_type = \"isotropic\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now, the isotropic engineering constants are enabled:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(str(mat2.engineering_constants))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Delete property set by setting it to `None`, or with `del`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "mat2.engineering_constants = None" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "mat2.engineering_constants" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from ansys.acp.core._tree_objects.material import EngineeringConstantsPropertySet\n", - "# re-create by assignment\n", - "mat2.engineering_constants = EngineeringConstantsPropertySet()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "mat2.engineering_constants" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Variable material property" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "mat3 = model.materials['Epoxy_EGlass_UD shear_degra']" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(str(mat3.engineering_constants))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "All read-only" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "mat3.engineering_constants.nu13 = (1, 2, 3)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "mat3.engineering_constants.field_variables" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": {}, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/dev_utils/test.ipynb b/dev_utils/test.ipynb deleted file mode 100644 index cf964deca5..0000000000 --- a/dev_utils/test.ipynb +++ /dev/null @@ -1,129 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## PyACP testing notebook\n", - "\n", - "This notebook loads a PyACP model, and is intended for interactive testing / exploration." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Setup" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Import dependencies" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import os\n", - "import pathlib\n", - "\n", - "import ansys.acp.core as pyacp" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Launch server" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Note: Use the ansys-launcher to configure the desired launch mode, e.g. ``ansys-launcher configure ACP direct``" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "server = pyacp.launch_acp()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "server.wait(timeout=20)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "client = pyacp.Client(server)\n", - "client.clear()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Import model" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "model_file = pathlib.Path(os.getcwd()).parent / \"tests\" / \"data\" / \"minimal_complete_model.acph5\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "model_file_remote = client.upload_file(str(model_file))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "model = client.import_model(path=str(model_file_remote))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Test area\n", - "\n", - "Add your testing below. Do not commit the changes.\n", - "\n", - "---" - ] - } - ], - "metadata": {}, - "nbformat": 4, - "nbformat_minor": 2 -}