{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Extract Conductor Coordinates\n\nUse the Output parser to extract conductor coordinates and forces\n\nDownload Input files\n\n* :download:`dipole_2d.data <../../../../../examples/input_files/dipole_2d.data>`\n* :download:`dipole_2d.post.xml <../../../../../examples/input_files/dipole_2d.post.xml>`\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setting up\nStandard Loading of input, Parsing and Initializing RoxiePlotOutputs object\n\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import pandas as pd\n\nfrom roxieapi.output.parser import RoxieOutputParser\n\nparser = RoxieOutputParser(\"../input_files/dipole_2d.post.xml\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Extract Geometry\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "geom = parser.opt[1].coilGeometries\n\ncolumns = [\"cond\", \"block\", \"layer\", \"x1\", \"y1\", \"x2\", \"y2\", \"x3\", \"y3\", \"x4\", \"y4\"]\ndata = [\n (cond.nr, cond.block_id, cond.layer_id, *cond.geometry.flatten())\n for cond in geom.values()\n]\n\ndf_geom = pd.DataFrame(data, columns=columns)\n\ndf_geom" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Merge Geometry with forces\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "df_forces = parser.opt[1].step[1].conductorForces\n\ndf_all = df_geom.merge(df_forces, on=\"cond\")\n\ndf_all" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.9.20" } }, "nbformat": 4, "nbformat_minor": 0 }