:class:`Model` ============== .. py:class:: ansys.dpf.core.model.Model(data_sources=None, server=None) Connects to a gRPC DPF server and allows access to a result using the DPF framework. :param data_sources: Accepts either a :class:`dpf.core.DataSources` instance or the path of the result file to open as an os.PathLike object or a str. The default is ``None``. :type data_sources: str, dpf.core.DataSources, os.PathLike :param server: Server with the channel connected to the remote or local instance. The default is ``None``, in which case an attempt is made to use the global server. :type server: server.DPFServer, optional .. rubric:: Examples >>> from ansys.dpf import core as dpf >>> from ansys.dpf.core import examples >>> transient = examples.download_transient_result() >>> model = dpf.Model(transient) .. py:currentmodule:: Model Overview -------- .. tab-set:: .. tab-item:: Methods .. list-table:: :header-rows: 0 :widths: auto * - :py:attr:`~operator` - Operator associated with the data sources of this model. * - :py:attr:`~plot` - Plot the mesh of the model. .. tab-item:: Properties .. list-table:: :header-rows: 0 :widths: auto * - :py:attr:`~metadata` - Model metadata. * - :py:attr:`~results` - Available results of the model. * - :py:attr:`~mesh_by_default` - If true, the mesh is connected by default to operators supporting the mesh input. .. tab-item:: Special methods .. list-table:: :header-rows: 0 :widths: auto * - :py:attr:`~__str__` - Return string representation of the model. Import detail ------------- .. code-block:: python from ansys.dpf.core.model import Model Property detail --------------- .. py:property:: metadata Model metadata. Includes: - ``data_sources`` - ``meshed_region`` - ``time_freq_support`` - ``result_info`` - ``mesh_provider`` - ``mesh_info`` :returns: **metadata** :rtype: Metadata .. rubric:: Examples >>> from ansys.dpf.core import Model >>> from ansys.dpf.core import examples >>> transient = examples.download_transient_result() >>> model = Model(transient) Get the meshed region of the model and extract the element numbers. >>> meshed_region = model.metadata.meshed_region >>> meshed_region.elements.scoping.ids[2] np.int32(759) Get the data sources of the model. >>> ds = model.metadata.data_sources Print the number of result sets. >>> tf = model.metadata.time_freq_support >>> tf.n_sets 35 Get the unit system used in the analysis. >>> rinfo = model.metadata.result_info >>> rinfo.unit_system 'MKS: m, kg, N, s, V, A, degC' .. py:property:: results Available results of the model. Organizes the results from DPF into accessible methods. All the available results are dynamically created depending on the model's class:`ansys.dpf.core.result_info`. :returns: **results** -- Available results of the model if possible, else returns common results. :rtype: Results, CommonResults .. attribute:: all types of results Result provider helper wrapping all types of provider available for a given result file. :type: Result .. rubric:: Examples >>> from ansys.dpf import core as dpf >>> from ansys.dpf.core import examples >>> model = dpf.Model(examples.find_electric_therm()) >>> v = model.results.electric_potential >>> dissip = model.results.thermal_dissipation_energy .. rubric:: Examples Extract the result object from a model. >>> from ansys.dpf import core as dpf >>> from ansys.dpf.core import examples >>> model = dpf.Model(examples.find_simple_bar()) >>> results = model.results # printable object Access the displacement at all times. >>> from ansys.dpf.core import Model >>> from ansys.dpf.core import examples >>> transient = examples.download_transient_result() >>> model = Model(transient) >>> displacements = model.results.displacement.on_all_time_freqs.eval() .. py:property:: mesh_by_default If true, the mesh is connected by default to operators supporting the mesh input. Method detail ------------- .. py:method:: operator(name) Operator associated with the data sources of this model. :param name: Operator name, which must be valid. :type name: str .. rubric:: Examples Create a displacement operator. >>> from ansys.dpf.core import Model >>> from ansys.dpf.core import examples >>> transient = examples.download_transient_result() >>> model = Model(transient) >>> disp = model.operator('U') Create a sum operator. >>> sum = model.operator('accumulate') .. py:method:: __str__() Return string representation of the model. .. py:method:: plot(color='w', show_edges=True, **kwargs) Plot the mesh of the model. :param color: color of the mesh faces in PyVista format. The default is white with ``"w"``. :type color: str :param show_edges: Whether to show the mesh edges. The default is ``True``. :type show_edges: bool :param \*\*kwargs: Additional keyword arguments for the plotter. For additional keyword arguments, see ``help(pyvista.plot)``. :type \*\*kwargs: optional .. rubric:: Examples Plot the model using the default options. >>> from ansys.dpf.core import Model >>> from ansys.dpf.core import examples >>> transient = examples.download_transient_result() >>> model = Model(transient) >>> model.plot()