{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Plot Jz at a given time step\n\nUse the Output parser to extract info of the time steps\n\nDownload Input files\n\n* :download:`dipole_2d.data <../../../../../examples/input_files/eddy_currents.data>`\n* :download:`dipole_2d.post.xml <../../../../../examples/input_files/eddy_currents.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": [ "from roxieapi.commons.roxie_constants import PlotLabels\nfrom roxieapi.commons.types import Plot2D\nfrom roxieapi.output.parser import RoxieOutputParser\nfrom roxieapi.output.plots import RoxiePlotOutputs\n\nxml_file_path = \"../input_files/eddy_currents.post.xml\"\ndata_file_path = \"../input_files/eddy_currents.data\"\n\nplots = RoxiePlotOutputs(xml_file_path, data_file_path)\nparser = RoxieOutputParser(xml_file_path)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Show available plots of Eddy currents Time steps\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# These are the possible things to plot on Mesh for eddy-currents\n# Select one of the {pl}\n\nfor pl in PlotLabels.plotMesh2D_desc:\n lbl, _ = PlotLabels.lbl_desc_mesh2D(pl)\n print(f\"Mesh Eddy plot '{pl}' - Label: '{lbl}'\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## In the above ROXIE file, we used 2 \"Nsteps\" (transient steps) and each one has 4 \"Evaluation steps\"\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "transient_steps = parser.opt[1].transient_steps_number\neddy_steps = parser.opt[1].step[1].eddy_steps_number\n\nprint(\n f\"We have {transient_steps} transient steps, and each has {eddy_steps} eddy steps.\"\n)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Let's plot the current density during the excitation @ 4th eddy time step\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "snapshot_time = parser.opt[1].step[1].eddyTimeSteps[4].time\nplot_created = Plot2D.create(f\"Jz @{snapshot_time:.2f} s\")\n\n# Pass the selected {pl} to plot\nplot_created.add_meshPlot(\"jz\")\n\n# Plot on 1st (optim) run, 2nd excitation (transient) step, 4th eddy time step\nfigure = plots.plots2d.plot_xs(plot_created, opt_step=1, trans_step=2, eddy_step=4)\n\n# Eddy step is Optional, so below plot should be the same since the last (4-th) eddy step is used by default\nfigure = plots.plots2d.plot_xs(plot_created, opt_step=1, trans_step=2)" ] } ], "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.11.13" } }, "nbformat": 4, "nbformat_minor": 0 }