{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Getting Started with AnyPyTools" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Running a simple macro" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\"Drawing\"\n", "\n", "For the sake of the tutorial we will use a small 'toy' model of a simplified knee joint (see the figure.) The model is defined in the file [Knee.any](Knee.any), which is placed in the current working directory.\n", "\n", "Next, let us run the model from python. First, we import the `AnyPyProcess` class and create an instance of the class.\n", " " ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from anypytools import AnyPyProcess \n", "app = AnyPyProcess()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next, we need to instruct the AnyBody Modelling System to load the and run the model. We do this using _AnyScript_ macro commands. These are short commands that can automate operations in the AnyBody Modeling System (AMS). Operation that are normally done by pointing and clicking in the AMS graphical user interface. \n", "\n", "You can read more on _AnyScript_ macros in the \"User Interface Features\" tutorial that accompanies the AnyBody Modeling System.\n", "\n", "Now we define an _AnyScript_ macro that we want to run on the model.\n", "\n", "```\n", "load \"Knee.any\"\n", "operation Main.MyStudy.Kinematics\n", "run\n", "```\n", "\n", "The macro will command AnyBody to load the model and run the Kinematics operation. \n", "\n", "The macro is executed by parsing it to the `start_macro()` method of the `AnyPyProcess` object." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "3894a7240733488091f71282139f093b", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/1 [00:00" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "\n", "plt.plot(max_muscle_act);" ] } ], "metadata": { "anaconda-cloud": {}, "interpreter": { "hash": "7840ed1e0d8c0fa6141b9782bb3c547b5e5fa4178e680f89033f8188680e7ee3" }, "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.10.0" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "state": { "038e0133795041578af6416b3b529338": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {} }, "0ceec8ad7db7414fbba5fcf560b2597a": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": { "children": [ "IPY_MODEL_32b83ed3340b47e9b3f1dbf2a126171e", "IPY_MODEL_3148078fc5d642f8b3fe98693504a9f4", "IPY_MODEL_e1405d7ecc124975bd680a577805cc22" ], "layout": "IPY_MODEL_d4f9534578a94f9d8cc6d0c0befd1c5f" } }, "150aad3e6a4a415a90fc227a79665b9e": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "layout": "IPY_MODEL_038e0133795041578af6416b3b529338", "style": "IPY_MODEL_83acbfecc0594dcaba2d3bd1533fcef3", "value": "100%" } }, "1a375fe6b4384b6fb9bff4d0552c7673": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "layout": "IPY_MODEL_21637136d4884f0e95d39329d3abaf62", "style": "IPY_MODEL_7c8a586e484b4a719de1eca2272fb178", "value": "100%" } }, "1af44622829c4294955ef5cbe7d1d607": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {} }, "208d149848f34d0ebfff66a0e5b7135d": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {} }, "21637136d4884f0e95d39329d3abaf62": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {} }, "2bc61f27c9434772a5f222bf38bc6148": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "description_width": "" } }, "2da674cf084344189789d2f8281548bb": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "description_width": "" } }, "3148078fc5d642f8b3fe98693504a9f4": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": { "bar_style": "success", "layout": "IPY_MODEL_fda2cf827ee049e3a7664a7b36ba5e0a", "max": 1, "style": "IPY_MODEL_855981dd6596479e8daf6421a721c351", "value": 1 } }, "32b83ed3340b47e9b3f1dbf2a126171e": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "layout": "IPY_MODEL_e9cc6f729bd840b7baef014b0e9eefe7", "style": "IPY_MODEL_fb94187b176a4f079a17684f810528f5", "value": "100%" } }, "3894a7240733488091f71282139f093b": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": { "children": [ "IPY_MODEL_c27aec8b6b274003a21dc8ed20995983", "IPY_MODEL_5f2700786493433cb05f0de916b7a01a", "IPY_MODEL_9c13066159d1421585fc4956305f845f" ], "layout": "IPY_MODEL_7a17bd77ad224b9cb11d9ec77dc65e4a" } }, "3cb00413495246b5bf8ba65871c170dd": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {} }, "46d2e908baf8439fbcaecccfc9829643": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "layout": "IPY_MODEL_3cb00413495246b5bf8ba65871c170dd", "style": "IPY_MODEL_4ba3800318ac477cb56657e6dce06793", "value": "100%" } }, "4b4642f56e5344c783603a3f1fd4f4af": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": { "children": [ "IPY_MODEL_1a375fe6b4384b6fb9bff4d0552c7673", "IPY_MODEL_b2a9ffa2983d4848a81a563e173c8e87", "IPY_MODEL_d9d138d1fcb441498a8c61e3b72933e4" ], "layout": "IPY_MODEL_208d149848f34d0ebfff66a0e5b7135d" } }, "4ba3800318ac477cb56657e6dce06793": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "description_width": "" } }, "4d7ebb51ea4641bba8a4ad134916637d": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {} }, "4e29c8e0a7ff4e29b87299813951d83e": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {} }, "4ef9c185f96b4e35877d408cc677f531": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {} }, "4f0eb23d26cf4cfc9b990cc9369b700b": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "description_width": "" } }, "507936e5207e44ec9d4272e9d3f743bd": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": { "children": [ "IPY_MODEL_150aad3e6a4a415a90fc227a79665b9e", "IPY_MODEL_f8f0e173843142aab52a6067dde5562f", "IPY_MODEL_5ce047b5e97841f8a44c84d4f081ce48" ], "layout": "IPY_MODEL_4e29c8e0a7ff4e29b87299813951d83e" } }, "5ce047b5e97841f8a44c84d4f081ce48": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "layout": "IPY_MODEL_91e0d6541c844a9cbb70958295566b29", "style": "IPY_MODEL_e895e4089e3246729983c6dc68991c2f", "value": " 40/40 [00:39<00:00, 1.07it/s]" } }, "5f2700786493433cb05f0de916b7a01a": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": { "bar_style": "success", "layout": "IPY_MODEL_e4951310a5c6493caa7aa4e30b48d73d", "max": 1, "style": "IPY_MODEL_bb123cf25e9e457f896fd4e900b055c3", "value": 1 } }, "61cdbc29d5964aaba79332b6c1b9fd71": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "description_width": "" } }, "6ab49f196f694e0e942a8ad1c2083ba5": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {} }, "6b8f17ee499b4320bbef4ac064cffc59": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": { "children": [ "IPY_MODEL_46d2e908baf8439fbcaecccfc9829643", "IPY_MODEL_ecdc9b9531484f38a3bac6a8073516b6", "IPY_MODEL_a0330762cf2e413f8f237fd588a37670" ], "layout": "IPY_MODEL_76cd35d330fa4801a729f67c776b60e6" } }, "6dd8b36b2c67400d93a8c99f0c9709b7": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {} }, "76cd35d330fa4801a729f67c776b60e6": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {} }, "7a17bd77ad224b9cb11d9ec77dc65e4a": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {} }, "7be5e9eceb61402ab2e5da1d7464351f": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": { "description_width": "" } }, "7c8a586e484b4a719de1eca2272fb178": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "description_width": "" } }, "83a53e7dab034d21b5fb6b75c441a32b": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "description_width": "" } }, "83acbfecc0594dcaba2d3bd1533fcef3": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "description_width": "" } }, "855981dd6596479e8daf6421a721c351": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": { "description_width": "" } }, "91e0d6541c844a9cbb70958295566b29": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {} }, "939f80052ca54a84be271383a422dc6e": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {} }, "9c13066159d1421585fc4956305f845f": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "layout": "IPY_MODEL_939f80052ca54a84be271383a422dc6e", "style": "IPY_MODEL_83a53e7dab034d21b5fb6b75c441a32b", "value": " 1/1 [00:00<00:00, 1.39it/s]" } }, "a0330762cf2e413f8f237fd588a37670": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "layout": "IPY_MODEL_1af44622829c4294955ef5cbe7d1d607", "style": "IPY_MODEL_4f0eb23d26cf4cfc9b990cc9369b700b", "value": " 40/40 [00:28<00:00, 1.59it/s]" } }, "b2a9ffa2983d4848a81a563e173c8e87": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": { "bar_style": "success", "layout": "IPY_MODEL_c17b6bbe95944540b88d061ee4feb409", "max": 2, "style": "IPY_MODEL_b9a15dd9ccdb4372acf1b0d6c1d0ba3d", "value": 2 } }, "b9a15dd9ccdb4372acf1b0d6c1d0ba3d": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": { "description_width": "" } }, "bb123cf25e9e457f896fd4e900b055c3": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": { "description_width": "" } }, "c17b6bbe95944540b88d061ee4feb409": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {} }, "c27aec8b6b274003a21dc8ed20995983": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "layout": "IPY_MODEL_c9f3bb94474c44dea0bfa5dfbce63642", "style": "IPY_MODEL_61cdbc29d5964aaba79332b6c1b9fd71", "value": "100%" } }, "c9f3bb94474c44dea0bfa5dfbce63642": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {} }, "d4f9534578a94f9d8cc6d0c0befd1c5f": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {} }, "d9d138d1fcb441498a8c61e3b72933e4": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "layout": "IPY_MODEL_4d7ebb51ea4641bba8a4ad134916637d", "style": "IPY_MODEL_2bc61f27c9434772a5f222bf38bc6148", "value": " 2/2 [00:01<00:00, 1.27s/it]" } }, "e1405d7ecc124975bd680a577805cc22": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": { "layout": "IPY_MODEL_4ef9c185f96b4e35877d408cc677f531", "style": "IPY_MODEL_2da674cf084344189789d2f8281548bb", "value": " 1/1 [00:01<00:00, 1.13s/it]" } }, "e4951310a5c6493caa7aa4e30b48d73d": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {} }, "e895e4089e3246729983c6dc68991c2f": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "description_width": "" } }, "e9cc6f729bd840b7baef014b0e9eefe7": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {} }, "ecdc9b9531484f38a3bac6a8073516b6": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": { "bar_style": "success", "layout": "IPY_MODEL_6dd8b36b2c67400d93a8c99f0c9709b7", "max": 40, "style": "IPY_MODEL_f0cdf787876949e5a299b19803e7985c", "value": 40 } }, "f0cdf787876949e5a299b19803e7985c": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": { "description_width": "" } }, "f8f0e173843142aab52a6067dde5562f": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": { "bar_style": "success", "layout": "IPY_MODEL_6ab49f196f694e0e942a8ad1c2083ba5", "max": 40, "style": "IPY_MODEL_7be5e9eceb61402ab2e5da1d7464351f", "value": 40 } }, "fb94187b176a4f079a17684f810528f5": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": { "description_width": "" } }, "fda2cf827ee049e3a7664a7b36ba5e0a": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {} } }, "version_major": 2, "version_minor": 0 } } }, "nbformat": 4, "nbformat_minor": 4 }