Results

Module contains the Results and Result class that are created by the Model to easily access results in result files.

class ansys.dpf.core.results.Results(model)

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

displacement

Result provider helper wrapping regular displacement operator. With this wrapper, time and mesh scopings can easily be customized

Examples

Create a displacement 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.msup_transient)
>>> disp = model.results.displacement.on_last_time_freq.on_named_selection('_CONSTRAINEDNODES')
>>> last_time_disp = disp.eval()
Type

Result

stress

Result provider helper wrapping regular stress operator. With this wrapper, time and mesh scopings, location.. can easily be customized

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.msup_transient)
>>> stress = model.results.stress.on_last_time_freq.on_named_selection('_CONSTRAINEDNODES')
>>> last_time_stress = stress.eval()
Type

Result

.... all other 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()
class ansys.dpf.core.results.Result(model, result_info)

An instance of this class helps using dpf’s result providers. It helps connecting common inputs to the operator and recovering its fields container output. ‘Result’ is created by the model.

Examples

Create a displacement 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.msup_transient)
>>> disp = model.results.displacement.on_last_time_freq.on_named_selection('_CONSTRAINEDNODES')
>>> last_time_disp = disp.eval()

Create a stress result from the model and split the result by element shapes: solid, shell, beam

>>> model = dpf.Model(examples.download_all_kinds_of_complexity())
>>> stress = model.results.stress
>>> stress_split = stress.split_by_shape.eval()
>>> solid_stress = stress_split.solid_field()

Create a strain result from the model on all time sets and recover the operator to connect it to other operators

>>> model = dpf.Model(examples.msup_transient)
>>> strain = model.results.elastic_strain.on_all_time_freqs()
>>> eqv = dpf.operators.invariant.von_mises_eqv_fc(strain)
>>> strain_eqv = eqv.outputs.fields_container()
eval()

Evaluate the result provider with the inputs specified before and returns its result fields container

Returns

fields_container – if split_by_body is used, a BodyFieldsContainer is returned. if split_by_shape is used, a ElShapeFieldsContainer is returned.

Return type

FieldsContainer, ElShapeFieldsContainer, BodyFieldsContainer

Examples

>>> from ansys.dpf import core as dpf
>>> from ansys.dpf.core import examples
>>> model = dpf.Model(examples.msup_transient)
>>> disp = model.results.displacement
>>> fc = disp.on_all_time_freqs.eval()
property on_all_time_freqs

Sets the time scoping to all the time frequencies available in the time freq support

Returns

self

Return type

Result

Examples

>>> from ansys.dpf import core as dpf
>>> from ansys.dpf.core import examples
>>> model = dpf.Model(examples.msup_transient)
>>> disp = model.results.displacement
>>> disp.on_all_time_freqs.eval().get_label_scoping("time").ids
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
property on_first_time_freq

Sets the time scoping to the first time frequency available in the time freq support

Returns

self

Return type

Result

Examples

>>> from ansys.dpf import core as dpf
>>> from ansys.dpf.core import examples
>>> model = dpf.Model(examples.msup_transient)
>>> disp = model.results.displacement
>>> disp.on_first_time_freq.eval().get_label_scoping("time").ids
[1]
property on_last_time_freq

Sets the time scoping to the last time frequency available in the time freq support

Returns

self

Return type

Result

Examples

>>> from ansys.dpf import core as dpf
>>> from ansys.dpf.core import examples
>>> model = dpf.Model(examples.msup_transient)
>>> disp = model.results.displacement
>>> disp.on_last_time_freq.eval().get_label_scoping("time").ids
[20]
on_time_scoping(time_scoping)

Sets the time scoping to the given one

Parameters

time_scoping (float, list[float], int, list[int], Scoping) – time/frequency(ies) or time set(s) are specified

Returns

self

Return type

Result

Examples

Choose time sets

>>> from ansys.dpf import core as dpf
>>> from ansys.dpf.core import examples
>>> model = dpf.Model(examples.msup_transient)
>>> stress = model.results.stress
>>> fc = stress.on_time_scoping([1,2,3,19]).eval()
>>> len(fc)
4

Choose times, if the times chosen are not in the time freq support, results will be extrapolated

>>> fc = stress.on_time_scoping([0.115,0.125]).eval()
>>> len(fc)
2
>>> fc.time_freq_support.time_frequencies.data
array([0.115, 0.125])
on_named_selection(named_selection)

Sets the mesh scoping to a given name selection’s name

Parameters

named_selection (str) – name of the named selection or component in upper case

Returns

self

Return type

Result

Examples

Add a requested location to average result on nodes

>>> from ansys.dpf import core as dpf
>>> from ansys.dpf.core import examples
>>> model = dpf.Model(examples.msup_transient)
>>> stress = model.results.stress
>>> fc = stress.on_first_time_freq.on_named_selection('_CONSTRAINEDNODES').eval()
>>> len(fc[0].scoping)
40
property split_by_body

Set the mesh scoping to a scopings container where each scoping is a body

Returns

self

Return type

Result

Examples

>>> from ansys.dpf import core as dpf
>>> from ansys.dpf.core import examples
>>> model = dpf.Model(examples.download_all_kinds_of_complexity())
>>> disp = model.results.displacement
>>> fc_disp = disp.split_by_body.eval()
>>> len(fc_disp)
11
>>> fc_disp.get_mat_scoping().ids
[1, 5, 6, 10, 2, 7, 8, 13, 4, 12, 15]
>>> disp_mat_10 = fc_disp.get_field_by_mat_id(10)
property split_by_shape

Set the mesh scoping to a scopings container where each scoping is a specific element shape. The evaluated fields container will have on field on ‘solid’, one on ‘shell’, one on ‘beam’ and one on ‘unknown_shape’

Returns

self

Return type

Result

Examples

>>> from ansys.dpf import core as dpf
>>> from ansys.dpf.core import examples
>>> model = dpf.Model(examples.download_all_kinds_of_complexity())
>>> disp = model.results.displacement
>>> fc_disp = disp.split_by_shape.eval()
>>> len(fc_disp)
4
>>> shell_disp = fc_disp.shell_field()
>>> solid_disp = fc_disp.solid_field()
on_mesh_scoping(mesh_scoping)

Set the mesh scoping to the given mesh_scoping

Parameters

mesh_scoping (Scoping, list[int]) –

Returns

self

Return type

Result

Examples

Use a list of nodes

>>> from ansys.dpf import core as dpf
>>> from ansys.dpf.core import examples
>>> model = dpf.Model(examples.complex_rst)
>>> disp = model.results.displacement
>>> fc = disp.on_mesh_scoping([1,2,3]).eval()
>>> len(fc[0].scoping)
3

Use a Scoping to specify a list of entity ids with their location

>>> stress = model.results.stress
>>> scop = dpf.Scoping(ids=[3,4,5], location= dpf.locations.nodal)
>>> fc = stress.on_mesh_scoping(scop).eval()
>>> len(fc[0].scoping)
3
>>> fc[0].location
'Nodal'
on_location(location)

Set the requested location of the provider: elemental nodal fields can be averaged to nodal or elemental location

Parameters

location (str, locations) –

Returns

self

Return type

Result

Examples

Add a requested location to average result on nodes

>>> from ansys.dpf import core as dpf
>>> from ansys.dpf.core import examples
>>> model = dpf.Model(examples.complex_rst)
>>> stress = model.results.stress
>>> fc = stress.eval()
>>> fc[0].location
'ElementalNodal'
>>> fc = stress.on_location(dpf.locations.nodal).eval()
>>> fc[0].location
'Nodal'