Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogstools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Max Bittens
ogstools
Commits
46a2ebce
Commit
46a2ebce
authored
1 year ago
by
Florian Zill
Browse files
Options
Downloads
Patches
Plain Diff
[propertylib] updated tests
parent
0b67ce41
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_propertylib.py
+37
-8
37 additions, 8 deletions
tests/test_propertylib.py
with
37 additions
and
8 deletions
tests/test_propertylib.py
+
37
−
8
View file @
46a2ebce
...
@@ -5,8 +5,11 @@ import unittest
...
@@ -5,8 +5,11 @@ import unittest
import
numpy
as
np
import
numpy
as
np
from
pint.facets.plain
import
PlainQuantity
from
pint.facets.plain
import
PlainQuantity
from
ogstools.meshplotlib.examples
import
mesh_mechanics
from
ogstools.propertylib
import
presets
as
pp
from
ogstools.propertylib
import
presets
as
pp
from
ogstools.propertylib.matrix
import
Matrix
from
ogstools.propertylib.property
import
Scalar
,
u_reg
from
ogstools.propertylib.property
import
Scalar
,
u_reg
from
ogstools.propertylib.vector
import
Vector
qty
=
u_reg
.
Quantity
qty
=
u_reg
.
Quantity
...
@@ -77,10 +80,10 @@ class PhysicalPropertyTest(unittest.TestCase):
...
@@ -77,10 +80,10 @@ class PhysicalPropertyTest(unittest.TestCase):
def
test_von_mises
(
self
):
def
test_von_mises
(
self
):
"""
Test von_mises_stress property.
"""
"""
Test von_mises_stress property.
"""
sig_3D
=
np
.
array
([
3
,
1
,
1
,
1
,
1
,
1
])
*
1e6
sig_3D
=
np
.
array
([
3
,
1
,
1
,
1
,
1
,
1
])
*
1e6
self
.
equality
(
pp
.
von_
m
ises
_stress
,
sig_3D
,
qty
(
2
,
"
MPa
"
))
self
.
equality
(
pp
.
stress
.
von_
M
ises
,
sig_3D
,
qty
(
2
,
"
MPa
"
))
self
.
equality
(
pp
.
von_
m
ises
_stress
,
[
sig_3D
,
sig_3D
],
qty
([
2
,
2
],
"
MPa
"
))
self
.
equality
(
pp
.
stress
.
von_
M
ises
,
[
sig_3D
,
sig_3D
],
qty
([
2
,
2
],
"
MPa
"
))
sig_2D
=
np
.
array
([
2
,
1
,
1
,
1
])
*
1e6
sig_2D
=
np
.
array
([
2
,
1
,
1
,
1
])
*
1e6
self
.
equality
(
pp
.
von_
m
ises
_stress
,
sig_2D
,
qty
(
1
,
"
MPa
"
))
self
.
equality
(
pp
.
stress
.
von_
M
ises
,
sig_2D
,
qty
(
1
,
"
MPa
"
))
def
test_eff_pressure
(
self
):
def
test_eff_pressure
(
self
):
"""
Test effective_pressure property.
"""
"""
Test effective_pressure property.
"""
...
@@ -91,13 +94,39 @@ class PhysicalPropertyTest(unittest.TestCase):
...
@@ -91,13 +94,39 @@ class PhysicalPropertyTest(unittest.TestCase):
def
test_qp_ratio
(
self
):
def
test_qp_ratio
(
self
):
"""
Test qp_ratio property.
"""
"""
Test qp_ratio property.
"""
sig
=
np
.
array
([
4
,
4
,
1
,
1
,
1
,
1
])
*
1e6
sig
=
np
.
array
([
4
,
4
,
1
,
1
,
1
,
1
])
*
1e6
self
.
equality
(
pp
.
qp_ratio
,
sig
,
qty
(
-
100
,
"
percent
"
))
self
.
equality
(
pp
.
stress
.
qp_ratio
,
sig
,
qty
(
-
100
,
"
percent
"
))
self
.
equality
(
pp
.
qp_ratio
,
[
sig
]
*
2
,
qty
([
-
100
]
*
2
,
"
percent
"
))
self
.
equality
(
pp
.
stress
.
qp_ratio
,
[
sig
]
*
2
,
qty
([
-
100
]
*
2
,
"
percent
"
))
def
test_
dilatancy
(
self
):
def
test_
integrity_criteria
(
self
):
"""
Test
dilatancy property
.
"""
"""
Test
integrity criteria
.
"""
sig
=
np
.
array
([
4
,
1
,
2
,
1
,
1
,
1
])
*
1e6
sig
=
np
.
array
([
4
,
1
,
2
,
1
,
1
,
1
])
*
1e6
self
.
assertRaises
(
TypeError
,
pp
.
dilatancy_alkan_eff
,
sig
)
# not working for arrays (only works for meshes)
self
.
assertRaises
(
TypeError
,
pp
.
dilatancy_alkan
,
sig
)
self
.
assertGreater
(
np
.
max
(
pp
.
dilatancy_alkan
(
mesh_mechanics
)),
0
)
self
.
assertGreater
(
np
.
max
(
pp
.
dilatancy_alkan_eff
(
mesh_mechanics
)),
0
)
self
.
assertGreater
(
np
.
max
(
pp
.
dilatancy_critescu
(
mesh_mechanics
)),
0
)
self
.
assertGreater
(
np
.
max
(
pp
.
dilatancy_critescu_eff
(
mesh_mechanics
)),
0
)
self
.
assertGreater
(
np
.
max
(
pp
.
fluid_pressure_crit
(
mesh_mechanics
)),
0
)
def
test_tensor_attributes
(
self
):
"""
Test that the access of tensor attributes works.
"""
# data needs to be a 2D array
sig
=
np
.
asarray
([[
4
,
1
,
2
,
1
,
1
,
1
]])
*
1e6
self
.
assertTrue
(
np
.
all
(
pp
.
stress
.
eigenvalues
(
sig
)
>=
0
))
for
i
in
range
(
3
):
np
.
testing
.
assert_allclose
(
pp
.
stress
.
eigenvectors
[
i
].
magnitude
(
sig
),
1.0
)
self
.
assertGreater
(
pp
.
stress
.
det
(
sig
),
0
)
self
.
assertGreater
(
pp
.
stress
.
I1
(
sig
),
0
)
self
.
assertGreater
(
pp
.
stress
.
I2
(
sig
),
0
)
self
.
assertGreater
(
pp
.
stress
.
I3
(
sig
),
0
)
self
.
assertGreater
(
pp
.
stress
.
mean
(
sig
),
0
)
self
.
assertGreater
(
pp
.
stress
.
deviator
.
magnitude
(
sig
),
0
)
self
.
assertGreater
(
pp
.
stress
.
J1
(
sig
),
0
)
self
.
assertGreater
(
pp
.
stress
.
J2
(
sig
),
0
)
self
.
assertGreater
(
pp
.
stress
.
J3
(
sig
),
0
)
self
.
assertGreater
(
pp
.
stress
.
octahedral_shear
(
sig
),
0
)
def
test_simple
(
self
):
def
test_simple
(
self
):
"""
Test call functionality.
"""
"""
Test call functionality.
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment