-
-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added proposal to divide the main functionality of the Benchmark Base…
… class.
- Loading branch information
Showing
7 changed files
with
112 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ class BenchmarkXx(BenchmarkBase): | |
""" | ||
|
||
def __init__(self): | ||
pass | ||
super().__init__() | ||
|
||
def time_template(self): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from os.path import dirname, realpath, join | ||
from pathlib import Path, PosixPath | ||
|
||
|
||
class Base: | ||
@staticmethod | ||
def get_path(partial_path: str) -> Path: | ||
base_path = dirname(realpath(__file__)) | ||
path = Path(base_path) / Path(partial_path) | ||
return path | ||
|
||
@property | ||
def tardis_ref_path(self) -> Path: | ||
# TODO: This route is fixed but needs to get from the arguments given in the command line. | ||
# /app/tardis-refdata | ||
return Path('/app/tardis-refdata') | ||
|
||
@property | ||
def example_configuration_dir(self) -> Path: | ||
return self.get_path("../../tardis/io/configuration/tests/data") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
from collections import OrderedDict | ||
from copy import deepcopy | ||
from pathlib import Path | ||
|
||
from benchmarks.util.base import Base | ||
from tardis.io.atom_data import AtomData | ||
from tardis.io.configuration.config_reader import Configuration | ||
from tardis.io.util import yaml_load_file, YAMLLoader | ||
from tardis.model import SimulationState | ||
|
||
|
||
class Nlte: | ||
def __init__(self): | ||
self.__base = Base() | ||
|
||
@property | ||
def tardis_config_verysimple_nlte(self) -> OrderedDict: | ||
path: str = "../../tardis/io/configuration/tests/data/tardis_configv1_nlte.yml" | ||
filename: Path = self.__base.get_path(path) | ||
|
||
return yaml_load_file( | ||
filename, | ||
YAMLLoader, | ||
) | ||
|
||
@property | ||
def nlte_raw_model_root(self) -> SimulationState: | ||
return SimulationState.from_config( | ||
self.tardis_model_config_nlte_root, self.nlte_atom_data | ||
) | ||
|
||
@property | ||
def nlte_raw_model_lu(self) -> SimulationState: | ||
return SimulationState.from_config( | ||
self.tardis_model_config_nlte_lu, self.nlte_atom_data | ||
) | ||
|
||
@property | ||
def nlte_atom_data(self) -> AtomData: | ||
atomic_data = deepcopy(self.nlte_atomic_dataset) | ||
return atomic_data | ||
|
||
@property | ||
def nlte_atomic_dataset(self) -> AtomData: | ||
nlte_atomic_data = AtomData.from_hdf(self.nlte_atomic_data_fname) | ||
return nlte_atomic_data | ||
|
||
@property | ||
def nlte_atomic_data_fname(self) -> str: | ||
atomic_data_fname = f"{self.__base.tardis_ref_path}/nlte_atom_data/TestNLTE_He_Ti.h5" | ||
|
||
if not Path(atomic_data_fname).exists(): | ||
atom_data_missing_str = f"Atomic datafiles {atomic_data_fname} does not seem to exist" | ||
raise Exception(atom_data_missing_str) | ||
|
||
return atomic_data_fname | ||
|
||
@property | ||
def tardis_model_config_nlte_root(self) -> Configuration: | ||
config = Configuration.from_yaml( | ||
f"{self.__base.example_configuration_dir}/tardis_configv1_nlte.yml" | ||
) | ||
config.plasma.nlte_solver = "root" | ||
return config | ||
|
||
@property | ||
def tardis_model_config_nlte_lu(self) -> Configuration: | ||
config = Configuration.from_yaml( | ||
f"{self.__base.example_configuration_dir}/tardis_configv1_nlte.yml" | ||
) | ||
config.plasma.nlte_solver = "lu" | ||
return config |