Create animations for plots in 2D

Use the Output parser to extract info

Download Input files

Setting up

Standard Loading of input, Parsing and Initializing RoxiePlotOutputs object

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)

Show available Coil plots

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}")
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)

Show available Iron Mesh plots and Iron Mesh Plots for Eddy - Currents simulations

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}")
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)

You can animate all kinds of the above plots! Let’s plot the current densioty in the coils ——————-

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"))
<IPython.core.display.Image object>

Let’s plot the Vector Potential Az in the Iron Mesh plots

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"))
<IPython.core.display.Image object>

Let’s plot the current density during the excitation

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"))
<IPython.core.display.Image object>

Total running time of the script: (0 minutes 1.797 seconds)

Gallery generated by Sphinx-Gallery