Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92792040
header_test_slip_laws.cc
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Nov 23, 18:25
Size
4 KB
Mime Type
text/x-c
Expires
Mon, Nov 25, 18:25 (2 d)
Engine
blob
Format
Raw Data
Handle
22514253
Attached To
rMUSPECTRE µSpectre
header_test_slip_laws.cc
View Options
/**
* @file header_test_slip_laws.cc
*
* @author Till Junge <till.junge@epfl.ch>
*
* @date 25 Feb 2019
*
* @brief tests for the crystal plasticity slip laws
*
* Copyright © 2019 Till Junge
*
* µSpectre is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3, or (at
* your option) any later version.
*
* µSpectre is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with µSpectre; see the file COPYING. If not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Additional permission under GNU GPL version 3 section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with proprietary FFT implementations or numerical libraries, containing parts
* covered by the terms of those libraries' licenses, the licensors of this
* Program grant you additional permission to convey the resulting work.
*/
#include "materials/slip_laws.hh"
#include "materials/materials_toolbox.hh"
#include "tests.hh"
namespace
muSpectre
{
BOOST_AUTO_TEST_SUITE
(
Slip_Laws
);
BOOST_AUTO_TEST_CASE
(
tangent_test
)
{
constexpr
Dim_t
Dim
{
2
};
constexpr
Int
NbSlip
{
1
};
using
ColArray_t
=
Eigen
::
Array
<
Real
,
NbSlip
,
1
>
;
using
T2_t
=
Eigen
::
Matrix
<
Real
,
Dim
,
Dim
>
;
using
T4_t
=
T4Mat
<
Real
,
Dim
>
;
using
SlipLaw_t
=
SlipLaw
<
Dim
,
NbSlip
>
;
using
Hooke_t
=
MatTB
::
Hooke
<
Dim
,
T2_t
,
T4_t
>
;
Real
bulk_m
{
175e9
};
Real
shear_m
{
120e9
};
Real
gamma_dot0
{
10e-2
};
Real
m_par
{
.1
};
Real
a_par
{
0
};
Real
tau_y0
{
200e6
};
Real
q_n
{
1.4
};
Real
h_0
{
0e9
};
Real
delta_t
{
1e-3
};
Real
young
{
MatTB
::
convert_elastic_modulus
<
ElasticModulus
::
Young
,
ElasticModulus
::
Bulk
,
ElasticModulus
::
Shear
>
(
bulk_m
,
shear_m
)};
Real
poisson
{
MatTB
::
convert_elastic_modulus
<
ElasticModulus
::
Poisson
,
ElasticModulus
::
Bulk
,
ElasticModulus
::
Shear
>
(
bulk_m
,
shear_m
)};
T4_t
C
{
Hooke_t
::
compute_C_T4
(
young
,
poisson
)};
SlipLaw_t
law
{
gamma_dot0
,
delta_t
,
m_par
,
a_par
,
q_n
,
tau_y0
,
h_0
};
T2_t
CGe
{
T2_t
::
Identity
()};
CGe
(
0
,
1
)
=
CGe
(
0
,
1
)
=
.001
;
T2_t
S_star
{
2
*
CGe
};
ColArray_t
gamma_dot_current
{};
gamma_dot_current
(
0
)
=
1e-3
;
ColArray_t
gamma_dot_old
{};
gamma_dot_old
(
0
)
=
0
;
ColArray_t
tau_y_current
{};
tau_y_current
(
0
)
=
tau_y0
;
std
::
vector
<
T2_t
,
Eigen
::
aligned_allocator
<
T2_t
>>
SchmidT
(
1
);
SchmidT
[
0
]
<<
0
,
1
,
0
,
0
;
law
.
prepare_new_time_step
(
C
,
CGe
,
SchmidT
);
auto
tau_inc
{
law
.
compute_tau_inc
(
CGe
,
S_star
,
gamma_dot_current
,
gamma_dot_old
,
SchmidT
)};
auto
residual
{
law
.
compute_residual
(
gamma_dot_current
,
tau_inc
,
tau_y_current
)};
auto
dr_dgamma_dot
{
law
.
compute_dr_dgamma_dot
(
gamma_dot_current
,
tau_inc
,
tau_y_current
)};
// compare 1/dr_dgamma to finite difference approximations
auto
finite_diff
{[
&
](
Real
eps
)
{
return
(
law
.
compute_residual
(
gamma_dot_current
+
eps
,
tau_inc
,
tau_y_current
)
-
law
.
compute_residual
(
gamma_dot_current
-
eps
,
tau_inc
,
tau_y_current
))
/
(
2
*
eps
);
}};
auto
errfun
{
[](
Real
a
,
Real
b
)
{
return
std
::
abs
(
a
-
b
)
/
(
a
+
b
);
}};
constexpr
Int
NbChecks
{
10
};
Eigen
::
Array
<
Real
,
1
,
NbChecks
>
error
{
Eigen
::
Array
<
Real
,
1
,
NbChecks
>::
Zero
()};
for
(
int
i
{
0
};
i
<
NbChecks
;
++
i
)
{
Real
eps
{
1.
/
ipow
(
10
,
i
+
6
)};
Real
approx
{
finite_diff
(
eps
)(
0
)};
error
(
i
)
=
errfun
(
approx
,
1.
/
dr_dgamma_dot
(
0
));
}
std
::
cout
<<
"errors = "
<<
error
<<
std
::
endl
;
}
BOOST_AUTO_TEST_SUITE_END
();
}
// muSpectre
Event Timeline
Log In to Comment