How to extract rotational displacements on a static analysis ?

Member, Moderator, Employee Posts: 873
100 Answers 500 Comments 250 Likes Second Anniversary
✭✭✭✭
edited June 2023 in Structures

How can I extract the rotational displacement values from the result file of a static structural analysis using PyDPF?

Tagged:

Answers

  • Member, Moderator, Employee Posts: 873
    100 Answers 500 Comments 250 Likes Second Anniversary
    ✭✭✭✭

    raw_displacement operator can be used for that purpose. Please note that the data contained in raw_displacement will depend on the types of elements used, the type of analysis, whether the model is 2D or 3D, etc.

    Below is an example:

    1. import ansys.dpf.core as dpf
    2. import numpy as np
    3.  
    4.  
    5. rstfile = r'D:/nodal_solution/file.rst'
    6. datfile = r'D:/nodal_solution/ds.dat'
    7.  
    8.  
    9. substep = 4
    10.  
    11.  
    12. # create the DataSource
    13. ds = dpf.DataSources()
    14. ds.set_result_file_path(rstfile, key="rst")
    15. ds.add_file_path(datfile, key="dat")
    16.  
    17.  
    18. # instantiate a Model
    19. model = dpf.Model(data_sources=ds)
    20. print(model)
    21.  
    22.  
    23. # define a time_scoping on substep 4
    24. time_scoping = dpf.time_freq_scoping_factory.scoping_by_step_and_substep_from_model(
    25.     load_step_id=1,
    26.     subset_id=substep,
    27.     model=model
    28. )
    29.  
    30.  
    31. # extract the raw displacements
    32. displacement_fc = dpf.operators.result.raw_displacement(
    33.     time_scoping=time_scoping,
    34.     data_sources=model,
    35. ).eval()
    36. print(displacement_fc)
    37.  
    38.  
    39. # extract the field from the fields_container
    40. disp_field = displacement_fc[0]
    41. print(disp_field)
    42.  
    43.  
    44. # one can access the field's underlying numpy.ndarray using ".data"
    45. print(disp_field.data)
    46.  
    47.  
    48. # save to csv
    49. np.savetxt(
    50.     'displacement2_pydpf-core.csv',
    51.     X=disp_field.data,
    52.     delimiter=',',  comments='', fmt='%.18e',
    53.     header="UX, UY, UZ, RX, RY, RZ"
    54. )
    55.  
    56.  
    57. # optional: extract the rotational dofs from the field
    58. rotational_disp = dpf.operators.logic.component_selector(
    59.     field=disp_field,
    60.     component_number=[3, 4, 5]
    61. ).eval()
    62. print(rotational_disp)
    63.  
    64.  

Welcome!

It looks like you're new here. Sign in or register to get started.