ansys / pydpf-core

Data Processing Framework - Python Core
http://dpf.docs.pyansys.com/
MIT License
67 stars 23 forks source link

Workbench Created Named Selections not Available for Scoping? #152

Closed ssteller closed 2 years ago

ssteller commented 2 years ago

Hello,

I am post-processing simulations that have loading applied through a remote point, and workbench creates a group when it creates the MAPDL. I'd like to scope results to that selection, but they are not available as Named Selections (in model.metadata.named_selection). I am missing something? Can those be made available in the future?

Thank you for the help and the package!

dpfbuild commented 2 years ago

Hi @ssteller , Do you see your named selections if you type :

model.metadata.meshed_region.available_named_selections

Thanks Ramdane

ssteller commented 2 years ago

@dpfbuild Thanks for the quick reply. I do not see the one I am looking for. I do see a named selection that matches another boundary condition, but not the named selection for the pilot node that Workbench creates for a remote displacement BC. This could be a workbench/APDL issue not creating the named selection, or hiding it somehow. It is a pilot node, so auto created and may be internal only.

The file below (extension change from .dat to .txt for GitHub) is an example. I want the _npilot93 selection to measure reaction forces from applied BCs. I'm open to other ways as well if there is something better.

ds.txt

ansjkosloski commented 2 years ago

I don't think Mechanical creates Named Selections for a remote point. The option for "Pilot Node MAPDL Name" creates a parameter, not a Named Selection. If you need a Named Selection, you can add a command block under the remote point and add: NSEL,S,NODE,,apdl_name CM,ns_name,NODE

rlagha commented 2 years ago

Thanks @jkoslosk for the this.

@ssteller once you have the named selection you can create the scoping on it. Meanwhile you can use the node id to create a scoping and request results on it:

scoping = dpf.Scoping(ids=[12886],location = "Nodal")
rf = model.results.reaction_force.on_all_time_freqs()
rf.inputs.mesh_scoping.connect(scoping)
fields = rf.eval()
transpose = dpf.Operator("transpose_fields_container") # to get one field from the fields container
transpose.connect(0,fields)
fieldsout = transpose.get_output(0, dpf.common.types.fields_container)
print(fieldsout)
field = fieldsout[0]
field.data #this will contain the reaction forces on all time steps for the selected node
norm = dpf.operators.math.norm(field = field)
nrm_field = norm.eval()
nrm_field.data # component-wise norm of the reaction force field

After that you can use pyplot to plot it as curve:

import matplotlib.pyplot as plt
tdata = model.metadata.time_freq_support.time_frequencies.data
plt.plot(tdata, nrm_field.data, "r", label="reaction force")
plt.xlabel("Time (s)")
plt.ylabel("reaction force ")
plt.legend()
plt.show()

Thanks Ramdane

ssteller commented 2 years ago

@jkoslosk Thank you, you are correct. I missed that detail.

@rlagha Thank you as well, very helpful.

itanfeng commented 1 year ago

I am post-processing simulations that have loading applied through a remote point, and workbench crea

model.metadata.meshed_region.available_named_selections

why it just prints nothing but a blank list []

I actually created several named selections in workbench.

Really need some help!

Thanks a lot!