Skip to content
Snippets Groups Projects
Commit 42d15388 authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

fixes err2, outputs vorticity err stats as well

parent de8a9551
No related branches found
No related tags found
1 merge request!76Full convergence tests/examples
Pipeline #189275 passed
......@@ -100,7 +100,15 @@ class EDNS(TurTLE.DNS):
nshells = kspace['nshell'].shape[0]
kspace = self.get_kspace()
nshells = kspace['nshell'].shape[0]
vec_stat_datasets = ['err1', 'err2', 'err1_relative', 'err2_relative']
vec_stat_datasets = [
'velocity_err1',
'velocity_err2',
'velocity_err1_relative',
'velocity_err2_relative',
'vorticity_err1',
'vorticity_err2',
'vorticity_err1_relative',
'vorticity_err2_relative']
scal_stat_datasets = []
for k in vec_stat_datasets:
time_chunk = 2**20//(8*3*3*nshells)
......@@ -223,11 +231,16 @@ class EDNS(TurTLE.DNS):
def read_error_statistics(
self):
df = self.get_data_file()
for ff in ['velocity', 'vorticity']:
for ii in [1, 2]:
self.statistics['error/moments/err{0}'.format(ii)] = df['statistics/moments/err{0}'.format(ii)][()]
self.statistics['error/moments/err{0}_relative'.format(ii)] = df['statistics/moments/err{0}_relative'.format(ii)][()]
self.statistics['error/histograms/err{0}'.format(ii)] = df['statistics/histograms/err{0}'.format(ii)][()]
self.statistics['error/histograms/err{0}_relative'.format(ii)] = df['statistics/histograms/err{0}_relative'.format(ii)][()]
self.statistics['error/moments/{0}_err{1}'.format(ff, ii)] = \
df['statistics/moments/{0}_err{1}'.format(ff, ii)][()]
self.statistics['error/moments/{0}_err{1}_relative'.format(ff, ii)] = \
df['statistics/moments/{0}_err{1}_relative'.format(ff, ii)][()]
self.statistics['error/histograms/{0}_err{1}'.format(ff, ii)] = \
df['statistics/histograms/{0}_err{1}'.format(ff, ii)][()]
self.statistics['error/histograms/{0}_err{1}_relative'.format(ff, ii)] = \
df['statistics/histograms/{0}_err{1}_relative'.format(ff, ii)][()]
df.close()
return None
def plot_error_statistics(
......@@ -236,24 +249,31 @@ class EDNS(TurTLE.DNS):
err_norm = 1.0):
if type(fname) == type(None):
fname = self.simname + '_err_stats'
for ff in ['velocity', 'vorticity']:
f = plt.figure(figsize = (8, 8))
a = f.add_subplot(221)
a.plot(self.statistics['error/moments/err1'][:, 2, 3]**0.5)
a.plot(self.statistics['error/moments/err2'][:, 2, 3]**0.5)
a.plot(self.statistics['error/moments/{0}_err1'.format(ff)][:, 2, 3]**0.5)
a.plot(self.statistics['error/moments/{0}_err2'.format(ff)][:, 2, 3]**0.5)
a.set_title('absolute')
a.set_xlabel('iteration')
a = f.add_subplot(222)
a.plot(self.statistics['error/moments/err1_relative'][:, 2, 3]**0.5)
a.plot(self.statistics['error/moments/err2_relative'][:, 2, 3]**0.5)
a.plot(self.statistics['error/moments/{0}_err1_relative'.format(ff)][:, 2, 3]**0.5)
a.plot(self.statistics['error/moments/{0}_err2_relative'.format(ff)][:, 2, 3]**0.5)
a.set_title('relative')
a.set_xlabel('iteration')
a = f.add_subplot(223)
a.plot(self.statistics['error/histograms/err1'][-1, :, 3])
a.plot(self.statistics['error/histograms/err2'][-1, :, 3])
a.plot(self.statistics['error/histograms/{0}_err1'.format(ff)][-1, :, 3])
a.plot(self.statistics['error/histograms/{0}_err2'.format(ff)][-1, :, 3])
a.set_title('absolute')
a.set_yscale('log')
a = f.add_subplot(224)
print(self.statistics['error/histograms/err1_relative'][-1, :, 3])
a.plot(self.statistics['error/histograms/err1_relative'][-1, :, 3])
a.plot(self.statistics['error/histograms/err2_relative'][-1, :, 3])
a.plot(self.statistics['error/histograms/{0}_err1_relative'.format(ff)][-1, :, 3])
a.plot(self.statistics['error/histograms/{0}_err2_relative'.format(ff)][-1, :, 3])
a.set_title('relative')
a.set_yscale('log')
f.tight_layout()
f.savefig(fname + '.pdf')
f.suptitle(ff)
f.savefig(fname + '_' + ff + '.pdf')
plt.close(f)
return None
......
......@@ -145,6 +145,7 @@ int compare_real_fields(
kspace<FFTW, SMOOTH>* kk,
const field<rnumber, FFTW, THREE>* a,
const field<rnumber, FFTW, THREE>* b,
const std::string prefix,
const std::string suffix,
const hid_t stat_group,
const int ii,
......@@ -179,13 +180,13 @@ int compare_real_fields(
err->compute_stats(
kk,
stat_group,
"err" + suffix,
prefix + "_err" + suffix,
ii,
max_err_estimate);
err_relative->compute_stats(
kk,
stat_group,
"err" + suffix + "_relative",
prefix + "_err" + suffix + "_relative",
ii,
max_err_relative_estimate);
delete err;
......@@ -232,6 +233,19 @@ int fluid_error<rnumber>::do_stats()
this->fs1->get_kspace(),
tmp_vec1,
tmp_vec0,
"velocity",
"1",
stat_group,
this->iteration / niter_stat,
this->max_err_estimate,
this->max_err_relative_estimate);
this->fs1->get_rvorticity(tmp_vec0);
this->fs2->get_rvorticity(tmp_vec1);
compare_real_fields(
this->fs1->get_kspace(),
tmp_vec1,
tmp_vec0,
"vorticity",
"1",
stat_group,
this->iteration / niter_stat,
......@@ -248,10 +262,24 @@ int fluid_error<rnumber>::do_stats()
this->fs4->get_communicator(),
this->fs4->get_fftw_plan_rigor());
this->fs4->get_rvorticity(tmp_vec0);
compare_real_fields(
this->fs2->get_kspace(),
tmp_vec0,
tmp_vec1,
"vorticity",
"2",
stat_group,
this->iteration / niter_stat,
this->max_err_estimate,
this->max_err_relative_estimate);
this->fs2->get_rvelocity(tmp_vec1);
this->fs4->get_rvelocity(tmp_vec0);
compare_real_fields(
this->fs2->get_kspace(),
tmp_vec0,
tmp_vec1,
"velocity",
"2",
stat_group,
this->iteration / niter_stat,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment