diff --git a/docs/sphinx/changelog.rst b/docs/sphinx/changelog.rst index 6af67fe..f8d486a 100644 --- a/docs/sphinx/changelog.rst +++ b/docs/sphinx/changelog.rst @@ -41,6 +41,7 @@ Internal Changes - Added an active set solver for quadratic problems (:pull:`167`). By `Nathan Miller`_. - Allow for initial values to be set for the micromorphic hydra base class (:pull:`168`). By `Nathan Miller`_. - Working towards improved convergence (:pull:`170`). By `Nathan Miller`_. +- Set the initial estimate of the plastic multiplier to be positive in the case of yielding (:pull:`174`). By `Nathan Miller`_. Bug Fixes ========= diff --git a/src/cpp/tardigrade_hydraMicromorphicDruckerPragerPlasticityOptimization.cpp b/src/cpp/tardigrade_hydraMicromorphicDruckerPragerPlasticityOptimization.cpp index 275f331..ceb74bd 100644 --- a/src/cpp/tardigrade_hydraMicromorphicDruckerPragerPlasticityOptimization.cpp +++ b/src/cpp/tardigrade_hydraMicromorphicDruckerPragerPlasticityOptimization.cpp @@ -434,20 +434,47 @@ namespace tardigradeHydra{ indices = std::vector< unsigned int >( getStateVariableIndices( )->begin( ) + offset, getStateVariableIndices( )->end( ) ); - indices += ( *hydra->getNumConfigurations( ) ) * ( *hydra->getConfigurationUnknownCount( ) ); - values = std::vector< floatType >( 5, 0 ); values[ 0 ] = std::fmax( 0, -( *get_macroYield( ) ) ); + if ( ( *get_macroYield( ) ) > 0 ){ + + // Perturb the plastic multiplier + floatType delta = std::fmax( ( *get_plasticMultipliers( ) )[ 0 ], ( *hydra->getRelativeTolerance( ) ) * ( *get_macroYield( ) ) + ( *hydra->getAbsoluteTolerance( ) ) ); + indices.push_back( ( *getStateVariableIndices( ) )[ 0 ] ); + values.push_back( delta ); + + } + values[ 1 ] = std::fmax( 0, -( *get_microYield( ) ) ); + if ( ( *get_microYield( ) ) > 0 ){ + + // Perturb the plastic multiplier + floatType delta = std::fmax( ( *get_plasticMultipliers( ) )[ 1 ], ( *hydra->getRelativeTolerance( ) ) * ( *get_microYield( ) ) + ( *hydra->getAbsoluteTolerance( ) ) ); + indices.push_back( ( *getStateVariableIndices( ) )[ 1 ] ); + values.push_back( delta ); + + } + for ( unsigned int i = 0; i < dim; i++ ){ values[ i + 2 ] = std::fmax( 0, -( *get_microGradientYield( ) )[ i ] ); + if ( ( *get_microGradientYield( ) )[ i ] > 0 ){ + + // Perturb the plastic multiplier + floatType delta = std::fmax( ( *get_plasticMultipliers( ) )[ i + 2 ], ( *hydra->getRelativeTolerance( ) ) * ( *get_microGradientYield( ) )[ i ] + ( *hydra->getAbsoluteTolerance( ) ) ); + indices.push_back( ( *getStateVariableIndices( ) )[ i + 2 ] ); + values.push_back( delta ); + + } + } + indices += ( *hydra->getNumConfigurations( ) ) * ( *hydra->getConfigurationUnknownCount( ) ); + } } diff --git a/src/cpp/tests/test_tardigrade_hydraMicromorphicDruckerPragerPlasticityOptimization.cpp b/src/cpp/tests/test_tardigrade_hydraMicromorphicDruckerPragerPlasticityOptimization.cpp index 332bde9..d5e3a1a 100644 --- a/src/cpp/tests/test_tardigrade_hydraMicromorphicDruckerPragerPlasticityOptimization.cpp +++ b/src/cpp/tests/test_tardigrade_hydraMicromorphicDruckerPragerPlasticityOptimization.cpp @@ -1658,9 +1658,9 @@ BOOST_AUTO_TEST_CASE( test_suggestInitialIterates, * boost::unit_test::tolerance unsigned int configuration_unknown_count = 45; - floatType tolr = 1e-2; + floatType tolr = 1e-9; - floatType tola = 1e-3; + floatType tola = 1e-9; unsigned int maxIterations = 24; @@ -1808,9 +1808,15 @@ BOOST_AUTO_TEST_CASE( test_suggestInitialIterates, * boost::unit_test::tolerance R2.microGradientYield = -R.microGradientYield; - const std::vector< unsigned int > index_answer = { 100, 101, 102, 103, 104 }; + const std::vector< unsigned int > index_answer1 = { 100, 101, 102, 103, 104, 90, 91, 92, 93, 94 }; + const std::vector< unsigned int > index_answer2 = { 100, 101, 102, 103, 104 }; - floatVector answer1( 5, 0 ); + floatVector answer1( 10, 0 ); + answer1[ 5 ] = 0.01; + answer1[ 6 ] = 0.02; + answer1[ 7 ] = 0.03; + answer1[ 8 ] = 0.04; + answer1[ 9 ] = 0.05; floatVector answer2( 5, 0 ); answer2[ 0 ] = -R2.macroYield; @@ -1826,7 +1832,7 @@ BOOST_AUTO_TEST_CASE( test_suggestInitialIterates, * boost::unit_test::tolerance BOOST_TEST( answer1 == value_result, CHECK_PER_ELEMENT ); - BOOST_TEST( index_answer == index_result, CHECK_PER_ELEMENT ); + BOOST_TEST( index_answer1 == index_result, CHECK_PER_ELEMENT ); value_result.clear( ); index_result.clear( ); @@ -1835,6 +1841,6 @@ BOOST_AUTO_TEST_CASE( test_suggestInitialIterates, * boost::unit_test::tolerance BOOST_TEST( answer2 == value_result, CHECK_PER_ELEMENT ); - BOOST_TEST( index_answer == index_result, CHECK_PER_ELEMENT ); + BOOST_TEST( index_answer2 == index_result, CHECK_PER_ELEMENT ); }