diff --git a/.github/workflows/nfdi.yml b/.github/workflows/nfdi.yml new file mode 100644 index 0000000..c160766 --- /dev/null +++ b/.github/workflows/nfdi.yml @@ -0,0 +1,39 @@ +name: NFDI4Ing + +on: + push: + branches: [ main ] + pull_request: + +jobs: + build: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - uses: conda-incubator/setup-miniconda@v3 + with: + auto-update-conda: true + python-version: "3.12" + environment-file: environment.yml + auto-activate-base: false + - name: Installation and setup + shell: bash -l {0} + run: | + pip install -e qe_xml_parser + pip install -e python_workflow_definition + conda install -c conda-forge jupyter papermill + verdi presto --profile-name pwd + sudo apt-get install -y $(cat apt.txt) + - name: Create Additional Conda Environments + shell: bash -l {0} + run: | + conda env create -n preprocessing -f source/envs/preprocessing.yaml -y + conda env create -n processing -f source/envs/processing.yaml -y + conda env create -n postprocessing -f source/envs/postprocessing.yaml -y + - name: Tests + shell: bash -l {0} + run: | + papermill aiida_nfdi.ipynb aiida_nfdi_out.ipynb -k "python3" + papermill jobflow_nfdi.ipynb jobflow_nfdi_out.ipynb -k "python3" + papermill pyiron_base_nfdi.ipynb pyiron_base_nfdi_out.ipynb -k "python3" + papermill universal_workflow_nfdi.ipynb universal_workflow_nfdi_out.ipynb -k "python3" diff --git a/aiida_nfdi.ipynb b/aiida_nfdi.ipynb new file mode 100644 index 0000000..0d73c32 --- /dev/null +++ b/aiida_nfdi.ipynb @@ -0,0 +1,903 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "106ded66-d202-46ac-82b0-2755ca309bdd", + "metadata": {}, + "source": [ + "https://github.com/BAMresearch/NFDI4IngScientificWorkflowRequirements" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "6d86e804-245a-4d96-a1a3-1bc3216c3646", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "# conda environments:\n", + "#\n", + "base * /home/janssen/mambaforge\n", + "postprocessing /home/janssen/mambaforge/envs/postprocessing\n", + "preprocessing /home/janssen/mambaforge/envs/preprocessing\n", + "processing /home/janssen/mambaforge/envs/processing\n", + "\n" + ] + } + ], + "source": [ + "!conda env list" + ] + }, + { + "cell_type": "markdown", + "id": "11e09b78-cb72-465f-9c8b-5b77f0aa729c", + "metadata": {}, + "source": [ + "# Preprocessing " + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "a76e6c0a-98f2-4436-af10-8097da183341", + "metadata": {}, + "outputs": [], + "source": [ + "from nfdi_ing_workflow import (\n", + " generate_mesh,\n", + " convert_to_xdmf as _convert_to_xdmf,\n", + " poisson as _poisson,\n", + " plot_over_line,\n", + " substitute_macros,\n", + " compile_paper,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "89c02460-b543-442c-a27e-f1757dc2262e", + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.aiida import write_workflow_json\n", + "\n", + "from aiida_workgraph import WorkGraph, task\n", + "from aiida import orm, load_profile\n", + "load_profile()" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "549ecf27-88ef-4e77-8bd4-b616cfdda2e4", + "metadata": {}, + "outputs": [], + "source": [ + "convert_to_xdmf = task(outputs=[\"xdmf_file\", \"h5_file\"])(_convert_to_xdmf)\n", + "poisson = task(outputs=[\"numdofs\", \"pvd_file\", \"vtu_file\"])(_poisson)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "8d911f98-3b80-457f-a0f4-3cb37ebf1691", + "metadata": {}, + "outputs": [], + "source": [ + "domain_size = orm.Float(2.0)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1e7e14ba-c4a7-485f-9bd8-44625830cca0", + "metadata": {}, + "outputs": [], + "source": [ + "wg = WorkGraph(\"wg-nfdi\")" + ] + }, + { + "cell_type": "markdown", + "id": "cf1e22d2-9ce5-488f-8048-308d7d5d4966", + "metadata": {}, + "source": [ + "## generate mesh" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "71d411b6-cbec-489e-99e3-ba71680bcb5b", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "gmsh_output_file = wg.add_task(\n", + " generate_mesh,\n", + " name=\"generate_mesh\",\n", + " domain_size=domain_size,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "019938e7-8b41-47a9-b226-00e05dabc193", + "metadata": {}, + "source": [ + "## convert to xdmf" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "1d0d9804-f250-48b3-a5d0-a546d520f79b", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "meshio_output_dict = wg.add_task(\n", + " convert_to_xdmf,\n", + " name=\"convert_to_xdmf\",\n", + " gmsh_output_file=gmsh_output_file.outputs.result,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "ceb0b643-caaa-426c-9781-28703440e647", + "metadata": {}, + "source": [ + "# Processing" + ] + }, + { + "cell_type": "markdown", + "id": "11815a8b-319c-4ff3-8eae-330bf6e58eee", + "metadata": {}, + "source": [ + "## poisson" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "7b69bcff-e2b1-4d4a-b62c-6a1c86eeb590", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "poisson_dict = wg.add_task(\n", + " poisson,\n", + " name=\"poisson\",\n", + " meshio_output_xdmf=meshio_output_dict.outputs.xdmf_file, \n", + " meshio_output_h5=meshio_output_dict.outputs.h5_file,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "bc8a8634-029e-4337-96a2-a1f284cb4c38", + "metadata": {}, + "source": [ + "# Postprocessing" + ] + }, + { + "cell_type": "markdown", + "id": "157c5386-91a3-4e21-ac65-8f947f2d62fa", + "metadata": {}, + "source": [ + "## plot over line" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "3c4a29b0-eb1e-490a-8be0-e03cfff15e0a", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "pvbatch_output_file = wg.add_task(\n", + " plot_over_line,\n", + " name=\"plot_over_line\",\n", + " poisson_output_pvd_file=poisson_dict.outputs.pvd_file, \n", + " poisson_output_vtu_file=poisson_dict.outputs.vtu_file,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "54f1d4bd-b944-470f-9cf8-30e64a24eb6d", + "metadata": {}, + "source": [ + "## substitute macros" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "a0a4c233-322d-4723-9627-62ca2487bfa9", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "macros_tex_file = wg.add_task(\n", + " substitute_macros,\n", + " name=\"substitute_macros\",\n", + " pvbatch_output_file=pvbatch_output_file.outputs.result, \n", + " ndofs=poisson_dict.outputs.numdofs, \n", + " domain_size=domain_size,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "2031b693-acf3-48bd-bb00-e33f669381e9", + "metadata": {}, + "source": [ + "## compile paper" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "c281408f-e63d-4380-a7e6-c595d49fbb8f", + "metadata": {}, + "outputs": [], + "source": [ + "paper_output = wg.add_task(\n", + " compile_paper,\n", + " name=\"compile_paper\",\n", + " macros_tex=macros_tex_file.outputs.result, \n", + " plot_file=pvbatch_output_file.outputs.result,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "a384d70a-8ef5-4fdd-880c-56ac7eaf87b9", + "metadata": {}, + "outputs": [], + "source": [ + "wg" + ] + }, + { + "cell_type": "markdown", + "id": "5c1b0200-bba3-484d-ac49-f582898e974f", + "metadata": {}, + "source": [ + "# Convert " + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "196faf18-c46b-4f42-a652-698d2c580221", + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.aiida import write_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "fb23ad9c-76fd-4c0b-b546-e305d6c49796", + "metadata": {}, + "outputs": [], + "source": [ + "workflow_json_filename = \"aiida_nfdi.json\"" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "4139547a-9717-4708-b1a5-8202a0382d77", + "metadata": {}, + "outputs": [], + "source": [ + "write_workflow_json(wg=wg, file_name=workflow_json_filename)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "490df6a3-e402-4620-acf2-dbcfa0c5d537", + "metadata": {}, + "outputs": [], + "source": [ + "!cat {workflow_json_filename}" + ] + }, + { + "cell_type": "markdown", + "id": "11a829e2-face-469f-b343-2c95763b1f13", + "metadata": {}, + "source": [ + "# Load Workflow with jobflow" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4f3acabe-55df-479a-af4d-a23a80c4660d", + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.jobflow import load_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b6ba9444-a2c8-451b-b74c-19b0f69ba369", + "metadata": {}, + "outputs": [], + "source": [ + "from jobflow.managers.local import run_locally" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c3528d55-6bf7-47ed-a110-65c47446ba92", + "metadata": {}, + "outputs": [], + "source": [ + "flow = load_workflow_json(file_name=workflow_json_filename)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5ef48778-4209-425f-8c6b-85a4cd2f92ec", + "metadata": {}, + "outputs": [], + "source": [ + "result = run_locally(flow)\n", + "result" + ] + }, + { + "cell_type": "markdown", + "id": "397b16a2-e1ec-4eec-8562-1c84f585c347", + "metadata": {}, + "source": [ + "# Load Workflow with pyiron_base" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "fdde6b82-b51d-434a-a9a8-5a8c31bbb429", + "metadata": {}, + "outputs": [], + "source": [ + "from pyiron_base import Project" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "be4d5d93-e9f6-4072-a6be-0ee5dc93590f", + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.pyiron_base import load_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "4db75587-5f4c-416d-a1f6-c949077fa2ca", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "b5c4c082a18b4d5391aac8dd470570d5", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "0it [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "pr = Project(\"test\")\n", + "pr.remove_jobs(recursive=True, silently=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "4452a648-d4c3-4f5f-8678-ffb54bef17dc", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + "\n", + "\n", + "create_function_job_19ee2cba4a6ec0c97eab519834ce2c6b\n", + "\n", + "create_function_job=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4ab70>\n", + "\n", + "\n", + "\n", + "macros_tex_f8e7c70add5a6917362eaba96348676f\n", + "\n", + "macros_tex=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a8d0>\n", + "\n", + "\n", + "\n", + "macros_tex_f8e7c70add5a6917362eaba96348676f->create_function_job_19ee2cba4a6ec0c97eab519834ce2c6b\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "pvbatch_output_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "pvbatch_output_file=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a570>\n", + "\n", + "\n", + "\n", + "pvbatch_output_file_a227e82a0cabcaa4ff69b537232c3daf->macros_tex_f8e7c70add5a6917362eaba96348676f\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973\n", + "\n", + "poisson_output_pvd_file=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a1e0>\n", + "\n", + "\n", + "\n", + "poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973->pvbatch_output_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "plot_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "plot_file=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a570>\n", + "\n", + "\n", + "\n", + "poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973->plot_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "plot_file_a227e82a0cabcaa4ff69b537232c3daf->create_function_job_19ee2cba4a6ec0c97eab519834ce2c6b\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d\n", + "\n", + "meshio_output_xdmf=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d49dc0>\n", + "\n", + "\n", + "\n", + "meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d->poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3\n", + "\n", + "poisson_output_vtu_file=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a090>\n", + "\n", + "\n", + "\n", + "meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d->poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "ndofs_af456a32dc17ccd053cef8f83b61802e\n", + "\n", + "ndofs=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a600>\n", + "\n", + "\n", + "\n", + "meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d->ndofs_af456a32dc17ccd053cef8f83b61802e\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3->pvbatch_output_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3->plot_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "ndofs_af456a32dc17ccd053cef8f83b61802e->macros_tex_f8e7c70add5a6917362eaba96348676f\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "gmsh_output_file_b41125ac47f34334493d860607ee71a3\n", + "\n", + "gmsh_output_file=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d49af0>\n", + "\n", + "\n", + "\n", + "gmsh_output_file_b41125ac47f34334493d860607ee71a3->meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081\n", + "\n", + "meshio_output_h5=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d49a30>\n", + "\n", + "\n", + "\n", + "gmsh_output_file_b41125ac47f34334493d860607ee71a3->meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081->poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081->poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081->ndofs_af456a32dc17ccd053cef8f83b61802e\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "domain_size_f12a7f1986b9dd058dfc666dbe230b20\n", + "\n", + "domain_size=2.0\n", + "\n", + "\n", + "\n", + "domain_size_f12a7f1986b9dd058dfc666dbe230b20->macros_tex_f8e7c70add5a6917362eaba96348676f\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "domain_size_f12a7f1986b9dd058dfc666dbe230b20->gmsh_output_file_b41125ac47f34334493d860607ee71a3\n", + "\n", + "\n", + "\n", + "\n", + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "delayed_object = load_workflow_json(project=pr, file_name=workflow_json_filename)\n", + "delayed_object.draw()" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "1c2760b6-96b4-4f44-ac49-a229d4a0cf67", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The job generate_mesh_0b48cf5155cd6802c17d20bb58104132 was saved and received the ID: 2005\n", + "The job convert_to_xdmf_9ded0361e4866afe4962398287e4f6ae was saved and received the ID: 2006\n", + "The job poisson_2d98621ac2c8e43a266693cf65647173 was saved and received the ID: 2007\n", + "The job plot_over_line_004790462b53a54f512cc7e1a2a10519 was saved and received the ID: 2008\n", + "The job substitute_macros_52130ff9ec1931ec82532a7119df653f was saved and received the ID: 2009\n", + "The job compile_paper_b65627cdc212fc76a216689a26379fae was saved and received the ID: 2010\n" + ] + }, + { + "data": { + "text/plain": [ + "'/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/postprocessing/paper.pdf'" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "delayed_object.pull()" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "b3bba27e-ece9-4c02-834c-53e69844b140", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idstatuschemicalformulajobsubjobprojectpathprojecttimestarttimestoptotalcputimecomputerhamiltonhamversionparentidmasterid
02005finishedNonegenerate_mesh_0b48cf5155cd6802c17d20bb58104132/generate_mesh_0b48cf5155cd6802c17d20bb58104132None/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 15:02:38.490191NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
12006finishedNoneconvert_to_xdmf_9ded0361e4866afe4962398287e4f6ae/convert_to_xdmf_9ded0361e4866afe4962398287e4f6aeNone/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 15:02:45.247485NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
22007finishedNonepoisson_2d98621ac2c8e43a266693cf65647173/poisson_2d98621ac2c8e43a266693cf65647173None/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 15:02:52.878817NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
32008finishedNoneplot_over_line_004790462b53a54f512cc7e1a2a10519/plot_over_line_004790462b53a54f512cc7e1a2a10519None/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 15:03:02.977300NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
42009finishedNonesubstitute_macros_52130ff9ec1931ec82532a7119df653f/substitute_macros_52130ff9ec1931ec82532a7119df653fNone/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 15:03:10.674995NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
52010finishedNonecompile_paper_b65627cdc212fc76a216689a26379fae/compile_paper_b65627cdc212fc76a216689a26379faeNone/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 15:03:16.820860NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
\n", + "
" + ], + "text/plain": [ + " id status chemicalformula \\\n", + "0 2005 finished None \n", + "1 2006 finished None \n", + "2 2007 finished None \n", + "3 2008 finished None \n", + "4 2009 finished None \n", + "5 2010 finished None \n", + "\n", + " job \\\n", + "0 generate_mesh_0b48cf5155cd6802c17d20bb58104132 \n", + "1 convert_to_xdmf_9ded0361e4866afe4962398287e4f6ae \n", + "2 poisson_2d98621ac2c8e43a266693cf65647173 \n", + "3 plot_over_line_004790462b53a54f512cc7e1a2a10519 \n", + "4 substitute_macros_52130ff9ec1931ec82532a7119df653f \n", + "5 compile_paper_b65627cdc212fc76a216689a26379fae \n", + "\n", + " subjob projectpath \\\n", + "0 /generate_mesh_0b48cf5155cd6802c17d20bb58104132 None \n", + "1 /convert_to_xdmf_9ded0361e4866afe4962398287e4f6ae None \n", + "2 /poisson_2d98621ac2c8e43a266693cf65647173 None \n", + "3 /plot_over_line_004790462b53a54f512cc7e1a2a10519 None \n", + "4 /substitute_macros_52130ff9ec1931ec82532a7119df653f None \n", + "5 /compile_paper_b65627cdc212fc76a216689a26379fae None \n", + "\n", + " project \\\n", + "0 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "1 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "2 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "3 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "4 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "5 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "\n", + " timestart timestop totalcputime computer \\\n", + "0 2025-04-02 15:02:38.490191 None None pyiron@cmpc06#1 \n", + "1 2025-04-02 15:02:45.247485 None None pyiron@cmpc06#1 \n", + "2 2025-04-02 15:02:52.878817 None None pyiron@cmpc06#1 \n", + "3 2025-04-02 15:03:02.977300 None None pyiron@cmpc06#1 \n", + "4 2025-04-02 15:03:10.674995 None None pyiron@cmpc06#1 \n", + "5 2025-04-02 15:03:16.820860 None None pyiron@cmpc06#1 \n", + "\n", + " hamilton hamversion parentid masterid \n", + "0 PythonFunctionContainerJob 0.4 None None \n", + "1 PythonFunctionContainerJob 0.4 None None \n", + "2 PythonFunctionContainerJob 0.4 None None \n", + "3 PythonFunctionContainerJob 0.4 None None \n", + "4 PythonFunctionContainerJob 0.4 None None \n", + "5 PythonFunctionContainerJob 0.4 None None " + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pr.job_table()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "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.12.5" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/apt.txt b/apt.txt new file mode 100644 index 0000000..611b8e6 --- /dev/null +++ b/apt.txt @@ -0,0 +1,2 @@ +libgl1-mesa-glx +libegl1-mesa diff --git a/jobflow_nfdi.ipynb b/jobflow_nfdi.ipynb new file mode 100644 index 0000000..b36be26 --- /dev/null +++ b/jobflow_nfdi.ipynb @@ -0,0 +1,873 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "106ded66-d202-46ac-82b0-2755ca309bdd", + "metadata": {}, + "source": [ + "https://github.com/BAMresearch/NFDI4IngScientificWorkflowRequirements" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "6d86e804-245a-4d96-a1a3-1bc3216c3646", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "# conda environments:\n", + "#\n", + "base * /home/janssen/mambaforge\n", + "postprocessing /home/janssen/mambaforge/envs/postprocessing\n", + "preprocessing /home/janssen/mambaforge/envs/preprocessing\n", + "processing /home/janssen/mambaforge/envs/processing\n", + "\n" + ] + } + ], + "source": [ + "!conda env list" + ] + }, + { + "cell_type": "markdown", + "id": "11e09b78-cb72-465f-9c8b-5b77f0aa729c", + "metadata": {}, + "source": [ + "# Preprocessing " + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "a76e6c0a-98f2-4436-af10-8097da183341", + "metadata": {}, + "outputs": [], + "source": [ + "from nfdi_ing_workflow import (\n", + " generate_mesh as _generate_mesh, \n", + " convert_to_xdmf as _convert_to_xdmf,\n", + " poisson as _poisson,\n", + " plot_over_line as _plot_over_line,\n", + " substitute_macros as _substitute_macros,\n", + " compile_paper as _compile_paper,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "89c02460-b543-442c-a27e-f1757dc2262e", + "metadata": {}, + "outputs": [], + "source": [ + "from jobflow import job, Flow" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "549ecf27-88ef-4e77-8bd4-b616cfdda2e4", + "metadata": {}, + "outputs": [], + "source": [ + "generate_mesh = job(_generate_mesh)\n", + "convert_to_xdmf = job(_convert_to_xdmf, data=[\"xdmf_file\", \"h5_file\"])\n", + "poisson = job(_poisson, data=[\"numdofs\", \"pvd_file\", \"vtu_file\"])\n", + "plot_over_line = job(_plot_over_line)\n", + "substitute_macros = job(_substitute_macros)\n", + "compile_paper = job(_compile_paper)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "8d911f98-3b80-457f-a0f4-3cb37ebf1691", + "metadata": {}, + "outputs": [], + "source": [ + "domain_size = 2.0" + ] + }, + { + "cell_type": "markdown", + "id": "cf1e22d2-9ce5-488f-8048-308d7d5d4966", + "metadata": {}, + "source": [ + "## generate mesh" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "71d411b6-cbec-489e-99e3-ba71680bcb5b", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "gmsh_output_file = generate_mesh(\n", + " domain_size=domain_size,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "019938e7-8b41-47a9-b226-00e05dabc193", + "metadata": {}, + "source": [ + "## convert to xdmf" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "1d0d9804-f250-48b3-a5d0-a546d520f79b", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "meshio_output_dict = convert_to_xdmf(\n", + " gmsh_output_file=gmsh_output_file.output,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "ceb0b643-caaa-426c-9781-28703440e647", + "metadata": {}, + "source": [ + "# Processing" + ] + }, + { + "cell_type": "markdown", + "id": "11815a8b-319c-4ff3-8eae-330bf6e58eee", + "metadata": {}, + "source": [ + "## poisson" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "7b69bcff-e2b1-4d4a-b62c-6a1c86eeb590", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "poisson_dict = poisson(\n", + " meshio_output_xdmf=meshio_output_dict.output.xdmf_file, \n", + " meshio_output_h5=meshio_output_dict.output.h5_file,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "bc8a8634-029e-4337-96a2-a1f284cb4c38", + "metadata": {}, + "source": [ + "# Postprocessing" + ] + }, + { + "cell_type": "markdown", + "id": "157c5386-91a3-4e21-ac65-8f947f2d62fa", + "metadata": {}, + "source": [ + "## plot over line" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "3c4a29b0-eb1e-490a-8be0-e03cfff15e0a", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "pvbatch_output_file = plot_over_line(\n", + " poisson_output_pvd_file=poisson_dict.output.pvd_file, \n", + " poisson_output_vtu_file=poisson_dict.output.vtu_file,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "54f1d4bd-b944-470f-9cf8-30e64a24eb6d", + "metadata": {}, + "source": [ + "## substitute macros" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "a0a4c233-322d-4723-9627-62ca2487bfa9", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "macros_tex_file = substitute_macros( \n", + " pvbatch_output_file=pvbatch_output_file.output, \n", + " ndofs=poisson_dict.output.numdofs, \n", + " domain_size=domain_size,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "2031b693-acf3-48bd-bb00-e33f669381e9", + "metadata": {}, + "source": [ + "## compile paper" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "c281408f-e63d-4380-a7e6-c595d49fbb8f", + "metadata": {}, + "outputs": [], + "source": [ + "paper_output = compile_paper(\n", + " macros_tex=macros_tex_file.output, \n", + " plot_file=pvbatch_output_file.output,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "a384d70a-8ef5-4fdd-880c-56ac7eaf87b9", + "metadata": {}, + "outputs": [], + "source": [ + "flow = Flow([gmsh_output_file, meshio_output_dict, poisson_dict, pvbatch_output_file, macros_tex_file, paper_output])" + ] + }, + { + "cell_type": "markdown", + "id": "5c1b0200-bba3-484d-ac49-f582898e974f", + "metadata": {}, + "source": [ + "# Convert " + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "196faf18-c46b-4f42-a652-698d2c580221", + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.jobflow import write_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "fb23ad9c-76fd-4c0b-b546-e305d6c49796", + "metadata": {}, + "outputs": [], + "source": [ + "workflow_json_filename = \"jobflow_nfdi.json\"" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "4139547a-9717-4708-b1a5-8202a0382d77", + "metadata": {}, + "outputs": [], + "source": [ + "write_workflow_json(flow=flow, file_name=workflow_json_filename)" + ] + }, + { + "cell_type": "markdown", + "id": "11a829e2-face-469f-b343-2c95763b1f13", + "metadata": {}, + "source": [ + "# Load Workflow with aiida" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4f3acabe-55df-479a-af4d-a23a80c4660d", + "metadata": {}, + "outputs": [], + "source": [ + "from aiida import load_profile\n", + "\n", + "load_profile()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b6ba9444-a2c8-451b-b74c-19b0f69ba369", + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.aiida import load_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c3528d55-6bf7-47ed-a110-65c47446ba92", + "metadata": {}, + "outputs": [], + "source": [ + "wg = load_workflow_json(file_name=workflow_json_filename)\n", + "wg" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5ef48778-4209-425f-8c6b-85a4cd2f92ec", + "metadata": {}, + "outputs": [], + "source": [ + "wg.run()" + ] + }, + { + "cell_type": "markdown", + "id": "397b16a2-e1ec-4eec-8562-1c84f585c347", + "metadata": {}, + "source": [ + "# Load Workflow with pyiron_base" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "fdde6b82-b51d-434a-a9a8-5a8c31bbb429", + "metadata": {}, + "outputs": [], + "source": [ + "from pyiron_base import Project" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "be4d5d93-e9f6-4072-a6be-0ee5dc93590f", + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.pyiron_base import load_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "4db75587-5f4c-416d-a1f6-c949077fa2ca", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "b5c4c082a18b4d5391aac8dd470570d5", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "0it [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "pr = Project(\"test\")\n", + "pr.remove_jobs(recursive=True, silently=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "4452a648-d4c3-4f5f-8678-ffb54bef17dc", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + "\n", + "\n", + "create_function_job_19ee2cba4a6ec0c97eab519834ce2c6b\n", + "\n", + "create_function_job=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4ab70>\n", + "\n", + "\n", + "\n", + "macros_tex_f8e7c70add5a6917362eaba96348676f\n", + "\n", + "macros_tex=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a8d0>\n", + "\n", + "\n", + "\n", + "macros_tex_f8e7c70add5a6917362eaba96348676f->create_function_job_19ee2cba4a6ec0c97eab519834ce2c6b\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "pvbatch_output_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "pvbatch_output_file=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a570>\n", + "\n", + "\n", + "\n", + "pvbatch_output_file_a227e82a0cabcaa4ff69b537232c3daf->macros_tex_f8e7c70add5a6917362eaba96348676f\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973\n", + "\n", + "poisson_output_pvd_file=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a1e0>\n", + "\n", + "\n", + "\n", + "poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973->pvbatch_output_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "plot_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "plot_file=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a570>\n", + "\n", + "\n", + "\n", + "poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973->plot_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "plot_file_a227e82a0cabcaa4ff69b537232c3daf->create_function_job_19ee2cba4a6ec0c97eab519834ce2c6b\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d\n", + "\n", + "meshio_output_xdmf=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d49dc0>\n", + "\n", + "\n", + "\n", + "meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d->poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3\n", + "\n", + "poisson_output_vtu_file=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a090>\n", + "\n", + "\n", + "\n", + "meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d->poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "ndofs_af456a32dc17ccd053cef8f83b61802e\n", + "\n", + "ndofs=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a600>\n", + "\n", + "\n", + "\n", + "meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d->ndofs_af456a32dc17ccd053cef8f83b61802e\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3->pvbatch_output_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3->plot_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "ndofs_af456a32dc17ccd053cef8f83b61802e->macros_tex_f8e7c70add5a6917362eaba96348676f\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "gmsh_output_file_b41125ac47f34334493d860607ee71a3\n", + "\n", + "gmsh_output_file=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d49af0>\n", + "\n", + "\n", + "\n", + "gmsh_output_file_b41125ac47f34334493d860607ee71a3->meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081\n", + "\n", + "meshio_output_h5=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d49a30>\n", + "\n", + "\n", + "\n", + "gmsh_output_file_b41125ac47f34334493d860607ee71a3->meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081->poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081->poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081->ndofs_af456a32dc17ccd053cef8f83b61802e\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "domain_size_f12a7f1986b9dd058dfc666dbe230b20\n", + "\n", + "domain_size=2.0\n", + "\n", + "\n", + "\n", + "domain_size_f12a7f1986b9dd058dfc666dbe230b20->macros_tex_f8e7c70add5a6917362eaba96348676f\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "domain_size_f12a7f1986b9dd058dfc666dbe230b20->gmsh_output_file_b41125ac47f34334493d860607ee71a3\n", + "\n", + "\n", + "\n", + "\n", + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "delayed_object = load_workflow_json(project=pr, file_name=workflow_json_filename)\n", + "delayed_object.draw()" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "1c2760b6-96b4-4f44-ac49-a229d4a0cf67", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The job generate_mesh_0b48cf5155cd6802c17d20bb58104132 was saved and received the ID: 2005\n", + "The job convert_to_xdmf_9ded0361e4866afe4962398287e4f6ae was saved and received the ID: 2006\n", + "The job poisson_2d98621ac2c8e43a266693cf65647173 was saved and received the ID: 2007\n", + "The job plot_over_line_004790462b53a54f512cc7e1a2a10519 was saved and received the ID: 2008\n", + "The job substitute_macros_52130ff9ec1931ec82532a7119df653f was saved and received the ID: 2009\n", + "The job compile_paper_b65627cdc212fc76a216689a26379fae was saved and received the ID: 2010\n" + ] + }, + { + "data": { + "text/plain": [ + "'/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/postprocessing/paper.pdf'" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "delayed_object.pull()" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "b3bba27e-ece9-4c02-834c-53e69844b140", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idstatuschemicalformulajobsubjobprojectpathprojecttimestarttimestoptotalcputimecomputerhamiltonhamversionparentidmasterid
02005finishedNonegenerate_mesh_0b48cf5155cd6802c17d20bb58104132/generate_mesh_0b48cf5155cd6802c17d20bb58104132None/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 15:02:38.490191NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
12006finishedNoneconvert_to_xdmf_9ded0361e4866afe4962398287e4f6ae/convert_to_xdmf_9ded0361e4866afe4962398287e4f6aeNone/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 15:02:45.247485NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
22007finishedNonepoisson_2d98621ac2c8e43a266693cf65647173/poisson_2d98621ac2c8e43a266693cf65647173None/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 15:02:52.878817NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
32008finishedNoneplot_over_line_004790462b53a54f512cc7e1a2a10519/plot_over_line_004790462b53a54f512cc7e1a2a10519None/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 15:03:02.977300NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
42009finishedNonesubstitute_macros_52130ff9ec1931ec82532a7119df653f/substitute_macros_52130ff9ec1931ec82532a7119df653fNone/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 15:03:10.674995NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
52010finishedNonecompile_paper_b65627cdc212fc76a216689a26379fae/compile_paper_b65627cdc212fc76a216689a26379faeNone/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 15:03:16.820860NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
\n", + "
" + ], + "text/plain": [ + " id status chemicalformula \\\n", + "0 2005 finished None \n", + "1 2006 finished None \n", + "2 2007 finished None \n", + "3 2008 finished None \n", + "4 2009 finished None \n", + "5 2010 finished None \n", + "\n", + " job \\\n", + "0 generate_mesh_0b48cf5155cd6802c17d20bb58104132 \n", + "1 convert_to_xdmf_9ded0361e4866afe4962398287e4f6ae \n", + "2 poisson_2d98621ac2c8e43a266693cf65647173 \n", + "3 plot_over_line_004790462b53a54f512cc7e1a2a10519 \n", + "4 substitute_macros_52130ff9ec1931ec82532a7119df653f \n", + "5 compile_paper_b65627cdc212fc76a216689a26379fae \n", + "\n", + " subjob projectpath \\\n", + "0 /generate_mesh_0b48cf5155cd6802c17d20bb58104132 None \n", + "1 /convert_to_xdmf_9ded0361e4866afe4962398287e4f6ae None \n", + "2 /poisson_2d98621ac2c8e43a266693cf65647173 None \n", + "3 /plot_over_line_004790462b53a54f512cc7e1a2a10519 None \n", + "4 /substitute_macros_52130ff9ec1931ec82532a7119df653f None \n", + "5 /compile_paper_b65627cdc212fc76a216689a26379fae None \n", + "\n", + " project \\\n", + "0 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "1 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "2 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "3 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "4 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "5 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "\n", + " timestart timestop totalcputime computer \\\n", + "0 2025-04-02 15:02:38.490191 None None pyiron@cmpc06#1 \n", + "1 2025-04-02 15:02:45.247485 None None pyiron@cmpc06#1 \n", + "2 2025-04-02 15:02:52.878817 None None pyiron@cmpc06#1 \n", + "3 2025-04-02 15:03:02.977300 None None pyiron@cmpc06#1 \n", + "4 2025-04-02 15:03:10.674995 None None pyiron@cmpc06#1 \n", + "5 2025-04-02 15:03:16.820860 None None pyiron@cmpc06#1 \n", + "\n", + " hamilton hamversion parentid masterid \n", + "0 PythonFunctionContainerJob 0.4 None None \n", + "1 PythonFunctionContainerJob 0.4 None None \n", + "2 PythonFunctionContainerJob 0.4 None None \n", + "3 PythonFunctionContainerJob 0.4 None None \n", + "4 PythonFunctionContainerJob 0.4 None None \n", + "5 PythonFunctionContainerJob 0.4 None None " + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pr.job_table()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "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.12.5" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/nfdi_ing_workflow.py b/nfdi_ing_workflow.py new file mode 100644 index 0000000..254e73b --- /dev/null +++ b/nfdi_ing_workflow.py @@ -0,0 +1,133 @@ +import os +import subprocess +import shutil + +source_directory = os.path.join(os.path.dirname(os.path.abspath(__file__)), "source") + + +def generate_mesh(domain_size: float = 2.0) -> str: + stage_name = "preprocessing" + gmsh_output_file_name = "square.msh" + source_file_name ="unit_square.geo" + os.makedirs(stage_name, exist_ok=True) + _copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name) + _ = subprocess.check_output( + [ + "conda", "run", "-n", stage_name, "gmsh", "-2", "-setnumber", + "domain_size", str(domain_size), source_file_name, "-o", gmsh_output_file_name + ], + cwd=stage_name, + universal_newlines=True, + ).split("\n") + return os.path.abspath(os.path.join(stage_name, gmsh_output_file_name)) + + +def convert_to_xdmf(gmsh_output_file : str) -> str: + stage_name = "preprocessing" + meshio_output_file_name = "square.xdmf" + os.makedirs(stage_name, exist_ok=True) + _copy_file(stage_name=stage_name, source_file=gmsh_output_file) + _ = subprocess.check_output( + ["conda", "run", "-n", stage_name, "meshio", "convert", os.path.basename(gmsh_output_file), meshio_output_file_name], + cwd=stage_name, + universal_newlines=True, + ).split("\n") + return { + "xdmf_file": os.path.abspath(os.path.join(stage_name, meshio_output_file_name)), + "h5_file": os.path.join(os.path.abspath(stage_name), "square.h5"), + } + + +def poisson(meshio_output_xdmf: str, meshio_output_h5: str) -> dict: + stage_name = "processing" + poisson_output_pvd_file_name = "poisson.pvd" + poisson_output_numdofs_file_name = "numdofs.txt" + source_file_name = "poisson.py" + os.makedirs(stage_name, exist_ok=True) + _copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name) + _copy_file(stage_name=stage_name, source_file=meshio_output_xdmf) + _copy_file(stage_name=stage_name, source_file=meshio_output_h5) + _ = subprocess.check_output( + [ + "conda", "run", "-n", stage_name, "python", "poisson.py", + "--mesh", os.path.basename(meshio_output_xdmf), "--degree", "2", + "--outputfile", poisson_output_pvd_file_name, "--num-dofs", poisson_output_numdofs_file_name + ], + cwd=stage_name, + universal_newlines=True, + ).split("\n") + return { + "numdofs": _poisson_collect_output(numdofs_file=os.path.join(stage_name, poisson_output_numdofs_file_name)), + "pvd_file": os.path.abspath(os.path.join(stage_name, poisson_output_pvd_file_name)), + "vtu_file": os.path.abspath(os.path.join(stage_name, "poisson000000.vtu")), + } + + +def plot_over_line(poisson_output_pvd_file: str, poisson_output_vtu_file: str) -> str: + stage_name = "postprocessing" + pvbatch_output_file_name = "plotoverline.csv" + source_file_name = "postprocessing.py" + os.makedirs(stage_name, exist_ok=True) + _copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name) + _copy_file(stage_name=stage_name, source_file=poisson_output_pvd_file) + _copy_file(stage_name=stage_name, source_file=poisson_output_vtu_file) + _ = subprocess.check_output( + ["conda", "run", "-n", stage_name, "pvbatch", source_file_name, os.path.basename(poisson_output_pvd_file), pvbatch_output_file_name], + cwd=stage_name, + universal_newlines=True, + ).split("\n") + return os.path.abspath(os.path.join("postprocessing", pvbatch_output_file_name)) + + +def substitute_macros(pvbatch_output_file: str, ndofs: int, domain_size: float = 2.0) -> str: + stage_name = "postprocessing" + source_file_name = "prepare_paper_macros.py" + template_file_name = "macros.tex.template" + macros_output_file_name = "macros.tex" + os.makedirs(stage_name, exist_ok=True) + _copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name) + _copy_file_from_source(stage_name=stage_name, source_file_name=template_file_name) + _copy_file(stage_name=stage_name, source_file=pvbatch_output_file) + _ = subprocess.check_output( + [ + "conda", "run", "-n", stage_name, "python", "prepare_paper_macros.py", + "--macro-template-file", template_file_name, "--plot-data-path", os.path.basename(pvbatch_output_file), + "--domain-size", str(domain_size), "--num-dofs", str(ndofs), + "--output-macro-file", macros_output_file_name, + ], + cwd=stage_name, + universal_newlines=True, + ).split("\n") + return os.path.abspath(os.path.join(stage_name, macros_output_file_name)) + + +def compile_paper(macros_tex: str, plot_file: str) -> str: + stage_name = "postprocessing" + paper_output = "paper.pdf" + source_file_name = "paper.tex" + os.makedirs(stage_name, exist_ok=True) + _copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name) + _copy_file(stage_name=stage_name, source_file=macros_tex) + _copy_file(stage_name=stage_name, source_file=plot_file) + _ = subprocess.check_output( + ["conda", "run", "-n", stage_name, "tectonic", source_file_name], + universal_newlines=True, + cwd=stage_name, + ).split("\n") + return os.path.abspath(os.path.join(stage_name, paper_output)) + + +def _poisson_collect_output(numdofs_file: str) -> int: + with open(os.path.join(numdofs_file), "r") as f: + return int(f.read()) + + +def _copy_file(stage_name, source_file): + input_file = os.path.join(os.path.abspath(stage_name), os.path.basename(source_file)) + if input_file != source_file: + shutil.copyfile(source_file, input_file) + + +def _copy_file_from_source(stage_name, source_file_name): + source_file = os.path.join(source_directory, source_file_name) + shutil.copyfile(source_file, os.path.join(stage_name, source_file_name)) \ No newline at end of file diff --git a/pyiron_base_nfdi.ipynb b/pyiron_base_nfdi.ipynb new file mode 100644 index 0000000..92f3c22 --- /dev/null +++ b/pyiron_base_nfdi.ipynb @@ -0,0 +1,475 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "106ded66-d202-46ac-82b0-2755ca309bdd", + "metadata": {}, + "source": [ + "https://github.com/BAMresearch/NFDI4IngScientificWorkflowRequirements" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "6d86e804-245a-4d96-a1a3-1bc3216c3646", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "# conda environments:\n", + "#\n", + "base * /home/janssen/mambaforge\n", + "postprocessing /home/janssen/mambaforge/envs/postprocessing\n", + "preprocessing /home/janssen/mambaforge/envs/preprocessing\n", + "processing /home/janssen/mambaforge/envs/processing\n", + "\n" + ] + } + ], + "source": [ + "!conda env list" + ] + }, + { + "cell_type": "markdown", + "id": "11e09b78-cb72-465f-9c8b-5b77f0aa729c", + "metadata": {}, + "source": [ + "# Preprocessing " + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "a76e6c0a-98f2-4436-af10-8097da183341", + "metadata": {}, + "outputs": [], + "source": [ + "from nfdi_ing_workflow import (\n", + " generate_mesh as _generate_mesh, \n", + " convert_to_xdmf as _convert_to_xdmf,\n", + " poisson as _poisson,\n", + " plot_over_line as _plot_over_line,\n", + " substitute_macros as _substitute_macros,\n", + " compile_paper as _compile_paper,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "89c02460-b543-442c-a27e-f1757dc2262e", + "metadata": {}, + "outputs": [], + "source": [ + "from pyiron_base import Project, job" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "549ecf27-88ef-4e77-8bd4-b616cfdda2e4", + "metadata": {}, + "outputs": [], + "source": [ + "generate_mesh = job(_generate_mesh)\n", + "convert_to_xdmf = job(_convert_to_xdmf, output_key_lst=[\"xdmf_file\", \"h5_file\"])\n", + "poisson = job(_poisson, output_key_lst=[\"numdofs\", \"pvd_file\", \"vtu_file\"])\n", + "plot_over_line = job(_plot_over_line)\n", + "substitute_macros = job(_substitute_macros)\n", + "compile_paper = job(_compile_paper)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "508e6549-f7b8-492b-8c88-9e46c08ffca9", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "be42f1e956da4894a40ff667564b7f53", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "0it [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "pr = Project(\"test\")\n", + "pr.remove_jobs(recursive=True, silently=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "8d911f98-3b80-457f-a0f4-3cb37ebf1691", + "metadata": {}, + "outputs": [], + "source": [ + "domain_size = 2.0" + ] + }, + { + "cell_type": "markdown", + "id": "cf1e22d2-9ce5-488f-8048-308d7d5d4966", + "metadata": {}, + "source": [ + "## generate mesh" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "71d411b6-cbec-489e-99e3-ba71680bcb5b", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "gmsh_output_file = generate_mesh(\n", + " domain_size=domain_size,\n", + " pyiron_project=pr\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "019938e7-8b41-47a9-b226-00e05dabc193", + "metadata": {}, + "source": [ + "## convert to xdmf" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "1d0d9804-f250-48b3-a5d0-a546d520f79b", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "meshio_output_dict = convert_to_xdmf(\n", + " gmsh_output_file=gmsh_output_file,\n", + " pyiron_project=pr,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "ceb0b643-caaa-426c-9781-28703440e647", + "metadata": {}, + "source": [ + "# Processing" + ] + }, + { + "cell_type": "markdown", + "id": "11815a8b-319c-4ff3-8eae-330bf6e58eee", + "metadata": {}, + "source": [ + "## poisson" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "7b69bcff-e2b1-4d4a-b62c-6a1c86eeb590", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "poisson_dict = poisson(\n", + " meshio_output_xdmf=meshio_output_dict.output.xdmf_file, \n", + " meshio_output_h5=meshio_output_dict.output.h5_file,\n", + " pyiron_project=pr,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "bc8a8634-029e-4337-96a2-a1f284cb4c38", + "metadata": {}, + "source": [ + "# Postprocessing" + ] + }, + { + "cell_type": "markdown", + "id": "157c5386-91a3-4e21-ac65-8f947f2d62fa", + "metadata": {}, + "source": [ + "## plot over line" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "3c4a29b0-eb1e-490a-8be0-e03cfff15e0a", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "pvbatch_output_file = plot_over_line(\n", + " poisson_output_pvd_file=poisson_dict.output.pvd_file, \n", + " poisson_output_vtu_file=poisson_dict.output.vtu_file,\n", + " pyiron_project=pr,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "54f1d4bd-b944-470f-9cf8-30e64a24eb6d", + "metadata": {}, + "source": [ + "## substitute macros" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "a0a4c233-322d-4723-9627-62ca2487bfa9", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "macros_tex_file = substitute_macros( \n", + " pvbatch_output_file=pvbatch_output_file, \n", + " ndofs=poisson_dict.output.numdofs, \n", + " domain_size=domain_size,\n", + " pyiron_project=pr,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "2031b693-acf3-48bd-bb00-e33f669381e9", + "metadata": {}, + "source": [ + "## compile paper" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "c281408f-e63d-4380-a7e6-c595d49fbb8f", + "metadata": {}, + "outputs": [], + "source": [ + "paper_output = compile_paper(\n", + " macros_tex=macros_tex_file, \n", + " plot_file=pvbatch_output_file,\n", + " pyiron_project=pr,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "7b079060-0646-490e-9f1a-19376a1ebc6c", + "metadata": {}, + "source": [ + "# Convert " + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "65bdc51a-895e-421c-bf20-0f793a397f67", + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.pyiron_base import write_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "63f29646-3846-4a97-a033-20e9df0ac214", + "metadata": {}, + "outputs": [], + "source": [ + "workflow_json_filename = \"pyiron_base_nfdi.json\"" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "f62111ba-9271-4987-9c7e-3b1c9f9eae7a", + "metadata": {}, + "outputs": [], + "source": [ + "write_workflow_json(delayed_object=paper_output, file_name=workflow_json_filename)" + ] + }, + { + "cell_type": "markdown", + "id": "d789971e-8f41-45fa-832a-11fd72dea96e", + "metadata": {}, + "source": [ + "# Load Workflow with aiida" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a6e85e89-5d7a-40eb-809c-ac44974e3fd7", + "metadata": {}, + "outputs": [], + "source": [ + "from aiida import load_profile\n", + "\n", + "load_profile()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3de84fb7-b01b-4541-868a-92e881eb6e77", + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.aiida import load_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b33f5528-10cd-47c8-8723-622902978859", + "metadata": {}, + "outputs": [], + "source": [ + "wg = load_workflow_json(file_name=workflow_json_filename)\n", + "wg" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "15282ca1-d339-40e7-ad68-8a7613ed08da", + "metadata": {}, + "outputs": [], + "source": [ + "wg.run()" + ] + }, + { + "cell_type": "markdown", + "id": "55dc8d12-dfe6-4465-a368-b7e590ae6800", + "metadata": {}, + "source": [ + "# Load Workflow with pyiron_base" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "dff46eb8-e0e7-49bb-8c40-0db2df133124", + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.jobflow import load_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "6a189459-84e4-4738-ada1-37ee8c65b2ab", + "metadata": {}, + "outputs": [], + "source": [ + "from jobflow.managers.local import run_locally" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "6e7f3614-c971-4e2d-83f0-96f0d0fc04de", + "metadata": {}, + "outputs": [], + "source": [ + "flow = load_workflow_json(file_name=workflow_json_filename)" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "2d87ed45-f5d9-403f-a03a-26be4a47a3ef", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2025-04-02 14:59:47,651 INFO Started executing jobs locally\n", + "2025-04-02 14:59:49,002 INFO Starting job - generate_mesh (c116d67e-4d2a-4e50-82af-faee6ee474ef)\n", + "2025-04-02 14:59:54,666 INFO Finished job - generate_mesh (c116d67e-4d2a-4e50-82af-faee6ee474ef)\n", + "2025-04-02 14:59:54,666 INFO Starting job - convert_to_xdmf (5283e8af-6407-4a02-8bb7-0057df7ec6fe)\n", + "2025-04-02 15:00:01,183 INFO Finished job - convert_to_xdmf (5283e8af-6407-4a02-8bb7-0057df7ec6fe)\n", + "2025-04-02 15:00:01,184 INFO Starting job - poisson (ce03af6b-866c-41ba-b17c-9bdf1e965e58)\n", + "2025-04-02 15:00:10,982 INFO Finished job - poisson (ce03af6b-866c-41ba-b17c-9bdf1e965e58)\n", + "2025-04-02 15:00:10,983 INFO Starting job - plot_over_line (582b8920-93f3-4a9e-b216-e3b30a22f1dd)\n", + "2025-04-02 15:00:21,672 INFO Finished job - plot_over_line (582b8920-93f3-4a9e-b216-e3b30a22f1dd)\n", + "2025-04-02 15:00:21,673 INFO Starting job - substitute_macros (596ecf51-bc63-4770-8f0f-802662bb46df)\n", + "2025-04-02 15:00:27,059 INFO Finished job - substitute_macros (596ecf51-bc63-4770-8f0f-802662bb46df)\n", + "2025-04-02 15:00:27,059 INFO Starting job - compile_paper (a99bafcf-b306-418e-8383-576e3926bcbf)\n", + "2025-04-02 15:00:35,854 INFO Finished job - compile_paper (a99bafcf-b306-418e-8383-576e3926bcbf)\n", + "2025-04-02 15:00:35,855 INFO Finished executing jobs locally\n" + ] + }, + { + "data": { + "text/plain": [ + "{'c116d67e-4d2a-4e50-82af-faee6ee474ef': {1: Response(output='/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/preprocessing/square.msh', detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd'))},\n", + " '5283e8af-6407-4a02-8bb7-0057df7ec6fe': {1: Response(output={'xdmf_file': '/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/preprocessing/square.xdmf', 'h5_file': '/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/preprocessing/square.h5'}, detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd'))},\n", + " 'ce03af6b-866c-41ba-b17c-9bdf1e965e58': {1: Response(output={'numdofs': 357, 'pvd_file': '/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/processing/poisson.pvd', 'vtu_file': '/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/processing/poisson000000.vtu'}, detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd'))},\n", + " '582b8920-93f3-4a9e-b216-e3b30a22f1dd': {1: Response(output='/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/postprocessing/plotoverline.csv', detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd'))},\n", + " '596ecf51-bc63-4770-8f0f-802662bb46df': {1: Response(output='/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/postprocessing/macros.tex', detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd'))},\n", + " 'a99bafcf-b306-418e-8383-576e3926bcbf': {1: Response(output='/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/postprocessing/paper.pdf', detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd'))}}" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "result = run_locally(flow)\n", + "result" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "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.12.5" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/source/envs/postprocessing.yaml b/source/envs/postprocessing.yaml new file mode 100644 index 0000000..acd99ed --- /dev/null +++ b/source/envs/postprocessing.yaml @@ -0,0 +1,5 @@ +channels: + - conda-forge +dependencies: + - paraview=5.9.1=hfc1cbd4_3_egl + - tectonic=0.8.0=ha1fef3e_1 diff --git a/source/envs/preprocessing.yaml b/source/envs/preprocessing.yaml new file mode 100644 index 0000000..d9a2660 --- /dev/null +++ b/source/envs/preprocessing.yaml @@ -0,0 +1,5 @@ +channels: + - conda-forge +dependencies: + - gmsh=4.6.0=hd134328_0 + - meshio=5.0.5=pyhd8ed1ab_0 diff --git a/source/envs/processing.yaml b/source/envs/processing.yaml new file mode 100644 index 0000000..d4c2d9b --- /dev/null +++ b/source/envs/processing.yaml @@ -0,0 +1,4 @@ +channels: + - conda-forge +dependencies: + - fenics=2019.1.0=py39hf3d152e_26 diff --git a/source/macros.tex.template b/source/macros.tex.template new file mode 100644 index 0000000..0c12002 --- /dev/null +++ b/source/macros.tex.template @@ -0,0 +1,3 @@ +\newcommand{\domainSize}{${DOMAINSIZE}} +\newcommand{\numDofs}{${NUMDOFS}} +\newcommand{\plotDataPath}{${PLOTDATAPATH}} diff --git a/source/paper.tex b/source/paper.tex new file mode 100644 index 0000000..e8b0cfe --- /dev/null +++ b/source/paper.tex @@ -0,0 +1,22 @@ +\documentclass[12pt]{article} +\usepackage{graphicx} +\usepackage{pgfplots} + +\input{macros} + +\title{An exemplary workflow} + +\begin{document} +\maketitle + +\begin{figure}[h] + \centering% + \begin{tikzpicture} + \begin{axis}[] + \addplot[color=red,smooth,thick] table[col sep=comma,header=true,x index=2,y index=0] {\plotDataPath}; + \end{axis} + \end{tikzpicture} + \caption{Solution of the poisson equation over the line $L = \{(x, y)\in\Omega = {(0, \domainSize{})}^2 | x = y\}$ using \numDofs{} DoFs in the finite element model.}% +\end{figure} + +\end{document} diff --git a/source/poisson.py b/source/poisson.py new file mode 100644 index 0000000..d66939d --- /dev/null +++ b/source/poisson.py @@ -0,0 +1,108 @@ +""" +solution of the poisson equation on the unit square +""" + +from argparse import ArgumentParser +import dolfin as df + + +def boundary_expression(): + """Defines the function to be used for the boundary conditions""" + return "1.0 + x[0] * x[0] + 2.0 * x[1] * x[1]" + + +def solve_poisson( + meshfile: str, degree: int, bc_expression: str = boundary_expression() +): + """solves the poisson equation + + Parameters + ---------- + meshfile : str + FilePath to the mesh in xdmf format. + degree : int + Degree of the finite element space. + + Returns + ------- + solution : df.Function + """ + mesh = df.Mesh() + with df.XDMFFile(meshfile) as instream: + instream.read(mesh) + func_space = df.FunctionSpace(mesh, "CG", degree) + boundary_data = df.Expression(bc_expression, degree=2) + + def boundary(_, on_boundary): + return on_boundary + + boundary_conditions = df.DirichletBC(func_space, boundary_data, boundary) + trial_function = df.TrialFunction(func_space) + test_function = df.TestFunction(func_space) + source = df.Constant(-6.0) + lhs = df.dot(df.grad(trial_function), df.grad(test_function)) * df.dx + rhs = source * test_function * df.dx + + solution = df.Function(func_space) + df.solve(lhs == rhs, solution, boundary_conditions) + return solution + + +def solve_and_write_output( + mesh: str, degree: int, outputfile: str, numdofs=None, return_dofs=False +): + """solves the poisson equation and writes the solution + and the number of degrees of freedom to the given file + + Parameters + ---------- + meshfile : str + FilePath to the mesh in xdmf format. + degree : int + Degree of the finite element space. + outputfile : str + FilePath to the output file into which the solution is written. + numdofs : optional, str + FilePath to which the number of degrees of freedom is written. + return_dofs : optional, bool + If True, return number of degrees of freedom. + """ + discrete_solution = solve_poisson(mesh, degree) + discrete_solution.rename("u", discrete_solution.name()) + resultFile = df.File(outputfile) + resultFile << discrete_solution + + dofs = discrete_solution.function_space().dim() + print(f"Number of dofs used: {dofs}") + + if numdofs is not None: + with open(numdofs, "w") as handle: + handle.write("{}\n".format(dofs)) + if return_dofs: + return dofs + + +if __name__ == "__main__": + PARSER = ArgumentParser(description="run script for the poisson problem") + PARSER.add_argument("-m", "--mesh", required=True, help="mesh file to be used") + PARSER.add_argument( + "-d", "--degree", required=True, help="polynomial order to be used" + ) + PARSER.add_argument( + "-o", + "--outputfile", + required=True, + help="file name for the output to be written", + ) + PARSER.add_argument( + "-n", + "--num-dofs", + required=False, + default=None, + help="file name for the number of DoFs to be written", + ) + ARGS = vars(PARSER.parse_args()) + + solve_and_write_output( + ARGS["mesh"], int(ARGS["degree"]), ARGS["outputfile"], ARGS["num_dofs"] + ) diff --git a/source/postprocessing.py b/source/postprocessing.py new file mode 100644 index 0000000..0ed43af --- /dev/null +++ b/source/postprocessing.py @@ -0,0 +1,54 @@ +""" +$ pvbatch postprocessing.py -h +""" + +import sys +import argparse +from paraview.simple import ( + PlotOverLine, + PVDReader, + SaveData, + UpdatePipeline, +) + + +def main(args): + pvd_file = args.pvd + source = PVDReader(registrationName="poisson.pvd", FileName=[pvd_file]) + source.PointArrays = [args.field] + UpdatePipeline() + + (xmin, xmax, ymin, ymax, zmin, zmax) = source.GetDataInformation().GetBounds() + # init the 'Line' selected for 'Source' + plotOverLine1 = PlotOverLine( + registrationName="PlotOverLine1", Input=source, Source="Line" + ) + plotOverLine1.Source.Point1 = [xmin, ymin, zmin] + plotOverLine1.Source.Point2 = [xmax, ymax, zmax] + UpdatePipeline() + + # save data + SaveData( + args.csv, + proxy=plotOverLine1, + ChooseArraysToWrite=1, + PointDataArrays=["arc_length", args.field, "vtkValidPointMask"], + ) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser( + prog=f"pvbatch {__file__}", + description="Plots the solution over a line and writes the data to file.", + usage="%(prog)s [options] pvd csv", + ) + parser.add_argument("pvd", type=str, help="The source pvd filepath.") + parser.add_argument("csv", type=str, help="The target csv filepath.") + parser.add_argument( + "--field", + type=str, + default="u", + help="Field variable to plot (default: u)", + ) + args = parser.parse_args(sys.argv[1:]) + main(args) diff --git a/source/prepare_paper_macros.py b/source/prepare_paper_macros.py new file mode 100644 index 0000000..663407d --- /dev/null +++ b/source/prepare_paper_macros.py @@ -0,0 +1,43 @@ +""" +places the correct values into the paper macros template file +""" + +import string +import argparse + +PARSER = argparse.ArgumentParser( + description="Place computed values in the paper macros template file" +) +PARSER.add_argument( + "-f", "--macro-template-file", + required=False, default="macros.tex.template", + help="The macro template file" +) +PARSER.add_argument( + "-o", "--output-macro-file", + required=False, default="macros.tex", + help="The macro file to be written" +) +PARSER.add_argument( + "-s", "--domain-size", + required=True, help="The computed domain size", +) +PARSER.add_argument( + "-n", "--num-dofs", + required=True, help="The computed number of dofs", +) +PARSER.add_argument( + "-p", "--plot-data-path", + required=True, help="The path to the data for the plot over line" +) +ARGS = vars(PARSER.parse_args()) + + +with open(ARGS["output_macro_file"], "w") as out_file: + with open(ARGS["macro_template_file"], "r") as in_file: + raw = string.Template(in_file.read()) + out_file.write(raw.substitute({ + "DOMAINSIZE": ARGS["domain_size"], + "NUMDOFS": ARGS["num_dofs"], + "PLOTDATAPATH": ARGS["plot_data_path"] + })) diff --git a/source/unit_square.geo b/source/unit_square.geo new file mode 100644 index 0000000..b8f55b7 --- /dev/null +++ b/source/unit_square.geo @@ -0,0 +1,9 @@ +DefineConstant[ domain_size = 1.0 ]; +DefineConstant[ mesh_size = domain_size/4.0 ]; + +SetFactory("OpenCASCADE"); +Rectangle(1) = {0, 0, 0, domain_size, domain_size, 0}; +Physical Surface(1) = {1}; + +Printf("Used domain size: %f", domain_size); +Printf("Used mesh size: %f", mesh_size); diff --git a/universal_workflow_nfdi.ipynb b/universal_workflow_nfdi.ipynb new file mode 100644 index 0000000..2ae6836 --- /dev/null +++ b/universal_workflow_nfdi.ipynb @@ -0,0 +1,627 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Load Simple Workflow" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Aiida " + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Profile" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from python_workflow_definition.aiida import load_workflow_json\n", + "\n", + "from aiida import load_profile\n", + "load_profile()" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "workgraph = load_workflow_json(file_name='workflow_nfdi.json')" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "c1671fb385e3469ea269044a47160225", + "version_major": 2, + "version_minor": 1 + }, + "text/plain": [ + "NodeGraphWidget(settings={'minimap': True}, style={'width': '90%', 'height': '600px'}, value={'name': 'WorkGra…" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# TODO: Create inputs rather than tasks out of data nodes\n", + "workgraph" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "03/24/2025 12:15:40 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|continue_workgraph]: tasks ready to run: pickle_node3,pickle_node4\n", + "03/24/2025 12:15:49 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 1076, 1083\n", + "03/24/2025 12:16:27 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|update_task_state]: Task: pickle_node3, type: PYTHONJOB, finished.\n", + "03/24/2025 12:16:28 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|update_task_state]: Task: pickle_node4, type: PYTHONJOB, finished.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "invalid state\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "03/24/2025 12:16:29 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|continue_workgraph]: tasks ready to run: add_x_and_y1\n", + "03/24/2025 12:16:35 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 1098\n", + "03/24/2025 12:16:58 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|update_task_state]: Task: add_x_and_y1, type: PYTHONJOB, finished.\n", + "03/24/2025 12:16:59 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|continue_workgraph]: tasks ready to run: add_x_and_y_and_z2\n", + "03/24/2025 12:17:04 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 1111\n", + "03/24/2025 12:17:23 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|update_task_state]: Task: add_x_and_y_and_z2, type: PYTHONJOB, finished.\n", + "03/24/2025 12:17:25 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|continue_workgraph]: tasks ready to run: \n", + "03/24/2025 12:17:25 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|finalize]: Finalize workgraph.\n" + ] + } + ], + "source": [ + "\n", + "workgraph.run()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## executorlib" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "from executorlib import SingleNodeExecutor" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.executorlib import load_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "with SingleNodeExecutor(max_workers=1) as exe:\n", + " result = load_workflow_json(file_name=\"workflow_nfdi.json\", exe=exe).result()" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "6" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "result" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Jobflow" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/jan/mambaforge/lib/python3.12/site-packages/paramiko/pkey.py:82: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.\n", + " \"cipher\": algorithms.TripleDES,\n", + "/home/jan/mambaforge/lib/python3.12/site-packages/paramiko/transport.py:253: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.\n", + " \"class\": algorithms.TripleDES,\n" + ] + } + ], + "source": [ + "from jobflow.managers.local import run_locally" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.jobflow import load_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [], + "source": [ + "flow = load_workflow_json(file_name=\"workflow_nfdi.json\")" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2025-03-24 12:17:31,659 INFO Started executing jobs locally\n", + "2025-03-24 12:17:33,059 INFO Starting job - add_x_and_y (a8004d81-a7b8-41f1-a673-17b4d6e90ebf)\n", + "2025-03-24 12:17:33,061 INFO Finished job - add_x_and_y (a8004d81-a7b8-41f1-a673-17b4d6e90ebf)\n", + "2025-03-24 12:17:33,062 INFO Starting job - add_x_and_y_and_z (26ddcedb-34b3-4b09-883d-311b2689d870)\n", + "2025-03-24 12:17:33,066 INFO Finished job - add_x_and_y_and_z (26ddcedb-34b3-4b09-883d-311b2689d870)\n", + "2025-03-24 12:17:33,070 INFO Finished executing jobs locally\n" + ] + }, + { + "data": { + "text/plain": [ + "{'a8004d81-a7b8-41f1-a673-17b4d6e90ebf': {1: Response(output={'x': 1, 'y': 2, 'z': 3}, detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jan/notebooks/2025/2025-03-22-compare-workflows'))},\n", + " '26ddcedb-34b3-4b09-883d-311b2689d870': {1: Response(output=6, detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jan/notebooks/2025/2025-03-22-compare-workflows'))}}" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "result = run_locally(flow)\n", + "result" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## pyiron" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [], + "source": [ + "from pyiron_base import Project" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.pyiron_base import load_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "c62706b413eb44a391d2a24366c8ef82", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "0it [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "pr = Project(\"test\")\n", + "pr.remove_jobs(recursive=True, silently=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + "\n", + "\n", + "create_function_job_64c8e93072cd8858b5acc14f0b6a1345\n", + "\n", + "create_function_job=<pyiron_base.project.delayed.DelayedObject object at 0x7f6346efa3f0>\n", + "\n", + "\n", + "\n", + "x_66de6656099aebbaa5cdc840b1bf9733\n", + "\n", + "x=<pyiron_base.project.delayed.DelayedObject object at 0x7f6346efa030>\n", + "\n", + "\n", + "\n", + "x_66de6656099aebbaa5cdc840b1bf9733->create_function_job_64c8e93072cd8858b5acc14f0b6a1345\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "x_1d847da32ecaabf6731c38f798c3d4ce\n", + "\n", + "x=1\n", + "\n", + "\n", + "\n", + "x_1d847da32ecaabf6731c38f798c3d4ce->x_66de6656099aebbaa5cdc840b1bf9733\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "y_12cc51ee4250f1b82f9bc22e047ad944\n", + "\n", + "y=<pyiron_base.project.delayed.DelayedObject object at 0x7f6346efa000>\n", + "\n", + "\n", + "\n", + "x_1d847da32ecaabf6731c38f798c3d4ce->y_12cc51ee4250f1b82f9bc22e047ad944\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "z_91b561a78a57aad1d943f498a3c737ed\n", + "\n", + "z=<pyiron_base.project.delayed.DelayedObject object at 0x7f6346ef9ee0>\n", + "\n", + "\n", + "\n", + "x_1d847da32ecaabf6731c38f798c3d4ce->z_91b561a78a57aad1d943f498a3c737ed\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "y_12cc51ee4250f1b82f9bc22e047ad944->create_function_job_64c8e93072cd8858b5acc14f0b6a1345\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "z_91b561a78a57aad1d943f498a3c737ed->create_function_job_64c8e93072cd8858b5acc14f0b6a1345\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "y_a9ec4f5f33f0d64e74ed5d9900bceac6\n", + "\n", + "y=2\n", + "\n", + "\n", + "\n", + "y_a9ec4f5f33f0d64e74ed5d9900bceac6->x_66de6656099aebbaa5cdc840b1bf9733\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "y_a9ec4f5f33f0d64e74ed5d9900bceac6->y_12cc51ee4250f1b82f9bc22e047ad944\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "y_a9ec4f5f33f0d64e74ed5d9900bceac6->z_91b561a78a57aad1d943f498a3c737ed\n", + "\n", + "\n", + "\n", + "\n", + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "delayed_object = load_workflow_json(project=pr, file_name=\"workflow_nfdi.json\")\n", + "delayed_object.draw()" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The job add_x_and_y_68901482a2c5221cc845f828aabebd27 was saved and received the ID: 8\n", + "The job add_x_and_y_and_z_b671e81aaa4670d81d7eee509650af8d was saved and received the ID: 9\n" + ] + }, + { + "data": { + "text/plain": [ + "6" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "delayed_object.pull()" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idstatuschemicalformulajobsubjobprojectpathprojecttimestarttimestoptotalcputimecomputerhamiltonhamversionparentidmasterid
08finishedNoneadd_x_and_y_68901482a2c5221cc845f828aabebd27/add_x_and_y_68901482a2c5221cc845f828aabebd27None/home/jan/notebooks/2025/2025-03-22-compare-workflows/test/2025-03-24 12:17:37.412001NoneNonepyiron@p200300e77f488c66bae2561c878c14a2.dip0.t-ipconnect.de#1PythonFunctionContainerJob0.4NoneNone
19finishedNoneadd_x_and_y_and_z_b671e81aaa4670d81d7eee509650af8d/add_x_and_y_and_z_b671e81aaa4670d81d7eee509650af8dNone/home/jan/notebooks/2025/2025-03-22-compare-workflows/test/2025-03-24 12:17:39.161717NoneNonepyiron@p200300e77f488c66bae2561c878c14a2.dip0.t-ipconnect.de#1PythonFunctionContainerJob0.4NoneNone
\n", + "
" + ], + "text/plain": [ + " id status chemicalformula \\\n", + "0 8 finished None \n", + "1 9 finished None \n", + "\n", + " job \\\n", + "0 add_x_and_y_68901482a2c5221cc845f828aabebd27 \n", + "1 add_x_and_y_and_z_b671e81aaa4670d81d7eee509650af8d \n", + "\n", + " subjob projectpath \\\n", + "0 /add_x_and_y_68901482a2c5221cc845f828aabebd27 None \n", + "1 /add_x_and_y_and_z_b671e81aaa4670d81d7eee509650af8d None \n", + "\n", + " project \\\n", + "0 /home/jan/notebooks/2025/2025-03-22-compare-workflows/test/ \n", + "1 /home/jan/notebooks/2025/2025-03-22-compare-workflows/test/ \n", + "\n", + " timestart timestop totalcputime \\\n", + "0 2025-03-24 12:17:37.412001 None None \n", + "1 2025-03-24 12:17:39.161717 None None \n", + "\n", + " computer \\\n", + "0 pyiron@p200300e77f488c66bae2561c878c14a2.dip0.t-ipconnect.de#1 \n", + "1 pyiron@p200300e77f488c66bae2561c878c14a2.dip0.t-ipconnect.de#1 \n", + "\n", + " hamilton hamversion parentid masterid \n", + "0 PythonFunctionContainerJob 0.4 None None \n", + "1 PythonFunctionContainerJob 0.4 None None " + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pr.job_table()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Python" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.purepython import load_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "6" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "load_workflow_json(file_name=\"workflow_nfdi.json\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "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.12.5" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/workflow_nfdi.json b/workflow_nfdi.json new file mode 100644 index 0000000..141d170 --- /dev/null +++ b/workflow_nfdi.json @@ -0,0 +1,24 @@ +{ + "nodes": { + "0": "nfdi_ing_workflow.generate_mesh", + "1": "nfdi_ing_workflow.convert_to_xdmf", + "2": "nfdi_ing_workflow.poisson", + "3": "nfdi_ing_workflow.plot_over_line", + "4": "nfdi_ing_workflow.substitute_macros", + "5": "nfdi_ing_workflow.compile_paper", + "6": 2.0 + }, + "edges": [ + {"tn": 0, "th": "domain_size", "sn": 6, "sh": null}, + {"tn": 1, "th": "gmsh_output_file", "sn": 0, "sh": null}, + {"tn": 2, "th": "meshio_output_xdmf", "sn": 1, "sh": "xdmf_file"}, + {"tn": 2, "th": "meshio_output_h5", "sn": 1, "sh": "h5_file"}, + {"tn": 3, "th": "poisson_output_pvd_file", "sn": 2, "sh": "pvd_file"}, + {"tn": 3, "th": "poisson_output_vtu_file", "sn": 2, "sh": "vtu_file"}, + {"tn": 4, "th": "pvbatch_output_file", "sn": 3, "sh": null}, + {"tn": 4, "th": "ndofs", "sn": 2, "sh": "numdofs"}, + {"tn": 4, "th": "domain_size", "sn": 6, "sh": null}, + {"tn": 5, "th": "macros_tex", "sn": 4, "sh": null}, + {"tn": 5, "th": "plot_file", "sn": 3, "sh": null} + ] +} \ No newline at end of file