The DPF Model

The DPF model is the basic starting point for opening a file through DPF. From here you can connect various operators and display results and data from the result file.

To create a Model instance, import dpf and load a file. The path provided 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.simple_bar
model = dpf.Model(path)

Printing the model (or any other instance) ca be useful to understand what is available in the result file

print(model)

Out:

DPF Model
------------------------------
DPF Result Info
  Analysis: static
  Physics Type: mecanic
  Unit system: MKS: m, kg, N, s, V, A, degC
  Available results:
    U Displacement :nodal displacements
    ENF Element nodal Forces :element nodal forces
    ENG_VOL Volume :element volume
    ENG_SE Energy-stiffness matrix :element energy associated with the stiffness matrix
    ENG_AHO Hourglass Energy :artificial hourglass energy
    ENG_TH thermal dissipation energy :thermal dissipation energy
    ENG_KE Kinetic Energy :kinetic energy
    ENG_CO co-energy :co-energy (magnetics)
    ENG_INC incremental energy :incremental energy (magnetics)
    BFE Temperature :element structural nodal temperatures
------------------------------
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 full example using the model, see Basic DPF-Core Usage.

For a full description of the Model object, see the APIs section Model.

Model Metadata

The metadata of the model can be used to access all the information about an analysis:

  • the type of analysis

  • the time or frequencies description

  • the mesh

  • the available results

For example, you can get the analysis type with:

model.metadata.result_info.analysis_type

Out:

'static'

You can get information about the mesh:

>>> model.metadata.meshed_region.nodes.n_nodes
>>> model.metadata.meshed_region.elements.n_elements
>>> print(model.metadata.meshed_region.elements.element_by_id(1))

Out:

3751
3000
DPF Element 1
    Index:         1400
    Nodes:            8
    Type:       element_types.Hex8
    Shape:        Solid

You can the time sets with:

time_freq_support =  model.metadata.time_freq_support
print(time_freq_support.time_frequencies.data)

Out:

[1.]

For a full description of the Metadata object, see the APIs section Model.

Model Results

The model contains the results attribute, which you can use to create operators to access certain results. To view the available results, print them with:

print(model.results)

Out:


DPF Result Info

Analysis: static Physics Type: mecanic Unit system: MKS: m, kg, N, s, V, A, degC Available results:

U Displacement :nodal displacements ENF Element nodal Forces :element nodal forces ENG_VOL Volume :element volume ENG_SE Energy-stiffness matrix :element energy associated with the stiffness matrix ENG_AHO Hourglass Energy :artificial hourglass energy ENG_TH thermal dissipation energy :thermal dissipation energy ENG_KE Kinetic Energy :kinetic energy ENG_CO co-energy :co-energy (magnetics) ENG_INC incremental energy :incremental energy (magnetics) BFE Temperature :element structural nodal temperatures

Model.results

Available results of the model. Organize the results from DPF into accessible methods. All the available results are dynamically created depending on the model’s ‘ResultInfo’

Returns

Available results of the model

Return type

Results

all types of results

Result provider helper wrapping all types of provider available for a given result file

Examples

Create a stress result from the model and choose its time and mesh scopings

>>> from ansys.dpf import core as dpf
>>> from ansys.dpf.core import examples
>>> model = dpf.Model(examples.electric_therm)
>>> v = model.results.electric_potential
>>> rf = model.results.reaction_force
>>> dissip = model.results.thermal_dissipation_energy
Type

Result

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.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()

Choosing the time or frequencies or the spatial subset on which to get a given result is straightforward with this results attribute:

disp_result = model.results.displacement
disp_at_all_times_on_node_1 =  disp_result.on_all_time_freqs.on_mesh_scoping([1])

For a full example using the Result API, see Go Easily over Times Transient Analysis.

For a full description of the Model object, see the APIs section Results.

API Reference

See Model or Results for more information.