How to extract force reactions using DPF inside mechanical ?

Options
Vishnu
Vishnu Member, Employee Posts: 214
Name Dropper First Anniversary Solution Developer Community of Practice Member First Comment
edited June 2023 in Structures
Tagged:

Comments

  • Vishnu
    Vishnu Member, Employee Posts: 214
    Name Dropper First Anniversary Solution Developer Community of Practice Member First Comment
    edited May 2023
    Options

    Below is a simple code to extract the Y Reaction using DPF inside mechanical


    import mech_dpf
    import Ans.DataProcessing as dpf
    
    #Result Data
    analysis1 = ExtAPI.DataModel.Project.Model.Analyses[0]
    dataSource = dpf.DataSources(analysis1.Solution.ResultFilePath)
    
    #model
    my_model = dpf.Model(analysis1.Solution.ResultFilePath)
    
    #my mesh
    my_mesh = my_model.Mesh
    
    #Time list
    timelist = dpf.operators.metadata.time_freq_provider(data_sources=dataSource).outputs.gettime_freq_support().TimeFreqs.Data
    
    reaction = dpf.operators.result.reaction_force(time_scoping=timelist,data_sources=dataSource)
    Y_reaction = dpf.operators.logic.component_selector_fc(fields_container=reaction,component_number=1).outputs.fields_container.GetData()[0]
    
    print(sum(Y_reaction.Data))
    
    #Release Locked RST
    my_model.ReleaseStreams()
    
  • prasadmsonar_123
    prasadmsonar_123 Member Posts: 2
    Name Dropper First Comment
    Options

    Hello Vishnu,
    Thanks for this.
    Can we extract the results for total deformation at particular location for all the steps in the analysis and export it as csv??

  • Vishnu
    Vishnu Member, Employee Posts: 214
    Name Dropper First Anniversary Solution Developer Community of Practice Member First Comment
    Options

    @prasadmsonar_123
    You can

    Look at below code the dispfield_container is a field container which is a list of multiple fields (field for each time point)

    and the fields in turn contains the data of displacement(x,y,z) for each node

    now all you need to do is push the data to a CSV file:

    import mech_dpf,csv
    import Ans.DataProcessing as dpf
    
    #Result Data
    analysis1 = ExtAPI.DataModel.Project.Model.Analyses[0]
    dataSource = dpf.DataSources(analysis1.Solution.ResultFilePath)
    
    #model
    my_model = dpf.Model(analysis1.Solution.ResultFilePath)
    
    #my mesh
    my_mesh = my_model.Mesh
    
    
    #Time list
    timelist = dpf.operators.metadata.time_freq_provider(data_sources=dataSource).outputs.gettime_freq_support().TimeFreqs.Data
    
    
    dispfield_container = dpf.operators.result.displacement(time_scoping=timelist,data_sources=dataSource).outputs.fields_container