.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/howto_propertylib/plot_propertylib.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_auto_examples_howto_propertylib_plot_propertylib.py: Features of propertylib ===================================== .. sectionauthor:: Florian Zill (Helmholtz Centre for Environmental Research GmbH - UFZ) ``propertylib`` provides a common interface for other modules to structure reading, conversion and output of mesh data. .. GENERATED FROM PYTHON SOURCE LINES 12-19 .. code-block:: default import matplotlib.pyplot as plt import numpy as np import pandas as pd from ogstools.propertylib import presets .. GENERATED FROM PYTHON SOURCE LINES 20-21 There are some predefined default properties: .. GENERATED FROM PYTHON SOURCE LINES 21-26 .. code-block:: default tab = pd.DataFrame(presets.all_properties).set_index("output_name") tab["type"] = [p.type_name for p in presets.all_properties] tab.drop(["func", "bilinear_cmap"], axis=1).sort_values(["mask", "data_name"]) .. raw:: html
data_name data_unit output_unit mask categoric type
output_name
MaterialIDs MaterialIDs True Scalar
NodalForces NodalForces displacement_active False Vector
displacement displacement m m displacement_active False Vector
strain epsilon percent displacement_active False Matrix
effective_pressure sigma Pa MPa displacement_active False Scalar
QP_ratio sigma Pa percent displacement_active False Scalar
stress sigma Pa MPa displacement_active False Matrix
von_Mises_stress sigma Pa MPa displacement_active False Scalar
MassFlowRate MassFlowRate pressure_active False Scalar
pore_pressure pressure Pa MPa pressure_active False Scalar
hydraulic_height pressure m m pressure_active False Scalar
darcy_velocity velocity m/s m/s pressure_active False Vector
HeatFlowRate HeatFlowRate temperature_active False Scalar
temperature temperature K °C temperature_active False Scalar


.. GENERATED FROM PYTHON SOURCE LINES 27-31 You can access properties either form the entire collection or from a subset which only contains properties available to a specific OGS process. Calling a property converts the argument from data_unit to output_unit and applies a function if specified. .. GENERATED FROM PYTHON SOURCE LINES 31-35 .. code-block:: default print(presets.temperature(273.15)) # access from the entire collection print(presets.strain(0.01)) # access from Mechanics collection .. rst-class:: sphx-glr-script-out .. code-block:: none 0 °C 1 % .. GENERATED FROM PYTHON SOURCE LINES 36-41 VectorProperties and MatrixProperties contain other Properties which represent the result of an applied function on itself. Components can be accessed with brackets. VectorProperties should be of length 2 or 3 corresponding to the dimension. MatrixProperties likewise should be of length 4 [xx, yy, zz, xy] or 6 [xx, yy, zz, xy, yz, xz]. .. GENERATED FROM PYTHON SOURCE LINES 43-44 Element 1 (counting from 0) of a 3D displacement vector: .. GENERATED FROM PYTHON SOURCE LINES 44-47 .. code-block:: default print(presets.displacement[1]([0.01, 0.02, 0.03])) .. rst-class:: sphx-glr-script-out .. code-block:: none 0.02 m .. GENERATED FROM PYTHON SOURCE LINES 48-49 Magnitude of a 2D displacement vector from: .. GENERATED FROM PYTHON SOURCE LINES 49-52 .. code-block:: default print(presets.displacement.magnitude([0.03, 0.04])) .. rst-class:: sphx-glr-script-out .. code-block:: none 0.05 m .. GENERATED FROM PYTHON SOURCE LINES 53-54 Log of Magnitude of a 2D velocity vector from the Hydraulics collection: .. GENERATED FROM PYTHON SOURCE LINES 54-56 .. code-block:: default print(presets.velocity.log_magnitude(np.sqrt([50, 50]))) .. rst-class:: sphx-glr-script-out .. code-block:: none 1 .. GENERATED FROM PYTHON SOURCE LINES 57-58 Magnitude and trace of a 3D strain matrix: .. GENERATED FROM PYTHON SOURCE LINES 58-62 .. code-block:: default eps = np.array([1, 3, 9, 1, 2, 2]) * 1e-2 print(presets.strain.magnitude(eps)) print(presets.strain.trace(eps)) .. rst-class:: sphx-glr-script-out .. code-block:: none 10 % 13 % .. GENERATED FROM PYTHON SOURCE LINES 63-66 You can change the attributes of the defaults. For example for temperature from the Thermal Collection from the default output_unit °C to °F: .. GENERATED FROM PYTHON SOURCE LINES 66-73 .. code-block:: default temp = np.linspace(273.15, 373.15, 10) fig, axs = plt.subplots(2) axs[0].plot(presets.temperature(temp), color="r") temperature_F = presets.temperature.replace(output_unit="°F") axs[1].plot(temperature_F(temp), color="b") fig.show() .. image-sg:: /auto_examples/howto_propertylib/images/sphx_glr_plot_propertylib_001.png :alt: plot propertylib :srcset: /auto_examples/howto_propertylib/images/sphx_glr_plot_propertylib_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /workspaces/tools/.venv-devcontainer/lib/python3.9/site-packages/matplotlib/cbook/__init__.py:1345: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray. return np.asarray(x, float) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.081 seconds) .. _sphx_glr_download_auto_examples_howto_propertylib_plot_propertylib.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_propertylib.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_propertylib.ipynb `