diff --git a/tests/test_fractal.py b/tests/test_fractal.py index 2f3fe86..9af42d0 100644 --- a/tests/test_fractal.py +++ b/tests/test_fractal.py @@ -1,102 +1,102 @@ #!/usr/bin/python # -*- coding: utf-8 -*- ##* # # @author Guillaume Anciaux # # @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 . # # ################################################################ import sys, imp from util_test import import_tamaas def main(): tm = import_tamaas() #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(SurfaceForPythonReal(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())