Skip to content

Commit

Permalink
Merge pull request #174 from UCBoulder/maint/change-the-initial-guess…
Browse files Browse the repository at this point in the history
…-for-the-optimization-residual

Maint/change the initial guess for the optimization residual
  • Loading branch information
NateAM authored Sep 28, 2024
2 parents b8b09e6 + 8a033c0 commit 6409dff
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
1 change: 1 addition & 0 deletions docs/sphinx/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=========
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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( ) );

}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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( );
Expand All @@ -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 );

}

0 comments on commit 6409dff

Please sign in to comment.