From 149020bbe90ca76563ff0ba2bc4cbb78b7ec98ad Mon Sep 17 00:00:00 2001 From: Cristian C Lalescu <Cristian.Lalescu@ds.mpg.de> Date: Tue, 29 May 2018 16:10:59 +0200 Subject: [PATCH] fix dkz/Lz options --- bfps/DNS.py | 2 +- bfps/test/test_Parseval.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bfps/DNS.py b/bfps/DNS.py index c407a955..28291be5 100644 --- a/bfps/DNS.py +++ b/bfps/DNS.py @@ -718,7 +718,7 @@ class DNS(_code): opt.dkx = 2. / opt.Lx if type(opt.dky) == type(None): opt.dky = 2. / opt.Ly - if type(opt.dkx) == type(None): + if type(opt.dkz) == type(None): opt.dkz = 2. / opt.Lz if type(opt.nx) == type(None): opt.nx = opt.n diff --git a/bfps/test/test_Parseval.py b/bfps/test/test_Parseval.py index aa680426..b2afdbee 100644 --- a/bfps/test/test_Parseval.py +++ b/bfps/test/test_Parseval.py @@ -31,14 +31,17 @@ def main(): energyk = c.statistics['energy(k)'] nshell = c.get_data_file()['kspace/nshell'].value renergy = np.mean(c.statistics['renergy(t)']) - print(renergy, np.trapz(energyk[:-2], c.statistics['kshell'][:-2])) + print(renergy, np.sum(energyk[:-2]) * (c.parameters['dkx']*c.parameters['dky']*c.parameters['dkz'])) + print(c.parameters['dkx'], c.parameters['dky'], c.parameters['dkz']) f = plt.figure() a = f.add_subplot(111) - a.plot(c.statistics['kshell'], energyk) - a.plot(c.statistics['kshell'], (energyk / nshell)*(4*np.pi*c.statistics['kshell']**2)) - a.set_yscale('log') + a.plot(c.statistics['kshell'], energyk, label = 'unnormalized') + a.plot(c.statistics['kshell'], (energyk / nshell)*(4*np.pi*c.statistics['kshell']**2), label = 'normalized') + #a.set_yscale('log') a.set_xscale('log') + a.legend(loc = 'best') + f.tight_layout() f.savefig('spectrum.pdf') return None -- GitLab