.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gen/examples/output_parsing/plot_extract_conductor_coordinates.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_extract_conductor_coordinates.py: Extract Conductor Coordinates ============================= Use the Output parser to extract conductor coordinates and forces Download Input files * :download:`dipole_2d.data <../../../../../examples/input_files/dipole_2d.data>` * :download:`dipole_2d.post.xml <../../../../../examples/input_files/dipole_2d.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-24 .. code-block:: Python import pandas as pd from roxieapi.output.parser import RoxieOutputParser parser = RoxieOutputParser("../input_files/dipole_2d.post.xml") .. GENERATED FROM PYTHON SOURCE LINES 25-27 Extract Geometry ---------------- .. GENERATED FROM PYTHON SOURCE LINES 27-39 .. code-block:: Python geom = parser.opt[1].coilGeometries columns = ["cond", "block", "layer", "x1", "y1", "x2", "y2", "x3", "y3", "x4", "y4"] data = [ (cond.nr, cond.block_id, cond.layer_id, *cond.geometry.flatten()) for cond in geom.values() ] df_geom = pd.DataFrame(data, columns=columns) df_geom .. raw:: html
cond block layer x1 y1 x2 y2 x3 y3 x4 y4
0 1 0 1 Name: block_nr, dtype: int64 0 1 Name: layer_nr, dtype: int64 44.038746 1.612252 44.049389 0.250293 59.149850 0.250293 59.137363 1.848244
1 2 0 1 Name: block_nr, dtype: int64 0 1 Name: layer_nr, dtype: int64 43.980533 3.233498 44.012460 1.871873 59.111077 2.107865 59.073618 3.705426
2 3 0 1 Name: block_nr, dtype: int64 0 1 Name: layer_nr, dtype: int64 43.863107 4.852578 43.916309 3.491617 59.009394 3.963545 58.946973 5.560326
3 4 0 1 Name: block_nr, dtype: int64 0 1 Name: layer_nr, dtype: int64 43.685891 6.468005 43.760356 5.108043 58.844222 5.815790 58.756854 7.411400
4 5 0 1 Name: block_nr, dtype: int64 0 1 Name: layer_nr, dtype: int64 43.448846 8.078300 43.544557 6.719667 58.615520 7.663062 58.503225 9.257112
... ... ... ... ... ... ... ... ... ... ... ...
155 156 21 22 Name: block_nr, dtype: int64 21 2 Name: layer_nr, dtype: int64 -7.870124 27.096695 -9.500046 26.499157 -14.851506 40.620019 -12.913627 41.330457
156 157 22 23 Name: block_nr, dtype: int64 22 2 Name: layer_nr, dtype: int64 -9.727495 -26.422087 -11.344054 -25.789289 -17.000947 -39.790591 -15.078956 -40.542950
157 158 22 23 Name: block_nr, dtype: int64 22 2 Name: layer_nr, dtype: int64 -7.870124 -27.096695 -9.500046 -26.499157 -14.851506 -40.620019 -12.913627 -41.330457
158 159 23 24 Name: block_nr, dtype: int64 23 2 Name: layer_nr, dtype: int64 9.727495 -26.422087 11.344054 -25.789289 17.000947 -39.790591 15.078956 -40.542950
159 160 23 24 Name: block_nr, dtype: int64 23 2 Name: layer_nr, dtype: int64 7.870124 -27.096695 9.500046 -26.499157 14.851506 -40.620019 12.913627 -41.330457

160 rows × 11 columns



.. GENERATED FROM PYTHON SOURCE LINES 40-42 Merge Geometry with forces -------------------------- .. GENERATED FROM PYTHON SOURCE LINES 42-48 .. code-block:: Python df_forces = parser.opt[1].step[1].conductorForces df_all = df_geom.merge(df_forces, on="cond") df_all .. raw:: html
cond block layer x1 y1 x2 y2 x3 y3 x4 y4 fx fy ftr fpa fra faz
0 1 0 1 Name: block_nr, dtype: int64 0 1 Name: layer_nr, dtype: int64 44.038746 1.612252 44.049389 0.250293 59.149850 0.250293 59.137363 1.848244 -15999.283 -1145.3686 -1020.3099 -16007.745 -16018.317 -838.13061
1 2 0 1 Name: block_nr, dtype: int64 0 1 Name: layer_nr, dtype: int64 43.980533 3.233498 44.012460 1.871873 59.111077 2.107865 59.073618 3.705426 -15839.633 -4551.7958 -4179.2469 -15941.979 -16058.183 -3707.77230
2 3 0 1 Name: block_nr, dtype: int64 0 1 Name: layer_nr, dtype: int64 43.863107 4.852578 43.916309 3.491617 59.009394 3.963545 58.946973 5.560326 -15436.232 -7940.0025 -7330.9707 -15734.604 -16065.342 -6574.62320
3 4 0 1 Name: block_nr, dtype: int64 0 1 Name: layer_nr, dtype: int64 43.685891 6.468005 43.760356 5.108043 58.844222 5.815790 58.756854 7.411400 -14783.503 -11329.2430 -10504.0300 -15380.802 -16037.026 -9471.93290
4 5 0 1 Name: block_nr, dtype: int64 0 1 Name: layer_nr, dtype: int64 43.448846 8.078300 43.544557 6.719667 58.615520 7.663062 58.503225 9.257112 -13883.643 -14732.9170 -13720.8680 -14884.628 -15981.269 -12426.32000
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
155 156 21 22 Name: block_nr, dtype: int64 21 2 Name: layer_nr, dtype: int64 -7.870124 27.096695 -9.500046 26.499157 -14.851506 40.620019 -12.913627 41.330457 -78154.596 -14997.0900 78541.0080 12820.440 10462.645 78889.71200
156 157 22 23 Name: block_nr, dtype: int64 22 2 Name: layer_nr, dtype: int64 -9.727495 -26.422087 -11.344054 -25.789289 -17.000947 -39.790591 -15.078956 -40.542950 -71466.124 14505.0560 -71836.3880 12543.403 13136.504 -71730.29900
157 158 22 23 Name: block_nr, dtype: int64 22 2 Name: layer_nr, dtype: int64 -7.870124 -27.096695 -9.500046 -26.499157 -14.851506 -40.620019 -12.913627 -41.330457 -78154.596 14997.0900 -78541.0080 12820.440 10462.645 -78889.71200
158 159 23 24 Name: block_nr, dtype: int64 23 2 Name: layer_nr, dtype: int64 9.727495 -26.422087 11.344054 -25.789289 17.000947 -39.790591 15.078956 -40.542950 71466.124 14505.0560 71836.3880 12543.403 13136.504 71730.29900
159 160 23 24 Name: block_nr, dtype: int64 23 2 Name: layer_nr, dtype: int64 7.870124 -27.096695 9.500046 -26.499157 14.851506 -40.620019 12.913627 -41.330457 78154.596 14997.0900 78541.0080 12820.440 10462.645 78889.71200

160 rows × 17 columns



.. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.268 seconds) .. _sphx_glr_download_gen_examples_output_parsing_plot_extract_conductor_coordinates.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_extract_conductor_coordinates.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_extract_conductor_coordinates.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_extract_conductor_coordinates.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_