DPF model#
The DPF model provides the starting point for opening a result file.
From the Model
object, you can connect various operators and display results
and data.
To create an instance of the Model
object, import the pydpf-core
package and
load a result file. The path that you provide must be an absolute path
or a path relative to the DPF server.
from ansys.dpf import core as dpf
from ansys.dpf.core import examples
path = examples.find_simple_bar()
model = dpf.Model(path)
To understand what is available in the result file, you can print the model (or any other instance):
print(model)
DPF Model
------------------------------
Static analysis
Unit system: Metric (m, kg, N, s, V, A)
Physics Type: Mechanical
Available results:
- displacement: Nodal Displacement
- element_nodal_forces: ElementalNodal Element nodal Forces
- elemental_volume: Elemental Volume
- stiffness_matrix_energy: Elemental Energy-stiffness matrix
- artificial_hourglass_energy: Elemental Hourglass Energy
- thermal_dissipation_energy: Elemental thermal dissipation energy
- kinetic_energy: Elemental Kinetic Energy
- co_energy: Elemental co-energy
- incremental_energy: Elemental incremental energy
- structural_temperature: ElementalNodal Temperature
------------------------------
DPF Meshed Region:
3751 nodes
3000 elements
Unit: m
With solid (3D) elements
------------------------------
DPF Time/Freq Support:
Number of sets: 1
Cumulative Time (s) LoadStep Substep
1 1.000000 1 1
For a comprehensive model example, see Basic DPF-Core usage.
For a description of the Model
object, see Model.
Model metadata#
To access all information about an analysis, you can use model metadata:
Type of analysis
Time or frequency descriptions
Mesh
Available results
This example shows how you get the analysis type:
model.metadata.result_info.analysis_type
'static'
This example shows how you get mesh information:
model.metadata.meshed_region.nodes.n_nodes
model.metadata.meshed_region.elements.n_elements
print(model.metadata.meshed_region.elements.element_by_id(1))
3751
3000
DPF Element 1
Index: 1400
Nodes: 8
Type: element_types.Hex8
Shape: Solid
This example shows how you get time sets:
time_freq_support = model.metadata.time_freq_support
print(time_freq_support.time_frequencies.data)
[1.]
For a description of the Metadata
object, see Model.
Model results#
The model contains the results
attribute, which you can use to
create operators to access certain results.
This example shows how you view available results:
print(model.results)
Static analysis
Unit system: Metric (m, kg, N, s, V, A)
Physics Type: Mechanical
Available results:
- displacement: Nodal Displacement
- element_nodal_forces: ElementalNodal Element nodal Forces
- elemental_volume: Elemental Volume
- stiffness_matrix_energy: Elemental Energy-stiffness matrix
- artificial_hourglass_energy: Elemental Hourglass Energy
- thermal_dissipation_energy: Elemental thermal dissipation energy
- kinetic_energy: Elemental Kinetic Energy
- co_energy: Elemental co-energy
- incremental_energy: Elemental incremental energy
- structural_temperature: ElementalNodal Temperature
- Model.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.
- Return type:
- all types of results
Result provider helper wrapping all types of provider available for a given result file.
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
- Type:
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()
With the results
attribute, choosing the time, frequencies, or spatial subset
on which to get a given result is straightforward.
This example shows how you get displacement results on all time frequencies on the mesh scoping:
disp_result = model.results.displacement
disp_at_all_times_on_node_1 = disp_result.on_all_time_freqs.on_mesh_scoping([1])
For an example using the Result
object, see Choose a time scoping for a transient analysis.
For a description of the Model
object, see Results.