How to create elastic strain plot for each ply of a layered composite modeled by solids?

Options
Javier Vique
Javier Vique Member, Employee Posts: 76
First Answer First Anniversary Name Dropper 5 Likes

The idea is to automate the creation of elastic strains result in Mechanical on X or Y direction for all plies of a solid model, grouping these objects and then printing the maximum or minimum values.

Tagged:

Answers

  • Javier Vique
    Javier Vique Member, Employee Posts: 76
    First Answer First Anniversary Name Dropper 5 Likes
    Options

    Creating elastic strain object is straightforward in Mechanical. The main issue might be understanding how plies are selected when Sub Scope By is set as Ply. Please see the code below which identifies the plies (they've got 3D in their names') and then these are used in the scope of each result.

    import os
    
    Solution = ExtAPI.DataModel.Project.Model.Analyses[0].Solution
    AllPlies = ExtAPI.DataModel.GetObjectsByType(DataModelObjectCategory.AnalysisPly)
    
    def PostCreation(direction):
        MaximumResults = []
        MinimumResults = []
        for Ply in AllPlies:
            if '3D' in Ply.Name:
                StrainElastic = Solution.AddNormalElasticStrain()
                StrainElastic.Ply = [Ply]
                if direction == 'YY':
                    StrainElastic.NormalOrientation = NormalOrientationType.YAxis
                StrainElastic.By = SetDriverStyle.MaximumOverTime
                StrainElastic.DisplayOption = ResultAveragingType.ElementalMean
                StrainElastic.RenameBasedOnDefinition()
                MaximumResults.append(StrainElastic)
                StrainElasticMin = StrainElastic.Duplicate()
                StrainElasticMin.By = SetDriverStyle.MinimumOverTime
                StrainElasticMin.RenameBasedOnDefinition()
                MinimumResults.append(StrainElasticMin)
        name_max = '3D_Plies' + direction + '_MaxOverTime'
        name_min = '3D_Plies' + direction + '_MinOverTime'
        Solution.EvaluateAllResults()
        for i in MaximumResults:
            print('Result:%s Ply:%s Strain:%.5f' % (name_max,i.Name,i.Maximum.Value))
        for i in MinimumResults:
            print('Result:%s Ply:%s Strain:%.5f' % (name_max,i.Name,i.Minimum.Value))
        Result_Group = Tree.Group(MaximumResults)
        Result_Group.Name = name_max
        Result_Group = Tree.Group(MinimumResults)
        Result_Group.Name = name_min
        return
    
    PostCreation('XX')
    PostCreation('YY')