Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F83716909
check_result.py
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
Wed, Sep 18, 15:58
Size
1 KB
Mime Type
text/x-python
Expires
Fri, Sep 20, 15:58 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20882147
Attached To
rLIBMULTISCALE LibMultiScale
check_result.py
View Options
#!/usr/bin/env python3
import
numpy
as
np
import
sys
theoretical_strain
=
float
(
sys
.
argv
[
1
])
/
float
(
sys
.
argv
[
2
])
/
2
with
open
(
"strain_dump.txt"
)
as
fh
:
for
line
in
fh
:
pass
grad_u
=
np
.
array
([
float
(
val
)
for
val
in
line
.
split
()[
2
:]])
.
reshape
(
3
,
3
)
print
(
grad_u
,
grad_u
.
shape
)
epsilon
=
0.5
*
(
grad_u
+
grad_u
.
T
)
vol_change
=
1
/
3
*
np
.
diag
(
epsilon
)
.
sum
()
error_code
=
0
if
abs
(
vol_change
)
>
1e-10
:
print
(
"The linearised change in volume should be zero but is {0}"
.
format
(
vol_change
))
error_code
-=
1
else
:
print
(
"the change in volume is correct"
)
if
(
abs
(
epsilon
[
0
,
1
]
/
theoretical_strain
-
1
)
>
1e-3
):
print
(
"the x-y shear strain should be pretty exactly "
"{0} but it is {1}"
.
format
(
theoretical_strain
,
epsilon
[
0
,
1
]))
print
(
"This corresponds to an error of {0}"
.
format
(
abs
(
epsilon
[
0
,
1
]
/
theoretical_strain
-
1
)))
error_code
-=
2
else
:
print
(
"the mean x-y strain is correct"
)
if
abs
(
epsilon
[
0
,
2
])
>
1e-10
:
print
(
"the x-z shear strain should be zero but is {0}"
.
format
(
epsilon
[
0
,
2
]))
error_code
-=
4
else
:
print
(
"the mean x-z strain is correct"
)
if
abs
(
epsilon
[
1
,
2
])
>
1e-10
:
print
(
"the y-z shear strain should be zero but is {0}"
.
format
(
epsilon
[
1
,
2
]))
error_code
-=
4
else
:
print
(
"the mean y-z strain is correct"
)
sys
.
exit
(
error_code
)
Event Timeline
Log In to Comment