Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90375557
test_fractal.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
Fri, Nov 1, 02:14
Size
3 KB
Mime Type
text/x-python
Expires
Sun, Nov 3, 02:14 (2 d)
Engine
blob
Format
Raw Data
Handle
22064469
Attached To
rTAMAAS tamaas
test_fractal.py
View Options
#!/usr/bin/python
# -*- coding: utf-8 -*-
##*
#
# @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
#
# @section LICENSE
#
# Copyright (©) 2016 EPFL (Ecole Polytechnique Fédérale de
# Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
# Solides)
#
# Tamaas 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 of the License, or (at your option) any
# later version.
#
# Tamaas 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 Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Tamaas. If not, see <http://www.gnu.org/licenses/>.
#
#
################################################################
import
sys
,
imp
import
tamaas
as
tm
def
main
():
#generate surface
SG
=
tm
.
SurfaceGeneratorFilterFFT
()
SG
.
getGridSize
()
.
assign
(
512
)
SG
.
getHurst
()
.
assign
(
0.8
)
SG
.
getRMS
()
.
assign
(
1.
);
SG
.
getQ0
()
.
assign
(
4
);
SG
.
getQ1
()
.
assign
(
4
);
SG
.
getQ2
()
.
assign
(
32
);
SG
.
getRandomSeed
()
.
assign
(
156
);
SG
.
Init
()
a
=
SG
.
buildSurface
()
#compute and print surface statistics
class
Stats
:
def
__getitem__
(
self
,
key
):
return
self
.
__dict__
[
key
]
stats
=
Stats
()
stats
.
size
=
SG
.
getGridSize
()
stats
.
hurst
=
SG
.
getHurst
()
.
value
()
stats
.
rms
=
SG
.
getRMS
()
stats
.
k0
=
SG
.
getQ0
()
stats
.
k1
=
SG
.
getQ1
()
.
value
()
stats
.
k2
=
SG
.
getQ2
()
.
value
()
stats
.
seed
=
SG
.
getRandomSeed
()
stats
.
rms_spectral
=
tm
.
SurfaceStatistics
.
computeSpectralStdev
(
a
);
stats
.
rms_slopes_spectral
=
tm
.
SurfaceStatistics
.
computeSpectralRMSSlope
(
a
);
stats
.
rms_geometric
=
tm
.
SurfaceStatistics
.
computeStdev
(
tm
.
SurfaceForPythonReal
(
a
));
stats
.
rms_slopes_geometric
=
tm
.
SurfaceStatistics
.
computeRMSSlope
(
a
);
stats
.
moments
=
tm
.
SurfaceStatistics
.
computeMoments
(
a
);
stats
.
m0
=
stats
[
'rms_spectral'
]
**
2
stats
.
m2
=
stats
.
moments
[
0
]
stats
.
m4
=
stats
.
moments
[
1
]
stats
.
alpha
=
stats
[
'm0'
]
*
stats
[
'm4'
]
/
(
stats
[
'm2'
]
**
2
)
stats
.
L
=
1.
stats
.
m0prime
=
tm
.
SurfaceStatistics
.
computeAnalyticFractalMoment
(
0
,
stats
.
k1
,
stats
.
k2
,
stats
.
hurst
,
1.
,
stats
.
L
)
stats
.
moment_A
=
stats
.
m0
/
stats
.
m0prime
stats
.
analytic_m0
=
tm
.
SurfaceStatistics
.
computeAnalyticFractalMoment
(
0
,
stats
.
k1
,
stats
.
k2
,
stats
.
hurst
,
stats
.
moment_A
,
stats
.
L
);
stats
.
analytic_m2
=
tm
.
SurfaceStatistics
.
computeAnalyticFractalMoment
(
2
,
stats
.
k1
,
stats
.
k2
,
stats
.
hurst
,
stats
.
moment_A
,
stats
.
L
);
stats
.
analytic_m4
=
tm
.
SurfaceStatistics
.
computeAnalyticFractalMoment
(
4
,
stats
.
k1
,
stats
.
k2
,
stats
.
hurst
,
stats
.
moment_A
,
stats
.
L
);
stats
.
analytic_alpha
=
stats
.
analytic_m0
*
stats
.
analytic_m4
/
(
stats
.
analytic_m2
*
stats
.
analytic_m2
);
print
"""
[N] {size}
[rms] {rms}
[rmsSpectral] {rms_spectral}
[rmsSlopeSpectral] {rms_slopes_spectral}
[rmsSlopeGeometric] {rms_slopes_geometric}
[Hurst] {hurst}
[k1] {k1}
[k2] {k2}
[moment A] {moment_A}
[m0] {m0}
[analytic m0] {analytic_m0}
[m2] {m2}
[analytic m2] {analytic_m2}
[m4] {m4}
[analytic m4] {analytic_m4}
[alpha] {alpha}
[analytic_alpha] {analytic_alpha}
[seed] {seed}
"""
.
format
(
**
stats
.
__dict__
)
return
0
if
__name__
==
"__main__"
:
sys
.
exit
(
main
())
Event Timeline
Log In to Comment