Closed CFGrote closed 2 years ago
For what it's worth, I attach the notebook here
import starmatrix
from starmatrix import settings
from starmatrix.model import Model
custom_params = settings.default_settings()
custom_params
{'z': 0.02,
'sol_ab': 'as09',
'imf': 'kroupa2002',
'imf_alpha': 2.35,
'imf_m_low': 0.15,
'imf_m_up': 100,
'm_min': 0.98,
'm_max': 40.0,
'binary_fraction': 0.15,
'dtd_sn': 'rlp',
'dtd_correction_factor': 1.0,
'sn_yields': 'iwa1998',
'output_dir': 'results',
'matrix_headers': True,
'return_fractions': False,
'integration_step': 'logt',
'deprecation_warnings': True,
'expelled_elements_filename': '/home/grotec/Repositories/JOSSReviews/starmatrix/src/starmatrix/sample_input/expelled_elements',
'yield_corrections': {},
'total_time_steps': 300}
custom_params['binary_fraction'] = 0.13
custom_params['sol_ab'] = 'he10'
context = settings.validate(custom_params)
context
{'z': 0.02,
'sol_ab': 'he10',
'imf': 'kroupa2002',
'imf_alpha': 2.35,
'imf_m_low': 0.15,
'imf_m_up': 100,
'm_min': 0.98,
'm_max': 40.0,
'binary_fraction': 0.13,
'dtd_sn': 'rlp',
'dtd_correction_factor': 1.0,
'sn_yields': 'iwa1998',
'output_dir': 'results',
'matrix_headers': True,
'return_fractions': False,
'integration_step': 'logt',
'deprecation_warnings': True,
'expelled_elements_filename': '/home/grotec/Repositories/JOSSReviews/starmatrix/src/starmatrix/sample_input/expelled_elements',
'total_time_steps': 300}
Model(context).run()
from starmatrix import functions as sm
from starmatrix import matrix
stellar_mass = 5.09
z = 0.04
stellar_tau = sm.stellar_lifetime(stellar_mass, z)
stellar_tau
0.08900492008580678
contribution_matrix = matrix.q_sn(stellar_mass)
contribution_matrix
array([[0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00],
[0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00],
[0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00],
[0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00],
[9.58504495e-03, 9.58504495e-03, 9.58504495e-03, 9.58504495e-03,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00],
[2.83780834e-02, 2.83780834e-02, 2.83780834e-02, 2.83780834e-02,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00],
[2.30199837e-07, 2.30199837e-07, 2.30199837e-07, 2.30199837e-07,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00],
[2.77827390e-07, 2.77827390e-07, 2.77827390e-07, 2.77827390e-07,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00],
[0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
2.11851191e-01],
[4.00865234e-04, 4.00865234e-04, 4.00865234e-04, 4.00865234e-04,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00],
[1.68680915e-03, 1.68680915e-03, 1.68680915e-03, 1.68680915e-03,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00],
[3.05610129e-02, 3.05610129e-02, 3.05610129e-02, 3.05610129e-02,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00],
[1.67887123e-02, 1.67887123e-02, 1.67887123e-02, 1.67887123e-02,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00],
[2.36153281e-03, 2.36153281e-03, 2.36153281e-03, 2.36153281e-03,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00],
[1.24228533e-01, 1.24228533e-01, 1.24228533e-01, 1.24228533e-01,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00]])
contribution_matrix.shape
(15, 9)
starmatrix.constants.Q_MATRIX_ROWS, starmatrix.constants.Q_MATRIX_COLUMNS
(15, 9)
from matplotlib import pyplot as plt
plt.imshow(contribution_matrix)
Great, I'll close,
I'm following the "Advanced" example at https://starmatrix.readthedocs.io/en/latest/usage.html#examples.
Now I'm at the step to define my custom parameters. I could set it all up one by one but what would really be helpful is to be able to get a handle to the default variables and only customize the ones I want to vary. That's possible via
settings.default_settings()
but that is not mentioned in the tutorial. I suggest adding a corresponding line o the docs.The rest of the example works just fine.