Kratos icon indicating copy to clipboard operation
Kratos copied to clipboard

Fix cauchy stress calculation

Open RiccardoRossi opened this issue 4 years ago • 9 comments

Description Fixes the calculation of cauchy stresses for the base isotropic CL, and adds some todos which are errors we should look into

Please mark the PR with appropriate tags:

  • Api Breaker, Mpi, etc...

Changelog does a push forward to compute the cauchy stresses

RiccardoRossi avatar Nov 27 '20 09:11 RiccardoRossi

@RiccardoRossi the windows CI fails, can you check?

loumalouomega avatar Nov 27 '20 09:11 loumalouomega

Depends in #7887 BTW

loumalouomega avatar Nov 27 '20 09:11 loumalouomega

mmm it looks like some tests are failing. This is worrysome since the current implementation is ... wrong. A quickfix would be to do the push forward in the BaseSolidElement output function, but the errors that are appearing seem to indicate the function is actually used in the equilibrium computation. Note that prior to this PR the CauchyStress was defaulting to coincide with the PK2 stress, which is definitel not correct

i will remove the "FastPR" tag

@AlejandroCornejo @loumalouomega i think you need to take a deepeer look into this.

======================================================================                                                                                                      FAIL: test_execution (structural_mechanics_test_factory.SerialParallelRuleOfMixturesCubeDamageTest)                                                                         ----------------------------------------------------------------------                                                                                                      Traceback (most recent call last):                                                                                                                                            File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/structural_mechanics_test_factory.py", line 72, in test_execution               self.test.RunSolutionLoop()                                                                                                                                               File "/mnt/c/Users/rross/Programming/Kratos/bin/FullDebug/KratosMultiphysics/analysis_stage.py", line 69, in RunSolutionLoop                                                  self.FinalizeSolutionStep()                                                                                                                                               File "/mnt/c/Users/rross/Programming/Kratos/bin/FullDebug/KratosMultiphysics/analysis_stage.py", line 151, in FinalizeSolutionStep                                            process.ExecuteFinalizeSolutionStep()                                                                                                                                     File "/mnt/c/Users/rross/Programming/Kratos/bin/FullDebug/KratosMultiphysics/from_json_check_result_process.py", line 55, in ExecuteFinalizeSolutionStep                      self.assertTrue(self.process.IsCorrectResult(), "Results do not coincide with the JSON reference\n" + self.process.GetErrorMessage())                                   AssertionError: False is not true : Results do not coincide with the JSON reference                                                                                         Error checking for variable DAMAGE in GP 1, results:                                                                                                                        Element 1 0.1629115!=0.164142; rel_tol=1e-06, abs_tol=0.001                                                                                                                 Error checking for variable DAMAGE in GP 2, results:                                                                                                                        Element 1 0.165363!=0.164142; rel_tol=1e-06, abs_tol=0.001                                                                                                                  Error checking for variable DAMAGE in GP 5, results:                                                                                                                        Element 1 0.1629115!=0.164142; rel_tol=1e-06, abs_tol=0.001                                                                                                                 Error checking for variable DAMAGE in GP 6, results:                                                                                                                        Element 1 0.165363!=0.164142; rel_tol=1e-06, abs_tol=0.001                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ======================================================================                                                                                                      FAIL: test_execution (structural_mechanics_test_factory.AnisotropyTest)                                                                                                     ----------------------------------------------------------------------                                                                                                      Traceback (most recent call last):                                                                                                                                            File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/structural_mechanics_test_factory.py", line 72, in test_execution               self.test.RunSolutionLoop()                                                                                                                                               File "/mnt/c/Users/rross/Programming/Kratos/bin/FullDebug/KratosMultiphysics/analysis_stage.py", line 69, in RunSolutionLoop                                                  self.FinalizeSolutionStep()                                                                                                                                               File "/mnt/c/Users/rross/Programming/Kratos/bin/FullDebug/KratosMultiphysics/analysis_stage.py", line 151, in FinalizeSolutionStep                                            process.ExecuteFinalizeSolutionStep()                                                                                                                                     File "/mnt/c/Users/rross/Programming/Kratos/bin/FullDebug/KratosMultiphysics/from_json_check_result_process.py", line 55, in ExecuteFinalizeSolutionStep                      self.assertTrue(self.process.IsCorrectResult(), "Results do not coincide with the JSON reference\n" + self.process.GetErrorMessage())                                   AssertionError: False is not true : Results do not coincide with the JSON reference                                                                                         Error checking for variable DAMAGE in GP 1, results:                                                                                                                        Element 1 0.1629115!=0.164142; rel_tol=1e-06, abs_tol=0.001                                                                                                                 Error checking for variable DAMAGE in GP 2, results:                                                                                                                        Element 1 0.165363!=0.164142; rel_tol=1e-06, abs_tol=0.001                                                                                                                  Error checking for variable DAMAGE in GP 5, results:                                                                                                                        Element 1 0.1629115!=0.164142; rel_tol=1e-06, abs_tol=0.001                                                                                                                 Error checking for variable DAMAGE in GP 6, results:                                                                                                                        Element 1 0.165363!=0.164142; rel_tol=1e-06, abs_tol=0.001                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ======================================================================                                                                                                      FAIL: test_Shear_Linear_Elastic_3D (test_constitutive_law.TestConstitutiveLaw)                                                                                              ----------------------------------------------------------------------                                                                                                      Traceback (most recent call last):                                                                                                                                            File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_constitutive_law.py", line 235, in test_Shear_Linear_Elastic_3D            self._generic_constitutive_law_test(model_part, deformation_test)                                                                                                         File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_constitutive_law.py", line 178, in _generic_constitutive_law_test          self.assertAlmostEqual((reference_stress[j] - stress[j])/stress[j], 0.0, msg=("Error checking solution " + str(stress[j]) + " different from " + str(reference_stress[j]) + " with tolerance of " + str(tolerance)), delta=tolerance)                                                                                                               AssertionError: -0.7340425531914894 != 0.0 within 0.0001 delta (0.7340425531914894 difference) : Error checking solution 8676923076.92308 different from 2307692307.692308 with tolerance of 0.0001                                                                                                                                                                                                                                                                                                                                 ======================================================================                                                                                                      FAIL: test_Shear_Linear_Elastic_Plane_Stress_2D (test_constitutive_law.TestConstitutiveLaw)                                                                                 ----------------------------------------------------------------------                                                                                                      Traceback (most recent call last):                                                                                                                                            File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_constitutive_law.py", line 256, in test_Shear_Linear_Elastic_Plane_Stress_2D                                                                                                                                                                           self._generic_constitutive_law_test(model_part, deformation_test)                                                                                                         File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_constitutive_law.py", line 178, in _generic_constitutive_law_test          self.assertAlmostEqual((reference_stress[j] - stress[j])/stress[j], 0.0, msg=("Error checking solution " + str(stress[j]) + " different from " + str(reference_stress[j]) + " with tolerance of " + str(tolerance)), delta=tolerance)                                                                                                               AssertionError: -0.8275862068965517 != 0.0 within 0.0001 delta (0.8275862068965517 difference) : Error checking solution 7648351648.35165 different from 1318681318.681319 with tolerance of 0.0001                                                                                                                                                                                                                                                                                                                                 ======================================================================                                                                                                      FAIL: test_Shear_Linear_Elastic_Plane_Stress_Uncoupled_Shear_2D (test_constitutive_law.TestConstitutiveLaw)                                                                 ----------------------------------------------------------------------                                                                                                      Traceback (most recent call last):                                                                                                                                            File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_constitutive_law.py", line 270, in test_Shear_Linear_Elastic_Plane_Stress_Uncoupled_Shear_2D                                                                                                                                                           self._generic_constitutive_law_test(model_part, deformation_test)                                                                                                         File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_constitutive_law.py", line 178, in _generic_constitutive_law_test          self.assertAlmostEqual((reference_stress[j] - stress[j])/stress[j], 0.0, msg=("Error checking solution " + str(stress[j]) + " different from " + str(reference_stress[j]) + " with tolerance of " + str(tolerance)), delta=tolerance)                                                                                                               AssertionError: -0.1176502856906217 != 0.0 within 0.0001 delta (0.1176502856906217 difference) : Error checking solution 1494510960.105496 different from 1318681318.681319 with tolerance of 0.0001                                                                                                                                                                                                                                                                                                                                ======================================================================                                                                                                      FAIL: test_Shear_Plus_Strech_Linear_Elastic_3D (test_constitutive_law.TestConstitutiveLaw)                                                                                  ----------------------------------------------------------------------                                                                                                      Traceback (most recent call last):                                                                                                                                            File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_constitutive_law.py", line 242, in test_Shear_Plus_Strech_Linear_Elastic_3D                                                                                                                                                                            self._generic_constitutive_law_test(model_part, deformation_test)                                                                                                         File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_constitutive_law.py", line 178, in _generic_constitutive_law_test          self.assertAlmostEqual((reference_stress[j] - stress[j])/stress[j], 0.0, msg=("Error checking solution " + str(stress[j]) + " different from " + str(reference_stress[j]) + " with tolerance of " + str(tolerance)), delta=tolerance)                                                                                                               AssertionError: -0.7857142857142858 != 0.0 within 0.0001 delta (0.7857142857142858 difference) : Error checking solution 538461538461.53845 different from 115384615384.61537 with tolerance of 0.0001                                                                                                                                                                                                                                                                                                                              ======================================================================                                                                                                      FAIL: test_Uniaxial_Linear_Elastic_3D (test_constitutive_law.TestConstitutiveLaw)                                                                                           ----------------------------------------------------------------------                                                                                                      Traceback (most recent call last):                                                                                                                                            File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_constitutive_law.py", line 228, in test_Uniaxial_Linear_Elastic_3D         self._generic_constitutive_law_test(model_part, deformation_test)                                                                                                         File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_constitutive_law.py", line 178, in _generic_constitutive_law_test          self.assertAlmostEqual((reference_stress[j] - stress[j])/stress[j], 0.0, msg=("Error checking solution " + str(stress[j]) + " different from " + str(reference_stress[j]) + " with tolerance of " + str(tolerance)), delta=tolerance)                                                                                                               AssertionError: -0.1666666666666667 != 0.0 within 0.0001 delta (0.1666666666666667 difference) : Error checking solution 71076923076.92307 different from 59230769230.76922 with tolerance of 0.0001                                                                                                                                                                                                                                                                                                                                ======================================================================                                                                                                      FAIL: test_Uniaxial_Linear_Elastic_Plane_Stress_2D (test_constitutive_law.TestConstitutiveLaw)                                                                              ----------------------------------------------------------------------                                                                                                      Traceback (most recent call last):                                                                                                                                            File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_constitutive_law.py", line 249, in test_Uniaxial_Linear_Elastic_Plane_Stress_2D                                                                                                                                                                        self._generic_constitutive_law_test(model_part, deformation_test)                                                                                                         File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_constitutive_law.py", line 178, in _generic_constitutive_law_test          self.assertAlmostEqual((reference_stress[j] - stress[j])/stress[j], 0.0, msg=("Error checking solution " + str(stress[j]) + " different from " + str(reference_stress[j]) + " with tolerance of " + str(tolerance)), delta=tolerance)                                                                                                               AssertionError: -0.16666666666666663 != 0.0 within 0.0001 delta (0.16666666666666663 difference) : Error checking solution 58021978021.97801 different from 48351648351.648346 with tolerance of 0.0001                                                                                                                                                                                                                                                                                                                             ======================================================================                                                                                                      FAIL: test_Uniaxial_Linear_Elastic_Plane_Stress_Uncoupled_Shear_2D (test_constitutive_law.TestConstitutiveLaw)                                                              ----------------------------------------------------------------------                                                                                                      Traceback (most recent call last):                                                                                                                                            File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_constitutive_law.py", line 263, in test_Uniaxial_Linear_Elastic_Plane_Stress_Uncoupled_Shear_2D                                                                                                                                                        self._generic_constitutive_law_test(model_part, deformation_test)                                                                                                         File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_constitutive_law.py", line 178, in _generic_constitutive_law_test          self.assertAlmostEqual((reference_stress[j] - stress[j])/stress[j], 0.0, msg=("Error checking solution " + str(stress[j]) + " different from " + str(reference_stress[j]) + " with tolerance of " + str(tolerance)), delta=tolerance)                                                                                                               AssertionError: -0.16666666666666663 != 0.0 within 0.0001 delta (0.16666666666666663 difference) : Error checking solution 58021978021.97801 different from 48351648351.648346 with tolerance of 0.0001                                                                                                                                                                                                                                                                                                                             ======================================================================                                                                                                      FAIL: test_UL_2D_quadrilateral_block (test_patch_test_large_strain.TestPatchTestLargeStrain)                                                                                ----------------------------------------------------------------------                                                                                                      Traceback (most recent call last):                                                                                                                                            File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_patch_test_large_strain.py", line 823, in test_UL_2D_quadrilateral_block                                                                                                                                                                               self._UL_2D_quadrilateral(builder_type, linearize_on_old_iteration, 11 )                                                                                                  File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_patch_test_large_strain.py", line 818, in _UL_2D_quadrilateral             self.assertEqual(mp.ProcessInfo[KratosMultiphysics.NL_ITERATION_NUMBER], expected_iterations)                                                                           AssertionError: 19 != 11                                                                                                                                                                                                                                                                                                                                ======================================================================                                                                                                      FAIL: test_UL_2D_quadrilateral_elimination (test_patch_test_large_strain.TestPatchTestLargeStrain)                                                                          ----------------------------------------------------------------------                                                                                                      Traceback (most recent call last):                                                                                                                                            File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_patch_test_large_strain.py", line 833, in test_UL_2D_quadrilateral_elimination                                                                                                                                                                         self._UL_2D_quadrilateral(builder_type, linearize_on_old_iteration,11 )                                                                                                   File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_patch_test_large_strain.py", line 818, in _UL_2D_quadrilateral             self.assertEqual(mp.ProcessInfo[KratosMultiphysics.NL_ITERATION_NUMBER], expected_iterations)                                                                           AssertionError: 19 != 11                                                                                                                                                                                                                                                                                                                                ======================================================================                                                                                                      FAIL: test_UL_2D_triangle_block (test_patch_test_large_strain.TestPatchTestLargeStrain)                                                                                     ----------------------------------------------------------------------                                                                                                      Traceback (most recent call last):                                                                                                                                            File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_patch_test_large_strain.py", line 764, in test_UL_2D_triangle_block        self._UL_2D_triangle(builder_type, linearize_on_old_iteration,13 )                                                                                                        File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_patch_test_large_strain.py", line 758, in _UL_2D_triangle                  self.assertEqual(mp.ProcessInfo[KratosMultiphysics.NL_ITERATION_NUMBER], expected_iterations)                                                                           AssertionError: 20 != 13                                                                                                                                                                                                                                                                                                                                ======================================================================                                                                                                      FAIL: test_UL_2D_triangle_elimination (test_patch_test_large_strain.TestPatchTestLargeStrain)                                                                               ----------------------------------------------------------------------                                                                                                      Traceback (most recent call last):                                                                                                                                            File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_patch_test_large_strain.py", line 774, in test_UL_2D_triangle_elimination                                                                                                                                                                              self._UL_2D_triangle(builder_type, linearize_on_old_iteration,13 )                                                                                                        File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_patch_test_large_strain.py", line 758, in _UL_2D_triangle                  self.assertEqual(mp.ProcessInfo[KratosMultiphysics.NL_ITERATION_NUMBER], expected_iterations)                                                                           AssertionError: 20 != 13                                                                                                                                                                                                                                                                                                                                ======================================================================                                                                                                      FAIL: test_UL_3D_hexa_block (test_patch_test_large_strain.TestPatchTestLargeStrain)                                                                                         ----------------------------------------------------------------------                                                                                                      Traceback (most recent call last):                                                                                                                                            File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_patch_test_large_strain.py", line 894, in test_UL_3D_hexa_block            self._UL_3D_hexa(builder_type, linearize_on_old_iteration,11 )                                                                                                            File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_patch_test_large_strain.py", line 889, in _UL_3D_hexa                      self.assertEqual(mp.ProcessInfo[KratosMultiphysics.NL_ITERATION_NUMBER], expected_iterations)                                                                           AssertionError: 17 != 11                                                                                                                                                                                                                                                                                                                                ======================================================================                                                                                                      FAIL: test_UL_3D_hexa_elimination (test_patch_test_large_strain.TestPatchTestLargeStrain)                                                                                   ----------------------------------------------------------------------                                                                                                      Traceback (most recent call last):                                                                                                                                            File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_patch_test_large_strain.py", line 904, in test_UL_3D_hexa_elimination      self._UL_3D_hexa(builder_type, linearize_on_old_iteration,11 )                                                                                                            File "/mnt/c/Users/rross/Programming/Kratos/applications/StructuralMechanicsApplication/tests/test_patch_test_large_strain.py", line 889, in _UL_3D_hexa                      self.assertEqual(mp.ProcessInfo[KratosMultiphysics.NL_ITERATION_NUMBER], expected_iterations)                                                                           AssertionError: 17 != 11    

RiccardoRossi avatar Nov 27 '20 10:11 RiccardoRossi

Still failing :P

loumalouomega avatar Nov 27 '20 15:11 loumalouomega

Still failing :P

I think a consistent strain is important :P

loumalouomega avatar Nov 27 '20 16:11 loumalouomega

@RiccardoRossi @loumalouomega which is the status of this?

rubenzorrilla avatar Sep 15 '22 15:09 rubenzorrilla

@RiccardoRossi @loumalouomega which is the status of this?

I don't remember, hehe, let me see

loumalouomega avatar Sep 15 '22 15:09 loumalouomega

I did not remember this at all and it is actually really concerning...

AlejandroCornejo avatar Sep 15 '22 15:09 AlejandroCornejo

@RiccardoRossi @loumalouomega which is the status of this?

The tests should be updated, Okay from my side then

loumalouomega avatar Sep 15 '22 16:09 loumalouomega