Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F85846569
stiffness_matrix.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, Oct 2, 12:27
Size
1 KB
Mime Type
text/x-python
Expires
Fri, Oct 4, 12:27 (1 d, 22 h)
Engine
blob
Format
Raw Data
Handle
21279792
Attached To
rAKA akantu
stiffness_matrix.py
View Options
#!/usr/bin/env python3
import
akantu
import
numpy
as
np
def
getStiffnessMatrix
(
material_file
,
mesh_file
,
traction
):
akantu
.
parseInput
(
material_file
)
spatial_dimension
=
2
################################################################
# Initialization
################################################################
mesh
=
akantu
.
Mesh
(
spatial_dimension
)
mesh
.
read
(
mesh_file
)
model
=
akantu
.
SolidMechanicsModel
(
mesh
)
model
.
initFull
(
akantu
.
_static
)
model
.
assembleStiffnessMatrix
()
K
=
model
.
getDOFManager
()
.
getMatrix
(
'K'
)
stiff
=
akantu
.
AkantuSparseMatrix
(
K
)
.
toarray
()
return
stiff
################################################################
# main
################################################################
def
main
():
import
os
mesh_file
=
'plate.msh'
# if mesh was not created the calls gmsh to generate it
if
not
os
.
path
.
isfile
(
mesh_file
):
import
subprocess
ret
=
subprocess
.
call
(
'gmsh -format msh2 -2 plate.geo {0}'
.
format
(
mesh_file
),
shell
=
True
)
if
not
ret
==
0
:
raise
Exception
(
'execution of GMSH failed: do you have it installed ?'
)
material_file
=
'material.dat'
traction
=
1.
mat
=
getStiffnessMatrix
(
material_file
,
mesh_file
,
traction
)
print
(
mat
)
################################################################
if
__name__
==
"__main__"
:
main
()
Event Timeline
Log In to Comment