.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gen/examples/output_parsing/plot_2d_animation.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_2d_animation.py: Create animations for plots in 2D ============================= Use the Output parser to extract info 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-32 .. code-block:: Python from IPython.display import Image, display 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 33-35 Show available Coil plots ------------------- .. GENERATED FROM PYTHON SOURCE LINES 35-50 .. code-block:: Python trans = plots.output.opt[1].step[1] print("Coil Plots:") data_cols = trans.coilData.columns for col in data_cols: if col in PlotLabels.plot2D_desc: lbl, desc = PlotLabels.lbl_desc_plot2D(col) print(f" Plot {col}: {desc}") for hc_idx, hc in trans.harmonicCoils.items(): data_cols = hc.strandData for col in data_cols: if col in PlotLabels.plot2D_desc: lbl, desc = PlotLabels.lbl_desc_plot2D(col) print(f" Harmonic coil #{hc_idx}, Plot {col}: {desc}") .. rst-class:: sphx-glr-script-out .. code-block:: none Coil Plots: Plot 14: I (A) Plot 15: J (A/mm^2!) Plot 16: J-Cu (A/mm^2!) Plot 17: J-Sc (A/mm^2!) Plot 24: |I| (A) Plot 25: |J| (A/mm^2!) Plot 26: |J-Cu| (A/mm^2!) Plot 27: |J-Sc| (A/mm^2!) Plot 29: T (K) Plot 19: Bred x-comp (T) Plot 20: Bred y-comp (T) Plot 21: |Bred| (T) Plot 22: Ared (Tm) Harmonic coil #1, Plot 49: B1 Contrib. of I strand (T) Harmonic coil #1, Plot 50: B2 Contrib. of I strand (T) Harmonic coil #1, Plot 51: B3 Contrib. of I strand (T) Harmonic coil #1, Plot 52: B4 Contrib. of I strand (T) Harmonic coil #1, Plot 53: B5 Contrib. of I strand (T) Harmonic coil #1, Plot 54: B6 Contrib. of I strand (T) Harmonic coil #1, Plot 55: B7 Contrib. of I strand (T) Harmonic coil #1, Plot 56: B8 Contrib. of I strand (T) Harmonic coil #1, Plot 57: B9 Contrib. of I strand (T) Harmonic coil #1, Plot 58: B10 Contrib. of I strand (T) Harmonic coil #1, Plot 59: B11 Contrib. of I strand (T) Harmonic coil #1, Plot 146: B12 Contrib. of I strand (T) Harmonic coil #1, Plot 147: B13 Contrib. of I strand (T) Harmonic coil #1, Plot 148: B14 Contrib. of I strand (T) Harmonic coil #1, Plot 161: A1 Contrib. of I strand (T) Harmonic coil #1, Plot 162: A2 Contrib. of I strand (T) Harmonic coil #1, Plot 163: A3 Contrib. of I strand (T) Harmonic coil #1, Plot 164: A4 Contrib. of I strand (T) Harmonic coil #1, Plot 165: A5 Contrib. of I strand (T) Harmonic coil #1, Plot 166: A6 Contrib. of I strand (T) Harmonic coil #1, Plot 167: A7 Contrib. of I strand (T) Harmonic coil #1, Plot 168: A8 Contrib. of I strand (T) Harmonic coil #1, Plot 169: A9 Contrib. of I strand (T) Harmonic coil #1, Plot 170: A10 Contrib. of I strand (T) Harmonic coil #1, Plot 171: A11 Contrib. of I strand (T) Harmonic coil #1, Plot 172: A12 Contrib. of I strand (T) Harmonic coil #1, Plot 173: A13 Contrib. of I strand (T) Harmonic coil #1, Plot 174: A14 Contrib. of I strand (T) Harmonic coil #2, Plot 49: B1 Contrib. of I strand (T) Harmonic coil #2, Plot 50: B2 Contrib. of I strand (T) Harmonic coil #2, Plot 51: B3 Contrib. of I strand (T) Harmonic coil #2, Plot 52: B4 Contrib. of I strand (T) Harmonic coil #2, Plot 53: B5 Contrib. of I strand (T) Harmonic coil #2, Plot 54: B6 Contrib. of I strand (T) Harmonic coil #2, Plot 55: B7 Contrib. of I strand (T) Harmonic coil #2, Plot 56: B8 Contrib. of I strand (T) Harmonic coil #2, Plot 57: B9 Contrib. of I strand (T) Harmonic coil #2, Plot 58: B10 Contrib. of I strand (T) Harmonic coil #2, Plot 59: B11 Contrib. of I strand (T) Harmonic coil #2, Plot 146: B12 Contrib. of I strand (T) Harmonic coil #2, Plot 147: B13 Contrib. of I strand (T) Harmonic coil #2, Plot 148: B14 Contrib. of I strand (T) Harmonic coil #2, Plot 161: A1 Contrib. of I strand (T) Harmonic coil #2, Plot 162: A2 Contrib. of I strand (T) Harmonic coil #2, Plot 163: A3 Contrib. of I strand (T) Harmonic coil #2, Plot 164: A4 Contrib. of I strand (T) Harmonic coil #2, Plot 165: A5 Contrib. of I strand (T) Harmonic coil #2, Plot 166: A6 Contrib. of I strand (T) Harmonic coil #2, Plot 167: A7 Contrib. of I strand (T) Harmonic coil #2, Plot 168: A8 Contrib. of I strand (T) Harmonic coil #2, Plot 169: A9 Contrib. of I strand (T) Harmonic coil #2, Plot 170: A10 Contrib. of I strand (T) Harmonic coil #2, Plot 171: A11 Contrib. of I strand (T) Harmonic coil #2, Plot 172: A12 Contrib. of I strand (T) Harmonic coil #2, Plot 173: A13 Contrib. of I strand (T) Harmonic coil #2, Plot 174: A14 Contrib. of I strand (T) Harmonic coil #3, Plot 49: B1 Contrib. of I strand (T) Harmonic coil #3, Plot 50: B2 Contrib. of I strand (T) Harmonic coil #3, Plot 51: B3 Contrib. of I strand (T) Harmonic coil #3, Plot 52: B4 Contrib. of I strand (T) Harmonic coil #3, Plot 53: B5 Contrib. of I strand (T) Harmonic coil #3, Plot 54: B6 Contrib. of I strand (T) Harmonic coil #3, Plot 55: B7 Contrib. of I strand (T) Harmonic coil #3, Plot 56: B8 Contrib. of I strand (T) Harmonic coil #3, Plot 57: B9 Contrib. of I strand (T) Harmonic coil #3, Plot 58: B10 Contrib. of I strand (T) Harmonic coil #3, Plot 59: B11 Contrib. of I strand (T) Harmonic coil #3, Plot 146: B12 Contrib. of I strand (T) Harmonic coil #3, Plot 147: B13 Contrib. of I strand (T) Harmonic coil #3, Plot 148: B14 Contrib. of I strand (T) Harmonic coil #3, Plot 161: A1 Contrib. of I strand (T) Harmonic coil #3, Plot 162: A2 Contrib. of I strand (T) Harmonic coil #3, Plot 163: A3 Contrib. of I strand (T) Harmonic coil #3, Plot 164: A4 Contrib. of I strand (T) Harmonic coil #3, Plot 165: A5 Contrib. of I strand (T) Harmonic coil #3, Plot 166: A6 Contrib. of I strand (T) Harmonic coil #3, Plot 167: A7 Contrib. of I strand (T) Harmonic coil #3, Plot 168: A8 Contrib. of I strand (T) Harmonic coil #3, Plot 169: A9 Contrib. of I strand (T) Harmonic coil #3, Plot 170: A10 Contrib. of I strand (T) Harmonic coil #3, Plot 171: A11 Contrib. of I strand (T) Harmonic coil #3, Plot 172: A12 Contrib. of I strand (T) Harmonic coil #3, Plot 173: A13 Contrib. of I strand (T) Harmonic coil #3, Plot 174: A14 Contrib. of I strand (T) .. GENERATED FROM PYTHON SOURCE LINES 51-53 Show available Iron Mesh plots and Iron Mesh Plots for Eddy - Currents simulations ------------------- .. GENERATED FROM PYTHON SOURCE LINES 53-62 .. code-block:: Python print("Iron mesh plots:") data_cols = plots.output.opt[1].step[1].meshData.columns for col in data_cols: if col in PlotLabels.plotMesh2D_desc: lbl, desc = PlotLabels.lbl_desc_mesh2D(col) print(f" Plot {col}: {desc}") .. rst-class:: sphx-glr-script-out .. code-block:: none Iron mesh plots: Plot 31: Muer Plot 32: |B| (T) Plot 34: Az (Tm) Plot 35: (Muer-1)/(Muer+1) Plot 75: Bx (T) Plot 76: By (T) Plot 121: Eddy Jx current dens. (A/m**2) Plot 122: Eddy Jy current dens. (A/m**2) Plot 123: Eddy JZ current dens. (A/m**2) Plot 124: |J| (A/m**2) Plot 125: J**2*S (A**2) .. GENERATED FROM PYTHON SOURCE LINES 63-66 You can animate all kinds of the above plots! Let's plot the current densioty in the coils ------------------- .. GENERATED FROM PYTHON SOURCE LINES 66-78 .. code-block:: Python plot_created = Plot2D.create("My 2D Animation - J") plot_created.add_coilPlot("14", harm_coil=1) figure = plots.plots2d.create_anim( plot_created, opt_step=1, start_trans_step=1, end_trans_step=2, anim_filename="current_dens_coils_animation.gif", ) display(Image(filename="current_dens_coils_animation.gif")) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 79-81 Let's plot the Vector Potential Az in the Iron Mesh plots ------------------- .. GENERATED FROM PYTHON SOURCE LINES 81-93 .. code-block:: Python plot_created = Plot2D.create("My 2D Animation - I") plot_created.add_meshPlot("34") figure = plots.plots2d.create_anim( plot_created, opt_step=1, start_trans_step=1, end_trans_step=2, anim_filename="az_animation.gif", ) display(Image(filename="az_animation.gif")) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 94-96 Let's plot the current density during the excitation ------------------- .. GENERATED FROM PYTHON SOURCE LINES 96-106 .. code-block:: Python plot_created = Plot2D.create("My 2D Animation - Jz") plot_created.add_meshPlot("jz") figure = plots.plots2d.create_anim( plot_created, opt_step=1, start_trans_step=1, end_trans_step=2, anim_filename="jz_animation.gif", ) display(Image(filename="jz_animation.gif")) .. rst-class:: sphx-glr-script-out .. code-block:: none .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.797 seconds) .. _sphx_glr_download_gen_examples_output_parsing_plot_2d_animation.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_2d_animation.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_2d_animation.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_2d_animation.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_