Commit d486bf84 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

small bug fixes

parent 141ef2c6
......@@ -6,9 +6,9 @@ import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from mpp.python.mppy import Mpp, PROJECT_ROOT_DIR, PROJECT_PY_DATA_DIR
from mpp.python.mppy import Mpp
SPRNG5_DIR = os.path.abspath(os.path.join(PROJECT_ROOT_DIR, 'sprng5'))
SPRNG5_DIR = os.path.abspath(os.path.join(Mpp.PROJECT_ROOT_DIR, 'sprng5'))
font = {'family': 'DejaVu Sans',
'weight': 'normal',
......@@ -27,23 +27,29 @@ class MLMCMpp(Mpp):
def __init__(self):
super().__init__()
self.git_project_address = 'https://git.scc.kit.edu/yq8188/mlmc/'
self.executable = 'MLMC-M++'
def build_sprng5(self):
print('\n================ build sprng5 ================\n')
if not os.path.exists(SPRNG5_DIR + '/lib/libsprng.a'):
self.run_subprocess(['tar', 'xjf', 'sprng5.tar.bz2'], cwd=PROJECT_ROOT_DIR)
self.run_subprocess(['./configure', '--with-mpi=yes', '--with-fortran=no'],
cwd=SPRNG5_DIR)
self.run_subprocess(['make', '-j'], cwd=SPRNG5_DIR)
rc_tar = self.run_subprocess(['tar', 'xjf', 'sprng5.tar.bz2'],
cwd=self.PROJECT_ROOT_DIR)
rc_conf = self.run_subprocess(
['./configure', '--with-mpi=yes', '--with-fortran=no'],
cwd=SPRNG5_DIR)
rc_make = self.run_subprocess(['make', '-j'], cwd=SPRNG5_DIR)
return rc_tar + rc_conf + rc_make
return 0
def clean_sprng5(self):
if os.path.isdir(SPRNG5_DIR):
self.clean_directory(SPRNG5_DIR, True)
def build(self):
self.build_sprng5()
super().build()
rc_sprng5 = self.build_sprng5()
rc_build = super().build()
return rc_sprng5 + rc_build
def parse_convergence_table(self, log_content):
float_pattern = self.create_float_pattern()
......@@ -210,8 +216,8 @@ class MLMCMpp(Mpp):
self.plot_convergence_table(df, axes, label)
if plot_name is not None:
path = PROJECT_PY_DATA_DIR + 'Convergence_{}_{}.png'.format(plot_name,
self.now)
path = self.PROJECT_PY_DATA_DIR + 'Convergence_{}_{}.png'.format(plot_name,
self.now)
plt.savefig(path)
else:
plt.show()
......@@ -230,7 +236,7 @@ class MLMCMpp(Mpp):
if plot_name is not None:
path = os.path.abspath(os.path.join(
PROJECT_PY_DATA_DIR, 'MLMC_{}_{}.png'.format(plot_name, self.now)))
self.PROJECT_PY_DATA_DIR, 'MLMC_{}_{}.png'.format(plot_name, self.now)))
plt.savefig(path)
else:
plt.show()
......@@ -266,19 +272,14 @@ class MLMCMpp(Mpp):
def save_convergence_table(self, df=None, table_name=None):
self.create_convergence_table_from_log(df)
path = PROJECT_PY_DATA_DIR + 'Convergence_{}_{}.csv'.format(table_name, self.now)
path = self.PROJECT_PY_DATA_DIR + 'Convergence_{}_{}.csv'.format(table_name,
self.now)
df.to_csv(path)
def save_mlmc_table(self, df, table_name=None):
self.create_mlmc_table(df)
path = PROJECT_PY_DATA_DIR + 'MLMC_{}_{}.csv'.format(table_name, self.now)
path = self.PROJECT_PY_DATA_DIR + 'MLMC_{}_{}.csv'.format(table_name, self.now)
df.to_csv(path)
mpp = MLMCMpp()
if __name__ == "__main__":
path = os.path.dirname(os.path.realpath(__file__))
content = mpp.read_log(log_file='mlmc', log_dir=path)
mlmc_table = mpp.parse_mlmc_table(content)
mpp.show_mlmc_table(mlmc_table, plot_name='transport', show_mc=False)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment