Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GSOC] Benchmarking and Performance Improvement: objective 1 #2547

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ Gaurav Gautam <[email protected]> gautam1168 <[email protected]>
Gerrit Leck <[email protected]>
Gerrit Leck <[email protected]> Gerrit Leck <[email protected]>

Haleel Sada <[email protected]>
Haleel Sada <[email protected]> haleelsada <[email protected]>

Isaac Smith <[email protected]>
Isaac Smith <[email protected]> Isaac Smith <[email protected]>
Isaac Smith <[email protected]> smithis7 <[email protected]>
Expand Down
30 changes: 25 additions & 5 deletions benchmarks/benchmark_run_tardis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,39 @@
import os
from tardis.io.configuration.config_reader import Configuration
from tardis import run_tardis
from astropy import units as u

class Benchmarkruntardis:
"""Class to benchmark the run_tardis function.
"""
timeout = 200

def setup(self):
params = ['branch85_w7', 'uniform','power_law','exponential']
param_names = ['Density']

def setup(self, density):
filename = "tardis_configv1_benchmark.yml"
dir_path = os.path.dirname(os.path.realpath(__file__))
path = os.path.join(dir_path, "data", filename)
config = Configuration.from_yaml(path)
config.atom_data = "kurucz_cd23_chianti_H_He.h5"
config.model.structure.density.type = density
config.model.structure.velocity.start = 1000 * u.km/u.s
config.model.structure.velocity.stop = 2000 * u.km/u.s
config.model.structure.velocity.num = 20
if density == 'uniform':
config.model.structure.density.time_0 = 1 * u.day
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If many of these settings are the same, they don't need to be in the if statements

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added the common settings outside the if clause and anything that differ from default inside the if clause. I thought it would be better for readability.

config.model.structure.density.value = 5e-10 * u.kg/u.cm**3
elif density == 'power_law':
config.model.structure.density.time_0 = 1 * u.day
config.model.structure.density.rho_0 = 5e-10 * u.kg/u.cm**3
config.model.structure.density.v_0 = 500 * u.km/u.s
config.model.structure.density.exponent = -2
elif density == 'exponential':
config.model.structure.density.time_0 = 1 * u.day
config.model.structure.density.rho_0 = 5e-10 * u.kg/u.cm**3
config.model.structure.density.v_0 = 500 * u.km/u.s
self.config = config

def time_run_tardis(self):
sim = run_tardis(self.config, log_level="ERROR", show_progress_bars=False)

def time_run_tardis(self,density):
sim = run_tardis(self.config, log_level="ERROR",
show_progress_bars=False)
28 changes: 28 additions & 0 deletions benchmarks/benchmark_sdec_plotter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os
from tardis.io.configuration.config_reader import Configuration
from tardis import run_tardis
from tardis.visualization import SDECPlotter


class BenchmarkSDECplotter:
"""Class to benchmark Spectral element DEComposition (SDEC) Plot.
"""
timeout = 200

def setup(self):
filename = "tardis_configv1_benchmark.yml"
dir_path = os.path.dirname(os.path.realpath(__file__))
path = os.path.join(dir_path, "data", filename)
config = Configuration.from_yaml(path)
config.atom_data = "kurucz_cd23_chianti_H_He.h5"
self.config = config
self.sim = run_tardis(self.config, virtual_packet_logging=True)

def time_sdec_plot_mpl(self):
plotter = SDECPlotter.from_simulation(self.sim)
plotter.generate_plot_mpl()

def time_sdec_plot_ply(self):
plotter = SDECPlotter.from_simulation(self.sim)
plotter.generate_plot_ply()

Loading