Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93234059
phasefield-static.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, Nov 27, 05:44
Size
3 KB
Mime Type
text/x-python
Expires
Fri, Nov 29, 05:44 (1 d, 22 h)
Engine
blob
Format
Raw Data
Handle
22598076
Attached To
rAKA akantu
phasefield-static.py
View Options
#!/usr/bin/env python
# coding: utf-8
__copyright__
=
(
"Copyright (©) 2021-2023 EPFL (Ecole Polytechnique Fédérale de Lausanne)"
"Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)"
)
__license__
=
"LGPLv3"
import
numpy
as
np
import
akantu
as
aka
aka
.
parseInput
(
"material_static.dat"
)
dim
=
2
mesh
=
aka
.
Mesh
(
dim
)
mesh
.
read
(
"plate_static.msh"
)
model
=
aka
.
CouplerSolidPhaseField
(
mesh
)
solid
=
model
.
getSolidMechanicsModel
()
phase
=
model
.
getPhaseFieldModel
()
solid
.
initFull
(
_analysis_method
=
aka
.
_static
)
solver
=
solid
.
getNonLinearSolver
(
"static"
)
solver
.
set
(
"max_iterations"
,
100
)
solver
.
set
(
"threshold"
,
1e-8
)
solver
.
set
(
"convergence_type"
,
aka
.
SolveConvergenceCriteria
.
solution
)
solid
.
getNewSolver
(
"linear_static"
,
aka
.
TimeStepSolverType
.
static
,
aka
.
NonLinearSolverType
.
linear
)
solid
.
setIntegrationScheme
(
"linear_static"
,
"displacement"
,
aka
.
IntegrationSchemeType
.
pseudo_time
)
phase
.
initFull
(
_analysis_method
=
aka
.
_static
)
phase
.
getNewSolver
(
"nonlinear_static"
,
aka
.
TimeStepSolverType
.
static
,
aka
.
NonLinearSolverType
.
newton_raphson
,
)
phase
.
setIntegrationScheme
(
"nonlinear_static"
,
"damage"
,
aka
.
IntegrationSchemeType
.
pseudo_time
)
solver
=
phase
.
getNonLinearSolver
(
"nonlinear_static"
)
solver
.
set
(
"max_iterations"
,
100
)
solver
.
set
(
"threshold"
,
1e-4
)
solver
.
set
(
"convergence_type"
,
aka
.
SolveConvergenceCriteria
.
solution
)
solid
.
applyBC
(
aka
.
FixedValue
(
0
,
aka
.
_y
),
"bottom"
)
solid
.
applyBC
(
aka
.
FixedValue
(
0
,
aka
.
_x
),
"left"
)
# Initialization for bulk vizualisation
solid
.
setBaseName
(
"phasefield-static"
)
solid
.
addDumpFieldVector
(
"displacement"
)
solid
.
addDumpFieldVector
(
"external_force"
)
solid
.
addDumpField
(
"strain"
)
solid
.
addDumpField
(
"stress"
)
solid
.
addDumpField
(
"damage"
)
solid
.
addDumpField
(
"blocked_dofs"
)
nb_dofs
=
solid
.
getMesh
()
.
getNbNodes
()
*
dim
increment
=
solid
.
getIncrement
()
displacement
=
solid
.
getDisplacement
()
displacement
=
displacement
.
reshape
(
nb_dofs
)
blocked_dofs
=
solid
.
getBlockedDOFs
()
blocked_dofs
=
blocked_dofs
.
reshape
(
nb_dofs
)
damage
=
phase
.
getDamage
()
tolerance
=
1e-5
steps
=
1000
increment
=
5e-6
for
n
in
range
(
steps
):
print
(
"Computing iteration "
+
str
(
n
+
1
)
+
"/"
+
str
(
steps
))
solid
.
applyBC
(
aka
.
IncrementValue
(
increment
,
aka
.
_y
),
"top"
)
mask
=
blocked_dofs
==
False
# NOQA: E712
iiter
=
0
error_disp
=
1
error_dam
=
1
displacement_prev
=
displacement
[
mask
]
.
copy
()
damage_prev
=
damage
.
copy
()
damage_prev
=
damage_prev
# solve using staggered scheme
while
error_disp
>
tolerance
or
error_dam
>
tolerance
:
model
.
solve
(
"linear_static"
,
""
)
displacement_new
=
displacement
[
mask
]
damage_new
=
damage
delta_disp
=
displacement_new
-
displacement_prev
delta_dam
=
damage_new
-
damage_prev
error_disp
=
np
.
linalg
.
norm
(
delta_disp
)
error_dam
=
np
.
linalg
.
norm
(
delta_dam
)
iiter
+=
1
displacement_prev
=
displacement_new
.
copy
()
damage_prev
=
damage_new
.
copy
()
print
(
error_dam
,
error_disp
)
if
iiter
>
500
:
raise
Exception
(
"Convergence not reached"
)
if
n
%
50
==
0
:
solid
.
dump
()
solid
.
dump
()
Event Timeline
Log In to Comment