.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gen/examples/output_parsing/plot_eddy_snapshots.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gen_examples_output_parsing_plot_eddy_snapshots.py: Plot Jz at a given time step ============================= Use the Output parser to extract info of the time steps Download Input files * :download:`dipole_2d.data <../../../../../examples/input_files/eddy_currents.data>` * :download:`dipole_2d.post.xml <../../../../../examples/input_files/eddy_currents.post.xml>` .. GENERATED FROM PYTHON SOURCE LINES 14-18 Setting up ---------- Standard Loading of input, Parsing and Initializing RoxiePlotOutputs object .. GENERATED FROM PYTHON SOURCE LINES 18-30 .. code-block:: Python from roxieapi.commons.roxie_constants import PlotLabels from roxieapi.commons.types import Plot2D from roxieapi.output.parser import RoxieOutputParser from roxieapi.output.plots import RoxiePlotOutputs xml_file_path = "../input_files/eddy_currents.post.xml" data_file_path = "../input_files/eddy_currents.data" plots = RoxiePlotOutputs(xml_file_path, data_file_path) parser = RoxieOutputParser(xml_file_path) .. GENERATED FROM PYTHON SOURCE LINES 31-33 Show available plots of Eddy currents Time steps ------------------- .. GENERATED FROM PYTHON SOURCE LINES 33-42 .. code-block:: Python # These are the possible things to plot on Mesh for eddy-currents # Select one of the {pl} for pl in PlotLabels.plotMesh2D_desc: lbl, _ = PlotLabels.lbl_desc_mesh2D(pl) print(f"Mesh Eddy plot '{pl}' - Label: '{lbl}'") .. rst-class:: sphx-glr-script-out .. code-block:: none Mesh Eddy plot '31' - Label: 'MUER' Mesh Eddy plot '32' - Label: '|BTOT|' Mesh Eddy plot '34' - Label: 'AR' Mesh Eddy plot '35' - Label: 'MUEFAC' Mesh Eddy plot '75' - Label: 'Bx' Mesh Eddy plot '76' - Label: 'By' Mesh Eddy plot '121' - Label: 'JX' Mesh Eddy plot '122' - Label: 'JY' Mesh Eddy plot '123' - Label: 'JZ' Mesh Eddy plot '124' - Label: '|J|' Mesh Eddy plot '125' - Label: 'J2S' Mesh Eddy plot 'az' - Label: 'AZ' Mesh Eddy plot 'norm_deriv_az' - Label: 'dAz/dn' Mesh Eddy plot 'Bz' - Label: 'Bz' Mesh Eddy plot 'jx' - Label: 'JX' Mesh Eddy plot 'jy' - Label: 'JY' Mesh Eddy plot 'jz' - Label: 'JZ' Mesh Eddy plot 'j^2/sigma' - Label: 'J2S' Mesh Eddy plot 'Hx' - Label: 'HX' Mesh Eddy plot 'Hy' - Label: 'HY' Mesh Eddy plot 'Hz' - Label: 'HZ' .. GENERATED FROM PYTHON SOURCE LINES 43-45 In the above ROXIE file, we used 2 "Nsteps" (transient steps) and each one has 4 "Evaluation steps" ------------------- .. GENERATED FROM PYTHON SOURCE LINES 45-53 .. code-block:: Python transient_steps = parser.opt[1].transient_steps_number eddy_steps = parser.opt[1].step[1].eddy_steps_number print( f"We have {transient_steps} transient steps, and each has {eddy_steps} eddy steps." ) .. rst-class:: sphx-glr-script-out .. code-block:: none We have 2 transient steps, and each has 4 eddy steps. .. GENERATED FROM PYTHON SOURCE LINES 54-56 Let's plot the current density during the excitation @ 4th eddy time step ------------------- .. GENERATED FROM PYTHON SOURCE LINES 56-67 .. code-block:: Python snapshot_time = parser.opt[1].step[1].eddyTimeSteps[4].time plot_created = Plot2D.create(f"Jz @{snapshot_time:.2f} s") # Pass the selected {pl} to plot plot_created.add_meshPlot("jz") # Plot on 1st (optim) run, 2nd excitation (transient) step, 4th eddy time step figure = plots.plots2d.plot_xs(plot_created, opt_step=1, trans_step=2, eddy_step=4) # Eddy step is Optional, so below plot should be the same since the last (4-th) eddy step is used by default figure = plots.plots2d.plot_xs(plot_created, opt_step=1, trans_step=2) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /gen/examples/output_parsing/images/sphx_glr_plot_eddy_snapshots_001.png :alt: Jz @0.50 s :srcset: /gen/examples/output_parsing/images/sphx_glr_plot_eddy_snapshots_001.png, /gen/examples/output_parsing/images/sphx_glr_plot_eddy_snapshots_001_2_00x.png 2.00x :class: sphx-glr-multi-img * .. image-sg:: /gen/examples/output_parsing/images/sphx_glr_plot_eddy_snapshots_002.png :alt: Jz @0.50 s :srcset: /gen/examples/output_parsing/images/sphx_glr_plot_eddy_snapshots_002.png, /gen/examples/output_parsing/images/sphx_glr_plot_eddy_snapshots_002_2_00x.png 2.00x :class: sphx-glr-multi-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.787 seconds) .. _sphx_glr_download_gen_examples_output_parsing_plot_eddy_snapshots.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_eddy_snapshots.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_eddy_snapshots.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_eddy_snapshots.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_